Posted: Thu Feb 15, 2007 4:46 pm
whats kernelSize in? bytes? why add 3 then divide by 4?
thx!
p.s. how do you set the a20 in asm?
thx!
p.s. how do you set the a20 in asm?
The Place to Start for Operating System Developers
http://f.osdev.org/
breaks things and resets bochs?move_kernel:
mov esi, 0x00008000
mov edi, 0x00100000
mov ecx,( 0C800h + 3) / 4
rep movsd
you should be aware of the position-dependent forms: A normal jump is relative: if you do that here you end up executing in the wrong kernel image.GLNeo wrote:[ code ] breaks things and resets bochs?
Code: Select all
kernelimagestart:
MOV ESI, 0x80000
MOV EDI, 0x100000
MOV ECX, kernelimagesize
CLD
REP MOVSB
MOV EAX, kernelentry
JMP EAX
Beware that a20 must be enabled at this point - theres some material on this in the wiki you should probably read.bubach wrote:it starts loading at the beginning of realmode segment 0xffff which is at 1mb, so you can load 64kb after 1mb without going into unreal mode
Code: Select all
jmp kernel_load:
LoadSectors:
push ax
push bx
push cx
mov dl, 12h
div dl
inc ah
mov cl, ah
mov dh, al
and dh, 01h
shr al, 1
mov ch, al
mov dl, 00h
Read:
mov ah, 02h
mov al, 01h
int 13h
jc Read
pop cx
pop bx
pop ax
add bx, 0200h
inc ax
loop LoadSectors
ret
kernel_load:
mov ax, 0xffff
mov es, ax
mov bx, 0x0000
mov ax, 1
mov cx, 60
call LoadSectors
[When in PMODE]
kernel:
jmp 08h:100000h
Code: Select all
00005852715p[CPU ] >>PANIC<< prefetch: running in bogus memory
well actually 0xFFFF segment is short 16 bytes of 1 MiB so i hope that you take this into account and indeed the A20 line should be on. This is not a problem in bochs as it has the a20 by default(submitted a bug report for this). If the a20 line is not on the address wrap to 0 and that means you will overwrite the interruptvector table and the bios area.bubach wrote:it starts loading at the beginning of realmode segment 0xffff which is at 1mb, so you can load 64kb after 1mb without going into unreal mode.
this means that the protected mode problably didn't take well. try copying the byte 0xC3 to the location where your kernel starts and instead of jumping to it make a call. if this works then it is related to your kernel.GLneo wrote:bochs gives me: Code:
00005852715p[CPU ] >>PANIC<< prefetch: running in bogus memory
Code: Select all
ljmp $8:label
label:
mov $10000h, %eax
call *%eax
so i should do this:os64dev wrote: well actually 0xFFFF segment is short 16 bytes of 1 MiB so i hope that you take this into account
Code: Select all
kernel_load:
mov ax, 0xFFFF
mov es, ax
mov bx, 0x0010
mov ax, 1
mov cx, 60
call LoadSectors
Code: Select all
movl $0x080000, %esi;
movl $0x100000, %edi;
movl $0x007800, %ecx; //- 60 sectors at 512 bytes.
copy_loop:
movl (%esi), %edx;
movl %edx, (%edi);
addl $4, %esi;
addl $4, %edi;
subl $4, %ecx;
cmpl $0, %ecx;
jne copy_loop;