Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Koen Martens
gmcpu8
Commits
0518fa06
Commit
0518fa06
authored
Aug 18, 2019
by
Koen Martens
Browse files
gios: initialize uart, flush uart
parent
0125b5b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/asm/gios/bootstrap.S
View file @
0518fa06
...
...
@@ -9,10 +9,21 @@ loop:
jzre
done
jre
loop
done
:
.
ld
src
greeting
.
lddst
uart_send_string
.
ld
dst
uart_init
; initialize uart
puship
jmpdst
.
ldsrc
greeting
; write greeting to uart
.
lddst
uart_send_string
puship
jmpdst
.
lddst
uart_flush
; wait until flushed
puship
jmpdst
halt
;
; ROM data
;
...
...
src/asm/gios/ports.S
View file @
0518fa06
...
...
@@ -8,6 +8,10 @@ UART_0_RBR:
.
global
UART_0_THR
UART_0_THR
:
.
org
0
x2013
.
global
UART_0_LCR
UART_0_LCR
:
.
org
0
x2015
.
global
UART_0_LSR
UART_0_LSR
:
...
...
src/asm/gios/serial.S
View file @
0518fa06
.
global
uart_init
.
global
uart_send_byte
.
global
uart_send_string
.
global
uart_flush
uart_init
:
.
ldsrc
UART_0_LCR
.
lddst
UART_0_LCR
ld
r0
; set DLAB
imm
r1
,
0
b10000000
or
r0
,
r1
st
r0
.
lddst
UART_0_RBR
; set DLL
imm
r2
,
4
st
r2
.
lddst
UART_0_THR
; set DLM
imm
r2
,
0
st
r2
neg
r1
; reset DLAB
.
lddst
UART_0_LCR
and
r0
,
r1
st
r0
pop
r6
; ret
pop
r7
jmpdst
; send the byte in r0 to the uart
; if the transmit register is not empty, waits for it to become empty
...
...
@@ -29,8 +56,9 @@ uart_send_string:
push
r4
push
r5
.
lddst
uart_send_byte
puship
j
re
uart_send_byte
j
mpdst
pop
r5
pop
r4
...
...
@@ -46,3 +74,16 @@ _uart_send_string_done:
pop
r7
jmpdst
; wait until uart is finished (TEMT=1)
;
uart_flush
:
.
ldsrc
UART_0_LSR
; load LSR
ld
r0
imm
r1
,
0
b01000000
; bit6 = TEMT
and
r0
,
r1
jzre
uart_flush
; loop until TEMT = 1
pop
r6
pop
r7
jmpdst
; ret
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment