basics
-
LongHorn
basics
In what order should i do things if i load my kernel from Grubs to enable paging?
1.load idt and gdt
2.enable paging
3.mm and so on
Do i need to load gdt here?
Could i enable paging straight away? If i am doing so when should i load idt. After paging means should i store virtual address or physical address?
1.load idt and gdt
2.enable paging
3.mm and so on
Do i need to load gdt here?
Could i enable paging straight away? If i am doing so when should i load idt. After paging means should i store virtual address or physical address?
-
JoeKayzA
Re:basics
If you want to use a higher half kernel, you might want to enable paging first, like Colonel Kernel described in another thread recently. From this point on, all addresses will be virtual addresses of course.
After that, I'd say you should enable the memory manager (and get a set of 'real' page tables), and then load the gdt and idt. Since you are doing quite a lot of work (initializing paging and mm) without interrupts, you should test them quite well beforehand, since any exception will lead to a triple fault.
cheers Joe
After that, I'd say you should enable the memory manager (and get a set of 'real' page tables), and then load the gdt and idt. Since you are doing quite a lot of work (initializing paging and mm) without interrupts, you should test them quite well beforehand, since any exception will lead to a triple fault.
cheers Joe
- Colonel Kernel
- Member

- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re:basics
Actually, that's why I set up the IDT and GDT immediately after enabling paging. The order in which I initialize things is like so:JoeKayzA wrote: Since you are doing quite a lot of work (initializing paging and mm) without interrupts, you should test them quite well beforehand, since any exception will lead to a triple fault.
- Enable paging.
- Set up the kernel's initial stack
- Set up the GDT and IDT
- Copy GRUB's memory map into one of the kernel's buffers and wrap it in my own architecture-independent "object" (BootLoaderInfo)
- Call kmain(), passing it a pointer to the BootLoaderInfo
- Initializes the "kernel display" (my own VGA text mode & font)
- Initializes the subsystem responsible for sanely shutting down or rebooting the system when a fatal exception occurs
- Sets up all exception and interrupt handlers and re-maps the PIC
- Initializes the physical memory manager
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
- Colonel Kernel
- Member

- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re:basics
And get the most expensive machine, in case the administrator comes!
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
- Colonel Kernel
- Member

- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re:basics
You don't have to initialize the GDT and IDT after initializing paging just because I do it that way. I think it makes mapping the kernel into the "higher half" a lot easier though. My GDT and IDT initialization code is a mixture of C and asm, but you could write it all in asm if you want.LongHorn wrote: @ Colonel Kernel : you are saying that i have to enable gdt and idt after enable paging. Then are you suggesting me to set idt and gdt in asm itslef then call kmain?
Virtual.What should be loaded in gdtr and idtr then virtual or physical?
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
-
paulbarker
Re:basics
It's actually linear, not virtual. Just to tidy up the confusion, GDTR wants a linear address that will go thru the normal page translation. CR3 (for paging) wants a physical address.What should be loaded in gdtr and idtr then virtual or physical?
My problem is I can't find anywhere in the manual whether IDTR goes thru segment translation (via GDT) or not. I'm assuming it will go thru page translation (I can't see any reason for the IDTR to be a physical address). So what is it, linear or virtual?
-
JoeKayzA
Re:basics
To my knowledge, it doesn't, it's a linear address just like the GDT's. Remember, for a logical address (that goes through segment translation and then through paging), you need a segment selector (16bit) and an offset (32bit). The IDT pointer that you load into the IDTR doesn't contain a segment selector, so it can only be a linear address.My problem is I can't find anywhere in the manual whether IDTR goes thru segment translation (via GDT) or not.
And btw, AFAIK linear and virtual addresses are pretty much the same.
cheers Joe
-
LongHorn
Re:basics
Fine
I enabled paging, now what should i do?
->createpagetable
->pagebind
->pageunbind
(before mm)
Is there any need of creating further page tables? if so what are they? and where should be my pagedir and pagetable present? Its at 0x9C000 onwards for now. Where will it be created in a professional OS?
I enabled paging, now what should i do?
->createpagetable
->pagebind
->pageunbind
(before mm)
Is there any need of creating further page tables? if so what are they? and where should be my pagedir and pagetable present? Its at 0x9C000 onwards for now. Where will it be created in a professional OS?
-
YeXo
Re:basics
That depends on the amount of physical memory you want to use. You need at least 1 page table for every 4mb physical memory you want to use. The pagedirectory(s) and pagetable(s) will always be located at whatever location is free at that particular moment. Therefore you need to write a pmm (physical memory manager) before you write a vmm (virtual memory manager.).Is there any need of creating further page tables? if so what are they? and where should be my pagedir and pagetable present? Its at 0x9C000 onwards for now. Where will it be created in a professional OS?