summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/amd64
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-26 23:42:50 -0400
committerIan Moffett <ian@osmora.org>2024-05-26 23:44:35 -0400
commitc3e50e6a2101afeadca9568481b6ed4395ae560b (patch)
tree96cd08853bdde8a77a6d89511502f2a72ec4ea61 /sys/arch/amd64/amd64
parenta59842033c0a29f774f895278597c8fc8141f7ac (diff)
kernel: Fixup logging to work with syslog changes
This commit removes the KINFO(), KERR(), ... macros Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/amd64')
-rw-r--r--sys/arch/amd64/amd64/cpu_mp.c8
-rw-r--r--sys/arch/amd64/amd64/hpet.c13
-rw-r--r--sys/arch/amd64/amd64/ioapic.c3
-rw-r--r--sys/arch/amd64/amd64/lapic.c15
-rw-r--r--sys/arch/amd64/amd64/machdep.c4
-rw-r--r--sys/arch/amd64/amd64/trap.c32
6 files changed, 44 insertions, 31 deletions
diff --git a/sys/arch/amd64/amd64/cpu_mp.c b/sys/arch/amd64/amd64/cpu_mp.c
index cbc6afd..b9de227 100644
--- a/sys/arch/amd64/amd64/cpu_mp.c
+++ b/sys/arch/amd64/amd64/cpu_mp.c
@@ -42,6 +42,8 @@ __MODULE_NAME("cpu_mp");
__KERNEL_META("$Hyra$: cpu_mp.c, Ian Marco Moffett, "
"SMP related code");
+#define pr_trace(fmt, ...) kprintf("cpu_mp: " fmt, ##__VA_ARGS__)
+
static volatile struct limine_smp_request g_smp_req = {
.id = LIMINE_SMP_REQUEST,
.revision = 0
@@ -124,14 +126,14 @@ ap_bootstrap(struct cpu_info *ci)
tmr_irqstat_add(ci);
if (resp->cpu_count == 1) {
- KINFO("CPU has 1 core, no APs to bootstrap...\n");
+ pr_trace("CPU has 1 core, no APs to bootstrap...\n");
return;
}
- KINFO("Bootstrapping %d cores...\n", cpu_init_counter);
+ pr_trace("Bootstrapping %d cores...\n", cpu_init_counter);
for (size_t i = 0; i < resp->cpu_count; ++i) {
if (ci->id == cpus[i]->lapic_id) {
- KINFO("Skip %d (BSP)... continue\n", ci->id);
+ pr_trace("Skip %d (BSP)... continue\n", ci->id);
continue;
}
diff --git a/sys/arch/amd64/amd64/hpet.c b/sys/arch/amd64/amd64/hpet.c
index f63b47e..69dc0dd 100644
--- a/sys/arch/amd64/amd64/hpet.c
+++ b/sys/arch/amd64/amd64/hpet.c
@@ -41,6 +41,9 @@ __MODULE_NAME("hpet");
__KERNEL_META("$Hyra$: hpet.c, Ian Marco Moffett, "
"HPET driver");
+#define pr_trace(fmt, ...) kprintf("hpet: " fmt, ##__VA_ARGS__)
+#define pr_error(...) pr_trace(__VA_ARGS__)
+
#define HPET_REG_CAPS 0x00
#define HPET_GENERAL_CONFIG 0x10
#define HPET_REG_MAIN_COUNTER 0xF0
@@ -168,7 +171,7 @@ hpet_init(void)
/* Ensure caps aren't bogus */
if (CAP_REV_ID(caps) == 0) {
- KERR("Found bogus revision, assuming faulty\n");
+ pr_error("Found bogus revision, assuming faulty\n");
is_faulty = true;
return 1;
}
@@ -178,14 +181,14 @@ hpet_init(void)
* must be <= 0x05F5E100. So we'll consider it
* as bogus if it exceeds this value
*/
- KERR("Found bogus COUNTER_CLK_PERIOD, assuming faulty\n");
- KINFO("HPET REV - 0x%x\n", CAP_REV_ID(caps));
- KINFO("COUNTER_CLK_PERIOD - 0x%x\n", CAP_CLK_PERIOD(caps));
+ pr_error("Found bogus COUNTER_CLK_PERIOD, assuming faulty\n");
+ pr_trace("HPET REV - 0x%x\n", CAP_REV_ID(caps));
+ pr_trace("COUNTER_CLK_PERIOD - 0x%x\n", CAP_CLK_PERIOD(caps));
is_faulty = true;
return 1;
}
- KINFO("HPET integrity verified\n");
+ pr_trace("HPET integrity verified\n");
hpet_write(HPET_REG_MAIN_COUNTER, 0);
hpet_write(HPET_GENERAL_CONFIG, 1);
diff --git a/sys/arch/amd64/amd64/ioapic.c b/sys/arch/amd64/amd64/ioapic.c
index ffc732d..5dfdfa8 100644
--- a/sys/arch/amd64/amd64/ioapic.c
+++ b/sys/arch/amd64/amd64/ioapic.c
@@ -39,6 +39,7 @@ __MODULE_NAME("ioapic");
__KERNEL_META("$Hyra$: ioapic.c, Ian Marco Moffett, "
"I/O APIC driver");
+#define pr_trace(fmt, ...) kprintf("ioapic: " fmt, ##__VA_ARGS__)
#define IOAPIC_BASE_OFF(off) ((void *)((uintptr_t)ioapic_base + off))
static void *ioapic_base = NULL;
@@ -191,7 +192,7 @@ ioapic_init(void)
tmp = ioapic_readl(IOAPICVER);
redir_entry_cnt = __SHIFTOUT(tmp, 0xFF << 16) + 1;
- KINFO("Masking %d GSIs...\n", redir_entry_cnt);
+ pr_trace("Masking %d GSIs...\n", redir_entry_cnt);
for (uint8_t i = 0; i < redir_entry_cnt; ++i) {
ioapic_gsi_mask(i);
diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c
index 2f9c0b7..81432dd 100644
--- a/sys/arch/amd64/amd64/lapic.c
+++ b/sys/arch/amd64/amd64/lapic.c
@@ -47,15 +47,18 @@ __MODULE_NAME("lapic");
__KERNEL_META("$Hyra$: lapic.c, Ian Marco Moffett, "
"Local APIC driver");
+#define pr_trace(fmt, ...) kprintf("lapic: " fmt, ##__VA_ARGS__)
+#define pr_error(...) pr_trace(__VA_ARGS__)
+
/*
- * Only calls KINFO if we are the BSP.
+ * Only calls pr_trace if we are the BSP.
*/
-#define BSP_KINFO(...) do { \
+#define BSP_TRACE(...) do { \
uint64_t msr_val; \
\
msr_val = rdmsr(IA32_APIC_BASE_MSR); \
if (__TEST(msr_val, 1 << 8)) { \
- KINFO(__VA_ARGS__); \
+ pr_trace(__VA_ARGS__); \
} \
} while (0);
@@ -397,7 +400,7 @@ lapic_init(void)
/* Software enable the Local APIC via SVR */
lapic_reg_set(LAPIC_SVR, LAPIC_SW_ENABLE);
- BSP_KINFO("Enabled Local APIC for BSP\n");
+ BSP_TRACE("Enabled Local APIC for BSP\n");
lapic_set_ldr(ci);
/* Setup the timer descriptor */
@@ -411,7 +414,7 @@ lapic_init(void)
/* Set the Local APIC ID */
ci->id = lapic_get_id(ci);
- BSP_KINFO("BSP Local APIC ID: %d\n", ci->id);
+ BSP_TRACE("BSP Local APIC ID: %d\n", ci->id);
/* Setup LAPIC Timer TSS stack */
if (tss_alloc_stack(&tmr_stack, vm_get_page_size()) != 0) {
@@ -427,6 +430,6 @@ lapic_init(void)
idt_set_desc(SYSVEC_LAPIC_TIMER, IDT_INT_GATE_FLAGS,
(uintptr_t)lapic_tmr_isr, IST_SCHED);
- BSP_KINFO("LAPIC Timer on Interrupt Stack %d (IST_SCHED) with vector 0x%x\n",
+ BSP_TRACE("LAPIC Timer on Interrupt Stack %d (IST_SCHED) with vector 0x%x\n",
IST_SCHED, SYSVEC_LAPIC_TIMER);
}
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 34bea11..0c2718a 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -145,7 +145,7 @@ backtrace(void)
off_t off;
const char *name;
- kprintf("** Backtrace **\n");
+ kprintf(OMIT_TIMESTAMP "** Backtrace **\n");
__ASMV("mov %%rbp, %0" : "=r" (rbp) :: "memory");
while (1) {
@@ -158,7 +158,7 @@ backtrace(void)
if (name == NULL)
name = "???";
- kprintf("[0x%p] <%s+0x%x>\n", rip, name, off);
+ kprintf(OMIT_TIMESTAMP "[0x%p] <%s+0x%x>\n", rip, name, off);
}
}
diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c
index 539ee48..531f2f5 100644
--- a/sys/arch/amd64/amd64/trap.c
+++ b/sys/arch/amd64/amd64/trap.c
@@ -44,6 +44,8 @@ __MODULE_NAME("trap");
__KERNEL_META("$Hyra$: trap.c, Ian Marco Moffett, "
"Trap handling");
+#define pr_error(fmt, ...) kprintf("trap: " fmt, ##__VA_ARGS__)
+
static const char *trap_type[] = {
[TRAP_BREAKPOINT] = "breakpoint",
[TRAP_ARITH_ERR] = "arithmetic error",
@@ -92,14 +94,15 @@ dbg_errcode(struct trapframe *tf)
switch (tf->trapno) {
case TRAP_PAGEFLT:
- kprintf("bits (pwui): %c%c%c%c\n",
+ kprintf(OMIT_TIMESTAMP
+ "bits (pwui): %c%c%c%c\n",
__TEST(ec, __BIT(0)) ? 'p' : '-',
__TEST(ec, __BIT(1)) ? 'w' : '-',
__TEST(ec, __BIT(2)) ? 'u' : '-',
__TEST(ec, __BIT(4)) ? 'i' : '-');
break;
case TRAP_SS:
- kprintf("ss: 0x%x\n", ec);
+ kprintf(OMIT_TIMESTAMP "ss: 0x%x\n", ec);
break;
}
}
@@ -108,9 +111,9 @@ static void
trap_print(struct trapframe *tf)
{
if (tf->trapno < TRAP_COUNT) {
- kprintf("** Fatal %s **\n", trap_type[tf->trapno]);
+ kprintf(OMIT_TIMESTAMP "** Fatal %s **\n", trap_type[tf->trapno]);
} else {
- kprintf("** Unknown trap %d **\n", tf->trapno);
+ kprintf(OMIT_TIMESTAMP "** Unknown trap %d **\n", tf->trapno);
}
dbg_errcode(tf);
@@ -127,7 +130,8 @@ regdump(struct trapframe *tf)
: "memory"
);
- kprintf("RAX=%p RCX=%p RDX=%p\n"
+ kprintf(OMIT_TIMESTAMP
+ "RAX=%p RCX=%p RDX=%p\n"
"RBX=%p RSI=%p RDI=%p\n"
"RFL=%p CR2=%p CR3=%p\n"
"RBP=%p RSP=%p RIP=%p\n",
@@ -186,9 +190,9 @@ handle_user_pf(struct proc *curtd, struct trapframe *tf,
s = vm_fault(fault_addr, access_type);
if (s != 0) {
- KERR("Got page fault @ 0x%p\n", fault_addr);
- KERR("Fault access mask: 0x%x\n", access_type);
- KERR("Raising SIGSEGV to PID %d...\n", curtd->pid);
+ pr_error("Got page fault @ 0x%p\n", fault_addr);
+ pr_error("Fault access mask: 0x%x\n", access_type);
+ pr_error("Raising SIGSEGV to PID %d...\n", curtd->pid);
regdump(tf);
raise_fatal(curtd, sched_tmr, SIGSEGV);
}
@@ -232,8 +236,8 @@ trap_handler(struct trapframe *tf)
*/
if (tf->trapno == TRAP_NMI) {
trap_print(tf);
- kprintf("Possible hardware failure?\n");
- panic("Caught NMI; bailing out\n");
+ kprintf(OMIT_TIMESTAMP "Possible hardware failure?\n");
+ panic(OMIT_TIMESTAMP "Caught NMI; bailing out\n");
}
if (curtd == NULL) {
@@ -244,16 +248,16 @@ trap_handler(struct trapframe *tf)
switch (tf->trapno) {
case TRAP_ARITH_ERR:
- KERR("Got arithmetic error - raising SIGFPE...\n");
- KERR("SIGFPE -> PID %d\n", curtd->pid);
+ pr_error("Got arithmetic error - raising SIGFPE...\n");
+ pr_error("SIGFPE -> PID %d\n", curtd->pid);
raise_fatal(curtd, &sched_tmr, SIGFPE);
break;
case TRAP_PAGEFLT:
handle_user_pf(curtd, tf, &sched_tmr);
break;
default:
- KERR("Got %s - raising SIGSEGV...\n", trap_type[tf->trapno]);
- KERR("SIGSEGV -> PID %d\n", curtd->pid);
+ pr_error("Got %s - raising SIGSEGV...\n", trap_type[tf->trapno]);
+ pr_error("SIGSEGV -> PID %d\n", curtd->pid);
regdump(tf);
raise_fatal(curtd, &sched_tmr, SIGSEGV);
break;