refactor (syscalls): refactored syscalls to match the documented SysABI
This commit is contained in:
parent
3fbc9dc274
commit
4070959736
|
@ -7,50 +7,40 @@
|
||||||
#include "utils/status.h"
|
#include "utils/status.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SYSCALLS_FILES = 0x01,
|
SYSCALLS_FILES = 0x00,
|
||||||
SYSCALLS_MEMORY = 0x02,
|
SYSCALLS_MEMORY = 0x01,
|
||||||
SYSCALLS_PROC = 0x03,
|
SYSCALLS_PROC = 0x02,
|
||||||
SYSCALLS_RUNTIME_LINKER = 0x04,
|
SYSCALLS_DRIVERS = 0x03,
|
||||||
SYSCALLS_COMPATABILITY = 0x05,
|
|
||||||
|
|
||||||
SYSCALLS_KERNEL = 0xFF
|
SYSCALLS_KERNEL = 0xFF
|
||||||
}syscall_group_E;
|
}syscall_group_E;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SYSCALL_FILES_OPEN = 0x0101,
|
SYSCALL_NX_FS_OPEN = 0x0001,
|
||||||
SYSCALL_FILES_CLOSE = 0x0102,
|
SYSCALL_NX_FS_CLOSE = 0x0002,
|
||||||
SYSCALL_FILES_READ = 0x0103,
|
SYSCALL_NX_FS_READ = 0x0003,
|
||||||
SYSCALL_FILES_WRITE = 0x0104,
|
SYSCALL_NX_FS_WRITE = 0x0004,
|
||||||
SYSCALL_FILES_DELETE = 0x0105,
|
SYSCALL_NX_FS_DELETE = 0x0005,
|
||||||
SYSCALL_FILES_LIST = 0x0106,
|
SYSCALL_NX_FS_LIST = 0x0006,
|
||||||
SYSCALL_FILES_INFO = 0x0107,
|
SYSCALL_NX_FS_INFO = 0x0007,
|
||||||
|
|
||||||
SYSCALL_MEMORY_MAP = 0x0201,
|
SYSCALL_NX_MEM_ALLOC = 0x0101,
|
||||||
SYSCALL_MEMORY_UNMAP = 0x0202,
|
SYSCALL_NX_MEM_FREE = 0x0102,
|
||||||
SYSCALL_MEMORY_LABEL = 0x0203,
|
SYSCALL_NX_MEM_LABEL = 0x0103,
|
||||||
SYSCALL_MEMORY_RANGE = 0x0204,
|
SYSCALL_NX_MEM_UNLABEL = 0x0104,
|
||||||
SYSCALL_MEMORY_ACCESS = 0x0205,
|
|
||||||
|
|
||||||
SYSCALL_PROCESS_CREATE = 0x0301,
|
SYSCALL_NX_PROC_CREATE = 0x0201,
|
||||||
SYSCALL_PROCESS_ENV = 0x0302,
|
SYSCALL_NX_PROC_SIGNAL_SEND = 0x0202,
|
||||||
SYSCALL_PROCESS_SIGNAL = 0x0303,
|
SYSCALL_NX_PROC_SIGNAL_SET_HANDLER = 0x0203,
|
||||||
SYSCALL_PROCESS_THREAD_CREATE = 0x0304,
|
SYSCALL_NX_PROC_THREAD_CREATE = 0x0204,
|
||||||
SYSCALL_PROCESS_THREAD_START = 0x0305,
|
SYSCALL_NX_PROC_THREAD_START = 0x0205,
|
||||||
SYSCALL_PROCESS_THREAD_PAUSE = 0x0306,
|
SYSCALL_NX_PROC_THREAD_PAUSE = 0x0206,
|
||||||
SYSCALL_PROCESS_THREAD_KILL = 0x0307,
|
SYSCALL_NX_PROC_THREAD_KILL = 0x0207,
|
||||||
|
|
||||||
SYSCALL_RUNTIME_LINKER_OPEN = 0x0401,
|
SYSCALL_NX_DRV_REGISTER = 0x0301,
|
||||||
SYSCALL_RUNTIME_LINKER_CLOSE = 0x0402,
|
|
||||||
SYSCALL_RUNTIME_LINKER_LOAD_SYMBOL = 0x0403,
|
|
||||||
SYSCALL_RUNTIME_LINKER_STATUS = 0x0404,
|
|
||||||
SYSCALL_RUNTIME_LINKER_STANDARD_MOD = 0x0405,
|
|
||||||
|
|
||||||
SYSCALL_COMPATABILITY_ABI_TYPE = 0x0501,
|
SYSCALL_NX_KERNEL_SCHEDULER_START = 0xFF00,
|
||||||
SYSCALL_COMPATABILITY_ABI_VERSION = 0x0502,
|
SYSCALL_NX_KERNEL_PANIC = 0xFF01
|
||||||
SYSCALL_COMPATABILITY_ACTION = 0x0503,
|
|
||||||
|
|
||||||
SYSCALL_KERNEL_SCHEDULER_START = 0xFF00,
|
|
||||||
SYSCALL_KERNEL_PANIC = 0xFF01
|
|
||||||
} syscall_E;
|
} syscall_E;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "mm/page_frame.h"
|
#include "mm/page_frame.h"
|
||||||
#include "mm/region.h"
|
#include "mm/region.h"
|
||||||
|
|
||||||
void syscall_handle_nx_fopen(cpu_state_T* state) {
|
void syscall_handle_nx_fs_open(cpu_state_T* state) {
|
||||||
string_t path = (string_t)state->rdi; // arg1
|
string_t path = (string_t)state->rdi; // arg1
|
||||||
uint64_t len = state->rsi; // arg2
|
uint64_t len = state->rsi; // arg2
|
||||||
file_descriptor_t* fd_ptr = (file_descriptor_t*)state->rdx; // arg3
|
file_descriptor_t* fd_ptr = (file_descriptor_t*)state->rdx; // arg3
|
||||||
|
@ -23,7 +23,7 @@ void syscall_handle_nx_fopen(cpu_state_T* state) {
|
||||||
*fd_ptr = file_descriptor_request(scheduler_get_current_process()->fd_array, node);
|
*fd_ptr = file_descriptor_request(scheduler_get_current_process()->fd_array, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_fclose(cpu_state_T* state) {
|
void syscall_handle_nx_fs_close(cpu_state_T* state) {
|
||||||
file_descriptor_t fd = (file_descriptor_t)state->rdi; // arg1
|
file_descriptor_t fd = (file_descriptor_t)state->rdi; // arg1
|
||||||
|
|
||||||
file_descriptor_free(scheduler_get_current_process()->fd_array, fd);
|
file_descriptor_free(scheduler_get_current_process()->fd_array, fd);
|
||||||
|
@ -31,7 +31,7 @@ void syscall_handle_nx_fclose(cpu_state_T* state) {
|
||||||
state->rax = STATUS_SUCCESS;
|
state->rax = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_fread(cpu_state_T* state) {
|
void syscall_handle_nx_fs_read(cpu_state_T* state) {
|
||||||
file_descriptor_t fd = (file_descriptor_t)state->rdi; // arg1
|
file_descriptor_t fd = (file_descriptor_t)state->rdi; // arg1
|
||||||
uint64_t offset = state->rsi; // arg2
|
uint64_t offset = state->rsi; // arg2
|
||||||
uint8_t* mem = (uint8_t*)state->rdx; // arg3
|
uint8_t* mem = (uint8_t*)state->rdx; // arg3
|
||||||
|
@ -63,7 +63,7 @@ void syscall_handle_nx_fread(cpu_state_T* state) {
|
||||||
state->rax = read_bytes;
|
state->rax = read_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
void syscall_handle_nx_fs_write(cpu_state_T* state) {
|
||||||
file_descriptor_t fd = (file_descriptor_t)state->rdi; // arg1
|
file_descriptor_t fd = (file_descriptor_t)state->rdi; // arg1
|
||||||
uint64_t offset = state->rsi; // arg2
|
uint64_t offset = state->rsi; // arg2
|
||||||
uint8_t* mem = (uint8_t*)state->rdx; // arg3
|
uint8_t* mem = (uint8_t*)state->rdx; // arg3
|
||||||
|
@ -103,7 +103,7 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
||||||
state->rax = written_bytes;
|
state->rax = written_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_fdelete(cpu_state_T* state) {
|
void syscall_handle_nx_fs_delete(cpu_state_T* state) {
|
||||||
string_t path = (string_t)state->rdi; // arg1
|
string_t path = (string_t)state->rdi; // arg1
|
||||||
string_t len = (string_t)state->rsi; // arg2
|
string_t len = (string_t)state->rsi; // arg2
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ void syscall_handle_nx_fdelete(cpu_state_T* state) {
|
||||||
state->rax = STATUS_SUCCESS;
|
state->rax = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_flist(cpu_state_T* state) {
|
void syscall_handle_nx_fs_list(cpu_state_T* state) {
|
||||||
string_t path = (string_t)state->rdi; // arg1
|
string_t path = (string_t)state->rdi; // arg1
|
||||||
uint64_t len = state->rsi; // arg2
|
uint64_t len = state->rsi; // arg2
|
||||||
uint8_t* mem = (uint8_t*)state->rdx; // arg3
|
uint8_t* mem = (uint8_t*)state->rdx; // arg3
|
||||||
|
@ -153,7 +153,7 @@ void syscall_handle_nx_flist(cpu_state_T* state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void syscall_handle_nx_mmap(cpu_state_T* state) {
|
void syscall_handle_nx_mem_alloc(cpu_state_T* state) {
|
||||||
uint8_t* addr = (uint8_t*)state->rdi; // arg1
|
uint8_t* addr = (uint8_t*)state->rdi; // arg1
|
||||||
uint64_t n = state->rsi; // arg2
|
uint64_t n = state->rsi; // arg2
|
||||||
uint64_t flags = (uint64_t)state->rdx; // arg3
|
uint64_t flags = (uint64_t)state->rdx; // arg3
|
||||||
|
@ -187,7 +187,7 @@ void syscall_handle_nx_mmap(cpu_state_T* state) {
|
||||||
state->rax = STATUS_SUCCESS;
|
state->rax = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_munmap(cpu_state_T* state) {
|
void syscall_handle_nx_mem_free(cpu_state_T* state) {
|
||||||
void* addr = (void*)state->rdi; // arg1
|
void* addr = (void*)state->rdi; // arg1
|
||||||
uint64_t n = state->rsi; // arg2
|
uint64_t n = state->rsi; // arg2
|
||||||
|
|
||||||
|
@ -207,7 +207,8 @@ 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) {
|
|
||||||
|
void syscall_handle_nx_proc_create(cpu_state_T* state) {
|
||||||
string_t path = (string_t)state->rdi; // arg1
|
string_t path = (string_t)state->rdi; // arg1
|
||||||
uint64_t len = state->rsi; // arg2
|
uint64_t len = state->rsi; // arg2
|
||||||
pid_t* pid = (pid_t*)state->rdx; // arg3
|
pid_t* pid = (pid_t*)state->rdx; // arg3
|
||||||
|
@ -245,7 +246,7 @@ void syscall_handle_nx_pcreate(cpu_state_T* state) {
|
||||||
state->rax = STATUS_SUCCESS;
|
state->rax = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syscall_handle_nx_psignal(cpu_state_T* state) {
|
void syscall_handle_nx_proc_signal_send(cpu_state_T* state) {
|
||||||
pid_t pid = (pid_t)state->rdi; // arg1
|
pid_t pid = (pid_t)state->rdi; // arg1
|
||||||
uint64_t signal = state->rsi; // arg2
|
uint64_t signal = state->rsi; // arg2
|
||||||
|
|
||||||
|
@ -273,28 +274,28 @@ cpu_state_T* syscall_handle(cpu_state_T* state) {
|
||||||
case SYSCALLS_FILES: {
|
case SYSCALLS_FILES: {
|
||||||
|
|
||||||
switch (state->rax) {
|
switch (state->rax) {
|
||||||
case SYSCALL_FILES_OPEN: {
|
case SYSCALL_NX_FS_OPEN: {
|
||||||
syscall_handle_nx_fopen(state);
|
syscall_handle_nx_fs_open(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_FILES_CLOSE: {
|
case SYSCALL_NX_FS_CLOSE: {
|
||||||
syscall_handle_nx_fclose(state);
|
syscall_handle_nx_fs_close(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_FILES_READ: {
|
case SYSCALL_NX_FS_READ: {
|
||||||
syscall_handle_nx_fread(state);
|
syscall_handle_nx_fs_read(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_FILES_WRITE: {
|
case SYSCALL_NX_FS_WRITE: {
|
||||||
syscall_handle_nx_fwrite(state);
|
syscall_handle_nx_fs_write(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_FILES_DELETE: {
|
case SYSCALL_NX_FS_DELETE: {
|
||||||
syscall_handle_nx_fdelete(state);
|
syscall_handle_nx_fs_delete(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_FILES_LIST: {
|
case SYSCALL_NX_FS_LIST: {
|
||||||
syscall_handle_nx_flist(state);
|
syscall_handle_nx_fs_list(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,12 +304,12 @@ cpu_state_T* syscall_handle(cpu_state_T* state) {
|
||||||
|
|
||||||
case SYSCALLS_MEMORY: {
|
case SYSCALLS_MEMORY: {
|
||||||
switch (state->rax) {
|
switch (state->rax) {
|
||||||
case SYSCALL_MEMORY_MAP: {
|
case SYSCALL_NX_MEM_ALLOC: {
|
||||||
syscall_handle_nx_mmap(state);
|
syscall_handle_nx_mem_alloc(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_MEMORY_UNMAP: {
|
case SYSCALL_NX_MEM_FREE: {
|
||||||
syscall_handle_nx_munmap(state);
|
syscall_handle_nx_mem_free(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,23 +318,19 @@ cpu_state_T* syscall_handle(cpu_state_T* state) {
|
||||||
|
|
||||||
case SYSCALLS_PROC: {
|
case SYSCALLS_PROC: {
|
||||||
switch (state->rax) {
|
switch (state->rax) {
|
||||||
case SYSCALL_PROCESS_CREATE: {
|
case SYSCALL_NX_PROC_CREATE: {
|
||||||
syscall_handle_nx_pcreate(state);
|
syscall_handle_nx_proc_create(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_PROCESS_SIGNAL: {
|
case SYSCALL_NX_PROC_SIGNAL_SEND: {
|
||||||
syscall_handle_nx_psignal(state);
|
syscall_handle_nx_proc_signal_send(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SYSCALLS_RUNTIME_LINKER: {
|
case SYSCALLS_DRIVERS: {
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case SYSCALLS_COMPATABILITY: {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,12 +346,12 @@ cpu_state_T* syscall_handle(cpu_state_T* state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state->rax) {
|
switch (state->rax) {
|
||||||
case SYSCALL_KERNEL_SCHEDULER_START: {
|
case SYSCALL_NX_KERNEL_SCHEDULER_START: {
|
||||||
return_state = scheduler_start(state);
|
return_state = scheduler_start(state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SYSCALL_KERNEL_PANIC: {
|
case SYSCALL_NX_KERNEL_PANIC: {
|
||||||
panic(state, (string_t)arg1);
|
panic(state, (string_t)arg1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue