Loading a descriptor in C (PM)
Posted: Thu Jul 08, 2004 6:32 pm
Umm... this could be stupid, but here it goes:
I've already managed to get the bootstrap and the loader working, and I'm writing the kernel in C now. I loaded the IDT and a basic GDT with 3 descriptors (a null descriptor, a code desc and a data/stack code - I' m using the Flat Mode) in the loader(asm), and I have a gdt pointer in the kernel code (the address of this pointer is obtained during compilation with another program) that looks like this:
My goal is to develop Hardware Task Switching, so I also created a TSS struct. I'm thinking in just 3 task right now. This means something like:
Ok, now I want to add a new descriptor for each tss, and my question is... How do I get the linear address of the begining of each Tss? That's it, I think that I can't just write:
right? (Of course, the tssdesc struct is not like I 've shown, that was just a simple example). I mean, &mytss[ 0 ] isn 't just an offset? How do I get the linear address under Protected mode? (I have switched to PM in the Loader, asm code)
(Sorry for my bad english, and if the question is too stupid - I'm new at this)
I've already managed to get the bootstrap and the loader working, and I'm writing the kernel in C now. I loaded the IDT and a basic GDT with 3 descriptors (a null descriptor, a code desc and a data/stack code - I' m using the Flat Mode) in the loader(asm), and I have a gdt pointer in the kernel code (the address of this pointer is obtained during compilation with another program) that looks like this:
Code: Select all
dword _gdt;
Code: Select all
struct TSS mytss[3];
Code: Select all
((tssdesc*)_gdt + 0x03)->base = &mytss[0];
(Sorry for my bad english, and if the question is too stupid - I'm new at this)