feat(kernel): add PL011 UART console and arch I/O helpers
- Add IOSerial: PL011 (0x0900_0000) TX with FIFO-full polling, yield while waiting - Add Arch/IO.h (32-bit MMIO with DSB) and Arch/CPU.h (yield, WFI) - Extend types.h (e.g. ASCII, Address, Int/UInt aliases) - Wire KernelMain to IOSerialPutString for early boot output - Drop .sourcekit-lsp config; note IO glob in CMake (commented)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
static inline void CPUYield() {
|
||||
__asm__ volatile ("yield" ::: "memory");
|
||||
}
|
||||
|
||||
static inline void CPUWaitForInterrupt() {
|
||||
__asm__ volatile ("wfi" ::: "memory");
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <types.h>
|
||||
|
||||
static inline void IOAddressWrite32(UInt64 address, UInt32 value) {
|
||||
__asm__ volatile ("dsb sy" ::: "memory"); // wait till all previous writes are finished physically
|
||||
*(volatile UInt32*)address = value;
|
||||
__asm__ volatile ("dsb sy" ::: "memory"); // wait till my write is finished physically
|
||||
}
|
||||
|
||||
static inline UInt32 IOAddressRead32(UInt64 address) {
|
||||
UInt32 value = *(volatile UInt32*)address;
|
||||
__asm__ volatile ("dsb ld" ::: "memory"); // wait till my read is finished physically
|
||||
return value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <types.h>
|
||||
|
||||
enum {
|
||||
kUARTBaseAddress = 0x09000000, // TODO: make it dynamic by parsing DTB
|
||||
};
|
||||
|
||||
Int32 IOSerialPutCharacter(ASCII character);
|
||||
Int32 IOSerialPutString(const ASCII* string);
|
||||
@@ -7,12 +7,18 @@ typedef unsigned char UInt8;
|
||||
typedef unsigned short UInt16;
|
||||
typedef unsigned int UInt32;
|
||||
typedef unsigned long long UInt64;
|
||||
typedef unsigned long long UInt;
|
||||
|
||||
typedef UInt Address;
|
||||
typedef UInt8* BytePointer;
|
||||
typedef UInt8* MemoryPointer;
|
||||
|
||||
typedef signed char Int8;
|
||||
typedef signed short Int16;
|
||||
typedef signed int Int32;
|
||||
typedef signed long long Int64;
|
||||
typedef int Int;
|
||||
|
||||
typedef UInt64 Size;
|
||||
|
||||
typedef char ASCII;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user