Skip to content

Commit

Permalink
General Cleanup #151
Browse files Browse the repository at this point in the history
Uses 4 spaces as TAB.
Commenting unused code. (i.e. if statement with no action)

apps/
boot/
platform/
sbin/
var/
  • Loading branch information
srifqi committed Jan 16, 2017
1 parent fd7936a commit 6be4495
Show file tree
Hide file tree
Showing 27 changed files with 949 additions and 1,124 deletions.
56 changes: 27 additions & 29 deletions apps/sh/built-in/exit/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
**/

#include <stdio/stdio.h>
#include <misc/status_codes.h>
Expand All @@ -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
};


30 changes: 11 additions & 19 deletions apps/sh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
** Ashish Ahuja
**/


#include <sh/values.h>
#include <clear/clear.h>
#include <boneos_logo/boneos_logo.h>
Expand All @@ -47,17 +46,17 @@
#include <drv/driver.h>
#include <drv/cmos/rtc/rtc.h>
#include <sh/built-in/exit/exit.h>
#include <date/date.h>
#include <whoami/whoami.h>
#include <uptime/uptime.h>
#include <date/date.h>
#include <whoami/whoami.h>
#include <uptime/uptime.h>
#include <watch/watch.h>

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[] =
Expand All @@ -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;
}







76 changes: 35 additions & 41 deletions apps/sh/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,60 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
#include <str_t.h>
#include <stdbool.h>
#include <unistd/unistd.h>
#include <string/string.h>

#include <str_t.h>
#include <stdbool.h>
#include <unistd/unistd.h>
#include <string/string.h>

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;
}
2 changes: 0 additions & 2 deletions apps/sh/values.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ char* VAR_PWD = "/";
char* VAR_RELEASE = "0.0.1";
char* VAR_OSNAME = "BoneOS";
char* VAR_PLATFORM = "x86_32";


4 changes: 2 additions & 2 deletions boot/boot/grub/grub.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
menuentry "BoneOS x86 " {
multiboot /boot/BoneOS.bin
boot
multiboot /boot/BoneOS.bin
boot
}
2 changes: 1 addition & 1 deletion platform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ all:
(cd $(PLAT) && $(MAKE))

clean:
(cd $(PLAT) && $(MAKE) clean)
(cd $(PLAT) && $(MAKE) clean)
33 changes: 13 additions & 20 deletions platform/pc/cpu/interrupts/pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
**/

/*
* @function irq_remap:
Expand All @@ -31,28 +31,21 @@
#include <cpu/interrupts/interrupts.h>
#include <cpu/interrupts/pic.h>


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);
}






Loading

0 comments on commit 6be4495

Please sign in to comment.