diff --git a/bin/boneshell/boneshell.c b/bin/boneshell/boneshell.c index ce8be47..8fd6c57 100644 --- a/bin/boneshell/boneshell.c +++ b/bin/boneshell/boneshell.c @@ -19,6 +19,7 @@ ** @contributors: ** Amanuel Bogale : start + ** Ashish Ahuja **/ #include @@ -34,6 +35,7 @@ #include #include #include <../platform/pc/drv/ps2/kbd/kbd.c> +#include extern volatile bool TAB_PREVIOUS_VALUE_SET; extern volatile char* TAB_PREVIOUS_VALUE; @@ -50,6 +52,7 @@ volatile bool exit_set__shell = false; volatile bool tab_multiple_opts = false; volatile bool tab_one_opt = false; volatile bool tab_zero_opt = false; +volatile bool exit_shell = false; bool executed_internally=false; void removeSpaces(char* source) @@ -74,6 +77,7 @@ void loop_terminal() printk ("%s release %s started at ", VAR_OSNAME, VAR_RELEASE); start_time = rtc_get_time(); rtc_print_struct(start_time); + //__debug_print_cpu_info(); while(1) { start_shell:; @@ -116,9 +120,12 @@ void loop_terminal() scank (true, true, "%s", cmd_active.value + (strlen (cmd_active.value))); } - if(strcmp(cmd_active.value, "exit")==0) + if(strcmp(cmd_active.value, "exit")==0 || exit_set__shell == true) + //if (exit_set__shell == true) { shell_instance_cnt--; + exit_set__shell = false; + strcpy (cmd_active.value, " "); printk("Exited shell instance #%d\n",shell_instance_cnt+1); goto end_shell; } diff --git a/include/bin/boneshell/boneshell.h b/include/bin/boneshell/boneshell.h index 58988bd..db45dd3 100644 --- a/include/bin/boneshell/boneshell.h +++ b/include/bin/boneshell/boneshell.h @@ -4,6 +4,7 @@ #include extern struct cmd_t cmd_boneshell; +extern volatile bool exit_shell; #endif /*_BIN_BONE_SHELL_H_*/ diff --git a/platform/pc/drv/ps2/kbd/kbd.c b/platform/pc/drv/ps2/kbd/kbd.c index 86b14a4..160f483 100644 --- a/platform/pc/drv/ps2/kbd/kbd.c +++ b/platform/pc/drv/ps2/kbd/kbd.c @@ -1,3 +1,4 @@ + /** ** This file is part of BoneOS. ** @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -44,14 +46,17 @@ #include #include + + volatile struct kbd_info_t kbd_info; -volatile int INDEX_CURSOR_POSITION = 0; -volatile bool UP_KEY_ACTIVE = true; +volatile int INDEX_CURSOR_POSITION=0; +volatile bool UP_KEY_ACTIVE=true; volatile bool TAB_PREVIOUS_VALUE_SET = false; volatile char* TAB_PREVIOUS_VALUE = 0; -char tab__[1024]; +char tab__ [1024]; + //Is this getting emulated at a terminal extern volatile bool TERMINAL_MODE; @@ -69,6 +74,7 @@ struct device_driver_t kbd_driver = .version = "8042" }; + /* * @function key_press: * Nested Function under @@ -103,10 +109,11 @@ void key_release(uint8_t scancode) if ( kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode] == KBD_LEFT_SHIFT_PRESS_ID || kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode] == KBD_RIGHT_SHIFT_PRESS_ID - ) - kbd_info.is_shift = false; + ) { + kbd_info.is_shift = false; + } - if ((int) scancode == 29) //Scancode of "Control" key + if ((int)(scancode) == 29) //Scancode of "Control" key kbd_info.is_ctrl = false; } @@ -123,12 +130,13 @@ void kbd_early_init() if(!kbd_info.tests.bat_test) { kbd_driver.status = STATUS_DRIVER_MALFUNCTION; - printck(0x3, 0x1, "BAT TEST FAILED"); + printck(0x3,0x1,"BAT TEST FAILED"); } else kbd_driver.status = STATUS_DRIVER_OK; - led_light(false, false, false); + + led_light(false,false,false); kbd_info.is_shift = false; kbd_info.is_caps = false; @@ -138,6 +146,8 @@ void kbd_early_init() kbd_info.current_kbd_layout_index = QWERTY_USA_INDEX; } + + /* * @utility wait_until_enter * Utility for Scank , to @@ -156,12 +166,14 @@ void wait_until_enter(char key) * and adds to length input. * used for when character typed. */ + static inline void inc_al() { INDEX_CURSOR_POSITION++; LENGTH_INPUT++; } + /* * @utility key_handler_util * Utility used for default @@ -178,25 +190,34 @@ static inline void inc_al() void key_handler_util(int key) { //First checking for shortcut commands - if(kbd_info.is_ctrl == true) + if (kbd_info.is_ctrl == true) { - if(key == 'l' || key == 'L') + if (key == 'l' || key == 'L') { - cmds[CMD_CLEAR_INDEX]->handler("clear"); + cmds [CMD_CLEAR_INDEX]->handler ("clear"); printk (" "); kbd_info.key = KBD_ENTER_PRESS_ID; key_handler(); - cmds[CMD_CLEAR_INDEX]->handler("clear"); + kbd_info.key = ' '; + cmds [CMD_CLEAR_INDEX]->handler ("clear"); return; } - else if(key == 'h' || key == 'H') + else if (key == 'h' || key == 'H') { key_handler_util_backspace(); return; } + else if (key == 'd' || key == 'D') + { + cmds [CMD_EXIT_INDEX]->handler ("exit"); + kbd_info.key = KBD_ENTER_PRESS_ID; + key_handler(); + kbd_info.key = ' '; + return; + } } - if(isalpha(key) == 0) + if(isalpha(key)==0) { if(print_scank == true && active_scank == true) { @@ -204,6 +225,7 @@ void key_handler_util(int key) printk("%c", key); wait_until_enter(key); } + else if(active_scank == true) wait_until_enter(key); } @@ -212,20 +234,26 @@ void key_handler_util(int key) if(kbd_info.is_caps == false && print_scank == true && active_scank == true) { inc_al(); - if (kbd_info.is_shift == true) + if (kbd_info.is_shift == true) { printk("%c", toupper(key)); - else if (kbd_info.is_shift == false) + } + else if (kbd_info.is_shift == false) { printk ("%c", tolower (key)); + } wait_until_enter(key); } else if(kbd_info.is_caps == true && print_scank == true && active_scank == true) { inc_al(); if(kbd_info.is_shift == true) - key = tolower(key); + { + key = tolower (key); + } else - key = toupper(key); - printk("%c", key); + { + key = toupper (key); + } + printk ("%c", key); wait_until_enter(key); } else if(active_scank == true) @@ -243,14 +271,15 @@ void key_handler_util_backspace() if(print_scank == true) printk("\b"); - INDEX_CURSOR_POSITION -= 1; - LENGTH_INPUT -= 1; + INDEX_CURSOR_POSITION-=1; + LENGTH_INPUT-=1; } } + bool tab_util(volatile char* buf_scan, volatile char* _cmd) { - for(int i = 0; buf_scan[i]; i++) + for(int i=0; buf_scan[i]; i++) if(buf_scan[i] != _cmd[i]) return false; @@ -259,43 +288,45 @@ bool tab_util(volatile char* buf_scan, volatile char* _cmd) void key_handler_util_tab() { - int index_tab = 0; - int num_cmds = 0; - for(int i = 0; cmds[i]; i++) + int index_tab=0; + int num_cmds=0; + for(int i=0; cmds[i]; i++) { if(tab_util(buffer_scank, cmds[i]->name) == true) { num_cmds++; - for(int j = 0; cmds[i]->name[j]; j++) + for(int j=0; cmds[i]->name[j]; j++) { tab__[index_tab] = cmds[i]->name[j]; index_tab++; } - for(int rep = 0; rep < 4; rep++) tab__[index_tab++] = ' '; + for(int rep=0; rep<4; rep++)tab__[index_tab++] = ' '; } } tab__[index_tab] = 0; - if(num_cmds == 1) + if(num_cmds==1) { printk ("\n"); for(int i = 0; tab__[i]; i ++) { printk("%c", tab__[i]); - cmd_active.value[i] = tab__[i]; + cmd_active.value [i] = tab__ [i]; } - tab_one_opt = true; + tab_one_opt=true; return; } if (num_cmds > 1) { tab_multiple_opts=true; printk ("\n"); - for(int i = 0; tab__[i]; i++) + for(int i=0; tab__[i]; i++) printk("%c", tab__[i]); } - else + else { tab_zero_opt = true; + } } + /* * @function key_handler: * Handles key events. @@ -311,89 +342,91 @@ void key_handler() //Is shift pressed case KBD_LEFT_SHIFT_PRESS_ID: case KBD_RIGHT_SHIFT_PRESS_ID: - kbd_info.is_shift = true; - break; + kbd_info.is_shift = true; + break; case KBD_CAPS_PRESS_ID: - kbd_info.is_caps = !kbd_info.is_caps; - break; + kbd_info.is_caps = !kbd_info.is_caps; + break; case KBD_UP_KEY_ID: - if(TERMINAL_MODE == true && UP_KEY_ACTIVE == true) - { - UP_KEY_ACTIVE = false; - int LENGTH_INPUT_STORE = LENGTH_INPUT; + if(TERMINAL_MODE == true && UP_KEY_ACTIVE == true) + { + UP_KEY_ACTIVE = false; + int LENGTH_INPUT_STORE = LENGTH_INPUT; - for (int i = 0; i < LENGTH_INPUT_STORE; i++) - key_handler_util_backspace(); + for (int i=0; i= 32 && ((int) kbd_info.key) <= 47) - key_handler_util(kbd_info.key); - else if(((int) kbd_info.key) >= 58 && ((int) kbd_info.key) <= 64) - key_handler_util(kbd_info.key); - else if(((int) kbd_info.key) >= 91 && ((int) kbd_info.key) <= 96) - key_handler_util(kbd_info.key); - else if(((int) kbd_info.key) >= 123 && ((int) kbd_info.key) <= 126) - key_handler_util(kbd_info.key); - break; + if(isalpha(kbd_info.key)!=0) + key_handler_util(kbd_info.key); + else if(isdigit(kbd_info.key)!=0) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 32 && ((int)kbd_info.key) <=47) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 58 && ((int)kbd_info.key) <=64) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 91 && ((int)kbd_info.key) <=96) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 123 && ((int)kbd_info.key) <=126) + key_handler_util(kbd_info.key); + break; } } + /* * @function kbd_handler: * Primary Keyboard Handler @@ -405,7 +438,7 @@ void key_handler() */ void kbd_handler(int_regs *r) { - if(r) {}; + if(r){}; kbd_info.scancode = kbd_enc_read_input_buf(); if(kbd_info.scancode & 0x80) @@ -432,7 +465,7 @@ int init_kbd() { kbd_driver.initalized = true; kbd_early_init(); - install_irq_handler(IRQ_NUM_KBD, kbd_handler); + install_irq_handler(IRQ_NUM_KBD,kbd_handler); return STATUS_OK; } diff --git a/var/cpu/cpu_info.c b/var/cpu/cpu_info.c index ea1afe6..f7919c8 100644 --- a/var/cpu/cpu_info.c +++ b/var/cpu/cpu_info.c @@ -113,7 +113,7 @@ int init_cpu_info() cpu_info.signature = cpu_id.signature; find_comp(cpu_info.vendorID); signature_proccessing(cpu_info.signature); - + return STATUS_OK; }