diff options
author | Marvin Borner | 2020-06-20 16:28:14 +0200 |
---|---|---|
committer | Marvin Borner | 2020-06-20 16:28:14 +0200 |
commit | cdea72777ae088e865b1100436a7ece7d5877347 (patch) | |
tree | b1a697dfdf917f4649f6e386450813240cd47fd5 /src/entry.asm | |
parent | dcf6dca74b8baadb8fdade55aad9068a60c3d25e (diff) |
Added bootloader and basic ext2 parsing
Diffstat (limited to 'src/entry.asm')
-rw-r--r-- | src/entry.asm | 89 |
1 files changed, 82 insertions, 7 deletions
diff --git a/src/entry.asm b/src/entry.asm index 7404ccc..0567f61 100644 --- a/src/entry.asm +++ b/src/entry.asm @@ -1,8 +1,36 @@ bits 16 - org 0x7c00 -jmp start +global _start +_start: + ; Clear screen + mov ax, 0x003 + int 0x10 + + ; Welcome user! + mov si, hello_msg + call print + + ; Check LBA support + mov ah, 0x41 + mov bx, 0x55AA + int 0x13 + jc lba_error + cmp bx, 0xAA55 + jnz lba_error + + ; Check disk and move dl + and dl, 0x80 + jz disk_error + mov [drive], dl + + ; Load stage two + mov bx, stage_two + mov [dest], bx + call disk_read + + ; JUMP + jmp stage_two print: mov ah, 0x0E @@ -16,15 +44,62 @@ print: print_end: ret -start: - mov ax, 0x003 - int 0x10 +disk_read: + mov si, packet ; Address of dap + mov ah, 0x42 ; Extended read + mov dl, [drive] ; Drive number + int 0x13 + jc disk_error + ret - mov si, hello +; Errors +disk_error: + mov si, disk_error_msg call print jmp $ +lba_error: + mov si, lba_error_msg + call print + jmp $ + +; Variables +hello_msg db "Welcome! Loading Melvix...", 0x0A, 0x0D, 0x00 +disk_error_msg db "Disk error!", 0x0a, 0x0d, 0x00 +lba_error_msg db "LBA error!", 0x0a, 0x0d, 0x00 +stage_two_msg db "Stage2 loaded", 0x0a, 0x0d, 0x00 +disk_success_msg db "Disk is valid", 0x0a, 0x0d, 0x00 +drive db 0 -hello db "Loading Melvix...", 0x0A, 0x0D, 0x00 +; Data +packet: + db 0x10 ; Packet size + db 0 ; Always 0 +count: + dw 4 ; Number of sectors to transfer +dest: + dw 0 ; Destination offset + dw 0 ; Destination segment +lba: + dd 1 ; LBA number + dd 0 ; More storage bytes +; End of boot sector times 510 - ($ - $$) db 0 dw 0xAA55 + +stage_two: + mov si, stage_two_msg + call print + + mov ax, [superblock +56] + cmp ax, 0xEF53 + jne disk_error + + mov si, disk_success_msg + call print + + jmp $ + + +times 1024 - ($ - $$) db 0 +superblock: |