From d2c3ce2d15a956553fc2481d7f592abcbaca6cf6 Mon Sep 17 00:00:00 2001 From: acevest Date: Sun, 9 Aug 2026 17:21:53 +0800 Subject: [PATCH] rename printlxy to ap_printlxy --- {drivers => include}/console.h | 0 include/printk.h | 11 ++++++----- kernel/ap.c | 16 ++++++++-------- {drivers => kernel}/console.c | 0 kernel/printk.c | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) rename {drivers => include}/console.h (100%) rename {drivers => kernel}/console.c (100%) diff --git a/drivers/console.h b/include/console.h similarity index 100% rename from drivers/console.h rename to include/console.h diff --git a/include/printk.h b/include/printk.h index 4cbed83..458d6ac 100644 --- a/include/printk.h +++ b/include/printk.h @@ -18,12 +18,13 @@ int printk(const char* fmtstr, ...); int printd(const char* fmtstr, ...); -int printlo(unsigned int line, unsigned int offset, const char* fmtstr, ...); +int ap_print(unsigned int xpos, unsigned int ypos, const char* fmtstr, ...); + +#define ap_printl(line, fmt, args...) ap_print(1, line, fmt, ##args) +#define ap_printll(line, fmt, args...) ap_print(0, line, fmt, ##args) +#define ap_printlr(line, fmt, args...) ap_print(40, line, fmt, ##args) +#define ap_printlxy(line, offset, fmt, args...) ap_print(offset, line, fmt, ##args) -#define printl(line, fmt, args...) printlo(1, line, fmt, ##args) -#define printll(line, fmt, args...) printlo(0, line, fmt, ##args) -#define printlr(line, fmt, args...) printlo(40, line, fmt, ##args) -#define printlxy(line, offset, fmt, args...) printlo(offset, line, fmt, ##args) // monitor print line enum { diff --git a/kernel/ap.c b/kernel/ap.c index 36b2be1..36fb6d4 100644 --- a/kernel/ap.c +++ b/kernel/ap.c @@ -225,7 +225,7 @@ void ap_kernel_entry() { asm("sti;"); const char* title = "KERNEL MONITOR"; - printlxy(MPL_TITLE, (80 - strlen(title)) / 2, title); + ap_printlxy(MPL_TITLE, (80 - strlen(title)) / 2, title); void system_monitor(); system_monitor(); @@ -263,19 +263,19 @@ void _system_monitor() { // extern volatile uint64_t jiffies; // extern volatile uint64_t hpet_ticks; // jiffies 和 hpet_ticks 是同一个东西 - printlxy(MPL_IRQ, MPO_HPET, "HPET: %lu", jiffies); + ap_printlxy(MPL_IRQ, MPO_HPET, "HPET: %lu", jiffies); // extern volatile uint8_t kbd_scan_code; extern volatile uint64_t kbd_irq_cnt; - printlxy(MPL_IRQ, MPO_KEYBOARD, "KBD: %02x %lu", kbd_scan_code, kbd_irq_cnt); + ap_printlxy(MPL_IRQ, MPO_KEYBOARD, "KBD: %02x %lu", kbd_scan_code, kbd_irq_cnt); // - printlxy(MPL_IRQ, MPO_AP_CLOCK, "AP: %lu", ap_lapic_ticks); + ap_printlxy(MPL_IRQ, MPO_AP_CLOCK, "AP: %lu", ap_lapic_ticks); extern disk_request_queue_t disk_request_queue; disk_request_queue_t* drq = &disk_request_queue; - printlxy(MPL_IRQ, MPO_DISK, "DISK: %lu/%u/%lu", drq->req_count, drq->pending_count, drq->completed_count); + ap_printlxy(MPL_IRQ, MPO_DISK, "DISK: %lu/%u/%lu", drq->req_count, drq->pending_count, drq->completed_count); // void print_all_tasks(); @@ -312,7 +312,7 @@ const char* task_state(unsigned int state) { void print_all_tasks() { extern task_t* monitor_tasks[]; - printl(MPL_TASK_TITLE, " NAME STATE TK/PI REASON SCHED KEEP"); + ap_printl(MPL_TASK_TITLE, " NAME STATE TK/PI REASON SCHED KEEP"); for (int i = 0; i < 10; i++) { task_t* p = monitor_tasks[i]; @@ -321,7 +321,7 @@ void print_all_tasks() { continue; } - printl(MPL_TASK_0 + p->pid, "%08x %-6s:%u %s %02d/%02u %-10s %-9u %-9u", + ap_printl(MPL_TASK_0 + p->pid, "%08x %-6s:%u %s %02d/%02u %-10s %-9u %-9u", p, // p->name, // p->pid, // @@ -345,7 +345,7 @@ void ide_stat_print(ide_pci_controller_t* ide_ctrl) { int i = atomic_read(&(ide_ctrl->irq_cnt)); int c = atomic_read(&(ide_ctrl->consumed_cnt)); int channel = ide_ctrl->channel; - printlxy(MPL_IDE0 + channel, MPO_IDE, "IDE%d req %u irq %u consumed %u", channel, r, i, c); + ap_printlxy(MPL_IDE0 + channel, MPO_IDE, "IDE%d req %u irq %u consumed %u", channel, r, i, c); } void print_all_ides() { diff --git a/drivers/console.c b/kernel/console.c similarity index 100% rename from drivers/console.c rename to kernel/console.c diff --git a/kernel/printk.c b/kernel/printk.c index 663bbfa..c227225 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -86,7 +86,7 @@ int printd(const char* fmtstr, ...) { } extern tty_t* const monitor_tty; -int printlo(unsigned int xpos, unsigned int ypos, const char* fmtstr, ...) { +int ap_print(unsigned int xpos, unsigned int ypos, const char* fmtstr, ...) { static char plobuf[1024]; va_list args; -- 2.47.0