boot code needs fix [FIXED]
Here's one of my old bootsector that loads to 1mb, sets a20 + pmode and I think it checks memory too. It's not FAT12, and max kernel size is like 64 (becasue 1mb + 64kb is what you can access in rm), it only loads like 50kb right now though.
HTH
HTH
- Attachments
-
- NOFSboot.asm
- (7.87 KiB) Downloaded 111 times
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
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?
From my kernel:
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
what would happen if i did this:
bochs gives me:
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
Author of COBOS
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
p.s. my kernel started before the move from 0x1000 to 1MB point so it enters PMODE just fine( i think )
the following may sound lame but i have a vague memory about the same error:
- did you turn off interrupts before switching to pmode or did you setup an idt.
- is you kernel compiled with origin at 1Mib.
i just looked at you code and you seem to be missing the gdt entry for a code segement. you are jumping to a data segment which would explain the error.
- did you turn off interrupts before switching to pmode or did you setup an idt.
- is you kernel compiled with origin at 1Mib.
i just looked at you code and you seem to be missing the gdt entry for a code segement. you are jumping to a data segment which would explain the error.
Author of COBOS
my boot sector works,
i just want to know how to put my kernel at 0x100000 and jmp to it.
my boot sector works for 0x8000, but not for 0x100000
how (mabey some code) do i get this: http://lemonos.cvs.sourceforge.net/lemo ... iew=markup
to load my kernel to 0x100000?
thx
i just want to know how to put my kernel at 0x100000 and jmp to it.
my boot sector works for 0x8000, but not for 0x100000
how (mabey some code) do i get this: http://lemonos.cvs.sourceforge.net/lemo ... iew=markup
to load my kernel to 0x100000?
thx
well you can copy the stuff you loaded at 0x8000 to 1 Mib after jumping to protected mode, that should do the trick. sorry i only know at&t syntax.
problably the rep stosl is faster but you'll get the idea.
and remember to compile the kernel at $100000 and enable the address line a20, if you wish to do the a20 later maybe use $200000 but i think pmode requires a20.
problably the rep stosl is faster but you'll get the idea.
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;
Author of COBOS