aboutsummaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2021-12-03 09:55:06 -0700
committerChristian Cunningham <cc@localhost>2021-12-03 09:55:06 -0700
commitc06fb44b7f63bbb94523f0f4d2908d34d22b94c2 (patch)
tree527c687aebaf9acb8be6e594d9ebb1dae4287d26 /src/drivers
parent72e74f2e3203dc9627f13e740e0d88091ff1d149 (diff)
Started moving source files to subdirectories
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/uart.S75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/drivers/uart.S b/src/drivers/uart.S
new file mode 100644
index 0000000..0864b7e
--- /dev/null
+++ b/src/drivers/uart.S
@@ -0,0 +1,75 @@
+.section ".text"
+
+.globl uart_init
+uart_init:
+ //*UART0_IMSC = 1 << 4;
+ // IGNORE OVERRUN
+ mov r2, #0x1038
+ movt r2, #0x3F20
+ mov r3, #0b10000
+ str r3, [r2]
+ //*IRQ_ENABLE2 = 1 << 25;
+ mov r2, #0xB214
+ movt r2, #0x3F00
+ mov r3, #0
+ movt r3, #0b1000000000
+ str r3, [r2]
+ //*GPU_INTERRUPTS_ROUTING = 0x00;
+ // Route GPU interrupts to Core0
+ mov r2, #0x000C
+ movt r2, #0x4000
+ eor r3, r3
+ str r3, [r2]
+ bx lr
+
+.globl uart_char
+uart_char:
+ mov r2, #0x1000
+ movt r2, #0x3f20
+uart_char.loop:
+ ldr r3, [r2, #24]
+ tst r3, #0b100000
+ bne uart_char.loop
+ str r0, [r2]
+ bx lr
+
+.globl uart_string
+uart_string:
+ push {r4, lr}
+ mov r4, r0
+ ldrb r0, [r0]
+ cmp r0, #0
+ popeq {r4, pc}
+uart_string.loop:
+ bl uart_char
+ ldrb r0, [r4, #1]!
+ cmp r0, #0
+ bne uart_string.loop
+ pop {r4, pc}
+
+.globl uart_hex
+uart_hex:
+ push {r4, lr}
+ mov r2, #0x1000
+ movt r2, #0x3f20
+uart_hex.loop:
+ ldr r3, [r2, #24]
+ tst r3, #0b100000
+ bne uart_hex.loop
+ mov r3, #7
+uart_hex.hloop:
+ mov r1, r0
+ asr r1, r3
+ asr r1, r3
+ asr r1, r3
+ asr r1, r3
+ and r1, #0xf
+ add r1, #0x30
+ cmp r1, #0x3A
+ blt uart_hex.print
+ add r1, #7
+uart_hex.print:
+ str r1, [r2]
+ subs r3, #1
+ bge uart_hex.hloop
+ pop {r4, pc}