FASMMMMMMM
This commit is contained in:
parent
946c9e468d
commit
e2572d50af
15 changed files with 175 additions and 715 deletions
94
src/serial.asm
Normal file
94
src/serial.asm
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
SERIAL_PORT equ 0x3f8
|
||||
|
||||
serialinit:
|
||||
pushad
|
||||
|
||||
;Disable ints
|
||||
mov dx, SERIAL_PORT+1
|
||||
mov al, 0x00
|
||||
out dx, al
|
||||
|
||||
;Enable DLAB baud divisor and set 3 (38400 baud)
|
||||
mov al, 0x80
|
||||
mov dx, SERIAL_PORT+3
|
||||
out dx, al
|
||||
;Baud divisor lo byte
|
||||
mov al, 0x03
|
||||
mov dx, SERIAL_PORT
|
||||
out dx, al
|
||||
;Baud divisor hi byte
|
||||
mov al, 0x00
|
||||
mov dx, SERIAL_PORT+1
|
||||
out dx, al
|
||||
|
||||
;8bits, no parity, one stop bit
|
||||
mov al, 0x03
|
||||
mov dx, SERIAL_PORT+3
|
||||
out dx, al
|
||||
|
||||
;Enable+clear FIFO, 14-byte threshold
|
||||
mov al, 0xc7
|
||||
mov dx, SERIAL_PORT+2
|
||||
out dx, al
|
||||
|
||||
;IRQs enabled, RTS/DSR set
|
||||
mov al, 0x0b
|
||||
mov dx, SERIAL_PORT+4
|
||||
out dx, al
|
||||
|
||||
;Set loopback for test purposes
|
||||
mov al, 0x1e
|
||||
out dx, al
|
||||
|
||||
;; Check if serial is workie
|
||||
mov al, 0xae
|
||||
mov dx, SERIAL_PORT
|
||||
out dx, al
|
||||
in al, dx
|
||||
cmp al, 0xae
|
||||
jne serialiniterror
|
||||
|
||||
|
||||
;; Set serial to normal operation
|
||||
mov dx, SERIAL_PORT+4
|
||||
mov al, 0x0f
|
||||
out dx, al
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
serialwrite:
|
||||
pushad
|
||||
cld
|
||||
mov esi, stuff.bootmsg
|
||||
.loop:
|
||||
mov dx, SERIAL_PORT+5
|
||||
.wait:
|
||||
in al, dx
|
||||
and al, 0x20
|
||||
jz .wait
|
||||
lodsb
|
||||
or al, al
|
||||
jz .done
|
||||
mov dx, SERIAL_PORT
|
||||
out dx, al
|
||||
jmp .loop
|
||||
.done:
|
||||
popad
|
||||
ret
|
||||
|
||||
serialiniterror:
|
||||
mov esi, .msg
|
||||
mov edi, 0xb8000
|
||||
mov ah, 64
|
||||
cld
|
||||
.loop:
|
||||
lodsb
|
||||
or al, al
|
||||
jz .done
|
||||
stosw
|
||||
jmp .loop
|
||||
.done:
|
||||
popad
|
||||
ret
|
||||
.msg db "Serial init failed", 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue