Blob


1 // uart_virt.cc
2 // QEMU `virt` generic virtual platform
5 #include <hw.h>
6 #include <uart.h>
7 #include <pl011.h>
10 namespace Board {
11 namespace Uart {
14 namespace {
16 constexpr uintptr_t UART_BASE = 0x9000000;
18 } // anonymous namespace
21 void initialize()
22 {
23 Pl011::ControlRegister ControlRegister;
24 ControlRegister.m_u.m_Bits.m_UartEnable = 1;
25 ControlRegister.m_u.m_Bits.m_TransmitEnable = 1;
26 Hw::write32(UART_BASE + Pl011::CONTROL_REGISTER, ControlRegister.m_u.m_nValue);
27 }
30 void send(uint8_t nValue)
31 {
32 // spin while fifo is full
33 for (; ; )
34 {
35 Pl011::FlagRegister FlagRegister{Hw::read32(UART_BASE + Pl011::FLAG_REGISTER)};
36 if (!FlagRegister.m_u.m_Bits.m_TransmitFifoFull)
37 break;
38 }
39 Hw::write32(UART_BASE + Pl011::DATA_REGISTER, nValue);
40 }
43 uint8_t recv()
44 {
45 return 0;
46 }
49 } // namespace Uart
50 } // namespace Board