diff options
Diffstat (limited to 'Source/Kernel/Shell')
-rw-r--r-- | Source/Kernel/Shell/KernelShell-fs.class.cpp | 31 | ||||
-rw-r--r-- | Source/Kernel/Shell/KernelShell.class.cpp | 3 | ||||
-rw-r--r-- | Source/Kernel/Shell/KernelShell.class.h | 1 |
3 files changed, 35 insertions, 0 deletions
diff --git a/Source/Kernel/Shell/KernelShell-fs.class.cpp b/Source/Kernel/Shell/KernelShell-fs.class.cpp index 3ac7b20..b34fa7f 100644 --- a/Source/Kernel/Shell/KernelShell-fs.class.cpp +++ b/Source/Kernel/Shell/KernelShell-fs.class.cpp @@ -1,6 +1,8 @@ #include "KernelShell.class.h" #include <VFS/VFS.ns.h> #include <VFS/File.class.h> +#include <TaskManager/Task.ns.h> +#include <MemoryManager/PhysMem.ns.h> void KernelShell::ls(Vector<String>& args) { DirectoryNode* d = m_cwd; @@ -102,3 +104,32 @@ void KernelShell::wf(Vector<String>& args) { } } } + +void KernelShell::run(Vector<String>& args) { + if (args.size() == 1) { + *m_vt << "No app to run !\n"; + } else { + File f(args[1], FM_READ, m_cwd); + if (f.valid()) { + u32int magic = 0; + f.read<u32int>(&magic); + if (magic == 0xFEEDBEEF) { + u32int size; + f.read<u32int>(&size); + Process* p; + p = new Process(args[1], 0); + p->setVirtualTerminal(m_vt); + u8int *ptr = (u8int*)p->heap().alloc(size); + f.read(size, ptr); + new Thread(p, (thread_entry_t)ptr, 0); + kernelPageDirectory->switchTo(); + while (p->getState() != P_FINISHED) Task::currThread()->sleep(10); + delete p; + } else { + *m_vt << "Bad magic number : " << (u32int)magic << "\n"; + } + } else { + *m_vt << "Unable to read from file.\n"; + } + } +} diff --git a/Source/Kernel/Shell/KernelShell.class.cpp b/Source/Kernel/Shell/KernelShell.class.cpp index e2fbb69..ac89b68 100644 --- a/Source/Kernel/Shell/KernelShell.class.cpp +++ b/Source/Kernel/Shell/KernelShell.class.cpp @@ -3,7 +3,9 @@ #include <DeviceManager/Kbd.ns.h> #include <Library/Rand.ns.h> #include <Library/SimpleList.class.h> +#include <MemoryManager/PhysMem.ns.h> #include <VFS/VFS.ns.h> +#include <TaskManager/Task.ns.h> u32int KernelShell::m_instances = 0; @@ -51,6 +53,7 @@ u32int KernelShell::run() { {"mkdir", &KernelShell::mkdir}, {"rm", &KernelShell::rm}, {"wf", &KernelShell::wf}, + {"run", &KernelShell::run}, {"devices", &KernelShell::devices}, {"loadkeys", &KernelShell::loadkeys}, diff --git a/Source/Kernel/Shell/KernelShell.class.h b/Source/Kernel/Shell/KernelShell.class.h index 39e1ebd..48d9704 100644 --- a/Source/Kernel/Shell/KernelShell.class.h +++ b/Source/Kernel/Shell/KernelShell.class.h @@ -26,6 +26,7 @@ class KernelShell { void mkdir(Vector<String>& args); void rm(Vector<String>& args); void wf(Vector<String>& args); + void run(Vector<String>& args); //in KernelShell-sys void devices(Vector<String>& args); |