12using namespace syscore;
14using namespace MaxOS::common;
15using namespace MaxOS::hardwarecommunication;
16using namespace MaxOS::system;
17using namespace MaxOS::processes;
18using namespace MaxOS::memory;
44SyscallManager::~SyscallManager() =
default;
56 args.arg0 = status->rdi;
57 args.arg1 = status->rsi;
58 args.arg2 = status->rdx;
59 args.arg3 = status->r10;
60 args.arg4 = status->r8;
61 args.arg5 = status->r9;
62 args.return_value = 0;
63 args.return_state = status;
67 if (m_syscall_handlers[
syscall] !=
nullptr)
73 if (
args.return_state != status)
74 return args.return_state;
77 status->rdi =
args.arg0;
78 status->rsi =
args.arg1;
79 status->rdx =
args.arg2;
80 status->r10 =
args.arg3;
81 status->r8 =
args.arg4;
82 status->r9 =
args.arg5;
83 status->rax =
args.return_value;
172 size_t size =
args->arg0;
189 void* address = (
void*)
args->arg0;
205 auto name = (
char*)
args->arg1;
226 auto name = (
char*)
args->arg1;
261 auto buffer = (
void*)
args->arg1;
268 args->return_value = 0;
273 args->return_value =
resource->write(buffer,size,flags);
287 auto buffer = (
void*)
args->arg1;
294 args->return_value = 0;
350 thread->thread_state = ThreadState::STOPPED;
static Logger & Out()
Gets the active logger.
static Logger INFO()
Gets active logger set to info level.
static Logger ERROR()
Gets active logger set to ERROR level.
Stores the left, top, width and height of a rectangle.
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 BaseResourceRegistry * get_registry(resource_type_t type)
Gets a registry of a type.
static Scheduler * core_scheduler()
Gets the scheduler for the currently executing core.
static Process * get_process(uint64_t pid)
Gets a process on the currently executing core by its PID.
static system::cpu_status_t * yield(system::cpu_status_t *current)
Pass execution to the next thread.
static GlobalScheduler * system_scheduler()
Gets the system scheduler.
static Process * current_process()
Gets the process on the currently executing core.
static Thread * get_thread(uint64_t tid)
Gets a thread on the currently executing core by its TID.
static Thread * current_thread()
Gets the thread on the currently executing core.
A process that can be scheduled by the Scheduler, wraps & manages threads as well as its own address ...
The execution context of a sub-process thread.
static syscall_args_t * syscall_thread_sleep(syscall_args_t *args)
System call to sleep the current process.
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_close_process(syscall_args_t *args)
System call to close a process.
static syscall_args_t * syscall_resource_open(syscall_args_t *args)
System call to open a resource.
static syscall_args_t * syscall_thread_close(syscall_args_t *args)
System call to close a thread.
static syscall_args_t * syscall_thread_yield(syscall_args_t *args)
System call to yield the current process.
SyscallManager()
Construct a new Syscall Manager object and register the syscall handlers. Registers to interrupt 0x80...
void remove_syscall_handler(::syscore::SyscallType syscall)
Removes a syscall handler from the manager.
void set_syscall_handler(::syscore::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.
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...
The arguments passed to a syscall (simplified representation of values in registers)
Defines the SyscallManager class for handling system calls from userspace applications.