Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 56dc8a8)
raw | patch | inline | side by side (parent: 56dc8a8)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Sun, 22 Sep 2024 10:54:18 +0000 (18:54 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Sun, 22 Sep 2024 10:54:18 +0000 (18:54 +0800) |
| include/irq.h | patch | blob | history | |
| kernel/printk.c | patch | blob | history | |
| qemu.sh | patch | blob | history |
diff --git a/include/irq.h b/include/irq.h
--- a/include/irq.h
+++ b/include/irq.h
void enter_critical_zone();
void exit_critical_zone();
-#define ENTER_CRITICAL_ZONE \
- do { \
- enter_critical_zone(); \
- } while (0)
-#define EXIT_CRITICAL_ZONE \
- do { \
- exit_critical_zone(); \
- } while (0)
+#define ENTER_CRITICAL_ZONE(x) \
+ volatile uint32_t __critical_zone_eflags_##x = 0; \
+ irq_save(__critical_zone_eflags_##x);
+
+
+#define EXIT_CRITICAL_ZONE(x) \
+ irq_restore(__critical_zone_eflags_##x);
#define IRQ_CLOCK 0x00
#define IRQ_KEYBOARD 0x01
diff --git a/kernel/printk.c b/kernel/printk.c
--- a/kernel/printk.c
+++ b/kernel/printk.c
extern tty_t *const default_tty;
int printk(const char *fmtstr, ...) {
static char pkbuf[1024];
- ENTER_CRITICAL_ZONE;
+
+ ENTER_CRITICAL_ZONE(EFLAGS);
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(EFLAGS);
return 0;
}
extern tty_t *const debug_tty;
int printd(const char *fmtstr, ...) {
static char pdbuf[1024];
- ENTER_CRITICAL_ZONE;
+ ENTER_CRITICAL_ZONE(EFLAGS);
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(EFLAGS);
return 0;
}
int printlo(unsigned int xpos, unsigned int ypos, const char *fmtstr, ...) {
static char plobuf[1024];
char *args = (char *)(((char *)&fmtstr) + 4);
- ENTER_CRITICAL_ZONE;
+ ENTER_CRITICAL_ZONE(EFLAGS);
int size = vsprintf(plobuf, fmtstr, args);
tty_write_at(monitor_tty, xpos, ypos, plobuf, (size_t)size);
- EXIT_CRITICAL_ZONE;
+ EXIT_CRITICAL_ZONE(EFLAGS);
return 0;
}
--- a/qemu.sh
+++ b/qemu.sh
-serial tcp::6666,server,nowait \
-drive file=HD.IMG,format=raw,index=0,media=disk \
-drive file=kernel.iso,index=1,media=cdrom \
- -drive file=HDb.IMG,format=raw,index=2,media=disk \
-name kernel \
-device ich9-ahci,id=ahci \
-vga std \
-s -S \
&
+ #-drive file=HDb.IMG,format=raw,index=2,media=disk \
#-cpu qemu32,+apic \
#-cpu core2duo-v1,+apic \