Compare commits
No commits in common. "c0e1b688a499c20497604b387ba6d5b2d7c29e64" and "c02fdd7249cd1f7aac39c125042226bb906ac6d2" have entirely different histories.
c0e1b688a4
...
c02fdd7249
|
@ -32,12 +32,9 @@ typedef enum {
|
||||||
SYSCALL_MEMORY_ACCESS = 0x0205,
|
SYSCALL_MEMORY_ACCESS = 0x0205,
|
||||||
|
|
||||||
SYSCALL_PROCESS_CREATE = 0x0301,
|
SYSCALL_PROCESS_CREATE = 0x0301,
|
||||||
SYSCALL_PROCESS_ENV = 0x0302,
|
SYSCALL_PROCESS_ENVFILE = 0x0302,
|
||||||
SYSCALL_PROCESS_SIGNAL = 0x0303,
|
SYSCALL_PROCESS_START = 0x0303,
|
||||||
SYSCALL_PROCESS_THREAD_CREATE = 0x0304,
|
SYSCALL_PROCESS_SIGNAL = 0x0304,
|
||||||
SYSCALL_PROCESS_THREAD_START = 0x0305,
|
|
||||||
SYSCALL_PROCESS_THREAD_PAUSE = 0x0306,
|
|
||||||
SYSCALL_PROCESS_THREAD_KILL = 0x0307,
|
|
||||||
|
|
||||||
SYSCALL_RUNTIME_LINKER_OPEN = 0x0401,
|
SYSCALL_RUNTIME_LINKER_OPEN = 0x0401,
|
||||||
SYSCALL_RUNTIME_LINKER_CLOSE = 0x0402,
|
SYSCALL_RUNTIME_LINKER_CLOSE = 0x0402,
|
||||||
|
|
|
@ -9,9 +9,7 @@ typedef enum {
|
||||||
STATUS_SUCCESS,
|
STATUS_SUCCESS,
|
||||||
|
|
||||||
STATUS_PERMISSION_DENIED,
|
STATUS_PERMISSION_DENIED,
|
||||||
STATUS_RESOURCE_NOT_AVAILABLE,
|
STATUS_RESOURCE_NOT_AVAILABLE
|
||||||
STATUS_NOT_SUPPORTED,
|
|
||||||
STATUS_GENERIC_ERROR
|
|
||||||
} status_E;
|
} status_E;
|
||||||
|
|
||||||
extern string_t g_status_code_strings[3];
|
extern string_t g_status_code_strings[3];
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "boot/config.h"
|
#include "boot/config.h"
|
||||||
#include "platform/interrupts.h"
|
#include "platform/interrupts.h"
|
||||||
#include "platform/gdt.h"
|
#include "platform/gdt.h"
|
||||||
#include "platform/syscall.h"
|
|
||||||
#include "mm/page_frame.h"
|
#include "mm/page_frame.h"
|
||||||
#include "mm/page_map.h"
|
#include "mm/page_map.h"
|
||||||
#include "mm/region.h"
|
#include "mm/region.h"
|
||||||
|
@ -65,16 +64,16 @@ void kmain(boot_info_T boot_info) {
|
||||||
|
|
||||||
log(LOG_INFO, "!=====[ Kernel Initialized ]=====!\n");
|
log(LOG_INFO, "!=====[ Kernel Initialized ]=====!\n");
|
||||||
|
|
||||||
pid_t pid;
|
void* buffer = vfs_resolve_path(&g_root_fs, "/initrd/shell.elf")->cache->buffer;
|
||||||
syscall_perform(SYSCALL_PROCESS_CREATE, (uint64_t)"/initrd/shell.elf", 0, (uint64_t)&pid, 0);
|
elf_executable_T* exec = elf_executable_create(buffer);
|
||||||
|
pid_t proc = process_spawn(PROCESS_KERNEL, "shell", exec, buffer);
|
||||||
|
|
||||||
process_T* process = scheduler_get_process(pid);
|
process_T* process = scheduler_get_process(proc);
|
||||||
thread_start(process->threads);
|
|
||||||
|
|
||||||
scheduler_dump_info(scheduler_get_process(PROCESS_KERNEL), 0);
|
|
||||||
|
|
||||||
g_tty->output = &process->stdin;
|
g_tty->output = &process->stdin;
|
||||||
process->stdout = &g_tty->input;
|
process->stdout = &g_tty->input;
|
||||||
|
|
||||||
|
thread_start(thread_spawn(proc, symbol_resolve_from_name(exec->symbols, exec->num_symbols, "_start")->address + MEM_REGION_PROCESS_EXEC));
|
||||||
|
|
||||||
CORE_HALT_FOREVER
|
CORE_HALT_FOREVER
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,44 +207,6 @@ void syscall_handle_nx_munmap(cpu_state_T* state) {
|
||||||
state->rax = STATUS_SUCCESS;
|
state->rax = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_pcreate(cpu_state_T* state) {
|
|
||||||
string_t path = (string_t)state->rdi; // arg1
|
|
||||||
uint64_t len = state->rsi; // arg2
|
|
||||||
pid_t* pid = (pid_t*)state->rdx; // arg3
|
|
||||||
string_t name = (string_t)state->rcx; // arg4
|
|
||||||
|
|
||||||
vfs_node_T* node = vfs_resolve_path(&g_root_fs, path);
|
|
||||||
if (node == NULL || node->type != VFS_NODE_FILE) {
|
|
||||||
state->rax = STATUS_RESOURCE_NOT_AVAILABLE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* buffer = memory_allocate(node->size);
|
|
||||||
vfs_file_read(node, 0, node->size, buffer);
|
|
||||||
|
|
||||||
elf_executable_T* exec = elf_executable_create(buffer);
|
|
||||||
if (exec == NULL) {
|
|
||||||
memory_free(buffer);
|
|
||||||
state->rax = STATUS_NOT_SUPPORTED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name == NULL) {
|
|
||||||
name = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pid = process_spawn(scheduler_get_current_process()->id, name, exec, buffer);
|
|
||||||
if (*pid == PROCESS_NONE) {
|
|
||||||
state->rax = STATUS_GENERIC_ERROR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void* entry = (void*)(symbol_resolve_from_name(exec->symbols, exec->num_symbols, "_start")->address + MEM_REGION_PROCESS_EXEC);
|
|
||||||
|
|
||||||
thread_spawn(*pid, entry);
|
|
||||||
|
|
||||||
state->rax = STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cpu_state_T* syscall_handle(cpu_state_T* state) {
|
cpu_state_T* syscall_handle(cpu_state_T* state) {
|
||||||
cpu_state_T* return_state = state;
|
cpu_state_T* return_state = state;
|
||||||
|
@ -298,12 +260,6 @@ cpu_state_T* syscall_handle(cpu_state_T* state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case SYSCALLS_PROC: {
|
case SYSCALLS_PROC: {
|
||||||
switch (state->rax) {
|
|
||||||
case SYSCALL_PROCESS_CREATE: {
|
|
||||||
syscall_handle_nx_pcreate(state);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue