MHN
Add a comment on Hacker News →
1 of 81 comments
  1.   // QEMU UART registers - these addresses are for QEMU's 16550A UART
      #define UART_BASE 0x10000000
      #define UART_THR  (*(volatile char *)(UART_BASE + 0x00)) // Transmit Holding Register
      #define UART_RBR  (*(volatile char *)(UART_BASE + 0x00)) // Receive Buffer Register
      #define UART_LSR  (*(volatile char *)(UART_BASE + 0x05)) // Line Status Register
    
    This looks odd. Why are receive and transmit buffer the same and why would you use such a weird offset? Iirc RISC-V allows that, but my gut says I'd still align this to the word size.