From: acevest Date: Tue, 17 Sep 2024 02:54:57 +0000 (+0800) Subject: printk的buf改为局部变量 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=97163d9cc918474dd3aaa6f9d85bd01dc572b324;p=kernel.git printk的buf改为局部变量 --- diff --git a/Makefile b/Makefile index b2c8ab4..3fa3152 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ CC = $(CROSS_PREFIX)gcc LD = $(CROSS_PREFIX)ld CFLAGS = -g -c -fno-builtin -m32 -DBUILDER='"$(shell whoami)"' -# 指示编译器生成不依赖位置无关代码 +# 指示编译器禁止生成位置无关代码 CFLAGS += -fno-pic # 指示编译器在生成目标文件时不省略函数调用栈帧指针: frame pointer CFLAGS += -fno-omit-frame-pointer diff --git a/kernel/irq.c b/kernel/irq.c index 701513a..63ee4e9 100644 --- a/kernel/irq.c +++ b/kernel/irq.c @@ -90,6 +90,7 @@ __attribute__((regparm(1))) void irq_handler(pt_regs_t *regs) { irq_desc_t *p = irq_desc + irq; irq_action_t *action = p->action; + // 在qemu启动后如果gdb有加断点,就很会一直触发中断重入 reenter++; reenter_count += reenter == 0 ? 0 : 1; assert(irq_disabled()); @@ -160,6 +161,10 @@ __attribute__((regparm(1))) void irq_handler(pt_regs_t *regs) { return; } + // if (irq != 0) { + // return; + // } + enable_irq(); // 如果需要调度程序 diff --git a/kernel/printk.c b/kernel/printk.c index 74fd9a1..3934245 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -22,41 +22,45 @@ int vsprintf(char *buf, const char *fmt, char *args); void serial_write(const char *buf, size_t size); -char pkbuf[1024]; + extern tty_t *const default_tty; int printk(const char *fmtstr, ...) { - ENTER_CRITICAL_ZONE; + char pkbuf[1024]; + // ENTER_CRITICAL_ZONE; char *args = (char *)(((char *)&fmtstr) + 4); int size = vsprintf(pkbuf, fmtstr, args); tty_write(default_tty, pkbuf, (size_t)size); serial_write(pkbuf, (size_t)size); - EXIT_CRITICAL_ZONE; + // EXIT_CRITICAL_ZONE; return 0; } extern tty_t *const debug_tty; -char pdbuf[1024]; int printd(const char *fmtstr, ...) { - ENTER_CRITICAL_ZONE; + char pdbuf[1024]; + // ENTER_CRITICAL_ZONE; char *args = (char *)(((char *)&fmtstr) + 4); int size = vsprintf(pdbuf, fmtstr, args); tty_write(debug_tty, pdbuf, (size_t)size); serial_write(pdbuf, (size_t)size); - EXIT_CRITICAL_ZONE; + // EXIT_CRITICAL_ZONE; return 0; } -char plobuf[1024]; + extern tty_t *const monitor_tty; int printlo(unsigned int xpos, unsigned int ypos, const char *fmtstr, ...) { - ENTER_CRITICAL_ZONE; + char plobuf[1024]; char *args = (char *)(((char *)&fmtstr) + 4); int size = vsprintf(plobuf, fmtstr, args); + + ENTER_CRITICAL_ZONE; + tty_write_at(monitor_tty, xpos, ypos, plobuf, (size_t)size); EXIT_CRITICAL_ZONE; diff --git a/kernel/task_root.c b/kernel/task_root.c index b71231d..59ad457 100644 --- a/kernel/task_root.c +++ b/kernel/task_root.c @@ -101,7 +101,7 @@ void taskA_entry() { current->priority = 7; while (1) { - sysc_wait(7); + sysc_wait(37); uint64_t sect_nr = get_next_deubug_sect_nr(); memset(disk_buf1, 0, 512); @@ -128,7 +128,7 @@ void taskB_entry() { current->priority = 13; while (1) { - sysc_wait(7); + sysc_wait(73); uint64_t sect_nr = get_next_deubug_sect_nr(); memset(disk_buf2, 0, 512); disk_request_t r; diff --git a/qemu.sh b/qemu.sh index 50df4d3..9fd85e0 100755 --- a/qemu.sh +++ b/qemu.sh @@ -31,6 +31,9 @@ qemu-system-i386 \ -s -S \ & + #-cpu qemu32,+apic \ + #-cpu core2duo-v1,+apic \ + pid=$! echo "pid is ${pid}"