flat assembler
Message board for the users of flat assembler.

Index > OS Construction > How to executing BIOS Interrupt in PMode?

Author
Thread Post new topic Reply to topic
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
I need that for set up video mode in my OS.
Post 07 Sep 2012, 00:21
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
return in rm, set video mode with bios, return in pm, or...
write a driver for the video card in pm.
Post 07 Sep 2012, 12:56
View user's profile Send private message Visit poster's website Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
And more precisely, the method for doing the former is:

  • disable interrupts
  • switch paging off (by clearing the PG bit in cr0)
  • flush the TLB (cr3)
  • "jump" to a 16 bit code area (using the real-mode code descriptor)
  • adjust segment registers for real-mode (using the real-mode data descriptor)
  • load the real-mode IVT
  • switch to real-mode (clear PE bit in cr0)
  • enable interrupts
  • <run real-mode code>
  • switch back to protected-mode as you first did
Post 07 Sep 2012, 16:57
View user's profile Send private message Reply with quote
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
OK, I now almost understand at all,
Now, i need to know how to load Real mode IVT..
Can you tell me about that? Smile
Post 08 Sep 2012, 01:26
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
Same as in protected-mode, use the lidt instruction for that. Since you inherit the IVT the BIOS created before you entered protected-mode, you don't have to set anything up. So an IVT such as this should work:
Code:
IVT   dw 1023
     dd 0
    
Post 08 Sep 2012, 12:37
View user's profile Send private message Reply with quote
asmdev



Joined: 21 Dec 2006
Posts: 18
asmdev
don't forget to restore PIC to its original state which would probably mean disabling ioapic for a modern os
Post 08 Sep 2012, 13:39
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
If you see my post here, there's a vesa demo i coded, that goes to and from realmode for mode switching, from vesa to text mode to vesa etc, every 10 seconds.
Fasm source included.
http://board.flatassembler.net/topic.php?p=143625#143625

Also see Mike Gonta work.
Post 08 Sep 2012, 16:55
View user's profile Send private message Reply with quote
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
Ok, I understand now Smile
Thanks All, and also to Dex for your code. your code helpful Smile
Post 10 Sep 2012, 12:50
View user's profile Send private message Reply with quote
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
Hey, wait...
i get little problem just now...

yesterday, i try to write small booloader that load gdt, switch to pmode and then back to rmode and print a char using int 10h
yeah, i'm very glad, it works Very Happy

just now, i m trying to re implement that to my kernel...
first, bootloader load it to 0500:0000, but bochs said something like this :
....[cpu0]virtual_emm_read32.. blah blah blah...
whats wrong?
then i try changed bootloader to make my kernel loaded at 0600:0000, yeah, i get no errors, but the interrupt not executed Sad
so, i decide to change bootloader again. now it load my kernel at 1000:0000.
i get error like first experiment :p
Post 11 Sep 2012, 10:13
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.