What should I do before switching to Protected or long-mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

What should I do before switching to Protected or long-mode

Post by Holus »

So far:
1. I checked the memory so I know what limits my memory-manager has.
2. I checked the bootdevice so I can define how to read from it to set-up other hardware.

Is there more main functions I should check using BIOS interrupts, because it's almost impossible in PROTECTED-MODE or LONG-MODE?
Computer says NOOOO
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: What should I do before switching to Protected or long-m

Post by Casm »

Holus wrote:So far:
1. I checked the memory so I know what limits my memory-manager has.
2. I checked the bootdevice so I can define how to read from it to set-up other hardware.

Is there more main functions I should check using BIOS interrupts, because it's almost impossible in PROTECTED-MODE or LONG-MODE?
You don't have to use the BIOS to scan the PCI bus, but you can do so. In any case, if you later think of something which should have gone into your real mode boot code, you can simply go back and put it in. I have a structure, containing various pieces of useful information, which I pass to the kernel. So if needed I could just add some extra fields to that, and pass any newly acquired info to the kernel.
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: What should I do before switching to Protected or long-m

Post by Holus »

Casm wrote: You don't have to use the BIOS to scan the PCI bus, but you can do so. In any case, if you later think of something which should have gone into your real mode boot code, you can simply go back and put it in. I have a structure, containing various pieces of useful information, which I pass to the kernel. So if needed I could just add some extra fields to that, and pass any newly acquired info to the kernel.
I'm the @$$ who still want to "HOPE" the bootloader is 1 stage of 0x200 bytes.
I hope it's small if i find some thing. :shock:

Scanning PCI is an already build function. But thanks for the sugestion.
Computer says NOOOO
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: What should I do before switching to Protected or long-m

Post by Chandra »

1. Enable A20
2. Get the memory map
3. Scan for a list of available fundamental devices attached to the system.
4. Switch to some high res graphics, if you need to.
5. Load the 2nd stage loader, modules or the kernel off the disk.
6. ...

The whole setup depends upon your requirement, of course.
Cheers.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: What should I do before switching to Protected or long-m

Post by Holus »

Chandra wrote:1. Enable A20
2. Get the memory map
3. Scan for a list of available fundamental devices attached to the system.
4. Switch to some high res graphics, if you need to.
5. Load the 2nd stage loader, modules or the kernel off the disk.
6. ...

The whole setup depends upon your requirement, of course.
Cheers.
Setting the graphics is a real good one!! Thanks. I try to find some information about setting a propper VESA mode but all articles set it bij INT 0x10.

There must be a way setting the state bij using the ports. I need it somewere in the year 2057 when someone develloped the first programm for my OS. But setting it and not changing the state is a good advise for now.

Thanks
Computer says NOOOO
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: What should I do before switching to Protected or long-m

Post by Holus »

Chandra wrote:1. Enable A20
2. Get the memory map
3. Scan for a list of available fundamental devices attached to the system.
4. Switch to some high res graphics, if you need to.
5. Load the 2nd stage loader, modules or the kernel off the disk.
6. ...

The whole setup depends upon your requirement, of course.
Cheers.
Does someone know how to switch banks in Pmode (no bios INT 0x10) using the IO PORTS.
Is it a standaard routine or is it card specific?
Computer says NOOOO
rdos
Member
Member
Posts: 3308
Joined: Wed Oct 01, 2008 1:55 pm

Re: What should I do before switching to Protected or long-m

Post by rdos »

The only standard that exists for video-mode switching, and that is widely adopted, is int 0x10 from real-mode / V86 mode. There was an EGA/VGA standard for doing graphics, but not even that standard defined how to switch modes with IO-instructions. It was (and still is) int 0x10 that do that.

If one don't want to have a fixed graphics resolution, there is a need to support V86-mode in order to be able to switch video-mode once the kernel is started. It's not too hard to support on newer processors that has V86 extensions.
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: What should I do before switching to Protected or long-m

Post by Holus »

