summaryrefslogtreecommitdiff
path: root/na/lib/klog.cc
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-07-10 11:24:56 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-07-10 11:24:56 +0800
commit1767d390fbf3d0c65389de46caf0b6d43ef3b6ad (patch)
tree0f5e01cd7c7a05abb6b1c7472d7f00f49caf02cc /na/lib/klog.cc
parent63dc025705f6533b91fb1a7d26e6ed864efd9900 (diff)
downloadlume-1767d390fbf3d0c65389de46caf0b6d43ef3b6ad.tar.gz
lume-1767d390fbf3d0c65389de46caf0b6d43ef3b6ad.tar.xz
feat: establish bootable new architecture checkpoint
Replace the compressed boot path with a relocatable higher-half RISC-V entry, expand memory and SMP support, and add the driver, TTY, VFS, exec, signal, syscall, initramfs, and self-test infrastructure needed for a bootable kernel checkpoint.
Diffstat (limited to 'na/lib/klog.cc')
-rw-r--r--na/lib/klog.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/na/lib/klog.cc b/na/lib/klog.cc
index bf081de..86c67f8 100644
--- a/na/lib/klog.cc
+++ b/na/lib/klog.cc
@@ -166,9 +166,7 @@ static void ring_drop_oldest(uint32 needed)
static void console_emit(const char* s, int len)
{
- for (int i = 0; i < len; ++i) {
- early_putc(s[i]);
- }
+ console_write_all(s, len);
}
static int klog_format_line(char* out, int out_size,
@@ -329,12 +327,20 @@ static void klog_vex(KlogLevel level, KlogSubsys subsys,
ring_write_bytes(msg, hdr.len);
if (do_console) {
g_klog.console_tail = g_klog.head;
+ /* Emit to UART while holding the lock to prevent
+ * interleaved output from concurrent CPUs. */
+ char line[KLOG_LINE_MAX + 64];
+ int line_len = klog_format_line(line, sizeof(line),
+ hdr, msg, hdr.len);
+ if (line_len > 0) {
+ console_emit(line, line_len);
+ }
}
- }
-
- if (do_console) {
+ } else if (do_console) {
+ /* Pre-init or panic mode: emit without lock */
char line[KLOG_LINE_MAX + 64];
- int line_len = klog_format_line(line, sizeof(line), hdr, msg, hdr.len);
+ int line_len = klog_format_line(line, sizeof(line),
+ hdr, msg, hdr.len);
if (line_len > 0) {
console_emit(line, line_len);
}