aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/machdep.c14
-rw-r--r--sys/arch/amd64/conf/GENERIC1
-rw-r--r--sys/include/sys/syslog.h2
-rw-r--r--sys/kern/init_main.c3
-rw-r--r--sys/kern/kern_syslog.c9
5 files changed, 29 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index b047dd8..03b10f0 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -28,6 +28,7 @@
*/
#include <sys/types.h>
+#include <sys/syslog.h>
#include <machine/cpu.h>
#include <machine/gdt.h>
#include <machine/tss.h>
@@ -36,6 +37,7 @@
#include <machine/asm.h>
#include <machine/cpuid.h>
#include <machine/lapic.h>
+#include <machine/uart.h>
#if defined(__SPECTRE_IBRS)
#define SPECTRE_IBRS __SPECTRE_IBRS
@@ -90,6 +92,18 @@ try_mitigate_spectre(void)
ibrs_enable();
}
+void
+serial_init(void)
+{
+ uart_init();
+}
+
+void
+serial_putc(char c)
+{
+ uart_write(c);
+}
+
/*
* Get the descriptor for the currently
* running processor.
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index a7bbc81..19c9a62 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -1,5 +1,6 @@
// Kernel options
option SPECTRE_IBRS no
+option SERIAL_DEBUG yes
// Kernel constants
setval SCHED_NQUEUE 4
diff --git a/sys/include/sys/syslog.h b/sys/include/sys/syslog.h
index 9a044b9..889bf37 100644
--- a/sys/include/sys/syslog.h
+++ b/sys/include/sys/syslog.h
@@ -37,6 +37,8 @@
#define OMIT_TIMESTAMP "\x01"
void kprintf(const char *fmt, ...);
+void serial_init(void);
+void serial_putc(char c);
void vkprintf(const char *fmt, va_list *ap);
#endif /* !_KERNEL */
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 02e8705..71763b3 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -60,6 +60,9 @@ start_init(void)
int
main(void)
{
+ /* Setup serial driver */
+ serial_init();
+
/* Startup the console */
cons_init();
kprintf("Starting Hyra/%s v%s: %s\n", HYRA_ARCH, HYRA_VERSION,
diff --git a/sys/kern/kern_syslog.c b/sys/kern/kern_syslog.c
index 6962a69..7f66db0 100644
--- a/sys/kern/kern_syslog.c
+++ b/sys/kern/kern_syslog.c
@@ -34,6 +34,12 @@
#include <stdarg.h>
#include <string.h>
+#if defined(__SERIAL_DEBUG)
+#define SERIAL_DEBUG __SERIAL_DEBUG
+#else
+#define SERIAL_DEBUG 0
+#endif
+
/* Global logger lock */
static struct spinlock lock = {0};
@@ -44,6 +50,9 @@ syslog_write(const char *s, size_t len)
while (len--) {
cons_putch(&g_root_scr, *p);
+ if (SERIAL_DEBUG) {
+ serial_putc(*p);
+ }
++p;
}
}