diff --git a/student-distrib/keyboard.c b/student-distrib/keyboard.c index 17abc762995977052388473944325151a7685818..4e695cc1c262d61ecbc5bfaa3e366a32acb7d771 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 3b658b33d2f0a39f401a746cb3cc1c61d3231a09..521a935dbf08cfa291dd3209eeaf2e79da9f0ae1 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 325f335d821f627eeebec73b06a5fa09fc0dce71..2f3821492338886701596609420b86fb47e525b4 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 d22f01ad8d267846c21635bfc90d8dc53e5fc44a..98e587c77bf4bc26fc30f9ecac3f9d80d4089910 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 3d531f8148a330f60ad0e9269ab313d87bac6fc3..1170a55064a391c3783686e5c6891b007de92ab5 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);