feat: added UART support with a basic kprint in kernel

wip: DTB
This commit is contained in:
karina
2026-04-20 16:20:31 +04:00
parent ef9aa56d11
commit 635052c8dc
8 changed files with 158 additions and 13 deletions
+19
View File
@@ -0,0 +1,19 @@
let kUARTBaseAddress: UInt = 0x09000000 // TODO: Make it dynamic by parsion DTB
@_cdecl("putchar")
@discardableResult func _serialPutchar(_ char: Int32) -> Int32 {
let uartFR: UInt = kUARTBaseAddress + 0x18// TXFF -- TRansmit FIFO Full for PL011 is 5 bit of FR reg (0x18)
while (mmio_read32(uartFR) & (1 << 5)) != 0 {
// i love pizza btw
}
mmio_write32(UInt(kUARTBaseAddress), UInt32(char))
return char
}
public func kprint(_ message: StaticString) {
for i in 0..<message.utf8CodeUnitCount {
_serialPutchar(Int32(message.utf8Start[i]))
}
}