Hi Nikhil,
Its almost the correct sequence.
It is the job of the OS to take 386 from Real to Protected Mode ( maybe by setting the CR0 bit, I'm trying to find this in the Kernel sources :)
CR0 is a register not a bit. It contains system control flags. Switching from Real Mode to Protected mode happens when the PE (Protection Enable) bit in this register is set. I think protected mode is enabled in /usr/src/linux-2.4/arch/i386/boot/setup.S section "code32_start" and paging is enabled in /usr/src/linux-2.4/arch/i386/kernel/head.S section "startup_32".
Now it is expected that Track 0 contains valid OS. (Some Magic Number AFAIK) Now where does the Bootloader come into picture? (
I >dunno pls someone elucidate on this)
BIOS looks for the content of sector 0 (bootsect.S in linux). If it has the magic number 'AA55' at offset 510 it is considered valid. In case a bootloader is used , part of the bootloader (lilo etc.) exists in the bootsector(Sector 0) and has the magic number AA55.
Verify this in :-
/usr/src/linux/arch/i386/boot/bootsect.S (note : this file is used when lilo not used)
regards, Sabu
--- Nikhil Joshi nikhil_joshi@gmx.net wrote:
386DX has 3 modes:
- Real Mode (for older apps, specifically for
8086/88 support) 2. Virtual Real Mode or Virtual 86 mode(for having (some) protected mode feat. in real mode) 3. Protected Mode
Protected mode has following advantages:
- Full 32 bit addressing
- Better interrupt/fault handling (more no. of
interrupt conditions possible) 3. Multiuser, Multitasking environment possible because of different previlege levels, task switiching thru call gates and interrupt gates, etc. 4. Data is secure at the hardware level. Non previleged task will not be able to access higher privelege data segment 5. Better memory management
and more ...
However it is interesting to note that whenever 386 is reset it will go into Real Mode by *default* (obviously for DOS and other real mode OSes which dont know about protected mode.)
It is the job of the OS to take 386 from Real to Protected Mode ( maybe by setting the CR0 bit, I'm trying to find this in the Kernel sources :) )
After protected mode has been initialized, kernel loads the IVT (Interrupt Vector Table ), the previlege levels of the data and code segments ( *maybe* this facility is used for user level file acess/execution previleges ) and continues loading the OS.
P.S. But how the Kernel is loaded in first place by the BIOS? Conjecture:
When reset, 386 points to a default location in PROM. ( the location is FFFF0H note: for 8086 compatibility 16 bit address)
The default location then has a subroutine which passes control to the BIOS (a sort of PROM right ?)
Now BIOS performs the IO checks. Afterwards it searches for address (Track 0) of a media (CDROM/HDD/FDD). Now it is expected that Track 0 contains valid OS. (Some Magic Number AFAIK)
Now where does the Bootloader come into picture? ( I dunno pls someone elucidate on this)
Ok lets assume that Bootloader "fools" BIOS in believing that it actually is an OS.
Now control is transferred to the bootloader which according to the option selected loads the kernel of the selected OS. The kernel now continues with its operation....
whew... Can someone pls tell whether this is the right sequence?
-- Nikhil Earth,19.12N 73.02E
-- _______________________________________________
__________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com