extern boot_mem_map_size
%include 'macros.inc'
+%define CON_SERIAL
[bits 16]
global _start
jmp exit
.notvm86:
+%ifdef CON_SERIAL
call setup_serial
+%endif
call enable_a20
call detect_memory
; ---------------------- memory detection -----------------------
detect_memory:
+ mov si, memdet_detram
+ call printstr
mov si, memdet_e820_msg
call printstr
call detect_mem_e820
mov si, str_fail
call printstr
+ mov si, memdet_detram
+ call printstr
mov si, memdet_e801_msg
call printstr
call detect_mem_e801
mov si, str_fail
call printstr
+ mov si, memdet_detram
+ call printstr
mov esi, memdet_88_msg
call printstr
call detect_mem_88
mov esi, str_fail
call printstr
+ mov si, memdet_detram
+ call printstr
mov esi, memdet_cmos_msg
call printstr
call detect_mem_cmos
str_ok db 'OK',10,0
str_fail db 'failed',10,0
memdet_fail_msg db 'Failed to detect available memory!',10,0
-memdet_e820_msg db 'Detecting RAM (BIOS 15h/0xe820)... ',0
-memdet_e801_msg db 'Detecting RAM (BIOS 15h/0xe801)... ',0
-memdet_88_msg db 'Detecting RAM (BIOS 15h/0x88, max 64mb)... ',0
-memdet_cmos_msg db 'Detecting RAM (CMOS)...',0
+memdet_detram db 'Detecting RAM '
+memdet_e820_msg db '(BIOS 15h/0xe820)... ',0
+memdet_e801_msg db '(BIOS 15h/0xe801)... ',0
+memdet_88_msg db '(BIOS 15h/0x88, max 64mb)... ',0
+memdet_cmos_msg db '(CMOS)...',0
; detect extended memory using BIOS call 15h/e820
detect_mem_e820:
; ----------------------- serial console ------------------------
+%ifdef CON_SERIAL
setup_serial:
; set clock divisor
mov dx, UART_BASE + 3 ; LCTL
jmp ser_printstr
.end: ret
+%endif ; def CON_SERIAL
+
+
printstr:
lodsb
test al, al
cmp al, 10 ; check for line-feed and insert CR before it
jnz .nolf
push ax
+%ifdef CON_SERIAL
mov al, 13
call ser_putchar
+%endif
mov dl, 13
mov ah, 2
int 21h
pop ax
-.nolf: call ser_putchar
+.nolf:
+%ifdef CON_SERIAL
+ call ser_putchar
+%endif
mov ah, 2
mov dl, al
int 21h
jmp printstr
.end: ret
- [bits 32]
-ser_putchar_pmode:
- SER_PUTCHAR
- ret
-
-ser_putstr_pmode:
- lodsb
- test al, al
- jz .end
- cmp al, 10
- jnz .nolf
- push ax
- mov al, 13
- call ser_putchar_pmode
- pop ax
-.nolf: call ser_putchar_pmode
- jmp ser_putstr_pmode
-.end: ret
-
align 4
enterpm dd 0xbad00d ; space for linear address for far jump to pmode