35 lines
736 B
C
35 lines
736 B
C
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
// Copyright (c) 2026 0xKSor
|
|
|
|
#include <IO/Serial.h>
|
|
#include <Arch/IO.h>
|
|
#include <Arch/CPU.h>
|
|
|
|
static UInt64 sUARTAddress = kUARTBaseAddress;
|
|
|
|
void SerialUpdate(UInt64 address) {
|
|
sUARTAddress = address;
|
|
}
|
|
|
|
Int32 SerialPutCharacter(ASCII character) {
|
|
// TXFF -- TRansmit FIFO Full for PL011 is 5 bit of FR reg (0x18)
|
|
UInt64 uartFR = sUARTAddress + 0x18;
|
|
|
|
while ((IOAddressRead32(uartFR) & (1 << 5)) != 0) {
|
|
CPUYield();
|
|
}
|
|
|
|
IOAddressWrite32(sUARTAddress, character);
|
|
return character;
|
|
}
|
|
|
|
Int32 SerialPutString(const ASCII* string) {
|
|
Int i = 0;
|
|
while (string[i] != '\0') {
|
|
SerialPutCharacter(string[i]);
|
|
i++;
|
|
}
|
|
|
|
return i;
|
|
}
|