This commit is contained in:
Baptiste Wicht 2013-10-10 17:21:34 +02:00
parent 3f756ecd03
commit b296a2b13c
3 changed files with 76 additions and 98 deletions

View File

@ -1,32 +1,35 @@
[BITS 16] [BITS 16]
jmp rm_start
%include "src/utils/intel_16.asm"
; Start in real mode ; Start in real mode
rm_start: rm_start:
; 1. Set stable environment
; Set stack space (4K) and stack segment ; Set stack space (4K) and stack segment
mov ax, 0x7C0
add ax, 288 mov ax, 0x7C0
mov ss, ax add ax, 288
mov sp, 4096 mov ss, ax
mov sp, 4096
; Set data segment ; Set data segment
mov ax, 0x7C0 mov ax, 0x7C0
mov ds, ax mov ds, ax
; 2. Welcome the user to the bootloader ; 2. Welcome the user to the bootloader
call new_line_16 call new_line_16
mov si, header_0 mov si, header_0
call print_line_16 call print_line_16
mov si, header_1 mov si, header_1
call print_line_16 call print_line_16
mov si, header_2 mov si, header_2
call print_line_16 call print_line_16
call new_line_16 call new_line_16
@ -44,10 +47,10 @@ rm_start:
call key_wait call key_wait
mov si, load_kernel mov si, load_kernel
call print_line_16 call print_line_16
BASE equ 0x100 ; 0x0100:0x0 = 0x1000 BASE equ 0x100 ; 0x0100:0x0 = 0x1000
sectors equ 0x20 ; sectors to read sectors equ 0x20 ; sectors to read
; Reset disk drive ; Reset disk drive
xor ax, ax xor ax, ax
@ -73,7 +76,7 @@ rm_start:
jmp dword BASE:0x0 jmp dword BASE:0x0
reset_failed: reset_failed:
mov si, reset_failed_msg mov si, reset_failed_msg
call print_line_16 call print_line_16
@ -85,59 +88,15 @@ read_failed:
error_end: error_end:
mov si, load_failed mov si, load_failed
call print_line_16 call print_line_16
jmp $ jmp $
; Functions
new_line_16:
mov ah, 0Eh
mov al, 0Ah
int 10h
mov al, 0Dh
int 10h
ret
print_line_16:
mov ah, 0Eh
.repeat:
lodsb
cmp al, 0
je .done
int 10h
jmp .repeat
.done:
call new_line_16
ret
key_wait:
mov al, 0xD2
out 64h, al
mov al, 0x80
out 60h, al
keyup:
in al, 0x60
and al, 10000000b
jnz keyup
Keydown:
in al, 0x60
ret
; Datas ; Datas
header_0 db '******************************', 0 header_0 db '******************************', 0
header_1 db 'Welcome to Thor OS Bootloader!', 0 header_1 db 'Welcome to Thor OS Bootloader!', 0
header_2 db '******************************', 0 header_2 db '******************************', 0
press_key_msg db 'Press any key to load the kernel...', 0 press_key_msg db 'Press any key to load the kernel...', 0
load_kernel db 'Attempt to load the kernel...', 0 load_kernel db 'Attempt to load the kernel...', 0
@ -148,6 +107,7 @@ key_wait:
bootdev db 0 bootdev db 0
; Make a real bootsector ; Make a real bootsector
times 510-($-$$) db 0
dw 0xAA55 times 510-($-$$) db 0
dw 0xAA55

View File

@ -1,6 +1,8 @@
[BITS 16]
jmp _start jmp _start
[BITS 16] %include "src/utils/intel_16.asm"
_start: _start:
; Set stack space ; Set stack space
@ -27,35 +29,6 @@ _start:
jmp $ jmp $
; Functions
new_line_16:
mov ah, 0Eh
mov al, 0Ah
int 10h
mov al, 0Dh
int 10h
ret
print_line_16:
mov ah, 0Eh
.repeat:
lodsb
cmp al, 0
je .done
int 10h
jmp .repeat
.done:
call new_line_16
ret
; Datas ; Datas
kernel_header_0 db '******************************', 0 kernel_header_0 db '******************************', 0

45
src/utils/intel_16.asm Normal file
View File

@ -0,0 +1,45 @@
[BITS 16]
; Functions
new_line_16:
mov ah, 0Eh
mov al, 0Ah
int 10h
mov al, 0Dh
int 10h
ret
print_line_16:
mov ah, 0Eh
.repeat:
lodsb
cmp al, 0
je .done
int 10h
jmp .repeat
.done:
call new_line_16
ret
key_wait:
mov al, 0xD2
out 64h, al
mov al, 0x80
out 60h, al
keyup:
in al, 0x60
and al, 10000000b
jnz keyup
Keydown:
in al, 0x60
ret