From: acevest Date: Tue, 16 May 2023 07:54:14 +0000 (+0800) Subject: 关中断执行print* X-Git-Url: http://zhaoyanbai.com/repos/html/index.html?a=commitdiff_plain;h=8c86cb1777c2f75bbef3ec331fa0c110c31cb8b1;p=kernel.git 关中断执行print* --- diff --git a/kernel/printk.c b/kernel/printk.c index 77a3a46..08eee39 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -15,34 +15,43 @@ *-------------------------------------------------------------------------- */ +#include #include #include - int vsprintf(char *buf, const char *fmt, char *args); char pkbuf[1024]; extern tty_t default_tty; int printk(const char *fmtstr, ...) { + unsigned long iflags; + irq_save(iflags); char *args = (char *)(((char *)&fmtstr) + 4); int size = vsprintf(pkbuf, fmtstr, args); tty_write(&default_tty, pkbuf, (size_t)size); + irq_restore(iflags); return 0; } extern tty_t debug_tty; char pdbuf[1024]; int printd(const char *fmtstr, ...) { + unsigned long iflags; + irq_save(iflags); char *args = (char *)(((char *)&fmtstr) + 4); int size = vsprintf(pdbuf, fmtstr, args); tty_write(&debug_tty, pdbuf, (size_t)size); + irq_restore(iflags); return 0; } char plobuf[1024]; extern tty_t monitor_tty; int printlo(unsigned int xpos, unsigned int ypos, const char *fmtstr, ...) { + unsigned long iflags; + irq_save(iflags); char *args = (char *)(((char *)&fmtstr) + 4); int size = vsprintf(plobuf, fmtstr, args); tty_write_at(&monitor_tty, xpos, ypos, plobuf, (size_t)size); + irq_restore(iflags); return 0; }