We are working on a project to learn how to write a kernel and learn the ins and outs. We have a bootstrap loader written and it appears to work. However we are having a problem with the kernel loading. I'll start with the first part:
bootloader.asm:
[BITS 16]
[ORG 0x0000]
;
; all the stuff in between
;
; the bottom of the bootstrap loader
datasector dw 0x0000
cluster dw 0x0000
ImageName db "KERNEL SYS"
msgLoading db 0x0D, 0x0A, "Loading Kernel Shell", 0x0D, 0x0A, 0x00
msgCRLF db 0x0D, 0x0A, 0x00
msgProgress db ".", 0x00
msgFailure db 0x0D, 0x0A, "ERROR : Press key to reboot", 0x00
TIMES 510-($-$$) DB 0
DW 0xAA55
;*************************************************************************
The bootloader.asm is too long for the editor without causing it to chug and choke. In addition, the bootloader and kernel do work within bochs as we do get the message "Welcome to our OS". Anyway, the following is what we have for a kernel at this point.
kernel.asm:
[BITS 16]
[ORG 0x0000]
[SEGMENT .text] ; code segment
mov ax, 0x0100 ; location where kernel is loaded
mov ds, ax
mov es, ax
cli
mov ss, ax ; stack segment
mov sp, 0xFFFF ; stack pointer at 64k limit
sti
mov si, strWelcomeMsg ; load message
call _disp_str
mov ah, 0x00
int 0x16 ; interrupt: await keypress
int 0x19 ; interrupt: reboot
_disp_str:
lodsb ; load next character
or al, al ; test for NUL character
jz .DONE
mov ah, 0x0E ; BIOS teletype
mov bh, 0x00 ; display page 0
mov bl, 0x07 ; text attribute
int 0x10 ; interrupt: invoke BIOS
jmp _disp_str
.DONE:
ret
[SEGMENT .data] ; initialized data segment
strWelcomeMsg db "Welcome to our OS", 0x00
[SEGMENT .bss] ; uninitialized data segment
Using nasm 2.06rc2 I compile as such:
nasm bootloader.asm -o bootloader.bin -f bin
nasm kernel.asm -o kernel.sys -f bin
We write bootloader.bin to the floppy as such:
dd if=bootloader.bin bs=512 count=1 of/dev/fd0
We write kernel.sys to the floppy as such:
cp kernel.sys /dev/fd0
As I stated, this works in bochs. But booting from the floppy we get output like so:
Loading Kernel Shell
...........
ERROR : Press key to reboot
Other specifics: OpenSUSE 11.2, GNOME desktop, AMD x64 Any other information I may have missed, feel free to ask. I tried to get everything in here that would be needed. If I need to, I can find a way to get the entire bootloader.asm posted somewhere. We are not really interested in using GRUB either for several reasons. This could change, but we want to see this boot successful before we really consider GRUB.
EDIT: The bootstrap loader is suppose to be 512 bytes, written to the boot sector (very first sector) of the disk. Take my word for it, bootloader is 512 bytes compiled. The kernel is suppose to be in the very next sector.