1 #include <stdint.h> 2 3 /* 4 * Zynq Ultrascale+ MPSoC / GHS 5 * 6 * Implements standard I/O through UART 7 * 8 * XXX assume the UART has already been initialized by bootloader 9 */ 10 #define UART_BASE 0xff000000U /* UART0 */ 11 12 #define UART_FIFO *((volatile uint32_t *)(UART_BASE+0x0030U)) 13 #define UART_SR *((volatile uint32_t *)(UART_BASE+0x002CU)) 14 #define UART_SR_TXFULL 0x00000010U 15 16 write(int fno,const void * buf,long size)17long write(int fno, const void *buf, long size) 18 { 19 if (fno != 1) return -1; 20 21 const char *p = buf; 22 const char *pmax = p + size; 23 while (p < pmax) { 24 char c = *p++; 25 if (c == '\n') { 26 /* expand LF to CR+LF */ 27 while ((UART_SR & UART_SR_TXFULL) != 0); 28 UART_FIFO = '\r'; 29 } 30 while ((UART_SR & UART_SR_TXFULL) != 0); 31 UART_FIFO = c; 32 } 33 34 return size; 35 } 36