Max OS 0.3
Loading...
Searching...
No Matches
syscalls.h
Go to the documentation of this file.
1
9#ifndef MAXOS_SYSTEM_SYSCALLS_H
10#define MAXOS_SYSTEM_SYSCALLS_H
11
12#include <cstdint>
13
14#include <libkpi/syscalls.h>
15#include <libcommon/vector.h>
16#include <libcommon/colour.h>
17
20#include <processes/scheduler.h>
21#include <processes/block.h>
23
24
25namespace MaxOS::system {
26
27 // Forward declaration
28 class SyscallManager;
29
37 typedef struct SyscallArguments {
38
39 uint64_t arg0;
40 uint64_t arg1;
41 uint64_t arg2;
42 uint64_t arg3;
43 uint64_t arg4;
44 uint64_t arg5;
45 uint64_t return_value;
47
48 } syscall_args_t;
49
51 typedef syscall_args_t* (* syscall_func_t)(syscall_args_t* args);
52
60
61 private:
62 syscall_func_t m_syscall_handlers[256] = { };
63
64 public:
67
69
70 void set_syscall_handler(::MaxOS::KPI::SyscallType syscall, syscall_func_t handler);
71 void remove_syscall_handler(::MaxOS::KPI::SyscallType syscall);
72
74
77
84
85 };
86}
87
88
89#endif //MAXOS_SYSTEM_SYSCALLS_H
Defines BlockingLock class for thread synchronization.
Handles a certain interrupt number.
Definition interrupts.h:44
virtual void handle_interrupt()
Handles an interrupt.
Provides an API for userspace applications to interact with the kernel.
Definition syscalls.h:59
static syscall_args_t * syscall_klog(syscall_args_t *args)
System call to log a message to the kernel log.
Definition syscalls.cpp:120
static syscall_args_t * syscall_resource_create(syscall_args_t *args)
System call to create a resource.
Definition syscalls.cpp:175
static syscall_args_t * syscall_resource_close(syscall_args_t *args)
System call to close a resource.
Definition syscalls.cpp:216
static syscall_args_t * syscall_resource_open(syscall_args_t *args)
System call to open a resource.
Definition syscalls.cpp:197
static syscall_args_t * syscall_resource_registry_create(syscall_args_t *args)
System call to create a new resource registry.
Definition syscalls.cpp:287
SyscallManager()
Construct a new Syscall Manager object and register the syscall handlers. Registers to interrupt 0x80...
Definition syscalls.cpp:24
void set_syscall_handler(::MaxOS::KPI::SyscallType syscall, syscall_func_t handler)
Loads a syscall handler into the manager.
Definition syscalls.cpp:98
static syscall_args_t * syscall_free_memory(syscall_args_t *args)
System call to free a block of memory.
Definition syscalls.cpp:160
static syscall_args_t * syscall_resource_write(syscall_args_t *args)
System call to write to a resource.
Definition syscalls.cpp:233
void remove_syscall_handler(::MaxOS::KPI::SyscallType syscall)
Removes a syscall handler from the manager.
Definition syscalls.cpp:108
static syscall_args_t * syscall_allocate_memory(syscall_args_t *args)
System call to allocate a block of memory.
Definition syscalls.cpp:142
static syscall_args_t * syscall_resource_read(syscall_args_t *args)
System call to read from a resource.
Definition syscalls.cpp:259
struct PACKED MaxOS::system::CPUStatus cpu_status_t
Alias for CPUStatus struct.
Defines a InterruptManager and InterruptHandler for managing hardware and software interrupts.
Defines a MemoryManager class for handling memory allocation and deallocation.
Defines scheduler resource classes for wrapping userspace bridge Resources in the Global Scheduler,...
Defines a GlobalScheduler and Scheduler for managing processes and threads.
The arguments passed to a syscall (simplified representation of values in registers)
Definition syscalls.h:37
uint64_t arg0
First argument (in rdi)
Definition syscalls.h:39
uint64_t arg1
Second argument (in rsi)
Definition syscalls.h:40
uint64_t return_value
The return value of the syscall (in rax)
Definition syscalls.h:45
uint64_t arg4
Fifth argument (in r8)
Definition syscalls.h:43
uint64_t arg3
Fourth argument (in rcx)
Definition syscalls.h:42
uint64_t arg2
Third argument (in rdx)
Definition syscalls.h:41
cpu_status_t * return_state
The CPU state to return to after the syscall.
Definition syscalls.h:46
uint64_t arg5
Sixth argument (in r9)
Definition syscalls.h:44
syscall_args_t *(* syscall_func_t)(syscall_args_t *args)
Definition syscalls.h:51