os-workshop

same materials and sample source for RV32 OS projects
git clone http://frotz.net/git/os-workshop.git
Log | Files | Refs

debug-io.c (576B)


      1 // Copyright 2022, Brian Swetland <swetland@frotz.net>
      2 // Licensed under the Apache License, Version 2.0.
      3 
      4 #include <stdio.h>
      5 #include <stdarg.h>
      6 
      7 #include <hw/platform.h>
      8 #include <hw/litex.h>
      9 #include <hw/debug.h>
     10 
     11 #define uart_rd(a) io_rd32(UART0_BASE + LX_UART_ ## a)
     12 #define uart_wr(a,v) io_wr32(UART0_BASE + LX_UART_ ## a, v)
     13 
     14 void xputc(unsigned c) {
     15 	if (c == '\n') {
     16 		while (uart_rd(TXFULL)) ;
     17 		uart_wr(TX, '\r');
     18 	}
     19 	while (uart_rd(TXFULL)) ;
     20 	uart_wr(TX, c);
     21 }
     22 
     23 void xputs(const char* s) {
     24 	while (*s != 0) {
     25 		xputc(*s++);
     26 	}
     27 }
     28 
     29 int xgetc(void) {
     30 	return -1;
     31 }
     32