🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #48

Re: Protected Mode 386/486 Questions...

#48
From: Jerzy Tarasiuk
Date: Fri, 30 Oct 1992 03:28
53 lines
3470 bytes
>>>>> On Fri, 23 Oct 1992 10:21:13 GMT, madia@gecko.cis.ohio-state.edu (joseph anthony madia) said:
j> 	I am just starting to program for Protected Mode and I have a few
j> questions. I understand how things are supposed to work (I have a good book
j> that explains the hardware layout and the protection mechanism), but, I 
j> need some more specific help in the following areas:
j> 	1.  Going from Real-to-Protected mode (Setting up GDT, IDT, etc). Is
j> 	    there any source code that I can get that shows explicitly how 
j> 	    to do this?

Can do it by BIOS call (one of int 15h services), but because it
programs interrupt controllers, better write own program: setup
a GDT (absolutely necessary, at least code and stack segments),
setup IDT (recommended, for example to handle exceptions),
enable A20 (by a command to 8042; or bit 20 of address on bus will
be 0 regardless of what address CPU uses),
and then can set Protection Enable bit is MSW.
Note immediately after setting it must:
- execute long jump to load CS (I am not sure if it is really
  necessary to do it immediately, but must do it before any
  far call or servicing interrupt/exception or bad value would
  be pushed on stack...)
- load SS (or have no stack, since cannot call, push, ...).
- it is recommended to load some valid descriptors to DS,ES.

j> 	2.  ABIOS calls. An example of a disk read or write would be great,
j> 	    but any ABIOS calls would help. (I have the Phoenix ABIOS book
j> 	    as a reference, but it has NO examples at all)

I don't know if BIOS can work in PM. At least it is hard to make
a program working in all: Real, Protected and Virtual86 modes
(the P and V both have PE flag set in MSW).
Some BIOS services work OK if descriptor 0x40 has base 0x400 (as in
Real Mode), e.g. keyboard and timer interrupts (at least at the
machine I tried it).
Can also return to Real Mode when a service is needed and go
back into Protected Mode when it is done...

j> 	3.  Writing to Video RAM. I haven't found any information on how to
j> 	    do this. Is it as easy as setting the descriptor base to A00000
j> 	    (or whatever) and using it just like Real mode, or is it totally
j> 	    different?

Can do it (base=0xB0000). 

Yet another thing to do before setting Protected Mode: store at
DWORD 0x467 FAR address of a Real Mode program and set Shutdown
byte in CMOS RAM (0F) to 0A; if a Shutdown will occur (e.g. due
to exception during exception servicing or lack of handler),
BIOS will transfer control to the program after CPU reset.
And: remember to save interrupt mask, BIOS will probably mask
all interrupts after reset.
I tried to write PM programs several times... Now don't remember
where have their sources, but can send you when find. Need it ?
Technical Details
Message-ID: <JT.92Oct30042845@fizyk1.fuw.edu.pl>
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!natinst.com!cs.utexas.edu!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!fuw.edu.pl!cocos!jt
References: <1992Oct23.102113.14172@cis.ohio-state.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!natinst.com!cs.utexas.edu!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!fuw.edu.pl!cocos!jt
From: jt@fuw.edu.pl (Jerzy Tarasiuk)
Subject: Re: Protected Mode 386/486 Questions...
In-Reply-To: madia@gecko.cis.ohio-state.edu's message of Fri, 23 Oct 1992 10:21:13 GMT
Message-ID: <JT.92Oct30042845@fizyk1.fuw.edu.pl>
Sender: news@fuw.edu.pl
Nntp-Posting-Host: fizyk1
Organization: Warsaw University Physics Dept.
References: <1992Oct23.102113.14172@cis.ohio-state.edu>
Date: Fri, 30 Oct 1992 03:28:45 GMT
Lines: 53