Kernel loading from cd
Posted: Sat Aug 14, 2010 4:27 pm
Hi guys. I've developed(90% copied from your page, but i understand it) a bootloader. After entering in 32 bits protected mode i try to load my kernel, but the bootloader freezes.
Here is my code
bootloader.asm
kernel.cpp
Also when i compile the kernel i get the next warning
Sorry for my bad english and i hope that somebody can help me.
L.E Oh, and for testing I use a file created with windows command copy /b
and i use that image as bootsector of an iso image(Ultra ISO)
Then i emulate that iso image in Virtualbox.
Here is my code
bootloader.asm
Code: Select all
[BITS 16]
[ORG 0x7C00]
cli ;disable interupts
xor ax, ax
mov ds, ax ; set ds to 0
lgdt [gdt_desc] ; Load the GDT
mov eax, cr0 ; Copy the contents of CR0 into EAX
or eax, 1 ; Set bit 0
mov cr0, eax ; Copy the contents of EAX into CR0
jmp 08h:clear_pipe ; Jump to code segment, offset clear_pipe
[BITS 32] ; We now need 32-bit instructions
clear_pipe:
mov ax, 10h ; Save data segment identifyer
mov ds, ax ; Move a valid data segment into the data segment register
mov ss, ax ; Move a valid data segment into the stack segment register
mov esp, 090000h ; Move the stack pointer to 090000h
mov byte [ds:0B8000h], 'P' ; Move the ASCII-code of 'P' into first video memory
mov byte [ds:0B8001h], 0x07 ; Assign a color code
start: ;read kernel
mov ax,0
mov es,ax
mov bx,0x1200 ;memory location where we will load the kernel
mov ah,0x02
mov al,0x01
mov ch,0x00
mov dl,80h
mov dh,1
mov bx,0x000
int 13h
jc start
mov byte [ds:0B8002h], 'P' ; Move the ASCII-code of 'P' into first video memory
mov byte [ds:0B8003h], 0x07 ; Assign a color code
jmp 0x120:0000
gdt: ; Address for the GDT
gdt_null: ; Null Segment
dd 0
dd 0
gdt_code: ; Code segment, read/execute, nonconforming
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_data: ; Data segment, read/write, expand down
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end: ; Used to calculate the size of the GDT
gdt_desc: ; The GDT descriptor
dw gdt_end - gdt - 1 ; Limit (size)
dd gdt ; Address of the GDT
times 510-($-$$) db 0x00 ; Fill up the file with zeros
dw 0AA55h ; Boot sector identifyer
Code: Select all
void kernel_main(){
unsigned char *videoram = (unsigned char *) 0xb8000;
videoram[0] = 65; /* character 'A' */
videoram[1] = 0x07; /* forground, background color. */
for(;;);
linker.ldCannot find entry symbol kernel_main
Code: Select all
ENTRY (kernel_main)
SECTIONS{
. = 0x00100000;
.text :{
*(.text)
}
.rodata ALIGN (0x1000) : {
*(.rodata)
}
.data ALIGN (0x1000) : {
*(.data)
}
.bss : {
sbss = .;
*(COMMON)
*(.bss)
ebss = .;
}
}
L.E Oh, and for testing I use a file created with windows command copy /b
Code: Select all
copy /b bootloader.bin+kernel.bin out.img
Then i emulate that iso image in Virtualbox.