From b8eac7c0b049a55ccd364952320da548b8c245be Mon Sep 17 00:00:00 2001 From: Abinader <abinade2@illinois.edu> Date: Sun, 29 Apr 2018 11:42:56 -0500 Subject: [PATCH] fixed ctrl L --- student-distrib/keyboard.c | 39 +++++++++++++++++--------------------- student-distrib/keyboard.h | 2 +- student-distrib/lib.c | 21 -------------------- student-distrib/lib.h | 1 - student-distrib/syscall.c | 3 +++ 5 files changed, 21 insertions(+), 45 deletions(-) diff --git a/student-distrib/keyboard.c b/student-distrib/keyboard.c index 17abc76..4e695cc 100644 --- a/student-distrib/keyboard.c +++ b/student-distrib/keyboard.c @@ -146,10 +146,10 @@ void KB_init(void) { // initialize modifier flags enter_flag[0] = enter_flag[1] = enter_flag[2] = 0; - ctrl_flag[0] = ctrl_flag[1] = ctrl_flag[2] = 0; - caps_flag = 0; - alt_flag = 0; + ctrl_flag = 0; + caps_flag = 0; + alt_flag = 0; shift_flag = 0; enable_irq(KB_IRQ); @@ -298,13 +298,13 @@ void KB_handler(void) { case 0x1D : //ctrl pressed - ctrl_flag[visible_terminal] = 1; + ctrl_flag = 1; send_eoi(KB_IRQ); return; case 0x9D : //ctrl released - ctrl_flag[visible_terminal] = 0; + ctrl_flag = 0; send_eoi(KB_IRQ); return; @@ -350,16 +350,6 @@ void KB_handler(void) { pressed_key = scan_to_key_name(SCANCODE, scanCode); } - // 0x15 = scancode for L - // check if ctrl-L is pressed - if(ctrl_flag[visible_terminal] /*&& !shift_flag*/ && pressed_key == 0x15) - { - //clear(); - clear_memory(); - reset_cursor(); - send_eoi(KB_IRQ); - return; - } if(alt_flag && !shift_flag) { @@ -387,15 +377,20 @@ void KB_handler(void) { page_table[0xB8] = ((uint32_t)0xB8000) | USER | READ_WRITE | PRESENT; flush_tlb(); - //memcpy( (void*)TERM_VID, (const void*) terminal[visible_terminal].vid_mem, _4_KB ); + // 0x15 = scancode for L + // check if ctrl-L is pressed + if(ctrl_flag && !shift_flag && !alt_flag && pressed_key == 0x15) + { + clear(); + reset_cursor(); - //update_cursor(visible_terminal); + if(terminal[visible_terminal].pcb->shell_flag) + printf("391OS> "); - // if(terminal_switch_return == 0) - // { - // send_eoi(KB_IRQ); - // execute((uint8_t *)"shell"); - // } + remap2(running_terminal); + send_eoi(KB_IRQ); + return; + } // handle unknown keys by not printing switch (pressed_key) diff --git a/student-distrib/keyboard.h b/student-distrib/keyboard.h index 3b658b3..521a935 100644 --- a/student-distrib/keyboard.h +++ b/student-distrib/keyboard.h @@ -19,7 +19,7 @@ uint8_t caps_flag; uint8_t shift_flag; uint8_t alt_flag; - uint8_t ctrl_flag[3]; + uint8_t ctrl_flag; volatile uint8_t enter_flag[3]; /************************ KB driver functions ************************/ diff --git a/student-distrib/lib.c b/student-distrib/lib.c index 325f335..2f38214 100644 --- a/student-distrib/lib.c +++ b/student-distrib/lib.c @@ -24,27 +24,6 @@ void clear(void) { } } -void clear_memory(void) -{ - int32_t i; - uint8_t * video_memory; - - if(running_terminal == running_terminal) - video_memory = (uint8_t *) video_mem; - else - video_memory = (uint8_t *) terminal[visible_terminal].vid_mem; - - for (i = 0; i < NUM_ROWS * NUM_COLS; i++) { - *(uint8_t *)(video_memory + (i << 1)) = ' '; - *(uint8_t *)(video_memory + (i << 1) + 1) = ATTRIB; - } - - for (i = 0; i < NUM_ROWS * NUM_COLS; i++) { - *(uint8_t *)(terminal[visible_terminal].vid_mem + (i << 1)) = ' '; - *(uint8_t *)(terminal[visible_terminal].vid_mem + (i << 1) + 1) = ATTRIB; - } -} - /* https://wiki.osdev.org/Text_Mode_Cursor * void update_cursor(void); * Inputs: void diff --git a/student-distrib/lib.h b/student-distrib/lib.h index d22f01a..98e587c 100644 --- a/student-distrib/lib.h +++ b/student-distrib/lib.h @@ -15,7 +15,6 @@ int8_t *itoa(uint32_t value, int8_t* buf, int32_t radix); int8_t *strrev(int8_t* s); uint32_t strlen(const int8_t* s); void clear(void); -void clear_memory(void); void reset_cursor(void); void update_cursor(int32_t term_id); int32_t get_screen_x(void); diff --git a/student-distrib/syscall.c b/student-distrib/syscall.c index 3d531f8..1170a55 100644 --- a/student-distrib/syscall.c +++ b/student-distrib/syscall.c @@ -206,6 +206,9 @@ int32_t execute(const uint8_t* command){ terminal[running_terminal].pcb = pcb_ptr; + if(strncmp("shell", parsed_cmd, 5) == 0) + terminal[running_terminal].pcb->shell_flag = 1; + //printf("[EXE] using pcb = %x\n", terminal[running_terminal].pcb); //printf("[EXE] set pcb ebp to %x , esp to %x\n", terminal[running_terminal].pcb->current_ebp, terminal[running_terminal].pcb->current_esp); -- GitLab