From: acevest Date: Sun, 28 May 2023 05:45:45 +0000 (+0800) Subject: 加入F1 F2 F3切换tty的功能 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=18cf417585b83e74d413f247fd578f2654e8c177;p=kernel.git 加入F1 F2 F3切换tty的功能 --- diff --git a/drivers/keyboard.c b/drivers/keyboard.c index b248dae..4864bf3 100644 --- a/drivers/keyboard.c +++ b/drivers/keyboard.c @@ -71,6 +71,10 @@ void kbd_handler(unsigned int irq, pt_regs_t *regs, void *dev_id) { cnsl_kbd_write(ch); } +extern tty_t default_tty; +extern tty_t monitor_tty; +extern tty_t debug_tty; + void kbd_debug(unsigned char scan_code) { static unsigned long kbd_cnt = 0; printl(MPL_KEYBOARD, "keyboard irq: %d scan code %02x", kbd_cnt++, scan_code); @@ -81,14 +85,13 @@ void kbd_debug(unsigned char scan_code) { printd("[%02x]", scan_code); - // if (scan_code == 0x3B) // F1 - // vga_switch(0); - // if (scan_code == 0x3C) // F2 - // vga_switch(1); - // if (scan_code == 0x3D) // F3 - // vga_switch(2); - // if (scan_code == 0x3E) // F4 - // vga_switch(3); + if (scan_code == 0x3B) { // F1 + tty_switch(&default_tty); + } else if (scan_code == 0x3C) { // F2 + tty_switch(&monitor_tty); + } else if (scan_code == 0x3D) { // F3 + tty_switch(&debug_tty); + } if (scan_code == 0x3F) // F5 debug_wait_queue_put(0); @@ -104,7 +107,6 @@ void kbd_debug(unsigned char scan_code) { ata_test(0); } if (scan_code == 0x44) { // F10 - void ata_send_read_identify_cmd(int dev); ata_send_read_identify_cmd(0); } @@ -116,8 +118,6 @@ void kbd_debug(unsigned char scan_code) { ; } - extern tty_t default_tty; - extern tty_t monitor_tty; if (scan_code == 0x58) { // F12 current_tty = current_tty != &default_tty ? &default_tty : &monitor_tty; tty_switch(current_tty); diff --git a/include/tty.h b/include/tty.h index 8fdae9f..b162f3a 100644 --- a/include/tty.h +++ b/include/tty.h @@ -13,10 +13,13 @@ #define TTY_BG_BLINK 0b1000 #define TTY_BLACK 0b0000 -#define TTY_WHITE 0b0111 -#define TTY_RED 0b0100 -#define TTY_GREEN 0b0010 #define TTY_BLUE 0b0001 +#define TTY_GREEN 0b0010 +#define TTY_CYAN 0b0011 +#define TTY_RED 0b0100 +#define TTY_PURPLE 0b101 +#define TTY_YELLOW 0b110 +#define TTY_WHITE 0b0111 typedef struct tty { char name[32]; diff --git a/kernel/task_init.c b/kernel/task_init.c index 94effeb..8ce0a76 100644 --- a/kernel/task_init.c +++ b/kernel/task_init.c @@ -10,7 +10,7 @@ #include #include int sysc_wait(unsigned long cnt); -kernel / task_init.c void init_task_entry() { +void init_task_entry() { current->priority = 10; // 继续内核未完成的初始化 diff --git a/kernel/tty.c b/kernel/tty.c index 0a6b5b3..f10f569 100644 --- a/kernel/tty.c +++ b/kernel/tty.c @@ -85,8 +85,8 @@ void init_ttys() { current_tty = &default_tty; init_tty(&debug_tty, "tty.debug", VADDR + 7 * TTY_VRAM_SIZE); - debug_tty.fg_color = TTY_BLACK; - debug_tty.bg_color = TTY_RED; + debug_tty.fg_color = TTY_FG_HIGHLIGHT | TTY_WHITE; + debug_tty.bg_color = TTY_CYAN; tty_clear(&debug_tty); }