Merge pull request #13 from E-Almqvist/dev

Update
pull/25/head
Elias Almqvist 3 years ago committed by GitHub
commit d518245ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      src/bios/disk.asm
  2. 50
      src/bootloader.asm

@ -1,20 +1,21 @@
disk_read: disk_read:
pusha pusha
push dx ; store dx on stack so that we can compare later
push dx mov ah, BIOS_DISK_READ ; specify function
mov ah, BIOS_DISK_READ
mov al, dh ; sector count
mov cl, 0x02
mov ch, 0x00 ; read from first cylinder mov al, dh ; read dh amount of sectors
mov dh, 0x00 ; head mov ch, 0x00 ; CYLINDER
mov dh, 0x00 ; HEAD
mov cl, 0x02 ; SECTOR
; data pointer: es:bx (standard) int BIOS_DISK_INT ; interrupt
int BIOS_DISK_INT ; do the interrupt
jc read_error ; if flag is set then jump to error ; Error checks
jc read_error ; carry flag set -> error
pop dx pop dx
cmp al, dh cmp dh, al ; if dh != al then error
jne sector_error jne sector_error
popa popa
@ -25,14 +26,22 @@ sector_error:
call println call println
read_error: read_error:
; Inform the user
mov bx, read_error_string mov bx, read_error_string
call println call println
; Print the error
mov bx, error_code_string
call print
mov dh, ah mov dh, ah
call print_hex call print_hex
disk_loop: mov bx, [ASCII_END]
call println
jmp $ jmp $
read_error_string: db "Disk read error", ASCII_END read_error_string: db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "ERROR! Disk read failed.", ASCII_END
sector_error_string: db "Invalid number of sectors read", ASCII_END error_code_string: db "Error code: ", ASCII_END
sector_error_string: db "Invalid number of sectors read!", ASCII_END

@ -1,51 +1,45 @@
[org 0x7c00] ; bootsector [org 0x7c00] ; bootsector
; Save the boot drive index
mov [BOOT_DRIVE], dl
mov bx, welcome_string ; Print the welcome string ; Move the stack pointer somewhere safe
call println mov bp, 0x8000 ; move it to 0x8000
mov sp, bp
mov bx, info_string ; Print version info ; Print the welcome string
mov bx, welcome_string
call println call println
; Read from disk ; Read second sector (outside bootsector)
mov bp, 0x8000 mov bx, 0x9000 ; LOAD LOCATION
mov sp, bp ; move the stack away so that it does not get overwritten mov dh, 2 ; SECTOR-COUNT
mov dl, [BOOT_DRIVE] ; DISK-INDEX
mov bx, 0x9000 call disk_read
mov dh, 2 ; read 2 sectors
call disk_read ; read
mov bx, read_test_string
call print
; Print out whatever bloated data that was read
mov dx, [0x9000] mov dx, [0x9000]
call print_hex call print_hex
mov bx, byte_sep_string mov bx, [ASCII_END]
call print call println
mov dx, [0x9000 + 512] mov dx, [0x9000 + 512] ; read from second sector too
call print_hex call print_hex
mov bx, empty_string
call println
jmp $ ; inf loop jmp $ ; inf loop
; Constants
%include "equ/ASCII.asm" %include "equ/ASCII.asm"
; SRs etc
%include "bios.asm" %include "bios.asm"
welcome_string: db "e Operating-System (eOS)", ASCII_END ; Data
info_string: db "Version 2021 0.0", ASCII_END welcome_string: db "e Operating-System (eOS)", ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "Version 2021 0.0", ASCII_END
read_test_string: db "Disk read: ", ASCII_END BOOT_DRIVE: db 0
byte_sep_string: db "; ", ASCII_END
empty_string: db ASCII_END
; Bootsector
times 510-($-$$) db 0 times 510-($-$$) db 0
db 0x55, 0xaa ; magic BIOS numbers dw 0xaa55 ; magic BIOS numbers
; Bloat bytes to test reading ; After bootsector
times 256 dw 0xEEEE times 256 dw 0xEEEE
times 256 dw 0xAAAA times 256 dw 0xAAAA

Loading…
Cancel
Save