I found something very usefull ([-X )!!
Good old interupts!!!

http://www.delorie.com/djgpp/doc/rbinter/id/92/2.html
http://www.delorie.com/djgpp/doc/rbinter/id/93/2.html

But the function is not supported on my computer
So i wouldn't use it is you want me as a costumer :lol:
Last edited by Holus on Sat Oct 08, 2011 12:38 pm, edited 1 time in total.
Computer says NOOOO
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: What should I do before switching to Protected or long-m

Post by Chandra »

Holus wrote:
Chandra wrote:1. Enable A20
2. Get the memory map
3. Scan for a list of available fundamental devices attached to the system.
4. Switch to some high res graphics, if you need to.
5. Load the 2nd stage loader, modules or the kernel off the disk.
6. ...

The whole setup depends upon your requirement, of course.
Cheers.
Does someone know how to switch banks in Pmode (no bios INT 0x10) using the IO PORTS.
Is it a standaard routine or is it card specific?
VESA3.0 does provide the protected mode interface but it still doesn't employ the use of ports. On the other hand, bank switching is slow and troublesome so you've better just go on with the Linear Frame Buffer(VESA2.0)
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: What should I do before switching to Protected or long-m

Post by DavidCooper »

Holus wrote:I try to find some information about setting a propper VESA mode but all articles set it bij INT 0x10.

There must be a way setting the state bij using the ports.
ij lijk your Dutch spellings, but whij stop at bij?
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: What should I do before switching to Protected or long-m

Post by Combuster »

rdos wrote:There was an EGA/VGA standard for doing graphics, but not even that standard defined how to switch modes with IO-instructions.
That's nonsense. The VGA is the standard, and any device that's compatible with it can be modechanged with the same I/O instructions that work on an original VGA. What you are probably referring to are the few graphics devices from that era that tried to be a VGA wannabe and sucked at it (and therefore are by definition NOT VGA-compatible).

In fact, a VGA driver is the most effective native graphics driver to write due to the abundant information and example code, and the fact that even now practically all machines still have support for it. You just won't be able to get high resolutions or high bitdepths with it. As a nice bonus, PCI video cards will actually tell you if they are VGA compatible.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: What should I do before switching to Protected or long-m

Post by Holus »

Chandra wrote: VESA3.0 does provide the protected mode interface but it still doesn't employ the use of ports. On the other hand, bank switching is slow and troublesome so you've better just go on with the Linear Frame Buffer(VESA2.0)
Maybe I'm not capable of searching,.. Can you point me to a URL about these VESA 3.0 functions. My graphical card is VESA 3.0 (should be 2.x+ and support that function BUT NO!!!)

Isn't it that bank-switching is slow because you use DMA and you GPU and with Linear Frame Buffer it's quick because you use your CPU? (isn't that from a time when the Graphical Cards where slow in de 80's)

I'm making an OS for a DATABASE and no full-hd moviestreamer. Isn't bank-switching better for me? (less CPU and more GPU is better for me)
Computer says NOOOO
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: What should I do before switching to Protected or long-m

Post by Combuster »

That spec isn't too hard to find

VBE3 supports linear framebuffers just as well as VBE2 cards do. One of the key differences is that the protected mode interface has been overhauled (and therefore, often missing). Not that VBE2 cards did a good job at that either.
Holus wrote:isn't that from a time when the Graphical Cards where slow in de 80's
As for the linear framebuffer, the only difference is that you have limited addressing space to write your memory to, and therefore have to use port IO (which is the actual slow part) to change the video card's internal addressing, as well as having to modify your drawing functions to the framebuffer to move the window where needed, adding more checks. Also, modern framebuffers can be set to be cached, while this can't be safely done for the VGA range, making the advantage of using the LFB even greater.

Therefore, everyone here that's using a 32-bit os and is sane, avoids bankswitching like the plague.

And that has nothing to do with a GPU, you need native drivers to do anything with that, and the BIOS won't do that for you.



EDIT: source got edited away. Nevertheless:
Holus wrote:LOL I speak alle Sprachen door elkaar. Heureusement, il est entendu :wink:
Image
Ils are 馬鹿, diesen mensen.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: What should I do before switching to Protected or long-m

Post by Holus »

Combuster wrote:VBE3 supports linear framebuffers just as well as VBE2 cards do. One of the key differences is that the protected mode interface has been overhauled (and therefore, often missing). Not that VBE2 cards did a good job at that either.
What is the best way to enable the "linear framebuffer"?

So if I anable it and look at the PCI - BAR there is no trobble with VIDEO anymore?

If I set a VIDEO mode like.
1900x1200x32bit

The computer allocates BASE ADDRESS .. BASE ADDRESS + 0x8B2900 for VIDEO memory??

I see it's taken C0000000-CFFFFFFF now.
That's a loss of 100 MB of RAM??
UUUUUUH I don't have C0000000 bytes of ram :oops:

Is this actual added DIRECT video memory????
Is there a way to disable all the memory locations I don't want to use. Unlink the DMA at A0000 for example.
Computer says NOOOO
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: What should I do before switching to Protected or long-m

Post by Chandra »

Holus wrote:What is the best way to enable the "linear framebuffer"?
Set Bit 14 in BX when calling Int 0x10.
(AX=4F02H, BX=Mode No. with bit 14 set)
Holus wrote:So if I anable it and look at the PCI - BAR there is no trobble with VIDEO anymore?
Not sure what you mean by that. You may want to check spellings and grammar.
Holus wrote:If I set a VIDEO mode like.
1900x1200x32bit
Forget it. It's hardly supported by any VESA Standard.
Holus wrote:I see it's taken C0000000-CFFFFFFF now.
That's a loss of 100 MB of RAM??
UUUUUUH I don't have C0000000 bytes of ram :oops:
C0000000 is the virtual address. Even if you have 16 Megabytes of RAM, you may still address this portion of Memory(depending on which portion of the memory is mapped for Input/Output). I recommend you get a comprehensive look at Memory Mapped Input Output.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Post Reply