From 43eac598b423653dcd5342f1f99b7ab54ffece48 Mon Sep 17 00:00:00 2001 From: Fortunate-MAN Date: Mon, 16 Jan 2017 20:17:55 +0530 Subject: [PATCH] Control + D support #159 --- bin/boneshell/boneshell.c | 9 ++++++++- include/bin/boneshell/boneshell.h | 1 + platform/pc/drv/ps2/kbd/kbd.c | 10 ++++++++++ var/cpu/cpu_info.c | 20 ++++++++++---------- 4 files changed, 29 insertions(+), 11 deletions(-) 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 5dd96a5..bb645fb 100644 --- a/platform/pc/drv/ps2/kbd/kbd.c +++ b/platform/pc/drv/ps2/kbd/kbd.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -196,6 +197,7 @@ void key_handler_util(int key) printk (" "); kbd_info.key = KBD_ENTER_PRESS_ID; key_handler(); + kbd_info.key = ' '; cmds [CMD_CLEAR_INDEX]->handler ("clear"); return; } @@ -204,6 +206,14 @@ void key_handler_util(int key) 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) diff --git a/var/cpu/cpu_info.c b/var/cpu/cpu_info.c index a5f69f2..b7afa65 100644 --- a/var/cpu/cpu_info.c +++ b/var/cpu/cpu_info.c @@ -15,18 +15,18 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ - + **/ + #include #include -#include +#include #include #include - + cpu_info_t cpu_info; static const char* vendor_id_strings[] = { @@ -91,7 +91,7 @@ static void signature_proccessing(uint32_t sig) { if(strcmp(cpu_info.companyName, "Intel")==0) { - int bit_twelve = (sig >> 12) & 1; + int bit_twelve = (sig >> 12) & 1; int bit_thirteen = (sig >> 13) & 1; if(bit_twelve == 0 && bit_thirteen == 0) cpu_info.proccecor_type = "Original OEM Proccecor"; @@ -115,7 +115,7 @@ int init_cpu_info() find_comp(cpu_info.vendorID); signature_proccessing(cpu_info.signature); - + return STATUS_OK; } @@ -127,8 +127,8 @@ void __debug_print_cpu_info() #ifdef DEBUG printk("CPU\n"); printk("---\n"); - printk("COMPANY : %s\n", cpu_info.companyName); + printk("COMPANY : %s\n", cpu_info.companyName); printk("VENDOR_ID : %s\n", cpu_info.vendorID); printk("PROCCECOR TYPE : %s\n", cpu_info.proccecor_type); - #endif -} \ No newline at end of file + #endif +}