Page 1 of 1

GDT Entries, Help?

Posted: Fri Feb 06, 2009 9:56 am
by Raven
By now i am done with second stage bootloader and am ready to load kernel.
BUT i am not sure about GDT entries like:

1. 1 null, 1 ring0 code, 1 ring0 data, 1 ring3 code, 1 ring3 data BUT how many TSS?

2. When i am in Second stage bootloader i need to access BPB of BootSector, is there any mechanism where from i can get this structure without loading bootsector again as it is alredy available in memory? Yes, pointing to memory locations but i need to calculate these values and use hardcore statements like
BPB_BytesPerSector equ 7c00h+oxb
Is there any other way that can be used?

3.Well right now in Second stage bootloader i have switched to protected mode but have declared a common handler for exceptions, how to use proper routines is easy but how to get address of IDT structure declared in Second Stage bootloader, like above

Please, reply me soon?

Re: GDT Entries, Help?

Posted: Fri Feb 06, 2009 11:14 am
by egos
Raven wrote:1. 1 null, 1 ring0 code, 1 ring0 data, 1 ring3 code, 1 ring3 data BUT how many TSS?
One on each processor.
Raven wrote:2. When i am in Second stage bootloader i need to access BPB of BootSector, is there any mechanism where from i can get this structure without loading bootsector again as it is alredy available in memory? Yes, pointing to memory locations but i need to calculate these values and use hardcore statements like
BPB_BytesPerSector equ 7c00h+oxb
Is there any other way that can be used?
It is your decision. For example, save BPB at 0x500 or at 0x7C00. The better way is DO NOT to transfer BPB at all. Boot device number is enough for this.
Raven wrote:3.Well right now in Second stage bootloader i have switched to protected mode but have declared a common handler for exceptions, how to use proper routines is easy but how to get address of IDT structure declared in Second Stage bootloader, like above...
sidt ?

Re: GDT Entries, Help?

Posted: Fri Feb 06, 2009 11:15 am
by gzaloprgm
1. 1 null, 1 ring0 code, 1 ring0 data, 1 ring3 code, 1 ring3 data BUT how many TSS?
Depends of if you want to use Hardware or Software Multitasking. If you want to use Hardware, you'll need one TSS per process. Otherwise you only need one, to hold the value ESP and SS will get after a Ring3 to Ring0 switch.
2. When i am in Second stage bootloader i need to access BPB of BootSector, is there any mechanism where from i can get this structure without loading bootsector again as it is alredy available in memory? Yes, pointing to memory locations but i need to calculate these values and use hardcore statements like
BPB_BytesPerSector equ 7c00h+oxb
Is there any other way that can be used?
Well, if your second stage loader is loader just above the first sector (0x7C00+512), then you could merge both files into the same .asm and reference symbolically to the values.
3.Well right now in Second stage bootloader i have switched to protected mode but have declared a common handler for exceptions, how to use proper routines is easy but how to get address of IDT structure declared in Second Stage bootloader, like above
I don't think the 2ยบ stage bootloader should have that. The bootloader expects the kernel to be a valid file. And if some exception happens in pmode while in the second stage (before jumping to the kernel), it's probably a bug in your code.

Cheers,
Gonzalo