Add help
This commit is contained in:
@@ -53,7 +53,7 @@ void amd64_timer_init(void) {
|
||||
// LAPIC Timer is only used to trigger task switches
|
||||
LAPIC(LAPIC_REG_TMRDIV) = 0x3;
|
||||
LAPIC(LAPIC_REG_LVTT) = 32 | (1 << 17);
|
||||
LAPIC(LAPIC_REG_TMRINITCNT) = 1000;
|
||||
LAPIC(LAPIC_REG_TMRINITCNT) = 10000;
|
||||
LAPIC(LAPIC_REG_TMRCURRCNT) = 0;
|
||||
|
||||
get_cpu()->ticks = 0;
|
||||
|
||||
+27
@@ -37,6 +37,7 @@ static int b_pwd(const char *_);
|
||||
static int b_cat(const char *path);
|
||||
static int b_curs(const char *arg);
|
||||
static int b_sleep(const char *arg);
|
||||
static int b_help(const char *arg);
|
||||
|
||||
static struct builtin builtins[] = {
|
||||
{
|
||||
@@ -69,6 +70,11 @@ static struct builtin builtins[] = {
|
||||
"Sleep N seconds",
|
||||
b_sleep
|
||||
},
|
||||
{
|
||||
"help",
|
||||
"Please help me",
|
||||
b_help
|
||||
},
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -208,6 +214,27 @@ static int b_sleep(const char *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int b_help(const char *arg) {
|
||||
if (arg) {
|
||||
// Describe a specific command
|
||||
for (size_t i = 0; builtins[i].run; ++i) {
|
||||
if (!strcmp(arg, builtins[i].name)) {
|
||||
printf("%s: %s\n", builtins[i].name, builtins[i].desc);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%s: Unknown command\n", arg);
|
||||
return -1;
|
||||
} else {
|
||||
for (size_t i = 0; builtins[i].run; ++i) {
|
||||
printf("%s: %s\n", builtins[i].name, builtins[i].desc);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void prompt(void) {
|
||||
printf("\033[36mygg\033[0m > ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user