Max OS 0.3
Loading...
Searching...
No Matches
syscalls.h
Go to the documentation of this file.
1
11#ifndef MAXOS_SYSTEM_SYSCALLS_H
12#define MAXOS_SYSTEM_SYSCALLS_H
13
14#include <cstdint>
15#include <cstddef>
17#include <common/vector.h>
18#include <common/colour.h>
20#include <processes/scheduler.h>
21#include <system/syscalls.h>
22
23
24namespace MaxOS::system {
25
26 // Forward declaration
27 class SyscallManager;
28
36 typedef struct SyscallArguments {
37
38 uint64_t arg0;
39 uint64_t arg1;
40 uint64_t arg2;
41 uint64_t arg3;
42 uint64_t arg4;
43 uint64_t arg5;
44 uint64_t return_value;
46
47 } syscall_args_t;
48
50 typedef syscall_args_t* (* syscall_func_t)(syscall_args_t* args);
51
87}
88
89
90#endif //MAXOS_SYSTEM_SYSCALLS_H
Enables a resource to be used by only one instance at a time through locking and unlocking.
Definition spinlock.h:21
Handles a certain interrupt number.
Definition interrupts.h:30
virtual void handle_interrupt()
Handles an interrupt.
Provides an API for userspace applications to interact with the kernel.
Definition syscalls.h:58
static syscall_args_t * syscall_thread_sleep(syscall_args_t *args)
System call to sleep the current process.
Definition syscalls.cpp:323
static syscall_args_t * syscall_klog(syscall_args_t *args)
System call to log a message to the kernel log.
Definition syscalls.cpp:141
static syscall_args_t * syscall_resource_create(syscall_args_t *args)
System call to create a resource.
Definition syscalls.cpp:201
static syscall_args_t * syscall_resource_close(syscall_args_t *args)
System call to close a resource.
Definition syscalls.cpp:240
static syscall_args_t * syscall_close_process(syscall_args_t *args)
System call to close a process.
Definition syscalls.cpp:117
static syscall_args_t * syscall_resource_open(syscall_args_t *args)
System call to open a resource.
Definition syscalls.cpp:222
static syscall_args_t * syscall_thread_close(syscall_args_t *args)
System call to close a thread.
Definition syscalls.cpp:342
static syscall_args_t * syscall_thread_yield(syscall_args_t *args)
System call to yield the current process.
Definition syscalls.cpp:309
SyscallManager()
Construct a new Syscall Manager object and register the syscall handlers. Registers to interrupt 0x80...
Definition syscalls.cpp:23
void remove_syscall_handler(::syscore::SyscallType syscall)
Removes a syscall handler from the manager.
Definition syscalls.cpp:105
void set_syscall_handler(::syscore::SyscallType syscall, syscall_func_t handler)
Loads a syscall handler into the manager.
Definition syscalls.cpp:95
static syscall_args_t * syscall_free_memory(syscall_args_t *args)
System call to free a block of memory.
Definition syscalls.cpp:186
static syscall_args_t * syscall_resource_write(syscall_args_t *args)
System call to write to a resource.
Definition syscalls.cpp:257
static syscall_args_t * syscall_allocate_memory(syscall_args_t *args)
System call to allocate a block of memory.
Definition syscalls.cpp:169
static syscall_args_t * syscall_resource_read(syscall_args_t *args)
System call to read from a resource.
Definition syscalls.cpp:283
Defines a Colour class for representing colours in RGBA format, along with ANSI and console colour en...
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 a GlobalScheduler and Scheduler for managing processes and threads.
The arguments passed to a syscall (simplified representation of values in registers)
Definition syscalls.h:36
uint64_t arg0
First argument (in rdi)
Definition syscalls.h:38
uint64_t arg1
Second argument (in rsi)
Definition syscalls.h:39
uint64_t return_value
The return value of the syscall (in rax)
Definition syscalls.h:44
uint64_t arg4
Fifth argument (in r8)
Definition syscalls.h:42
uint64_t arg3
Fourth argument (in rcx)
Definition syscalls.h:41
uint64_t arg2
Third argument (in rdx)
Definition syscalls.h:40
cpu_status_t * return_state
The CPU state to return to after the syscall.
Definition syscalls.h:45
uint64_t arg5
Sixth argument (in r9)
Definition syscalls.h:43
Defines the SyscallManager class for handling system calls from userspace applications.
syscall_args_t *(* syscall_func_t)(syscall_args_t *args)
Definition syscalls.h:50
Defines a Vector class for dynamically storing an array of elements.