Thanks for your help and time.
I'm sorry if this is to noob to be posted here but I'm stuck.
Code: Select all
/********************************************************************************/
/* */
/* FIREBIRD OS */
/* */
/* This is a simple asm bootloader for Firebird OS */
/* */
/********************************************************************************/
#################################
# Main code... #
#################################
.code16
.text
.globl _start
.include "kernel/kernel.inc"
_start:
/* BIOS will copy kernel to es:bx ... */
pushw $KERNEL_POS_ES # KERNEL_POS_ES:KERNEL_POS_BX...
popw %es
movw $KERNEL_POS_BX, %bx
/* Copy function settings... */
movb $0x2, %ah # Copy function...
movb $KERNEL_SECT, %al # Sectors to read...
movb $0x0, %ch # Cylinder 0...
movb $0x2, %cl # Sector 2...
movb $0x0, %dh # Head 0...
movb $0x0, %dl # Device 0...
/* Read... */
int $0x13
jnc read_done
/* Error reading... */
call reset_floppy
jnc _start # Read again...
/* Error reseting floppy... */
jmp error # Die...
read_done:
/* Enable A20 gate... */
cli # Clear interrupts...
inb $0x92, %al # Open al to port 0x92...
or $0x2, %al # Send value 0x2 to al...
outb %al, $0x92 # Close al port 0x92...
sti # Re-enable interrupts...
/* Move the GDT and load it... */
movw $GDT_ADDR>>4, %ax
movw %ax, %es
movw $gdt, %si
xorw %di, %di
movw $GDT_SIZE>>2, %cx
rep movsl
lgdt gdtr
/* Go protected mode... */
cli
movl %cr0, %eax
or $1, %eax
movl %eax, %cr0
ljmp $CODE_SEL, $protected_mode
.code32
protected_mode:
/* Jump to kernel... */
ljmp $CODE_SEL, $((KERNEL_POS_ES<<4)+KERNEL_POS_BX)
.code16
/* If we reach here something went wrong... */
error:
movw $error_str, %si
call print_string
/* Halt execution if we reach here... */
halt:
hlt
jmp halt
#################################
# Functions... #
#################################
reset_floppy:
push %ax # We use ax and dx so save the values...
push %dx
movw $0x0, %ax
movb $0x0, %dl # Drive to reset...
stc # Activate cartage flag...
int $0x13
pop %dx # Restore ax and dx...
pop %ax
ret
print_string:
pusha
movb $0xe, %ah # Teletype function...
.repeat:
lodsb # Get char from str...
cmpb $0, %al # End of string?
je .done
int $0x10 # Exec function...
jmp .repeat # Next char...
.done:
popa
ret
#################################
# Data... #
#################################
error_str:
.ascii "[!] Error booting Firebird OS...\0"
#################################
# GDT descriptor... #
#################################
gdtr:
gdtsize: .word gdt_end-gdt-1
gdtbase: .long GDT_ADDR
gdt:
/* Null descriptor... */
.quad 0x0000000000000000
/* Code segment with 4GB flat memory model... */
.quad 0x00cf9a000000ffff
/* Data segment with 4GB flat memory model... */
.quad 0x00cf92000000ffff
/* For future use... */
.quad 0x0000000000000000
.quad 0x0000000000000000
gdt_end:
#################################
# Boot signature... #
#################################
.org 0x1fe
.word 0xaa55