Port the very basic serial console from mtrr

It's enabled by the flag ENABLE_SERIAL CONSOLE
This commit is contained in:
Jasmine Iwanek
2022-11-05 21:43:42 -04:00
parent 5def97d138
commit 4cf229ee3a

View File

@@ -51,6 +51,7 @@ enum {
static int next_inst = 0;
static serial_device_t serial_devices[SERIAL_MAX];
//#define ENABLE_SERIAL_CONSOLE 1
#ifdef ENABLE_SERIAL_LOG
int serial_do_log = ENABLE_SERIAL_LOG;
@@ -193,6 +194,15 @@ serial_transmit(serial_t *dev, uint8_t val)
write_fifo(dev, val);
else if (dev->sd->dev_write)
dev->sd->dev_write(dev, dev->sd->priv, val);
#ifdef ENABLE_SERIAL_CONSOLE
if ((val >= ' ' && val <= '~') || val == '\r' || val == '\n') {
fputc(val, stdout);
if (val == '\n')
fflush(stdout);
} else {
fprintf(stdout, "[%02X]", val);
}
#endif
}
static void