Page 1 of 1

Prepare Kernel 2 Question

Posted: Thu Apr 08, 2010 11:27 am
by Annie
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

Re: Prepare Kernel 2 Question

Posted: Thu Apr 08, 2010 3:10 pm
by Mike
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.)

Re: Prepare Kernel 2 Question

Posted: Thu Apr 08, 2010 3:42 pm
by Andyhhp
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