Hi, i am a newbie on OS development.
I can't boot my C kernel, i have find a bootsector on this forum (from frank):
[The Assembly Code]:
org 7c00h
jmp start
start:
mov [drive],dl
; Update the segment registers
; mov ax, cs ; Copy cs into ax
; mov ds, ax ; cs->ax->ds
; mov es, ax ; cs->ax->es
; try this instead:
xor ax,ax
mov ds,ax
; (codesegment is already loaded)
jmp Running
; This is where the boot program runs.
Running:
; Load the second stage loader.
reset:
mov ax, 0x00
mov dl, [drive]
int 13h
jc reset
read:
mov bx, 1000h
mov ah, 0x02
mov al, 5
mov ch, 0
mov cl, 2
mov dh, 0
mov dl, [drive]
int 13h
jc read
cli
lgdt[gdtr]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp dword codesel:pmode
; Start A20
; a20line is more than this see: ;http://www.mega-tokyo.com/os/os-faq-memory.html
; anyway, I don't know if a20 line is necessary....
; (I just folowed the steps
; We are in protected mode here:
[bits 32]
pmode:
mov eax,datasel
mov ss,eax
mov ds,eax
mov es,eax
mov fs,eax
mov gs,eax
mov ax,0x10
mov ss,ax
mov esp,0xFFFF
mov dl,[drive]
jmp dword codesel:0x1000
; jmp 1000h:0000
; Global descriptor table
; this tells the comp where
; all the segments (now selectors) are
gdtr
dw gdt_end-1
dd gdt
gdt
nullsel equ $-gdt
gdt0
dd 0
dd 0
codesel equ $-gdt
dw 0ffffh
dw 0
db 0
db 09ah
db 0cfh
db 0h
datasel equ $-gdt
dw 0ffffh
dw 0h
db 0h
db 092h
db 0cfh
db 0
gdt_end
; This part makes sure the bootsector is 512 bytes.
drive db 0
times 510-($-$$) db 0
dw 0xAA55
[ And my kernel test code ]:
/* main.c: Nilix C Kernel */
/* Cette fonction affiche str ? la premi?re ligne de l'?cran */
void printk(char *str)
{
char *video = (char *)0xB8000;
while(*str!='\0')
{
*video=*str;
video++;
*video=0x57;
video++;
str++;
}
}
asm("jmp start");
void start()
{
printk("Kernel is speacking\n");
while(1)
{
}
}
Unix Commands:
ls
bootsect.asm boot.bin main.c
gcc -c main.c -o main.o
ld -Ttext=0x1000 -o nilix main.o
objcopy -R .note -R .comment -S -O binary nilix nilix.bin
dd if=boot.bin of=/dev/fd0
dd if=nilix.bin seek=1 of=/dev/fd0
I test and compile my source on:
AMD Athlon XP 2100+ (SuSE Linux 8.0).
But my computer reboot
I aslo test on:
AMD K6-2 (SuSE Linux 7.3)
But my computer reboot again
??? ???
Please, helpl me