moving kernel at 0x100000

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
kornox

moving kernel at 0x100000

Post by kornox »

Hi everyone,

i have a problem moving my kernel at phys 0x100000. Loading it at 0x10000 and jumping to it is no problem, but when i try to move it at 0x100000 and jump there, the system reboots.
The idea is to load the kernel over the 1st MB from the 16 byte loader, enter pmode and jump to it. Enabling a20 is ok, switching to pmode looks fine. I have tried:
xor ecx, ecx
mov ax, 0x10 ; my data seg ( phys 0x0 )
mov ds, ax
mov es, ax
mov cx, [kernel_size]
mov esi, 0x00010000
mov edi, 0x00100000
rep
a32 movsb
jmp dword 0x8:0x100000 ; 0x8 - code seg

and :

mov cx, [kernel_size] ; in bytes
shr cx, 1
inc cx
mov ax, 0x18 ; tmp desc
mov es, ax
mov si, gdt_copy_start
mov ax, 0x10
mov ds, ax
mov ax, 0x8700
copy_krnl:
int 0x15
jc copy_krnl
jmp dword 0x8:0x100000 ; 0x8 - code seg

using:

gdt_copy_start:
.null_seg
dd 0x00000000
dd 0x00000000
.code_seg
dw 0xffff
db 0x00, 0x00, 0x01
db 0x93

dw 0x0

.data_seg
dw 0xffff
db 0x00, 0x00, 0x10
db 0x93

dw 0x0
gdt_copy_end:
dd 0x0
dd 0x0

But jumping to 0x100000 reboots the system.
Can you give me some advice?
Thanks
DIGIT4L_PUNK

Re:moeing ekrnel at 0x100000

Post by DIGIT4L_PUNK »

do not use int 0x15.
switch to protected mode by yourself. then copy the kernel image to 0x00100000 and jump to it.
kornox

Re:moeing ekrnel at 0x100000

Post by kornox »

as my first example shows:
xor ecx, ecx
mov ax, 0x10 ; my data seg ( phys 0x0 )
mov ds, ax
mov es, ax
mov cx, [kernel_size]
mov esi, 0x00010000
mov edi, 0x00100000
rep
a32 movsb
jmp dword 0x8:0x100000 ; 0x8 - code seg

i try to move the kernel without any ints. But the result is the same. Both examples are in pmode.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:moeing ekrnel at 0x100000

Post by Pype.Clicker »

is the kernel actually linked for 1MB ?
What does the Bochs tell about the crash ?

(btw, next time, will you mind taking the time to type your title correctly ?)
Post Reply