GDT Entries, Help?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Raven
Member
Member
Posts: 41
Joined: Sun Feb 01, 2009 12:20 am

GDT Entries, Help?

Post 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?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: GDT Entries, Help?

Post 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 ?
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: GDT Entries, Help?

Post 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
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
Post Reply