Commit e7e94a70 authored by Ian Seyler's avatar Ian Seyler

Update MBR to use serial for message output.

parent 1aa01765
......@@ -12,10 +12,10 @@
; Default location of the second stage boot loader. This loads
; 32 KiB from sector 16 into memory at 0x8000
%define ST2_SECTORS 64
%define ST2_STARTSECTOR 16
%define ST2_ADDRESS 0x8000
%define ST2_SEGMENT 0x0000
%define DAP_SECTORS 64
%define DAP_STARTSECTOR 16
%define DAP_ADDRESS 0x8000
%define DAP_SEGMENT 0x0000
USE16
......@@ -33,6 +33,11 @@ entry:
mov [DriveNumber], dl ; BIOS passes drive number in DL
mov ah, 0
mov al, 11100011b ; 9600bps, no parity, 1 stop bit, 8 data bits
mov dx, 0 ; Serial port 0
int 0x14 ; Configure serial port
; Get the BIOS E820 Memory Map
; use the INT 0x15, eax= 0xE820 BIOS function to get a memory map
; inputs: es:di -> destination buffer for 24 byte entries
......@@ -126,7 +131,7 @@ check_A20:
; Read the 2nd stage boot loader into memory.
mov ah, 0x42 ; Extended Read
mov dl, [DriveNumber] ; http://www.ctyme.com/intr/rb-0708.htm
mov si, ST2_DAP
mov si, DAP
int 0x13
jc read_fail
......@@ -135,6 +140,9 @@ check_A20:
cmp ax, 0x3436 ; Match against the Pure64 binary
jne magic_fail
mov si, msg_OK
call print_string_16
; At this point we are done with real mode and BIOS interrupts. Jump to 32-bit mode.
cli ; No more interrupts
lgdt [cs:GDTR32] ; Load GDT register
......@@ -157,16 +165,17 @@ halt:
;------------------------------------------------------------------------------
; 16-bit function to print a string to the screen
; 16-bit function to output a string to the serial port
; IN: SI - Address of start of string
print_string_16: ; Output string in SI to screen
pusha
mov ah, 0x0E ; int 0x10 teletype function
mov dx, 0 ; Port 0
.repeat:
mov ah, 0x01 ; Serial - Write character to port
lodsb ; Get char from string
cmp al, 0
je .done ; If char is zero, end of string
int 0x10 ; Otherwise, print it
int 0x14 ; Output the character
jmp short .repeat
.done:
popa
......@@ -185,9 +194,10 @@ dw 0xFFFF, 0x0000, 0x9A00, 0x00CF ; 32-bit code descriptor
dw 0xFFFF, 0x0000, 0x9200, 0x00CF ; 32-bit data descriptor
gdt32_end:
msg_Load db "Pure64 MBR v1.0", 0
msg_MagicFail db " - Error!", 0
msg_ReadFail db "Failed to read drive.", 13, 10, 0
msg_Load db 10, "MBR ", 0
msg_OK db "OK", 0
msg_MagicFail db "- Bad Magic!", 0
msg_ReadFail db "Failed to read drive!", 0
times 446-$+$$ db 0
......@@ -199,13 +209,13 @@ times 476-$+$$ db 0
align 4
ST2_DAP:
DAP:
db 0x10
db 0x00
dw ST2_SECTORS
dw ST2_ADDRESS
dw ST2_SEGMENT
dq ST2_STARTSECTOR
dw DAP_SECTORS
dw DAP_ADDRESS
dw DAP_SEGMENT
dq DAP_STARTSECTOR
times 510-$+$$ db 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment