Prepare Kernel 2 Question

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
Annie
Posts:14
Joined:Thu Feb 12, 2009 9:11 pm
Prepare Kernel 2 Question

Post by Annie » Thu Apr 08, 2010 11:27 am

Hi,

Could anyone please explain to me why we do this

Code: Select all

%define ROOT_OFFSET 0x2e00                           
%define FAT_SEG 0x2c0
%define ROOT_SEG 0x2e0
I know that each Fat has 9 sectors, (512 bytes per sector), so each Fat has 4608 bytes.

However, the gap between FAT_SEG and ROOT_SEG is only 32 bytes. Will the FAT data override ROOT Directory data when we load? Will we use ROOT_OFFSET at all?

Thank you

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Re: Prepare Kernel 2 Question

Post by Mike » Thu Apr 08, 2010 3:10 pm

Hello,

FAT_SEG and ROOT_SEG are segments, not linear address. That is, they are loaded into segment registers. FAT_SEG:0 points to 0x2c00 linear while ROOT_SEG:0 points to 0x2e00 which is 512 bytes apart, enough for loading a sector of the FAT.

(Although there might be a bug in the bootloader here. It would only function correctly if it reads only 1 sector of the FAT which I do not believe it does.)
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: Prepare Kernel 2 Question

Post by Andyhhp » Thu Apr 08, 2010 3:42 pm

I cant remember where that code is from (im guessing fat12.inc but I am not sure)

However, when loading stage2 from the bootloader, or loading the kernel from stage2, it really doesnt matter if the information is overwritten. In each case, you are only loading a single file in a one-off mannor. Once you have the first block from the Root Directory, you only need the FAT to fully load the file.

~Andrew
Image

Post Reply