about summary refs log tree commit diff
path: root/src/pOS/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/pOS/arch')
-rw-r--r--src/pOS/arch/x86/kernel/shell/cmd.cpp33
-rw-r--r--src/pOS/arch/x86/kernel/shell/cmds/clear.cpp9
-rw-r--r--src/pOS/arch/x86/kernel/shell/cmds/halt.cpp9
-rw-r--r--src/pOS/arch/x86/kernel/shell/cmds/reboot.cpp9
-rw-r--r--src/pOS/arch/x86/kernel/shell/cmds/shutdown.cpp9
-rw-r--r--src/pOS/arch/x86/kernel/shell/shell.cpp (renamed from src/pOS/arch/x86/kernel/shell.cpp)19
6 files changed, 77 insertions, 11 deletions
diff --git a/src/pOS/arch/x86/kernel/shell/cmd.cpp b/src/pOS/arch/x86/kernel/shell/cmd.cpp
new file mode 100644
index 0000000..cc34f6e
--- /dev/null
+++ b/src/pOS/arch/x86/kernel/shell/cmd.cpp
@@ -0,0 +1,33 @@
+#include <string.h>
+#include <stdio.h>
+#include <kernel/shell/cmd.h>
+
+#include <kernel/debug.h>
+
+int CMD_MANAGER::execute(char* cmd)
+{
+    //char* arg = strtok(cmd, " ");
+
+    dbgprintf("cmd: %s\n", cmd);
+
+    switch(str2int(cmd))
+    {
+        case str2int("clear"):
+        case str2int("cls"):
+        case str2int("c"):
+             return CMD_Clear().execute(cmd);
+
+        case str2int("halt"):
+        case str2int("hlt"):
+            return CMD_Halt().execute(cmd);
+
+        case str2int("shutdown"):
+            return CMD_Shutdown().execute(cmd);
+
+        case str2int("reboot"):
+            return CMD_Reboot().execute(cmd);
+    }
+
+    printf("Unknown cmd: %s\n", cmd);
+    return -1;
+}
diff --git a/src/pOS/arch/x86/kernel/shell/cmds/clear.cpp b/src/pOS/arch/x86/kernel/shell/cmds/clear.cpp
new file mode 100644
index 0000000..1919a3a
--- /dev/null
+++ b/src/pOS/arch/x86/kernel/shell/cmds/clear.cpp
@@ -0,0 +1,9 @@
+#include <kernel/shell/cmd.h>
+#include <kernel/tty.h>
+
+int CMD_Clear::execute(const char* args)
+{
+    UNUSED_VARIABLE(args);
+    TTY::tty_initialize();
+    return 0;
+}
diff --git a/src/pOS/arch/x86/kernel/shell/cmds/halt.cpp b/src/pOS/arch/x86/kernel/shell/cmds/halt.cpp
new file mode 100644
index 0000000..2993af3
--- /dev/null
+++ b/src/pOS/arch/x86/kernel/shell/cmds/halt.cpp
@@ -0,0 +1,9 @@
+#include <kernel/shell/cmd.h>
+#include <kernel/acpi.h>
+
+int CMD_Halt::execute(const char* args)
+{
+    UNUSED_VARIABLE(args);
+    ACPI::halt();
+    return 0;
+}
diff --git a/src/pOS/arch/x86/kernel/shell/cmds/reboot.cpp b/src/pOS/arch/x86/kernel/shell/cmds/reboot.cpp
new file mode 100644
index 0000000..bf2dac3
--- /dev/null
+++ b/src/pOS/arch/x86/kernel/shell/cmds/reboot.cpp
@@ -0,0 +1,9 @@
+#include <kernel/shell/cmd.h>
+#include <kernel/acpi.h>
+
+int CMD_Reboot::execute(const char* args)
+{
+    UNUSED_VARIABLE(args);
+    ACPI::reboot();
+    return 0;
+}
diff --git a/src/pOS/arch/x86/kernel/shell/cmds/shutdown.cpp b/src/pOS/arch/x86/kernel/shell/cmds/shutdown.cpp
new file mode 100644
index 0000000..e0939d9
--- /dev/null
+++ b/src/pOS/arch/x86/kernel/shell/cmds/shutdown.cpp
@@ -0,0 +1,9 @@
+#include <kernel/shell/cmd.h>
+#include <kernel/acpi.h>
+
+int CMD_Shutdown::execute(const char* args)
+{
+    UNUSED_VARIABLE(args);
+    ACPI::shutdown();
+    return 0;
+}
diff --git a/src/pOS/arch/x86/kernel/shell.cpp b/src/pOS/arch/x86/kernel/shell/shell.cpp
index b6e74be..9dc1fcd 100644
--- a/src/pOS/arch/x86/kernel/shell.cpp
+++ b/src/pOS/arch/x86/kernel/shell/shell.cpp
@@ -1,4 +1,4 @@
-#include <kernel/shell.h>
+#include <kernel/shell/shell.h>
 
 char Shell::prefix[10];
 
@@ -8,7 +8,7 @@ int Shell::init(void)
     return run();
 }
 
-int Shell::run(void)     /* TODO: implement args */
+int Shell::run(void)
 {
     char c;
     char cmd[20];        /* Mem management */
@@ -17,13 +17,16 @@ int Shell::run(void)     /* TODO: implement args */
     while((c = getc()) && c != EOF)
     {
         putc(c);
-
-        if(c == '\n')
+        /* TODO: Handle signals */
+        if(c == '\b')
+            indx--;
+        else if(c == '\n')
         {
             cmd[indx] = '\0';
             indx = 0;
 
-            handle_cmd(cmd);
+            CMD_MANAGER::execute(cmd);
+
             printf(Shell::prefix);
         }
         else
@@ -34,12 +37,6 @@ int Shell::run(void)     /* TODO: implement args */
     return 0;
 }
 
-int Shell::handle_cmd(const char* cmd)
-{
-    printf("Unknown cmd: %s\n", cmd);
-    return 0;
-}
-
 void Shell::set_prefix(const char* new_prefix)
 {
     strncpy(prefix, new_prefix, sizeof(prefix));