Moving Kernel's Code

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
Tom

Moving Kernel's Code

Post 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,
PlayOS

Re:Moving Kernel's Code

Post 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.
Tim

Re:Moving Kernel's Code

Post 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.
Post Reply