segment after switching to protected mode

Started by MASM, January 05, 2012, 06:12:25 PM

Previous topic - Next topic

MASM

from what I read the 80386 comes out in the FFFF0000H code segment after enabling the PE bit.

my computer is an 80386 equipped with 8 MB of memory.

I have no RAM near 4 GB.

how can I tell my 80386 to come out in another segment when switching to protected mode?

dedndave

there is probably ROM (BIOS) at that address
it has been a long time since i played with this stuff, but here's what i remember...

there is a bit in the RTC RAM that you can set (probably named something like "warm boot")
if that bit is set, BIOS branches to an address that you have set in the BIOS data area (or maybe the IVT)
don't ask me the specifics - i am lucky to remember that much   :lol
but - it may give you enough info to google for more stuff

they used to use this mechanism to leave either protected mode or real mode (286 processor i think - i forget)
they would generate a triple-fault that caused the processor to reset and BIOS does the branch

FORTRANS

#2
Hi,

   "The Undocumented PC" says that register 0FH in the CMOS
RAM (in the RTC chip originally) controls the boot process.  If
you put a value of 5 or 6 there, the BIOS will jump to an address
stored at 40:67H.

HTH,

Steve

Edit Fixed as pointed out in Reply #3.  Thanks.
SRN

dedndave

QuoteIf you put a value of 5 or 6 there, the BIOS will jump to an address stored at 4-:67H

i am sure that Steve meant 40:67h
the segment at 40h is a small area called the BIOS data segment

MichaelW

Quote from: MASM on January 05, 2012, 06:12:25 PM
from what I read the 80386 comes out in the FFFF0000H code segment after enabling the PE bit.

my computer is an 80386 equipped with 8 MB of memory.

I have no RAM near 4 GB.

how can I tell my 80386 to come out in another segment when switching to protected mode?

FFFF0000H is fairly close to the 32-bit address where the processor starts executing, 0FFFFFFF0h. Regardless of how much memory the system has, it has some memory, probably ROM, mapped into this address. There is a thread where we discussed this here:

http://www.masm32.com/board/index.php?topic=13085.0

That address has nothing to do with your program switching to PM.

eschew obfuscation

dedndave

now that i remember a little better....
they used that triple-fault mechanism on 286 machines because the processor had no other way to exit protected mode
this fact is one of the reasons why the 286 was often refered to as "brain-dead"
newer processors have a better method built in

MichaelW

I think they used the triple-fault to do the mode switch quickly, as an alternative to the slower keyboard controller method.
eschew obfuscation

MASM

yes, there is BIOS ROM at FFFFFFF0H

my routine assumes a 64kB segment starting at FFFF0000H

this segment contains the startup code in its upper memory as well as the IDT and GDT in its lower memory.

after it is through with the startup code it forces an inter segment jump to whatever program

I am playing with the idea to pull my BIOS to replace it with an EPROM which has the startup code on it.

my last EPROM instruction would be an inter segment jump to a memory location below 8 MB (which is how much memory I have)

this would solve the ROM problem but it gives me no RAM at FFFF0000H to hold my IDT and GDT respectively.

I think I will have to create a data segment below 1 MB to hold my IDT and GDT

Actually from what I have heard the CPU assumes a data segement from 0000 to FFFF at startup but for some reason my code integrates the data into the code segement starting at FFFF0000

I am also reading this other thread which is very interesting