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.
my boot loader copies kernel linked at 0xc000_0000 at 0x100000.then it switches to protected mode.
the selectors in boot loader have base zero and limit 4 gb.then i jump to kernel.
in kernel i reload the selectors with base 0x4010_0000.but as soon as execute the jump instruction to load CS:IP with new values ,computer restarts.
please tell me the problem and how to remove it.
i'd be tempted to say that the offset of LGDT instruction is bound to 0xC000_0000, as any other part of your kernel. So when you try to load it, you actually load garbage from non-existent physical memory ...
from there, you can easily imagine that the next time you'll try to read out a descriptor (like when decoding the long jump instruction), chances are that you'll raise a GPF, which will quickly turn in a triple fault ... try to run your stuff in the Bochs and you'll see what i'm talking about ...
why not simply set a 0x4010_0000 base in the bootloader itself ?
start:
lgdt [GDTR-0xC000_0000+0x0010_0000] ;; currently running at 1MB
jmp CODESEL:.gdtr_reloaded ;; the offset is within the new segment, so everything should be fine
.gdtr_reloaded:
jmp .gdtr_reloaded
GDTR:
.limit dw GDT_END-GDT+1
.base dd GDT - 0xC000_0000 + 0x0010_0000
;; the base address is a segment-base, thus independent of the
;; current code/data/whatever segment base address, remember ?
GDT:
.null: dd 0,0
.code: dd ...
.data: dd ...
now i decided to load the selectors with desired base address in boot loader.so instead of jumping to some label
after switching to protected mode ,i jumped to 0x100000,the address where kernel has been loaded.
but the computer restarted.
i did this to check if such kind of jump works so that in future i can load selectors with base
0x40100000 using this technique.
please tell me why its not working and how can i load selectors in boot loader having base other than 0x00000000
there is an other way to use the kernel linked at 3GB and loaded at 1MB. This is by enabling paging as soon as you load your kenel(provided your kernel is loaded properly).This is what i've done anyway. I enabled paging first along with my memory manager and only then try anyhting else.
HTH