Commit Diff


commit - 29b6aefcc50d941aa40b4884b28a3ecc95f2752b
commit + 10d59256009269463132637ce6cc8d3ee2b6d8c0
blob - ffe40d5c20744cefd274edf24aad08d884d1f49f
blob + c116e424fb79befc590c62106c1e242668601b98
--- .gitignore
+++ .gitignore
@@ -1,6 +1,6 @@
 **/*.o
 **/.*.swp
-squat.elf
-squat.img
+squat-*.elf
+squat-*.img
 config.mk
 tools/img_eGON.BT0/img_eGON.BT0
blob - 925065f43c11f5f65d867b2ce1ec7d40606f3246
blob + c82f296bb7c7cd1f835d9e520713d8bd4c581d2d
--- Makefile
+++ Makefile
@@ -5,45 +5,46 @@ OBJCOPY		= llvm-objcopy
 
 ARCH		= aarch64
 TARGET		= ${ARCH}-none-elf
-BOARD		= virt
+-include	config.mk
+#BOARD		?= virt
+BOARD          ?= pinephone
 
 ASFLAGS		= -target ${TARGET}
-ASFILES		= boot.S
+ASFILES		+= boot.S
 
-CXXFLAGS	= -target ${TARGET}
+CXXFLAGS	+= -target ${TARGET}
 CXXFLAGS        +=-Wall -Wextra -Werror
 CXXFLAGS        +=-nostdlib -fno-exceptions -std=c++11
 CXXFLAGS	+=-ffreestanding -mgeneral-regs-only
 CXXFLAGS	+=-Iinclude
-CXXFILES	= kernel.cc uart_${BOARD}.cc
+CXXFILES	+= kernel.cc uart_${BOARD}.cc
 
 OBJS		= ${ASFILES:.S=.o} ${CXXFILES:.cc=.o}
 
--include	config.mk
 
-.PHONY:	clean qemu gdb-remote tools
+.PHONY:	all clean qemu gdb-remote tools
 
-all: squat.img
+all: squat-${BOARD}.img
 
-squat.img: squat.elf
-	${OBJCOPY} squat.elf -O binary squat.img
+squat-${BOARD}.img: squat-${BOARD}.elf
+	${OBJCOPY} squat-${BOARD}.elf -O binary squat-${BOARD}.img
 
-squat.elf: linker.ld ${OBJS}
-	${LD} -T linker.ld -o squat.elf ${OBJS}
+squat-${BOARD}.elf: linker.ld ${OBJS}
+	${LD} -T linker.ld -o squat-${BOARD}.elf ${OBJS}
 
 .S.o:
 	${AS} ${ASFLAGS} -c $< -o $@
 
 clean:
-	rm -rf *.o squat.elf squat.img
+	rm -rf *.o squat-*.elf squat-*.img
 	${MAKE} -C tools/img_eGON.BT0 clean
 
-qemu: squat.img
-	qemu-system-${ARCH} -M ${BOARD} -cpu cortex-a53 \
+#qemu: squat.img
+#	qemu-system-${ARCH} -M ${BOARD} -cpu cortex-a53 \
 			    -kernel squat.img -nographic -monitor none -serial stdio
-gdb-remote: squat.img
-	qemu-system-${ARCH} -s -S -M ${BOARD} -cpu cortex-a53 \
-			    -kernel squat.img -nographic -monitor none -serial stdio
+#gdb-remote: squat.img
+#	qemu-system-${ARCH} -s -S -M ${BOARD} -cpu cortex-a53 \
+#			    -kernel squat.img -nographic -monitor none -serial stdio
 
 tools:
 	${MAKE} -C tools/img_eGON.BT0 img_eGON.BT0
blob - 7663a12da52749a2f572dedb6a5cbed5c08869f6
blob + 83716a25dcdcecbdf2ac29c9c73d048806b63160
--- uart_virt.cc
+++ uart_virt.cc
@@ -43,6 +43,7 @@ void send(uint8_t nValue)
 
 uint8_t recv()
 {
+    // spin while fifo is full
     for (; ; )
     {
         Pl011::FlagRegister FlagRegister{Hw::read32(UART_BASE + Pl011::FLAG_REGISTER)};
blob - /dev/null
blob + ef9378c6b991cf1258d646018265cfeca686cf45 (mode 644)
--- /dev/null
+++ uart_pinephone.cc
@@ -0,0 +1,44 @@
+// uart_virt.cc
+// QEMU `virt` generic virtual platform
+
+
+#include <hw.h>
+#include <uart.h>
+
+
+namespace Board {
+namespace Uart {
+
+
+namespace {
+
+constexpr uintptr_t UART_BASE = 0x01c28000;
+
+} // anonymous namespace
+
+
+void initialize()
+{
+    /* TBD! */
+    (void)UART_BASE;
+    // Hw::write32(UART_BASE + Pl011::CONTROL_REGISTER, ControlRegister.m_u.m_nValue);
+}
+
+
+void send(uint8_t nValue)
+{
+    (void)nValue;
+    /* TBD! */
+    // Hw::write32(UART_BASE + Pl011::DATA_REGISTER, nValue);
+}
+
+
+uint8_t recv()
+{
+    // return Hw::read32(UART_BASE + Pl011::DATA_REGISTER) & 0xff;
+    return 0;
+}
+
+
+} // namespace Uart
+} // namespace Board