OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:01 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 11:17 am 
Offline

Joined: Mon Nov 19, 2018 12:13 pm
Posts: 22
ok. How would i go about doing that. and what bootloader do i use

_________________
- Mitchell Barnes the Confused Idiot
17 years old and programming assembly

“If you're going to tell me to give up then you're wasting time that you could be using to help someone else”

“Assembly is more readable and easy to use than c. Change my mind”


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 11:34 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 21, 2011 9:47 pm
Posts: 286
Location: Tustin, CA USA
Reading up on GRUB would be a good place to start. You would create a specially formatted executable with a multiboot header in the beginning of your binary which would request that GRUB set the resolution and color depth for you and provide the frame buffer address (and other related video information).

When you boot, GRUB would get control first and collect all the necessary information for you (and some other important information such as a memory map) and then load your code and jump to it. GRUB will put the CPU in protected mode and would set up a small stack and temporary GDT for you.

You need to know: GRUB will try to set the resolution based on "best effort". When you read the documentation you need to pay very close attention to the word "may", as GRUB may give up if you are asking for something it cannot figure how to comply with your request. GRUB might give you a different resolution that is "close" to the request or may not service the request at all if it cannot figure out what you are asking it to do. The good news is that GRUB will report back to you what it was able to accomplish for your request.

_________________
Adam

The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal

"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 12:13 pm 
Offline

Joined: Mon Nov 19, 2018 12:13 pm
Posts: 22
So if I were making a bootloader of my own, with a resolution selection, would that work?

_________________
- Mitchell Barnes the Confused Idiot
17 years old and programming assembly

“If you're going to tell me to give up then you're wasting time that you could be using to help someone else”

“Assembly is more readable and easy to use than c. Change my mind”


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 12:18 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
CheeseBees wrote:
So if I were making a bootloader of my own, with a resolution selection, would that work?


That would be a first step. The bootloader will give you to address of the frame buffer in memory. Chances are that this memory will be outside the 32 bits address space available to a 32 bits protected mode application. Consider that a 1080x768x32bpp frame buffer requires at least 3.16 GB of memory... That's very likely not going to be in the first 4 GB.

Your next step is going to figure out how to map the frame buffer memory into your address space and/or switch to 64 bits mode.

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 12:23 pm 
Offline

Joined: Mon Nov 19, 2018 12:13 pm
Posts: 22
my preference would be to do this in 64 bit

So assuming i have this working, where would this go in my list:
1. Make stuff boot obviously
2. Pci-e enumeration
3. Writing driver
4. Plotting the pixel(s)

_________________
- Mitchell Barnes the Confused Idiot
17 years old and programming assembly

“If you're going to tell me to give up then you're wasting time that you could be using to help someone else”

“Assembly is more readable and easy to use than c. Change my mind”


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 2:03 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
If you only want to plot pixels and you don't care about writing a driver, your steps are:
1. Boot with GRUB
2. Make sure the frame buffer meets your expectations (or change your expectations to match the frame buffer)
3. Plot pixels

You don't need to enumerate the PCI bus or write any drivers. GRUB will use the firmware (VBE/GOP) to set up the video card so that you can begin plotting pixels immediately.

If you want to be in 64-bit mode, add "switch to 64-bit mode" anywhere after step 1.

If you want to use your own bootloader instead of GRUB, your bootloader can still use the firmware to set up the video card.


If you're more interested in writing a driver and just using "being able to plot pixels" as a goal, your steps are:
1. Boot
2. Enumerate the PCI bus to learn (or set) the addresses of the video card
3. Write a driver
4. Plot pixels


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 2:08 pm 
Offline

Joined: Mon Nov 19, 2018 12:13 pm
Posts: 22
Octocontrabass wrote:
Enumerate the PCI bus to learn (or set) the addresses of the video card

now how would I go about doing that

_________________
- Mitchell Barnes the Confused Idiot
17 years old and programming assembly

“If you're going to tell me to give up then you're wasting time that you could be using to help someone else”

“Assembly is more readable and easy to use than c. Change my mind”


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Tue Nov 20, 2018 2:29 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
https://wiki.osdev.org/PCI


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Wed Nov 21, 2018 9:32 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
@CheeseBees: I noticed that you still haven't mentioned the development host OS (that is to say, the one you are developing the new OS/bare metal program on, and the one which is the host for QEMU) you are using. Most of what we've discusses regarding QEMU has assumed you are using some flavor of Linux for this, but if you are using something else such as Windows, MacOS (because Hackintoshen are a thing), FreeBSD, or, uh, I dunno, Haiku maybe... anyway, the development platform will factor into how the virtualization works.

For that matter, if it is Linux, then the distro, distro version, and kernel version will be significant as well, and which AMD drivers you are using (either the official Catalyst drivers, or the semi-supported but open source GPUOpen amdgpu ones) and the version of those may be too.

We might even need to know how you have the UEFI and GRUB boot options set up, as well as certain kernel build options (especially if you have tweaked any of them - uncommon for users of Debian/Ubuntu/Mint derived distros, but quite common for those running with high-performance, bleeding-edge distros such as Arch or Gentoo, or special-purpose ones such as Kali or Qubes).

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Wed Nov 21, 2018 10:22 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Quote:
Basically im using mingw w64 and nasm on windows 8.1


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Wed Nov 21, 2018 10:27 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
kzinti wrote:
Consider that a 1080x768x32bpp frame buffer requires at least 3.16 GB of memory... That's very likely not going to be in the first 4 GB.
???

I think you may be confusing GB and MB.


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Wed Nov 21, 2018 10:35 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 11, 2014 4:59 pm
Posts: 74
iansjack wrote:
kzinti wrote:
Consider that a 1080x768x32bpp frame buffer requires at least 3.16 GB of memory... That's very likely not going to be in the first 4 GB.
???

I think you may be confusing GB and MB.


@ianjack is right.
32bpp == 4 Bytes
1080 Pixels * 768 Pixels * 4 Bytes = 3317760 Bytes / 1 KiB = 3,24 MiB :)

_________________
https://blackdev.org/ - system programming, my own 64 bit kernel and software.


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Wed Nov 21, 2018 11:03 am 
Offline

Joined: Mon Nov 19, 2018 12:13 pm
Posts: 22
Anyone have a basic PCIe enumeration script in c?

_________________
- Mitchell Barnes the Confused Idiot
17 years old and programming assembly

“If you're going to tell me to give up then you're wasting time that you could be using to help someone else”

“Assembly is more readable and easy to use than c. Change my mind”


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Wed Nov 21, 2018 11:12 am 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
iansjack wrote:
I think you may be confusing GB and MB.


I think I might have :)

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Drawing to my screen should not be so hard
PostPosted: Wed Nov 21, 2018 11:19 am 
Offline

Joined: Mon Nov 19, 2018 12:13 pm
Posts: 22
kzinti wrote:
iansjack wrote:
I think you may be confusing GB and MB.


I think I might have :)

yeah i only have a 4GB card. lol i wouldnt be able to fit 1280x1024 32bpp

_________________
- Mitchell Barnes the Confused Idiot
17 years old and programming assembly

“If you're going to tell me to give up then you're wasting time that you could be using to help someone else”

“Assembly is more readable and easy to use than c. Change my mind”


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 57 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group