Files
mop3/libu/system.c
kamkow1 6298251e66
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 1m31s
Build documentation / build-and-deploy (push) Successful in 39s
Remove mail IPC subsystsem
2026-04-30 21:42:00 +02:00

119 lines
4.2 KiB
C

#include <stddef.h>
#include <stdint.h>
#include <syscall.h>
#include <system.h>
#define do_syscall1(id, a1, a2, a3, a4, a5, a6, ...) \
syscall(id, (uintptr_t)a1, (uintptr_t)a2, (uintptr_t)a3, (uintptr_t)a4, (uintptr_t)a5, \
(uintptr_t)a6)
#define do_syscall(...) do_syscall1(__VA_ARGS__, 0, 0, 0, 0, 0, 0)
int quit(void) { return do_syscall(SYS_QUIT, 0); }
int test(char c) { return do_syscall(SYS_TEST, c); }
int sched(void) { return do_syscall(SYS_SCHED, 0); }
void* map(uintptr_t vaddr, size_t pages, uint32_t flags) {
return (void*)do_syscall(SYS_MAP, vaddr, pages, flags);
}
int unmap(uintptr_t vaddr, size_t pages) { return do_syscall(SYS_UNMAP, vaddr, pages); }
int clone(uintptr_t vstack_top, void (*entry)(void), void* argument_ptr) {
return do_syscall(SYS_CLONE, vstack_top, entry, argument_ptr);
}
int mutex_create(void) { return do_syscall(SYS_MUTEX_CREATE, 0); }
int mutex_delete(int mutex_rid) { return do_syscall(SYS_MUTEX_DELETE, mutex_rid); }
int mutex_lock(int mutex_rid) { return do_syscall(SYS_MUTEX_LOCK, mutex_rid); }
int mutex_unlock(int mutex_rid) { return do_syscall(SYS_MUTEX_UNLOCK, mutex_rid); }
void* argument_ptr(void) { return (void*)do_syscall(SYS_ARGUMENT_PTR, 0); }
int device_do(const char* device_key, int cmd, void* a1, void* a2, void* a3, void* a4) {
return (int)do_syscall(SYS_DEVICE_DO, device_key, cmd, a1, a2, a3, a4);
}
int exec(const char* volume, const char* path, const char* cmdline) {
return (int)do_syscall(SYS_EXEC, volume, path, cmdline);
}
int volume_open(const char* volume) { return (int)do_syscall(SYS_VOLUME_OPEN, volume); }
int volume_close(void) { return (int)do_syscall(SYS_VOLUME_CLOSE, 0); }
int read_file(const char* path, size_t off, uint8_t* buffer, size_t size) {
return (int)do_syscall(SYS_READ_FILE, path, off, buffer, size);
}
int describe(const char* path, struct desc* desc) {
return (int)do_syscall(SYS_DESCRIBE, path, desc);
}
int get_procgroup(int pid) { return (int)do_syscall(SYS_GET_PROCGROUP, pid); }
int get_exec_pid(void) { return (int)do_syscall(SYS_GET_EXEC_PID, 0); }
int read_dir_entry(const char* path, struct dir_entry* entry, size_t entry_num) {
return (int)do_syscall(SYS_READ_DIR_ENTRY, path, entry, entry_num);
}
int create_file(const char* path) { return (int)do_syscall(SYS_CREATE_FILE, path); }
int write_file(const char* path, size_t off, uint8_t* buffer, size_t size, uint32_t flags) {
return (int)do_syscall(SYS_WRITE_FILE, path, off, buffer, size, flags);
}
int wait_for_pid(int pid) { return (int)do_syscall(SYS_WAIT_FOR_PID, pid); }
int kill(int pid) { return (int)do_syscall(SYS_KILL, pid); }
int create_dir(const char* path) { return (int)do_syscall(SYS_CREATE_DIR, path); }
int remove(const char* path) { return (int)do_syscall(SYS_REMOVE, path); }
int create_volume(const char* key, int fs_type, const char* device_key) {
return (int)do_syscall(SYS_CREATE_VOLUME, key, fs_type, device_key);
}
int exec_partial(const char* volume, const char* path, const char* cmdline) {
return (int)do_syscall(SYS_EXEC_PARTIAL, volume, path, cmdline);
}
int exec_partial_fini(int pid) { return (int)do_syscall(SYS_EXEC_PARTIAL_FINI, pid); }
int get_self_pid(void) { return (int)do_syscall(SYS_GET_SELF_PID, 0); }
int stream_write(int pgid, int rid, void* buffer, size_t size) {
return (int)do_syscall(SYS_STREAM_WRITE, pgid, rid, buffer, size);
}
int stream_read(int rid, void* buffer, size_t size) {
return (int)do_syscall(SYS_STREAM_READ, rid, buffer, size);
}
int get_proc_info(struct proc_info* infos, size_t count) {
return (int)do_syscall(SYS_GET_PROC_INFO, infos, count);
}
int get_device_info(struct device_info* infos, size_t count) {
return (int)do_syscall(SYS_GET_DEVICE_INFO, infos, count);
}
int get_volume_info(struct volume_info* infos, size_t count) {
return (int)do_syscall(SYS_GET_VOLUME_INFO, infos, count);
}
int volume_delete(const char* key) { return (int)do_syscall(SYS_VOLUME_DELETE, key); }
int date_time(struct date_time* dt) { return (int)do_syscall(SYS_DATE_TIME, dt); }
const char* get_cmdline(void) { return (const char*)do_syscall(SYS_GET_CMDLINE, 0); }
int proc_is_alive(int pid) { return (int)do_syscall(SYS_PROC_IS_ALIVE, pid); }