From a52f8be1d60bac1e1d9fa4ab57f35d61b47edd8d Mon Sep 17 00:00:00 2001 From: Muhammad Rifqi Priyo Susanto Date: Mon, 16 Jan 2017 12:12:14 +0700 Subject: [PATCH] General Cleanup #151 Uses 4 spaces as TAB. Commenting unused code. (i.e. if statement with no action) apps/ boot/ platform/ sbin/ var/ --- apps/sh/built-in/exit/exit.c | 56 +- apps/sh/shell.c | 30 +- apps/sh/utils.c | 76 +- apps/sh/values.c | 2 - boot/boot/grub/grub.cfg | 4 +- platform/Makefile | 2 +- platform/pc/cpu/interrupts/pic.c | 33 +- platform/pc/drv/cmos/rtc/rtc.c | 117 ++- platform/pc/drv/driver.c | 38 +- platform/pc/drv/pit/pit.c | 73 +- platform/pc/drv/ps2/kbd/kbd.c | 920 +++++++++--------- .../drv/ps2/kbd/kbd_layouts/scancodes_usa.c | 144 ++- platform/pc/drv/ps2/kbd/scancodes.c | 22 +- platform/pc/drv/ps2/kbd/utils.c | 47 +- platform/pc/drv/video/VGA/textmode/clear.c | 44 +- platform/pc/drv/video/VGA/textmode/putch.c | 30 +- .../pc/drv/video/VGA/textmode/term_scroll.c | 26 +- .../pc/drv/video/VGA/textmode/update_cursor.c | 26 +- platform/pc/drv/video/VGA/textmode/utils.c | 18 +- .../pc/drv/video/VGA/textmode/vga_textmode.c | 37 +- platform/pc/drv/video/VGA/vga.c | 71 +- platform/pc/drv/video/video.c | 32 +- platform/pc/io/io.c | 39 +- sbin/poweroff/poweroff.c | 70 +- sbin/reboot/reboot.c | 71 +- var/Makefile | 2 - var/cpu/cpu_info.c | 43 +- 27 files changed, 949 insertions(+), 1124 deletions(-) diff --git a/apps/sh/built-in/exit/exit.c b/apps/sh/built-in/exit/exit.c index 0e7fb69..90bc6a8 100644 --- a/apps/sh/built-in/exit/exit.c +++ b/apps/sh/built-in/exit/exit.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -30,47 +30,45 @@ extern volatile bool exit_set__shell; -struct cmd_opt_t* cmd_exit_opts[] = +struct cmd_opt_t* cmd_exit_opts[] = { - 0 + 0 }; int exit_handler(char* cmd) { size_t num_opts = get_opt_count(cmd); str_t opts[num_opts]; - get_opt(cmd,opts); - - if(num_opts==1) + get_opt(cmd, opts); + + if(num_opts == 1) { - exit_set__shell=true; + exit_set__shell = true; return STATUS_OK; } - else if(strcmp(opts[1].str,"--help")==0) + else if(strcmp(opts[1].str, "--help") == 0) printk(cmd_exit.help); - else + else printk(cmd_exit.invalid_use_msg); - + return STATUS_OK; } -struct cmd_t cmd_exit = +struct cmd_t cmd_exit = { - .name = "exit", - .usage = "exit [--help] ", - .help = "exit(1) \t\t\t\t BoneOS Terminal Manual \n" - "NAME : \n " - "\texit\n" - "SYNOPSIS : \n " - "\texit [--help]\n" - "DESCRIPTION : \n " - "\tCommand to exit the current \n " - "\tshell process\n", - .cmd_opts = cmd_exit_opts, - .handler = &exit_handler, - .invalid_use_msg = "Invalid use of exit command.\n" - "Type in exit --help for more help.\n", - .privilege = USER + .name = "exit", + .usage = "exit [--help] ", + .help = "exit(1) \t\t\t\t BoneOS Terminal Manual \n" + "NAME : \n " + "\texit\n" + "SYNOPSIS : \n " + "\texit [--help]\n" + "DESCRIPTION : \n " + "\tCommand to exit the current \n " + "\tshell process\n", + .cmd_opts = cmd_exit_opts, + .handler = &exit_handler, + .invalid_use_msg = "Invalid use of exit command.\n" + "Type in exit --help for more help.\n", + .privilege = USER }; - - diff --git a/apps/sh/shell.c b/apps/sh/shell.c index 9ee9c86..a51bcdd 100644 --- a/apps/sh/shell.c +++ b/apps/sh/shell.c @@ -22,7 +22,6 @@ ** Ashish Ahuja **/ - #include #include #include @@ -47,17 +46,17 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include volatile bool TERMINAL_MODE = false; -volatile uint32_t cmd_active_index=0; +volatile uint32_t cmd_active_index = 0; volatile uint32_t shell_instance_cnt = 0; -volatile struct typed_cmd cmd_active; +volatile struct typed_cmd cmd_active; rtc_t start_time; struct cmd_t *cmds[] = @@ -75,25 +74,18 @@ struct cmd_t *cmds[] = &cmd_pwd, &cmd_logname, &cmd_uname, - &cmd_date, - &cmd_whoami, - &cmd_uptime, + &cmd_date, + &cmd_whoami, + &cmd_uptime, &cmd_watch, 0 }; void init_terminal() { - assertkm(device_initalized(KBD_DRIVER_INDEX) , "Keyboard not intalized for starting shell!"); - TERMINAL_MODE=true; + assertkm(device_initalized(KBD_DRIVER_INDEX), "Keyboard not intalized for starting shell!"); + TERMINAL_MODE = true; cmds [CMD_CLEAR_INDEX]->handler("clear"); cmds[CMD_BONESHELL_INDEX]->handler("boneshell"); - TERMINAL_MODE=false; + TERMINAL_MODE = false; } - - - - - - - diff --git a/apps/sh/utils.c b/apps/sh/utils.c index 0e4a696..1b917b7 100644 --- a/apps/sh/utils.c +++ b/apps/sh/utils.c @@ -15,66 +15,60 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start **/ - - #include - #include - #include - #include - + +#include +#include +#include +#include + int termcmp(const char* cmd, const char* value) { - size_t num_opts_cmp = get_opt_count(value); - str_t opts_cmp[num_opts_cmp]; - get_opt(value,opts_cmp); - if(strcmp(opts_cmp[0].str,cmd)==0) - return 0; - return 1; + size_t num_opts_cmp = get_opt_count(value); + str_t opts_cmp[num_opts_cmp]; + get_opt(value, opts_cmp); + if(strcmp(opts_cmp[0].str, cmd) == 0) + return 0; + return 1; } bool is_contain_equal(char* s) { - while(*s) + while(*s) if(*s++ == '=') return true; - return false; + return false; } str_t term_assignment_return_variable(str_t s) { - int counter = 0; - str_t __return; - for(int i=0; i<200;i++) __return.str[i]=0; - - while(s.str[counter] != '=') { - __return.str[counter]+=s.str[counter]; - counter++; - } - return __return; + int counter = 0; + str_t __return; + for(int i = 0; i < 200; i++) __return.str[i] = 0; + + while(s.str[counter] != '=') { + __return.str[counter] += s.str[counter]; + counter++; + } + return __return; } str_t term_assignment_return_value(str_t s) { - int counter=0; - int self_index=0; - str_t __return; - for(int i=0; i<200;i++) __return.str[i]=0; - - while(s.str[counter++] != '='); - for(; s.str[counter]; counter++) - { - __return.str[self_index++]+=s.str[counter]; - } - - return __return; -} - - - - + int counter = 0; + int self_index = 0; + str_t __return; + for(int i = 0; i < 200; i++) __return.str[i] = 0; + while(s.str[counter++] != '='); + for(; s.str[counter]; counter++) + { + __return.str[self_index++] += s.str[counter]; + } + return __return; +} diff --git a/apps/sh/values.c b/apps/sh/values.c index 4ac9db1..f589330 100644 --- a/apps/sh/values.c +++ b/apps/sh/values.c @@ -30,5 +30,3 @@ char* VAR_PWD = "/"; char* VAR_RELEASE = "0.0.1"; char* VAR_OSNAME = "BoneOS"; char* VAR_PLATFORM = "x86_32"; - - diff --git a/boot/boot/grub/grub.cfg b/boot/boot/grub/grub.cfg index df2bdd4..6aa21a8 100644 --- a/boot/boot/grub/grub.cfg +++ b/boot/boot/grub/grub.cfg @@ -1,4 +1,4 @@ menuentry "BoneOS x86 " { - multiboot /boot/BoneOS.bin - boot + multiboot /boot/BoneOS.bin + boot } diff --git a/platform/Makefile b/platform/Makefile index 84542c1..ac58951 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -2,4 +2,4 @@ all: (cd $(PLAT) && $(MAKE)) clean: - (cd $(PLAT) && $(MAKE) clean) \ No newline at end of file + (cd $(PLAT) && $(MAKE) clean) diff --git a/platform/pc/cpu/interrupts/pic.c b/platform/pc/cpu/interrupts/pic.c index 7a27609..98a609d 100644 --- a/platform/pc/cpu/interrupts/pic.c +++ b/platform/pc/cpu/interrupts/pic.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ /* * @function irq_remap: @@ -31,28 +31,21 @@ #include #include - void remap_pic_irq() { - outb(I386_MASTER_REG_COMMAND , ICW1); - outb(I386_SLAVE_REG_COMMAND ,ICW1); + outb(I386_MASTER_REG_COMMAND, ICW1); + outb(I386_SLAVE_REG_COMMAND, ICW1); - outb(I386_MASTER_REG_DATA,IRQ_START); //0x20 = 32 - outb(I386_SLAVE_REG_IMR,IRQ_END); //0x28 = 47 + outb(I386_MASTER_REG_DATA, IRQ_START); //0x20 = 32 + outb(I386_SLAVE_REG_IMR, IRQ_END); //0x28 = 47 - outb(I386_MASTER_REG_DATA,I386_PIC_ICW2_IRQLINE_PRIMARY_IR2); //0x04 = 0100 - outb(I386_SLAVE_REG_IMR ,I386_PIC_ICW2_IRQLINE_SECONDARY_IR2); //0x02 = 010 + outb(I386_MASTER_REG_DATA, I386_PIC_ICW2_IRQLINE_PRIMARY_IR2); //0x04 = 0100 + outb(I386_SLAVE_REG_IMR, I386_PIC_ICW2_IRQLINE_SECONDARY_IR2); //0x02 = 010 - outb(I386_MASTER_REG_DATA,I386_PIC_ICW4_MASK_UPM); // 80x86 MODE - outb(I386_SLAVE_REG_IMR,I386_PIC_ICW4_MASK_UPM); // 80x86 MODE + outb(I386_MASTER_REG_DATA, I386_PIC_ICW4_MASK_UPM); // 80x86 MODE + outb(I386_SLAVE_REG_IMR, I386_PIC_ICW4_MASK_UPM); // 80x86 MODE - //Null out data registers - outb(I386_MASTER_REG_DATA,PIC_NULL); - outb(I386_SLAVE_REG_IMR ,PIC_NULL); + //Null out data registers + outb(I386_MASTER_REG_DATA, PIC_NULL); + outb(I386_SLAVE_REG_IMR, PIC_NULL); } - - - - - - diff --git a/platform/pc/drv/cmos/rtc/rtc.c b/platform/pc/drv/cmos/rtc/rtc.c index 81fa16b..dbeefed 100644 --- a/platform/pc/drv/cmos/rtc/rtc.c +++ b/platform/pc/drv/cmos/rtc/rtc.c @@ -43,83 +43,79 @@ uint8_t rtc_get_second() return inb(CMOS_REGiSTER_DATA); } - uint8_t rtc_get_minute() { outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_MINUTES); return inb (CMOS_REGiSTER_DATA); } - uint8_t rtc_get_hour() { - outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_HOURS); - return inb(CMOS_REGiSTER_DATA); + outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_HOURS); + return inb(CMOS_REGiSTER_DATA); } uint8_t rtc_get_weekday() { - outb(CMOS_REGISTER_SELECT,CMOS_REGISTER_WEEKDAY); - return inb(CMOS_REGiSTER_DATA); + outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_WEEKDAY); + return inb(CMOS_REGiSTER_DATA); } - uint8_t rtc_get_day_month() { - outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_DAYMONTH); - return inb(CMOS_REGiSTER_DATA); + outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_DAYMONTH); + return inb(CMOS_REGiSTER_DATA); } - uint8_t rtc_get_month() { - outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_MONTH); - return inb(CMOS_REGiSTER_DATA); + outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_MONTH); + return inb(CMOS_REGiSTER_DATA); } uint8_t rtc_get_year() { - outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_YEAR); - return inb(CMOS_REGiSTER_DATA); + outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_YEAR); + return inb(CMOS_REGiSTER_DATA); } uint8_t rtc_get_century() { - outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_CENTURY); - return inb(CMOS_REGiSTER_DATA); + outb(CMOS_REGISTER_SELECT, CMOS_REGISTER_CENTURY); + return inb(CMOS_REGiSTER_DATA); } static const char* month_to_text(uint8_t num) { - const char* month; - if(num < 1 || num > 12) - panik("INVALID MONTH"); - - const char* months_str[12] = - { - "Jan", "Feb" , "Mar", "Apr" , "May", - "Jun", "Jul", "Aug" , "Sep", "Oct", - "Nov", "Dec" - }; - - month = months_str[num-1]; - return month; + const char* month; + if(num < 1 || num > 12) + panik("INVALID MONTH"); + + const char* months_str[12] = + { + "Jan", "Feb" , "Mar", "Apr" , "May", + "Jun", "Jul", "Aug" , "Sep", "Oct", + "Nov", "Dec" + }; + + month = months_str[num - 1]; + return month; } static const char* date_to_text(uint8_t num) { - const char* date; - if(num < 1 || num > 7) - panik("INVALID MONTH"); - - const char* dates_str[7] = - { - "Mon", "Tue" , "Wed", "Thu" , "Fri", - "Sat", "Sun" - }; - - date = dates_str[num-2]; - return date; + const char* date; + if(num < 1 || num > 7) + panik("INVALID MONTH"); + + const char* dates_str[7] = + { + "Mon", "Tue" , "Wed", "Thu" , "Fri", + "Sat", "Sun" + }; + + date = dates_str[num - 2]; + return date; } rtc_t rtc_get_time() @@ -128,7 +124,7 @@ rtc_t rtc_get_time() rtc_t last; //Keep reading time until we get the same values twice memset(&last, 0xFF, sizeof(last)); - for (curr.year = 0;memcmp(&curr,&last,sizeof(curr)); last = curr) + for (curr.year = 0; memcmp(&curr, &last, sizeof(curr)); last = curr) { curr.century = rtc_get_century(); curr.year = rtc_get_year(); @@ -142,31 +138,30 @@ rtc_t rtc_get_time() return curr; } -void rtc_print_date () +void rtc_print_date() { rtc_t current_time = rtc_get_time(); printk("%s %s %x %x:%x:%x UTC %x%x\n", - date_to_text(current_time.weekday), - month_to_text(current_time.month), - current_time.day, - current_time.hour, - current_time.minute, - current_time.second, - current_time.century, - current_time.year); + date_to_text(current_time.weekday), + month_to_text(current_time.month), + current_time.day, + current_time.hour, + current_time.minute, + current_time.second, + current_time.century, + current_time.year); } -void rtc_print_struct (rtc_t current_time) +void rtc_print_struct(rtc_t current_time) { printk("%s %s %x %x:%x:%x UTC %x%x\n", - date_to_text(current_time.weekday), - month_to_text(current_time.month), - current_time.day, - current_time.hour, - current_time.minute, - current_time.second, - current_time.century, - current_time.year); + date_to_text(current_time.weekday), + month_to_text(current_time.month), + current_time.day, + current_time.hour, + current_time.minute, + current_time.second, + current_time.century, + current_time.year); } - diff --git a/platform/pc/drv/driver.c b/platform/pc/drv/driver.c index ea4981d..04b8470 100644 --- a/platform/pc/drv/driver.c +++ b/platform/pc/drv/driver.c @@ -47,52 +47,46 @@ struct device_driver_t *drivers[] = */ void setup_driver_handler(void) { + /*Initalize and Uninitalize functions for Video Driver*/ + video_driver.init = video_drivers[VGA_VIDEO_DRIVER_INDEX]->init; + video_driver.uninit = video_drivers[VGA_VIDEO_DRIVER_INDEX]->uninit; + video_driver.status = video_drivers[VGA_VIDEO_DRIVER_INDEX]->status; - /*Initalize and Uninitalize functions for Video Driver*/ - video_driver.init = video_drivers[VGA_VIDEO_DRIVER_INDEX]->init; - video_driver.uninit = video_drivers[VGA_VIDEO_DRIVER_INDEX]->uninit; - video_driver.status = video_drivers[VGA_VIDEO_DRIVER_INDEX]->status; - - init_all_drivers(); + init_all_drivers(); } //check if device is initalized bool device_initalized(int index) { - return (drivers[index]->initalized); + return (drivers[index]->initalized); } //initalize device driver int init_device_driver(uint32_t index) { - drivers[index]->init(); - return 0; + drivers[index]->init(); + return 0; } //uninitalize device driver int uninit_device_driver(uint32_t index) { - drivers[index]->uninit(); - return 0; + drivers[index]->uninit(); + return 0; } //initalize all device drivers int init_all_drivers(void) { - for(uint32_t i=0; drivers[i]; i++) - init_device_driver(i); - return 0; + for(uint32_t i = 0; drivers[i]; i++) + init_device_driver(i); + return 0; } //unintalize all device drivers int uninit_all_drivers(void) { - for(uint32_t i=0; drivers[i]; i++) - uninit_device_driver(i); - return 0; + for(uint32_t i = 0; drivers[i]; i++) + uninit_device_driver(i); + return 0; } - - - - - diff --git a/platform/pc/drv/pit/pit.c b/platform/pc/drv/pit/pit.c index d6121d6..4e4b291 100644 --- a/platform/pc/drv/pit/pit.c +++ b/platform/pc/drv/pit/pit.c @@ -28,18 +28,17 @@ #include #include #include -#include - +#include + //Timer Driver Handler struct device_driver_t pit_driver = { - .name = "8253 Programmable Interval Timer", - .init = &init_pit, - .uninit = &uninit_pit, - .version = "8253" + .name = "8253 Programmable Interval Timer", + .init = &init_pit, + .uninit = &uninit_pit, + .version = "8253" }; - volatile uint32_t pit_ticks = 0; /* @@ -49,7 +48,7 @@ volatile uint32_t pit_ticks = 0; */ static void send_pit_command(uint8_t cmd) { - outb(I386_PIT_CONTROL_WORD_REG, cmd); + outb(I386_PIT_CONTROL_WORD_REG, cmd); } /* @@ -59,7 +58,7 @@ static void send_pit_command(uint8_t cmd) */ static void send_msg_counter_0(uint8_t cmd) { - outb(I386_PIT_COUNTER_0_REG,cmd); + outb(I386_PIT_COUNTER_0_REG, cmd); } /* @@ -70,18 +69,18 @@ static void send_msg_counter_0(uint8_t cmd) */ static void pit_phase(int htz) { - //1.19MHz / htz - //dictates how any times - //the IRQ Should fire - int divisor = 1193180 / htz; + //1.19MHz / htz + //dictates how any times + //the IRQ Should fire + int divisor = 1193180 / htz; - send_pit_command( I386_PIT_OCW_BINCOUNT_BINARY | - I386_PIT_OCW_MODE_SQUAREWAVEGEN | - I386_PIT_OCW_RL_DATA | - I386_PIT_OCW_SCO_COUNTER_0); + send_pit_command(I386_PIT_OCW_BINCOUNT_BINARY | + I386_PIT_OCW_MODE_SQUAREWAVEGEN | + I386_PIT_OCW_RL_DATA | + I386_PIT_OCW_SCO_COUNTER_0); - send_msg_counter_0(divisor & 0xFF); - send_msg_counter_0(divisor >> 8); + send_msg_counter_0(divisor & 0xFF); + send_msg_counter_0(divisor >> 8); } /* @@ -95,9 +94,9 @@ static void pit_phase(int htz) */ static int pit_handler_nest() { - //printk("%d SECONDS\n", (pit_ticks/IRQ_SEC_HIT)); + //printk("%d SECONDS\n", (pit_ticks/IRQ_SEC_HIT)); - return 0; + return 0; } /* @@ -108,11 +107,11 @@ static int pit_handler_nest() */ static void pit_handler(int_regs *r) { - if(r){}; - pit_ticks++; - if (pit_ticks % IRQ_SEC_HIT == 0) - if(pit_handler_nest()!=0) - panik("PIT Handler Nest Exception"); + if(r){}; + pit_ticks++; + if(pit_ticks % IRQ_SEC_HIT == 0) + if(pit_handler_nest() != 0) + panik("PIT Handler Nest Exception"); } /* @@ -123,22 +122,16 @@ static void pit_handler(int_regs *r) */ int init_pit() { - pit_driver.initalized = true; - pit_driver.status = STATUS_DRIVER_OK; - pit_phase(IRQ_SEC_HIT); - install_irq_handler(IRQ_NUM_PIT,pit_handler); - return STATUS_OK; + pit_driver.initalized = true; + pit_driver.status = STATUS_DRIVER_OK; + pit_phase(IRQ_SEC_HIT); + install_irq_handler(IRQ_NUM_PIT, pit_handler); + return STATUS_OK; } int uninit_pit() { - pit_driver.initalized = false; - uninstall_irq_handler(IRQ_NUM_PIT); - return STATUS_OK; + pit_driver.initalized = false; + uninstall_irq_handler(IRQ_NUM_PIT); + return STATUS_OK; } - - - - - - diff --git a/platform/pc/drv/ps2/kbd/kbd.c b/platform/pc/drv/ps2/kbd/kbd.c index 5dd96a5..86b14a4 100644 --- a/platform/pc/drv/ps2/kbd/kbd.c +++ b/platform/pc/drv/ps2/kbd/kbd.c @@ -1,68 +1,65 @@ -/** - ** This file is part of BoneOS. - ** - ** BoneOS is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - - ** BoneOS is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - - ** You should have received a copy of the GNU General Public License - ** along with BoneOS. If not, see . - ** - ** @main_author : Amanuel Bogale - ** - ** @contributors: - - ** Amanuel Bogale : start - ** Ashish Ahuja - **/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -volatile struct kbd_info_t kbd_info; -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]; - - -//Is this getting emulated at a terminal -extern volatile bool TERMINAL_MODE; - -//getchar(); -extern volatile bool __get_char_set; -extern volatile char __get_char_chr; - +/** + ** This file is part of BoneOS. + ** + ** BoneOS is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + + ** BoneOS is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + + ** You should have received a copy of the GNU General Public License + ** along with BoneOS. If not, see . + ** + ** @main_author : Amanuel Bogale + ** + ** @contributors: + + ** Amanuel Bogale : start + ** Ashish Ahuja + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +volatile struct kbd_info_t kbd_info; +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]; + +//Is this getting emulated at a terminal +extern volatile bool TERMINAL_MODE; + +//getchar(); +extern volatile bool __get_char_set; +extern volatile char __get_char_chr; + //Keyboard Driver Handler struct device_driver_t kbd_driver = { @@ -70,412 +67,387 @@ struct device_driver_t kbd_driver = .init = &init_kbd, .uninit = &uninit_kbd, .version = "8042" -}; - - -/* - * @function key_press: - * Nested Function under - * @kbd_handler , and called - * if Key is pressed. - * - * @param scancode: - * Scancode in HEX Format. - * @return char: - * Returns character from that - * scancode in HEX Format. - */ -int key_press(uint8_t scancode) -{ - if(kbd_info.is_shift) - return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_shift[scancode]); - else - return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode]); -} - -/* - * @function key_release: - * Nested Function under - * @kbd_handler , and called - * if Key is released. - * - * @param scancode: - * Scancode in HEX Format. - */ -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; - } - - if ((int)(scancode) == 29) //Scancode of "Control" key - kbd_info.is_ctrl = false; -} - -/* - * @function kbd_early_init: - * Stuff to initalize - * before installing - * the PS/2 Keyboard - */ -void kbd_early_init() -{ - kbd_info.tests.bat_test = bat_test(); - - if(!kbd_info.tests.bat_test) - { - kbd_driver.status = STATUS_DRIVER_MALFUNCTION; - printck(0x3,0x1,"BAT TEST FAILED"); - } - else - kbd_driver.status = STATUS_DRIVER_OK; - - - led_light(false,false,false); - kbd_info.is_shift = false; - kbd_info.is_caps = false; - - active_scank = false; - print_scank = false; - - kbd_info.current_kbd_layout_index = QWERTY_USA_INDEX; -} - - - -/* - * @utility wait_until_enter - * Utility for Scank , to - * wait and store string - * until enter is pressed - */ -void wait_until_enter(char key) -{ - buffer_scank[index_scank++] = key; - buffer_scank[index_scank] = 0; -} - -/* - * @utility inc_al - * INcrements Position - * 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 - * cases in @key_handler. - * used to print non - * 'extreme-special' characters. - * - * @param key(int): - * Character represented - * int for NON-DOS MODE - * , and use of special - * characters.(#define) - */ -void key_handler_util(int key) -{ - //First checking for shortcut commands - if (kbd_info.is_ctrl == true) - { - if (key == 'l' || key == 'L') - { - cmds [CMD_CLEAR_INDEX]->handler ("clear"); - printk (" "); - kbd_info.key = KBD_ENTER_PRESS_ID; - key_handler(); - cmds [CMD_CLEAR_INDEX]->handler ("clear"); - return; - } - else if (key == 'h' || key == 'H') - { - key_handler_util_backspace(); - return; - } - } - - if(isalpha(key)==0) - { - if(print_scank == true && active_scank == true) - { - inc_al(); - printk("%c", key); - wait_until_enter(key); - } - - else if(active_scank == true) - wait_until_enter(key); - } - else - { - if(kbd_info.is_caps == false && print_scank == true && active_scank == true) - { - inc_al(); - if (kbd_info.is_shift == true) { - printk("%c", toupper(key)); - } - 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); - } - else - { - key = toupper (key); - } - printk ("%c", key); - wait_until_enter(key); - } - else if(active_scank == true) - wait_until_enter(key); - } -} - -void key_handler_util_backspace() -{ - if(!((LENGTH_INPUT-1) < 0)) - { - if(active_scank) - buffer_scank[index_scank--] = 0; - - if(print_scank == true) - printk("\b"); - - 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++) - if(buf_scan[i] != _cmd[i]) - return false; - - return true; -} - -void key_handler_util_tab() -{ - 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++) - { - tab__[index_tab] = cmds[i]->name[j]; - index_tab++; - } - for(int rep=0; rep<4; rep++)tab__[index_tab++] = ' '; - } - } - tab__[index_tab] = 0; - if(num_cmds==1) - { - printk ("\n"); - for(int i = 0; tab__[i]; i ++) { - printk("%c", tab__[i]); - cmd_active.value [i] = tab__ [i]; - } - tab_one_opt=true; - return; - } - - if (num_cmds > 1) { - tab_multiple_opts=true; - printk ("\n"); - for(int i=0; tab__[i]; i++) - printk("%c", tab__[i]); - } - else { - tab_zero_opt = true; - } -} - - -/* - * @function key_handler: - * Handles key events. - * called by primary - * keyborad handler - * @kbd_handler. - * - */ -void key_handler() -{ - switch(kbd_info.key) - { - //Is shift pressed - case KBD_LEFT_SHIFT_PRESS_ID: - case KBD_RIGHT_SHIFT_PRESS_ID: - kbd_info.is_shift = true; - break; - case KBD_CAPS_PRESS_ID: - 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; - - 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; - } -} - - -/* - * @function kbd_handler: - * Primary Keyboard Handler - * called by the IRQ Handler. - * - * @param int_regs *r: - * Info about Registers - * during IRQ Request - */ -void kbd_handler(int_regs *r) -{ - if(r){}; - kbd_info.scancode = kbd_enc_read_input_buf(); - - if(kbd_info.scancode & 0x80) - key_release(kbd_info.scancode & ~0x80); - else - { - kbd_info.key = key_press(kbd_info.scancode); - __get_char_chr = kbd_info.key; - __get_char_set = true; - key_handler(); - } -} - -/* - * @function init_kbd: - * Initalize the Keyboard - * PS/2 Driver - * - * @return {STATUS}: - * returns STATUS_OK - * if sucessfully exited. - */ -int init_kbd() -{ - kbd_driver.initalized = true; - kbd_early_init(); - install_irq_handler(IRQ_NUM_KBD,kbd_handler); - return STATUS_OK; -} - -/* - * @function uninit_kbd: - * Uninitalize the Keyboard - * PS/2 Driver - * - * @return {STATUS}: - * returns STATUS_OK - * if sucessfully exited. - */ -int uninit_kbd() -{ - kbd_driver.initalized = false; - uninstall_irq_handler(IRQ_NUM_KBD); - return STATUS_OK; -} - - - - - - +}; + +/* + * @function key_press: + * Nested Function under + * @kbd_handler , and called + * if Key is pressed. + * + * @param scancode: + * Scancode in HEX Format. + * @return char: + * Returns character from that + * scancode in HEX Format. + */ +int key_press(uint8_t scancode) +{ + if(kbd_info.is_shift) + return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_shift[scancode]); + else + return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode]); +} + +/* + * @function key_release: + * Nested Function under + * @kbd_handler , and called + * if Key is released. + * + * @param scancode: + * Scancode in HEX Format. + */ +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; + + if ((int) scancode == 29) //Scancode of "Control" key + kbd_info.is_ctrl = false; +} + +/* + * @function kbd_early_init: + * Stuff to initalize + * before installing + * the PS/2 Keyboard + */ +void kbd_early_init() +{ + kbd_info.tests.bat_test = bat_test(); + + if(!kbd_info.tests.bat_test) + { + kbd_driver.status = STATUS_DRIVER_MALFUNCTION; + printck(0x3, 0x1, "BAT TEST FAILED"); + } + else + kbd_driver.status = STATUS_DRIVER_OK; + + led_light(false, false, false); + kbd_info.is_shift = false; + kbd_info.is_caps = false; + + active_scank = false; + print_scank = false; + + kbd_info.current_kbd_layout_index = QWERTY_USA_INDEX; +} + +/* + * @utility wait_until_enter + * Utility for Scank , to + * wait and store string + * until enter is pressed + */ +void wait_until_enter(char key) +{ + buffer_scank[index_scank++] = key; + buffer_scank[index_scank] = 0; +} + +/* + * @utility inc_al + * INcrements Position + * 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 + * cases in @key_handler. + * used to print non + * 'extreme-special' characters. + * + * @param key(int): + * Character represented + * int for NON-DOS MODE + * , and use of special + * characters.(#define) + */ +void key_handler_util(int key) +{ + //First checking for shortcut commands + if(kbd_info.is_ctrl == true) + { + if(key == 'l' || key == 'L') + { + cmds[CMD_CLEAR_INDEX]->handler("clear"); + printk (" "); + kbd_info.key = KBD_ENTER_PRESS_ID; + key_handler(); + cmds[CMD_CLEAR_INDEX]->handler("clear"); + return; + } + else if(key == 'h' || key == 'H') + { + key_handler_util_backspace(); + return; + } + } + + if(isalpha(key) == 0) + { + if(print_scank == true && active_scank == true) + { + inc_al(); + printk("%c", key); + wait_until_enter(key); + } + else if(active_scank == true) + wait_until_enter(key); + } + else + { + if(kbd_info.is_caps == false && print_scank == true && active_scank == true) + { + inc_al(); + if (kbd_info.is_shift == true) + printk("%c", toupper(key)); + 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); + else + key = toupper(key); + printk("%c", key); + wait_until_enter(key); + } + else if(active_scank == true) + wait_until_enter(key); + } +} + +void key_handler_util_backspace() +{ + if(!((LENGTH_INPUT-1) < 0)) + { + if(active_scank) + buffer_scank[index_scank--] = 0; + + if(print_scank == true) + printk("\b"); + + 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++) + if(buf_scan[i] != _cmd[i]) + return false; + + return true; +} + +void key_handler_util_tab() +{ + 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++) + { + tab__[index_tab] = cmds[i]->name[j]; + index_tab++; + } + for(int rep = 0; rep < 4; rep++) tab__[index_tab++] = ' '; + } + } + tab__[index_tab] = 0; + if(num_cmds == 1) + { + printk ("\n"); + for(int i = 0; tab__[i]; i ++) { + printk("%c", tab__[i]); + cmd_active.value[i] = tab__[i]; + } + tab_one_opt = true; + return; + } + + if (num_cmds > 1) { + tab_multiple_opts=true; + printk ("\n"); + for(int i = 0; tab__[i]; i++) + printk("%c", tab__[i]); + } + else + tab_zero_opt = true; +} + +/* + * @function key_handler: + * Handles key events. + * called by primary + * keyborad handler + * @kbd_handler. + * + */ +void key_handler() +{ + switch(kbd_info.key) + { + //Is shift pressed + case KBD_LEFT_SHIFT_PRESS_ID: + case KBD_RIGHT_SHIFT_PRESS_ID: + kbd_info.is_shift = true; + break; + case KBD_CAPS_PRESS_ID: + 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; + + for (int i = 0; i < LENGTH_INPUT_STORE; i++) + key_handler_util_backspace(); + + for(int i = 0; cmd_active.value[i]; i++) + { + if(active_scank == true && print_scank == true) + { + wait_until_enter(cmd_active.value[i]); + LENGTH_INPUT++; + } + } + printk("%s", cmd_active.value); + } + break; + case KBD_CONTROL_PRESS_ID: + kbd_info.is_ctrl = true; + break; + case KBD_ENTER_PRESS_ID: + kbd_info.is_enter = true; + active_scank = false; + buffer_scank[index_scank] = 0; + + if(print_scank == true) + printk("\n"); + + UP_KEY_ACTIVE = true; //Reset Up Key + break; + case '\b': + key_handler_util_backspace(); + break; + case '\t': + if(TERMINAL_MODE==false) + { + printk("\t"); + LENGTH_INPUT += 4; + INDEX_CURSOR_POSITION += 4; + } + else + { + key_handler_util_tab(); + active_scank = false; + buffer_scank[index_scank] = 0; + + if(print_scank == true && tab_zero_opt == false) + printk("\n"); + + UP_KEY_ACTIVE = true; //Reset Up Key + TAB_PREVIOUS_VALUE_SET = true; + TAB_PREVIOUS_VALUE = buffer_scank; + } + break; + case '\n': + if(print_scank == true) + printk("\n"); + break; + default: + 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 + * called by the IRQ Handler. + * + * @param int_regs *r: + * Info about Registers + * during IRQ Request + */ +void kbd_handler(int_regs *r) +{ + if(r) {}; + kbd_info.scancode = kbd_enc_read_input_buf(); + + if(kbd_info.scancode & 0x80) + key_release(kbd_info.scancode & ~0x80); + else + { + kbd_info.key = key_press(kbd_info.scancode); + __get_char_chr = kbd_info.key; + __get_char_set = true; + key_handler(); + } +} + +/* + * @function init_kbd: + * Initalize the Keyboard + * PS/2 Driver + * + * @return {STATUS}: + * returns STATUS_OK + * if sucessfully exited. + */ +int init_kbd() +{ + kbd_driver.initalized = true; + kbd_early_init(); + install_irq_handler(IRQ_NUM_KBD, kbd_handler); + return STATUS_OK; +} + +/* + * @function uninit_kbd: + * Uninitalize the Keyboard + * PS/2 Driver + * + * @return {STATUS}: + * returns STATUS_OK + * if sucessfully exited. + */ +int uninit_kbd() +{ + kbd_driver.initalized = false; + uninstall_irq_handler(IRQ_NUM_KBD); + return STATUS_OK; +} diff --git a/platform/pc/drv/ps2/kbd/kbd_layouts/scancodes_usa.c b/platform/pc/drv/ps2/kbd/kbd_layouts/scancodes_usa.c index 4f50fe1..3b574c7 100644 --- a/platform/pc/drv/ps2/kbd/kbd_layouts/scancodes_usa.c +++ b/platform/pc/drv/ps2/kbd/kbd_layouts/scancodes_usa.c @@ -18,7 +18,7 @@ ** ** @contributors: - ** Amanuel Bogale : start + ** Amanuel Bogale : start ** Ashish Ahuja **/ @@ -28,86 +28,80 @@ int const QWERTY_USA_NOSHIFT_VAL[] = { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ - '9', '0', '-', '=', '\b', /* Backspace */ - '\t', /* Tab */ - 'q', 'w', 'e', 'r', /* 19 */ - 't', 'y', 'u', 'i', 'o', 'p', '[', ']', KBD_ENTER_PRESS_ID, /* Enter key */ - KBD_CONTROL_PRESS_ID, /* 29 - Control */ - 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */ - '\'', '`', KBD_LEFT_SHIFT_PRESS_ID, /* Left shift */ - '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ - 'm', ',', '.','/', KBD_RIGHT_SHIFT_PRESS_ID, /* Right shift */ - '*', - 0, /* Alt */ - ' ', /* Space bar */ - KBD_CAPS_PRESS_ID, /* Caps lock */ - 0, /* 59 - F1 key ... > */ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* < ... F10 */ - 0, /* 69 - Num lock*/ - 0, /* Scroll Lock */ - 0, /* Home key */ - KBD_UP_KEY_ID, /* Up Arrow */ - 0, /* Page Up */ - '-', - KBD_LEFT_KEY_ID, /* Left Arrow */ + '9', '0', '-', '=', '\b', /* Backspace */ + '\t', /* Tab */ + 'q', 'w', 'e', 'r', /* 19 */ + 't', 'y', 'u', 'i', 'o', 'p', '[', ']', KBD_ENTER_PRESS_ID, /* Enter key */ + KBD_CONTROL_PRESS_ID, /* 29 - Control */ + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */ + '\'', '`', KBD_LEFT_SHIFT_PRESS_ID, /* Left shift */ + '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ + 'm', ',', '.','/', KBD_RIGHT_SHIFT_PRESS_ID, /* Right shift */ + '*', + 0, /* Alt */ + ' ', /* Space bar */ + KBD_CAPS_PRESS_ID, /* Caps lock */ + 0, /* 59 - F1 key ... > */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* < ... F10 */ + 0, /* 69 - Num lock*/ + 0, /* Scroll Lock */ + 0, /* Home key */ + KBD_UP_KEY_ID, /* Up Arrow */ + 0, /* Page Up */ + '-', + KBD_LEFT_KEY_ID, /* Left Arrow */ 0, - KBD_RIGHT_KEY_ID, /* Right Arrow */ - '+', - 0, /* 79 - End key*/ - KBD_DOWN_KEY_ID, /* Down Arrow */ - 0, /* Page Down */ - 0, /* Insert Key */ - 0, /* Delete Key */ - 0, 0, 0, - 0, /* F11 Key */ - 0, /* F12 Key */ - 0, /* All other keys are undefined */ + KBD_RIGHT_KEY_ID, /* Right Arrow */ + '+', + 0, /* 79 - End key*/ + KBD_DOWN_KEY_ID, /* Down Arrow */ + 0, /* Page Down */ + 0, /* Insert Key */ + 0, /* Delete Key */ + 0, 0, 0, + 0, /* F11 Key */ + 0, /* F12 Key */ + 0, /* All other keys are undefined */ }; //USA Scancode Shift Pressed int const QWERTY_USA_SHIFT_VAL[] = { 0, 27, '!', '@', '#', '$', '%', '^', '&', '*', /* 9 */ - '(', ')', '_', '+', '\b', /* Backspace */ - '\t', /* Tab */ - 'Q', 'W', 'E', 'R', /* 19 */ - 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', KBD_ENTER_PRESS_ID, /* Enter key */ - KBD_CONTROL_PRESS_ID, /* 29 - Control */ - 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K' ,'L', ':', /* 39 */ - '\"' , '~', KBD_LEFT_SHIFT_PRESS_ID, /* Left shift */ - '|', 'Z', 'X', 'C', 'V', 'B', 'N', /* 49 */ - 'M', '<', '>', '?', KBD_RIGHT_SHIFT_PRESS_ID, /* Right shift */ - '*', - 0, /* Alt */ - ' ', /* Space bar */ - KBD_CAPS_PRESS_ID, /* Caps lock */ - 0, /* 59 - F1 key ... > */ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* < ... F10 */ - 0, /* 69 - Num lock*/ - 0, /* Scroll Lock */ - 0, /* Home key */ - KBD_UP_KEY_ID, /* Up Arrow */ - 0, /* Page Up */ - '-', - KBD_LEFT_KEY_ID, /* Left Arrow */ + '(', ')', '_', '+', '\b', /* Backspace */ + '\t', /* Tab */ + 'Q', 'W', 'E', 'R', /* 19 */ + 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', KBD_ENTER_PRESS_ID, /* Enter key */ + KBD_CONTROL_PRESS_ID, /* 29 - Control */ + 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K' ,'L', ':', /* 39 */ + '\"' , '~', KBD_LEFT_SHIFT_PRESS_ID, /* Left shift */ + '|', 'Z', 'X', 'C', 'V', 'B', 'N', /* 49 */ + 'M', '<', '>', '?', KBD_RIGHT_SHIFT_PRESS_ID, /* Right shift */ + '*', + 0, /* Alt */ + ' ', /* Space bar */ + KBD_CAPS_PRESS_ID, /* Caps lock */ + 0, /* 59 - F1 key ... > */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* < ... F10 */ + 0, /* 69 - Num lock*/ + 0, /* Scroll Lock */ + 0, /* Home key */ + KBD_UP_KEY_ID, /* Up Arrow */ + 0, /* Page Up */ + '-', + KBD_LEFT_KEY_ID, /* Left Arrow */ 0, - KBD_RIGHT_KEY_ID, /* Right Arrow */ - '+', - 0, /* 79 - End key*/ - KBD_DOWN_KEY_ID, /* Down Arrow */ - 0, /* Page Down */ - 0, /* Insert Key */ - 0, /* Delete Key */ - 0, 0, 0, - 0, /* F11 Key */ - 0, /* F12 Key */ - 0, /* All other keys are undefined */ + KBD_RIGHT_KEY_ID, /* Right Arrow */ + '+', + 0, /* 79 - End key*/ + KBD_DOWN_KEY_ID, /* Down Arrow */ + 0, /* Page Down */ + 0, /* Insert Key */ + 0, /* Delete Key */ + 0, 0, 0, + 0, /* F11 Key */ + 0, /* F12 Key */ + 0, /* All other keys are undefined */ }; - - - - - - diff --git a/platform/pc/drv/ps2/kbd/scancodes.c b/platform/pc/drv/ps2/kbd/scancodes.c index 1d651fd..ec79d50 100644 --- a/platform/pc/drv/ps2/kbd/scancodes.c +++ b/platform/pc/drv/ps2/kbd/scancodes.c @@ -15,34 +15,28 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start_ - **/ + **/ #include #include //QWERTY_USA LAYOUT -struct kbd_layout_t QWERTY_USA = +struct kbd_layout_t QWERTY_USA = { - .scancode_shift = QWERTY_USA_SHIFT_VAL, - .scancode_no_shift = QWERTY_USA_NOSHIFT_VAL, - .name = "QWERTY_USA", - .country = "USA" + .scancode_shift = QWERTY_USA_SHIFT_VAL, + .scancode_no_shift = QWERTY_USA_NOSHIFT_VAL, + .name = "QWERTY_USA", + .country = "USA" }; //All Keyboard Layouts -struct kbd_layout_t *kbd_layouts[] = +struct kbd_layout_t *kbd_layouts[] = { &QWERTY_USA, 0 }; - - - - - - diff --git a/platform/pc/drv/ps2/kbd/utils.c b/platform/pc/drv/ps2/kbd/utils.c index 927a7f2..70f1069 100644 --- a/platform/pc/drv/ps2/kbd/utils.c +++ b/platform/pc/drv/ps2/kbd/utils.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -29,35 +29,35 @@ #include /* - * Keyboard Ctrl : + * Keyboard Ctrl : * Read status register * and read command to ctrl */ uint8_t kbd_ctrl_read_status_reg() { - return (inb(KBD_CTRL_STATS_REG)); +return (inb(KBD_CTRL_STATS_REG)); } void kbd_ctrl_send_cmd(uint8_t cmd) { - while( (kbd_ctrl_read_status_reg() & KBD_CTRL_STATS_MASK_IN_BUF) != 0); + while((kbd_ctrl_read_status_reg() & KBD_CTRL_STATS_MASK_IN_BUF) != 0); outb(KBD_CTRL_CMD_REG,cmd); } /* - * Keyboard Encoder : + * Keyboard Encoder : * Read encoder input buffer * and send command to encoder */ uint8_t kbd_enc_read_input_buf() { - return (inb(KBD_ENC_INPUT_BUF_REG)); + return (inb(KBD_ENC_INPUT_BUF_REG)); } //Send command to encoder void kbd_enc_send_cmd(uint8_t cmd) { - while( (kbd_ctrl_read_status_reg() & KBD_CTRL_STATS_MASK_IN_BUF) != 0); + while((kbd_ctrl_read_status_reg() & KBD_CTRL_STATS_MASK_IN_BUF) != 0); outb(KBD_ENC_CMD_REG,cmd); } @@ -65,30 +65,25 @@ void kbd_enc_send_cmd(uint8_t cmd) bool bat_test(void) { kbd_ctrl_send_cmd(KBD_CTRL_CMD_SELF_TEST); - - while( (kbd_ctrl_read_status_reg() & KBD_CTRL_STATS_MASK_OUT_BUF) == 0); - + + while((kbd_ctrl_read_status_reg() & KBD_CTRL_STATS_MASK_OUT_BUF) == 0); + return (kbd_enc_read_input_buf () == 0x55) ? true : false; } //Set the LED Lights if true bool led_light(bool scroll, bool num, bool caps) { - uint8_t data_final = 0x0; - if(scroll) data_final |= KBD_SCROLL_LED_ON; - if(num) data_final |= KBD_NUM_LED_ON; - if(caps) data_final |= KBD_CAPS_LOCK_ON; + uint8_t data_final = 0x0; + if(scroll) data_final |= KBD_SCROLL_LED_ON; + if(num) data_final |= KBD_NUM_LED_ON; + if(caps) data_final |= KBD_CAPS_LOCK_ON; - kbd_info.led.num_lock = num; - kbd_info.led.caps_lock = caps; - kbd_info.led.scroll_lock = scroll; + kbd_info.led.num_lock = num; + kbd_info.led.caps_lock = caps; + kbd_info.led.scroll_lock = scroll; - kbd_enc_send_cmd(KBD_ENCODER_CMD_SET_LED); - kbd_enc_send_cmd(data_final); - return true; + kbd_enc_send_cmd(KBD_ENCODER_CMD_SET_LED); + kbd_enc_send_cmd(data_final); + return true; } - - - - - diff --git a/platform/pc/drv/video/VGA/textmode/clear.c b/platform/pc/drv/video/VGA/textmode/clear.c index 214c409..345047d 100644 --- a/platform/pc/drv/video/VGA/textmode/clear.c +++ b/platform/pc/drv/video/VGA/textmode/clear.c @@ -15,12 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ - + **/ #include #include @@ -28,11 +27,10 @@ #include #include - void term_zero() { - vga_driver.video_row=0; - vga_driver.video_column=0; + vga_driver.video_row = 0; + vga_driver.video_column = 0; } /* @@ -42,28 +40,22 @@ void term_zero() * mode 80x25 VGA. */ - -void clear_vga_textmode(void) +void clear_vga_textmode(void) { - term_zero(); - for(unsigned i=0; i. ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -29,7 +29,6 @@ #include #include - /* * @function putch_vga_80_x_25: * Puts a single character @@ -42,20 +41,15 @@ void putch_vga_textmode(char c) { - const size_t index = (vga_driver.video_row * video_driver_width + vga_driver.video_column); - uint16_t* VideoMemory = (uint16_t*)0xB8000; - uint8_t terminal_color = make_color(vga_driver.fg,vga_driver.bg); - - VideoMemory[index]= (terminal_color << 8)|c; - VideoMemory[index+1] = make_vgaentry(' ', terminal_color); - - vga_driver.video_column++; - if(vga_driver.video_column>=video_driver_width) vga_driver.video_row++,vga_driver.video_column=0; - if(vga_driver.video_row>=video_driver_height) term_scroll_vga_textmode(1); -} + const size_t index = (vga_driver.video_row * video_driver_width + vga_driver.video_column); + uint16_t* VideoMemory = (uint16_t*) 0xB8000; + uint8_t terminal_color = make_color(vga_driver.fg, vga_driver.bg); + VideoMemory[index] = (terminal_color << 8) | c; + VideoMemory[index + 1] = make_vgaentry(' ', terminal_color); - - - - + vga_driver.video_column++; + if(vga_driver.video_column >= video_driver_width) + vga_driver.video_row++, vga_driver.video_column = 0; + if(vga_driver.video_row >= video_driver_height) term_scroll_vga_textmode(1); +} diff --git a/platform/pc/drv/video/VGA/textmode/term_scroll.c b/platform/pc/drv/video/VGA/textmode/term_scroll.c index 8a63999..250e3b4 100644 --- a/platform/pc/drv/video/VGA/textmode/term_scroll.c +++ b/platform/pc/drv/video/VGA/textmode/term_scroll.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -30,24 +30,20 @@ #include #include - - void term_scroll_vga_textmode(int offset) { - uint16_t *screen = (uint16_t*)0xB8000; - for(unsigned i = 0; i < video_driver_height; i++){ - for (unsigned m = 0; m < video_driver_width; m++){ + uint16_t *screen = (uint16_t*) 0xB8000; + for(unsigned i = 0; i < video_driver_height; i++) + { + for (unsigned m = 0; m < video_driver_width; m++) + { screen[i * video_driver_width + m] = screen[(i + offset) * video_driver_width + m]; } } - vga_driver.video_row -=offset; - for(unsigned i=0; i. ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -34,23 +34,19 @@ volatile uint8_t __crsr_end = 15; int update_cursor_textmode(int row, int col, uint8_t crsr_start, uint8_t crsr_end) { - uint16_t position = (row*video_driver_width)+col; - - outb(CURSOR_REGISTER_SELECT,UPDATE_CURSOR_REGISTER_LOW); + uint16_t position = (row * video_driver_width) + col; + + outb(CURSOR_REGISTER_SELECT, UPDATE_CURSOR_REGISTER_LOW); outb(CURSOR_DATA_SEND, UPDATE_CURSOR_POS_LOW(position)); - - outb(CURSOR_REGISTER_SELECT,UPDATE_CURSOR_REGISTER_HIGH); - outb(CURSOR_DATA_SEND,UPDATE_CURSOR_POS_HIGH(position)); - if(col && row){}; + + outb(CURSOR_REGISTER_SELECT, UPDATE_CURSOR_REGISTER_HIGH); + outb(CURSOR_DATA_SEND, UPDATE_CURSOR_POS_HIGH(position)); + // if (col && row) {}; outw(CRTC_PORT, (crsr_start << 8) | 0x0A); outw(CRTC_PORT, (crsr_end << 8) | 0x0B); - + __crsr_start = crsr_start; __crsr_end = crsr_end; - + return STATUS_OK; } - - - - diff --git a/platform/pc/drv/video/VGA/textmode/utils.c b/platform/pc/drv/video/VGA/textmode/utils.c index 152cf89..3894821 100644 --- a/platform/pc/drv/video/VGA/textmode/utils.c +++ b/platform/pc/drv/video/VGA/textmode/utils.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -30,18 +30,12 @@ * to a 8bit integer * color. */ -uint8_t make_color(uint8_t fg, uint8_t bg) +uint8_t make_color(uint8_t fg, uint8_t bg) { return fg | bg << 4; } -uint16_t make_vgaentry(char c, uint8_t color) +uint16_t make_vgaentry(char c, uint8_t color) { - return ((uint16_t)c | (uint16_t)color << 8); -} - - - - - - + return ((uint16_t) c | (uint16_t) color << 8); +} diff --git a/platform/pc/drv/video/VGA/textmode/vga_textmode.c b/platform/pc/drv/video/VGA/textmode/vga_textmode.c index 04a5de4..f56bbf3 100644 --- a/platform/pc/drv/video/VGA/textmode/vga_textmode.c +++ b/platform/pc/drv/video/VGA/textmode/vga_textmode.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -33,32 +33,25 @@ #include #include - - - int init_vga_textmode() { - __textmode.w = video_driver_width; - __textmode.h = video_driver_height; - __textmode.name = video_driver_fullname; - return STATUS_OK; + __textmode.w = video_driver_width; + __textmode.h = video_driver_height; + __textmode.name = video_driver_fullname; + return STATUS_OK; } -vga_textmode_t __textmode = +vga_textmode_t __textmode = { - .clear = &clear_vga_textmode, - .putch = &putch_vga_textmode, - .update_cursor = &update_cursor_textmode, - .scroll = &term_scroll_vga_textmode, - .init = &init_vga_textmode + .clear = &clear_vga_textmode, + .putch = &putch_vga_textmode, + .update_cursor = &update_cursor_textmode, + .scroll = &term_scroll_vga_textmode, + .init = &init_vga_textmode }; -vga_textmode_t *vga_textmodes_arr[] = +vga_textmode_t *vga_textmodes_arr[] = { - &__textmode, - 0 + &__textmode, + 0 }; - - - - diff --git a/platform/pc/drv/video/VGA/vga.c b/platform/pc/drv/video/VGA/vga.c index a8e97c3..b69faf8 100644 --- a/platform/pc/drv/video/VGA/vga.c +++ b/platform/pc/drv/video/VGA/vga.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -30,60 +30,53 @@ #include #include -struct video_driver_t vga_driver = +struct video_driver_t vga_driver = { - .init = &init_vga_driver, - .uninit = &uninit_vga_driver, - .status = STATUS_DRIVER_OK + .init = &init_vga_driver, + .uninit = &uninit_vga_driver, + .status = STATUS_DRIVER_OK }; -void set_mode_util(putch_t putch_v, put_pixel_t put_pixel_v, clear_t clear_v, update_cursor_t update_cursor_v, scroll_t scroll_v) +void set_mode_util(putch_t putch_v, put_pixel_t put_pixel_v, clear_t clear_v, + update_cursor_t update_cursor_v, scroll_t scroll_v) { - vga_driver.putch = putch_v; - vga_driver.put_pixel = put_pixel_v; - vga_driver.clear = clear_v; - vga_driver.update_cursor = update_cursor_v; - vga_driver.scroll = scroll_v; + vga_driver.putch = putch_v; + vga_driver.put_pixel = put_pixel_v; + vga_driver.clear = clear_v; + vga_driver.update_cursor = update_cursor_v; + vga_driver.scroll = scroll_v; } int uninit_vga_driver() { - video_driver.initalized = false; - set_mode_util(0,0,0,0,0); - return STATUS_OK; + video_driver.initalized = false; + set_mode_util(0, 0, 0, 0, 0); + return STATUS_OK; } int init_vga_driver() { - video_driver.initalized = true; - vga_driver.res.w = video_driver_width; - vga_driver.res.h = video_driver_height; + video_driver.initalized = true; + vga_driver.res.w = video_driver_width; + vga_driver.res.h = video_driver_height; - if(strcmp(video_driver_mode,"TEXTMODE")==0) - { + if(strcmp(video_driver_mode, "TEXTMODE") == 0) + { vga_driver.mode = TEXT_MODE; - vga_driver.put_pixel=0; + vga_driver.put_pixel = 0; init_vga_textmode(); set_mode_util( - vga_textmodes_arr[0]->putch, - 0, - vga_textmodes_arr[0]->clear, - vga_textmodes_arr[0]->update_cursor, - vga_textmodes_arr[0]->scroll - ); - + vga_textmodes_arr[0]->putch, + 0, + vga_textmodes_arr[0]->clear, + vga_textmodes_arr[0]->update_cursor, + vga_textmodes_arr[0]->scroll + ); + vga_driver.name = vga_textmodes_arr[0]->name; vga_driver.fg = 7; vga_driver.bg = 0; - } - - return STATUS_OK; -} - + } - - - - - - + return STATUS_OK; +} diff --git a/platform/pc/drv/video/video.c b/platform/pc/drv/video/video.c index cd3519c..5818dba 100644 --- a/platform/pc/drv/video/video.c +++ b/platform/pc/drv/video/video.c @@ -22,36 +22,28 @@ **/ #include -#include -#include +#include +#include #include -#include +#include #include -#include - +#include + //Video Driver Handler struct device_driver_t video_driver = { - .name = "Video Driver", - .version = "STATUS_VERSION_NA" + .name = "Video Driver", + .version = "STATUS_VERSION_NA" }; size_t video_driver_width = 80; size_t video_driver_height = 25; -char* video_driver_name = "VGA"; -char* video_driver_mode = "TEXTMODE"; -char* video_driver_fullname = "VGA_TEXTMODE_80_x_25"; - +char* video_driver_name = "VGA"; +char* video_driver_mode = "TEXTMODE"; +char* video_driver_fullname = "VGA_TEXTMODE_80_x_25"; struct video_driver_t *video_drivers[] = { - &vga_driver, - 0 + &vga_driver, + 0 }; - - - - - - - diff --git a/platform/pc/io/io.c b/platform/pc/io/io.c index 73b0877..7461a21 100644 --- a/platform/pc/io/io.c +++ b/platform/pc/io/io.c @@ -15,23 +15,24 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ -#include +#include uint8_t inb(uint16_t port_num) { uint8_t result; - __asm__ __volatile__ ( + __asm__ __volatile__ + ( "inb %w[port_num],%b[result]\n\t" : [result] "=a" (result) // ASM -> Variable : [port_num] "Nd" (port_num) // VARIABLE -> ASM ); - + return result; } @@ -43,12 +44,11 @@ uint16_t inw(uint16_t port_num) "inw %w[port_num], %w[result]\n\t" : [result] "=a" (result) : [port_num] "Nd" (port_num) - ); - + ); + return result; } - uint32_t ind(uint16_t port_num) { uint32_t result; @@ -57,47 +57,40 @@ uint32_t ind(uint16_t port_num) "inl %w[port_num], %[result]\n\t" : [result] "=a" (result) : [port_num] "Nd" (port_num) - ); - + ); + return result; } - - void outb(uint16_t port_num,uint8_t data) { - __asm__ __volatile__ + __asm__ __volatile__ ( "outb %b[data],%w[port_num]\n\t" : : [data] "a" (data), - [port_num] "Nd" (port_num) + [port_num] "Nd" (port_num) ); } void outw(uint16_t port_num,uint16_t data) { - __asm__ __volatile__ + __asm__ __volatile__ ( "outw %w[data],%w[port_num]\n\t" : : [data] "a" (data), - [port_num] "Nd" (port_num) + [port_num] "Nd" (port_num) ); } void outd(uint16_t port_num,uint32_t data) { - __asm__ __volatile__ + __asm__ __volatile__ ( "outl %[data],%w[port_num]\n\t" : : [data] "a" (data), - [port_num] "Nd" (port_num) + [port_num] "Nd" (port_num) ); } - - - - - diff --git a/sbin/poweroff/poweroff.c b/sbin/poweroff/poweroff.c index 2f22f1f..2394288 100644 --- a/sbin/poweroff/poweroff.c +++ b/sbin/poweroff/poweroff.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -34,53 +34,41 @@ #include #include - - -struct cmd_opt_t* cmd_poweroff_opts[] = +struct cmd_opt_t* cmd_poweroff_opts[] = { 0 }; int cmd_poweroff_handler(char* cmd) { - size_t num_opts = get_opt_count(cmd); - str_t opts[num_opts]; - get_opt(cmd,opts); - - if(num_opts == 1) - root_sys_poweroff(); - else if(strcmp(opts[1].str, "--help")==0) - printk(cmd_poweroff.help); - else + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd, opts); + + if(num_opts == 1) + root_sys_poweroff(); + else if(strcmp(opts[1].str, "--help") == 0) + printk(cmd_poweroff.help); + else printk(cmd_poweroff.invalid_use_msg); - - return STATUS_OK; -} + return STATUS_OK; +} -struct cmd_t cmd_poweroff = +struct cmd_t cmd_poweroff = { - .name = "poweroff", - .usage ="poweroff [--help]", - .help = "poweroff(1) \t\t\t\t BoneOS Terminal Manual \n" - "NAME : \n " - "\tpoweroff\n" - "SYNOPSIS : \n " - "\tpoweroff [--help]\n" - "DESCRIPTION : \n " - "\tShuts down the Operating System. Currently only working in Bochs and Qemu.\n", - .cmd_opts = cmd_poweroff_opts, - .handler = &cmd_poweroff_handler, - .invalid_use_msg = "Invalid use of poweroff command.\n" - "Type in poweroff --help for more help.\n", - .privilege = ROOT + .name = "poweroff", + .usage ="poweroff [--help]", + .help = "poweroff(1) \t\t\t\t BoneOS Terminal Manual \n" + "NAME : \n " + "\tpoweroff\n" + "SYNOPSIS : \n " + "\tpoweroff [--help]\n" + "DESCRIPTION : \n " + "\tShuts down the Operating System. Currently only working in Bochs and Qemu.\n", + .cmd_opts = cmd_poweroff_opts, + .handler = &cmd_poweroff_handler, + .invalid_use_msg = "Invalid use of poweroff command.\n" + "Type in poweroff --help for more help.\n", + .privilege = ROOT }; - - - - - - - - - diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 66c04de..f4d68f1 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -15,11 +15,11 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + **/ #include #include @@ -32,52 +32,41 @@ #include #include - - -struct cmd_opt_t* cmd_reboot_opts[] = +struct cmd_opt_t* cmd_reboot_opts[] = { 0 }; int cmd_reboot_handler(char* cmd) { - size_t num_opts = get_opt_count(cmd); - str_t opts[num_opts]; - get_opt(cmd,opts); - - if(num_opts == 1) - root_sys_reboot(); - else if(strcmp(opts[1].str,"--help")==0) - printk(cmd_reboot.help); - else - printk(cmd_reboot.invalid_use_msg); - return STATUS_OK; + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd, opts); + + if(num_opts == 1) + root_sys_reboot(); + else if(strcmp(opts[1].str, "--help") == 0) + printk(cmd_reboot.help); + else + printk(cmd_reboot.invalid_use_msg); + + return STATUS_OK; } - -struct cmd_t cmd_reboot = +struct cmd_t cmd_reboot = { - .name = "reboot", - .usage ="reboot [--help]", - .help = "reboot(1) \t\t\t\t BoneOS Terminal Manual \n" - "NAME : \n " - "\treboot\n" - "SYNOPSIS : \n " - "\treboot [--help]\n " - "DESCRIPTION : \n " - "\tReboots the Operating System.\n", - .cmd_opts = cmd_reboot_opts, - .handler = &cmd_reboot_handler, - .invalid_use_msg = "Invalid use of reboot command.\n" - "Type in reboot --help for more help.\n", - .privilege = ROOT + .name = "reboot", + .usage ="reboot [--help]", + .help = "reboot(1) \t\t\t\t BoneOS Terminal Manual \n" + "NAME : \n " + "\treboot\n" + "SYNOPSIS : \n " + "\treboot [--help]\n " + "DESCRIPTION : \n " + "\tReboots the Operating System.\n", + .cmd_opts = cmd_reboot_opts, + .handler = &cmd_reboot_handler, + .invalid_use_msg = "Invalid use of reboot command.\n" + "Type in reboot --help for more help.\n", + .privilege = ROOT }; - - - - - - - - - diff --git a/var/Makefile b/var/Makefile index 176934d..965572a 100644 --- a/var/Makefile +++ b/var/Makefile @@ -2,8 +2,6 @@ BUILDROOT ?= ../ CSRCS = \ cpu/cpu_info.c - - LIBNAME := var diff --git a/var/cpu/cpu_info.c b/var/cpu/cpu_info.c index a5f69f2..ea1afe6 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[] = { @@ -73,15 +73,14 @@ static const char* vendor_company_strings[] = { "Parrelels" }; - static inline void find_comp(char* ID) { - for(int i=0; vendor_id_strings[i]; i++) + for(int i = 0; vendor_id_strings[i]; i++) { - if(strcmp(ID,vendor_id_strings[i])==0) + if(strcmp(ID,vendor_id_strings[i]) == 0) { - cpu_info.companyName = (char*)vendor_company_strings[i]; - return; + cpu_info.companyName = (char*) vendor_company_strings[i]; + return; } } cpu_info.companyName = "Unknown"; @@ -89,9 +88,9 @@ static inline void find_comp(char* ID) static void signature_proccessing(uint32_t sig) { - if(strcmp(cpu_info.companyName, "Intel")==0) + 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"; @@ -108,27 +107,23 @@ static void signature_proccessing(uint32_t sig) int init_cpu_info() { - cpu_info.vendorID =(char*) cpu_id.vendorID; + cpu_info.vendorID = (char*) cpu_id.vendorID; cpu_info.ecx_features = cpu_id.features_ecx; cpu_info.edx_features = cpu_id.features_edx; cpu_info.signature = cpu_id.signature; find_comp(cpu_info.vendorID); signature_proccessing(cpu_info.signature); - return STATUS_OK; } - - - void __debug_print_cpu_info() { #ifdef DEBUG - printk("CPU\n"); - printk("---\n"); - 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 + printk("CPU\n"); + printk("---\n"); + 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 +}