Page 1 of 1

Moving Kernel's Code

Posted: Mon Nov 25, 2002 2:48 pm
by Tom
Hello...In case I deside to add v86 mode to my kernel, how would I move my kernel above one meg?

My kernel is loaded at 0x9000.

Thank you,

Re:Moving Kernel's Code

Posted: Mon Nov 25, 2002 6:39 pm
by PlayOS
If you know the size of your kernel just load ecx with the size in bytes, es:edi (place to put it) and ds:esi (place to get it from) and then do a rep movsb (you should probably clear the DF flag (cld) aswell just to be sure), better still from c just call memcpy() and your done. Dont forget to jump into the new location. I would do this before enabling paging or anything like that. You should probably do this straight away before you do anything else (once you want to di that is ;)).

hope this helps.

Re:Moving Kernel's Code

Posted: Tue Nov 26, 2002 6:10 am
by Tim
It isn't a question of moving the kernel in memory, but of where it is located in virtual address space.

Before you start adding V86 mode, I'd recommend that you start using paging (heck, I'd recommend that you write a fully working kernel first). Then you can say that the kernel is at whatever address you want, regardless of where it is in physical memory.