13using namespace MaxOS::KPI;
14using namespace MaxOS::common;
15using namespace MaxOS::hardwarecommunication;
16using namespace MaxOS::system;
17using namespace MaxOS::processes;
18using namespace MaxOS::processes::resources;
19using namespace MaxOS::memory;
47SyscallManager::~SyscallManager() =
default;
59 args.
arg0 = status->rdi;
60 args.
arg1 = status->rsi;
61 args.
arg2 = status->rdx;
62 args.
arg3 = status->r10;
63 args.
arg4 = status->r8;
64 args.
arg5 = status->r9;
69 uint64_t syscall = status->rax;
70 if (m_syscall_handlers[syscall] !=
nullptr)
71 args = *(m_syscall_handlers[syscall](&args));
80 status->rdi = args.
arg0;
81 status->rsi = args.
arg1;
82 status->rdx = args.
arg2;
83 status->r10 = args.
arg3;
84 status->r8 = args.
arg4;
85 status->r9 = args.
arg5;
100 m_syscall_handlers[(uint8_t) syscall] = handler;
110 m_syscall_handlers[(uint8_t) syscall] =
nullptr;
123 char* message = (
char*) args->
arg0;
128 if (message[0] ==
'%' && message[1] ==
'h')
146 size_t size = args->
arg0;
163 void* address = (
void*) args->
arg0;
179 auto name = (
char*)args->
arg1;
180 auto flags = (size_t)args->
arg2;
181 auto data = (uintptr_t)args->
arg3;
201 auto name = (
char*)args->
arg1;
202 auto flags = (size_t)args->
arg2;
219 auto handle = (uint64_t )args->
arg0;
220 auto flags = (size_t)args->
arg1;
236 auto handle = (uint64_t )args->
arg0;
237 auto buffer = (
void*)args->
arg1;
238 auto size = (size_t)args->
arg2;
239 auto flags = (size_t)args->
arg3;
249 args->
return_value = resource->write(buffer,size,flags);
262 auto handle = (uint64_t)args->
arg0;
263 auto buffer = (
void*)args->
arg1;
264 auto size = (size_t)args->
arg2;
265 auto flags = (size_t)args->
arg3;
290 auto name = (
char*)args->
arg0;
291 auto type = (size_t)args->
arg1;
static LogRecord ERROR()
Gets the active logger for error logs.
static LogRecord INFO()
Gets the active logger for info logs.
static LogRecord Out()
Gets the active logger.
Handles a certain interrupt number.
virtual void handle_interrupt()
Handles an interrupt.
static void free(void *pointer)
Frees a block of memory using the current memory manager.
static void * malloc(size_t size)
Allocates a block of memory in the current USERSPACE heap.
static Process * current_process()
Gets the process on the currently executing core.
resources::ResourceManager resource_manager
The manger for resources used by this process.
virtual Resource * create_resource(const string &name, size_t flags, uintptr_t data)
Try to create a new resource with the specified name, will fail if the name is in use.
A generic wrapper for a registry of resources that exist on a userspace server.
static BaseResourceRegistry * get_registry(resource_type_t type)
Gets a registry of a type.
Resource * get_resource(uint64_t handle)
Gets a resource based on the handle id.
void close_resource(uint64_t handle, size_t flags)
Un registers the resource and then closes it.
uint64_t open_resource(resource_type_t type, const string &name, size_t flags)
Registers a resource with the resource manager and then opens it.
static syscall_args_t * syscall_klog(syscall_args_t *args)
System call to log a message to the kernel log.
static syscall_args_t * syscall_resource_create(syscall_args_t *args)
System call to create a resource.
static syscall_args_t * syscall_resource_close(syscall_args_t *args)
System call to close a resource.
static syscall_args_t * syscall_resource_open(syscall_args_t *args)
System call to open a resource.
static syscall_args_t * syscall_resource_registry_create(syscall_args_t *args)
System call to create a new resource registry.
SyscallManager()
Construct a new Syscall Manager object and register the syscall handlers. Registers to interrupt 0x80...
void set_syscall_handler(::MaxOS::KPI::SyscallType syscall, syscall_func_t handler)
Loads a syscall handler into the manager.
static syscall_args_t * syscall_free_memory(syscall_args_t *args)
System call to free a block of memory.
static syscall_args_t * syscall_resource_write(syscall_args_t *args)
System call to write to a resource.
void remove_syscall_handler(::MaxOS::KPI::SyscallType syscall)
Removes a syscall handler from the manager.
static syscall_args_t * syscall_allocate_memory(syscall_args_t *args)
System call to allocate a block of memory.
static syscall_args_t * syscall_resource_read(syscall_args_t *args)
System call to read from a resource.
struct PACKED MaxOS::system::CPUStatus cpu_status_t
Alias for CPUStatus struct.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
KPI::ResourceType resource_type_t
Alias to make the libsyscore ResourceType accessible here.
The arguments passed to a syscall (simplified representation of values in registers)
uint64_t arg0
First argument (in rdi)
uint64_t arg1
Second argument (in rsi)
uint64_t return_value
The return value of the syscall (in rax)
uint64_t arg4
Fifth argument (in r8)
uint64_t arg3
Fourth argument (in rcx)
uint64_t arg2
Third argument (in rdx)
cpu_status_t * return_state
The CPU state to return to after the syscall.
uint64_t arg5
Sixth argument (in r9)
Defines the SyscallManager class for handling system calls from userspace applications.