Renamed some syscalls

This commit is contained in:
2023-11-08 14:15:46 -06:00
parent c5ef8c53a7
commit 31f7eb34a6
8 changed files with 265 additions and 165 deletions

View File

@@ -9,6 +9,7 @@
#include "types/status.h"
#include "types/pid.h"
#include "types/oid.h"
#include "types/sighandler.h"
#include <libmalloc/memmap.h>
#include <stddef.h>
@@ -24,8 +25,6 @@
#define IO_PORT 1 << 1
#define IO_MAILBOX 2 << 1
typedef unsigned long (*signal_handler_t)(void*, void*);
struct process_context_t;
struct module_t
@@ -54,7 +53,7 @@ struct message_t
void kernel_initialize(struct boot_info_t *boot_info);
error_t kernel_set_syscall(int id, int arg_count, pid_t pid, void *func_ptr);
error_t kernel_set_syscall(int id, int arg_count, void *func_ptr);
size_t kernel_do_syscall(syscall_id_t id, syscall_arg_t arg1, syscall_arg_t arg2, syscall_arg_t arg3, void *pc, void *stack, unsigned long flags);

View File

@@ -1,5 +1,5 @@
#ifndef _QUARK_SYSCALLS_H
#define _QUARK_SYSCALLS_S
#define _QUARK_SYSCALLS_H
#include <types/syscallarg.h>
#include <types/syscallid.h>
@@ -26,7 +26,7 @@ static inline int mmap(void *addr, unsigned long length, long flags)
arg1.ptr = addr;
arg2.unsigned_int = length;
arg3.signed_int = flags;
return (int) _do_syscall(SYSCALL_MMAP, arg1, arg2, arg3);
return (int) _do_syscall(SYSCALL_MAP_ANON, arg1, arg2, arg3);
}
static inline int munmap(void *addr, unsigned long length)
@@ -37,7 +37,7 @@ static inline int munmap(void *addr, unsigned long length)
arg1.ptr = addr;
arg2.unsigned_int = length;
arg3.unsigned_int = 0UL;
return (int) _do_syscall(SYSCALL_MUNMAP, arg1, arg2, arg3);
return (int) _do_syscall(SYSCALL_UNMAP_ANON, arg1, arg2, arg3);
}
static inline int map_physical(void *addr, physaddr_t phys_addr, unsigned long length)

View File

@@ -1,16 +1,23 @@
#pragma once
#ifndef QUARK_SYSCALL_DEF_H
#define QUARK_SYSCALL_DEF_H
#include "types/syscallarg.h"
#include "types/sigaction.h"
#include "types/pid.h"
#include "types/oid.h"
#include "types/syscallret.h"
#include <stdbool.h>
#include <stddef.h>
typedef size_t (*syscall_ptr_0_t)();
extern void *syscall_table[];
typedef size_t (*syscall_ptr_1_t)(syscall_arg_t);
typedef syscallret_t (*syscall_ptr_0_t)();
typedef size_t (*syscall_ptr_2_t)(syscall_arg_t, syscall_arg_t);
typedef syscallret_t (*syscall_ptr_1_t)(syscall_arg_t);
typedef size_t (*syscall_ptr_3_t)(syscall_arg_t, syscall_arg_t, syscall_arg_t);
typedef syscallret_t (*syscall_ptr_2_t)(syscall_arg_t, syscall_arg_t);
typedef syscallret_t (*syscall_ptr_3_t)(syscall_arg_t, syscall_arg_t, syscall_arg_t);
struct syscall_t
{
@@ -26,28 +33,106 @@ struct syscall_t
};
};
size_t test_syscall(syscall_arg_t str);
/**
* @brief Outputs the given string from kernel mode.
*
* @param str The string to output.
*/
syscallret_t test_syscall(syscall_arg_t str);
size_t syscall_mmap(syscall_arg_t location, syscall_arg_t length, syscall_arg_t flags);
/**
*
*/
syscallret_t syscall_map_anon(syscall_arg_t location, syscall_arg_t length, syscall_arg_t flags);
size_t syscall_munmap(syscall_arg_t location, syscall_arg_t length);
/**
*
*/
syscallret_t syscall_unmap_anon(syscall_arg_t location, syscall_arg_t length);
size_t syscall_map_physical(syscall_arg_t arg_addr, syscall_arg_t arg_phys_addr, syscall_arg_t arg_length);
/**
*
*/
syscallret_t syscall_map_physical(syscall_arg_t arg_addr, syscall_arg_t arg_phys_addr, syscall_arg_t arg_length);
size_t syscall_unmap_physical(syscall_arg_t arg_addr, syscall_arg_t arg_length);
/**
*
*/
syscallret_t syscall_unmap_physical(syscall_arg_t arg_addr, syscall_arg_t arg_length);
size_t syscall_terminate_self();
/**
*
*/
syscallret_t syscall_open_port(syscall_arg_t id);
size_t syscall_create_object();
/**
*
*/
syscallret_t syscall_close_port(syscall_arg_t id);
size_t syscall_aquire_object();
/**
*
*/
syscallret_t syscall_send_pid(syscall_arg_t recipient, syscall_arg_t message, syscall_arg_t flags);
size_t syscall_release_object();
/**
*
*/
syscallret_t syscall_send_port(syscall_arg_t recipient, syscall_arg_t message, syscall_arg_t flags);
size_t syscall_send(syscall_arg_t recipient, syscall_arg_t message, syscall_arg_t flags);
/**
*
*/
syscallret_t syscall_receive(syscall_arg_t buffer, syscall_arg_t flags);
size_t syscall_receive(syscall_arg_t buffer, syscall_arg_t flags);
/**
*
*/
syscallret_t syscall_create_object(void *location, size_t size, int flags);
size_t syscall_open_port(syscall_arg_t id);
/**
*
*/
syscallret_t syscall_aquire_object(oid_t id, void *location);
size_t syscall_close_port(syscall_arg_t id);
/**
*
*/
syscallret_t syscall_release_object(oid_t id);
/**
*
*/
syscallret_t syscall_get_pid();
/**
*
*/
syscallret_t syscall_clone(void (*entry)(void*), void *arg, void *stack, int flags);
/**
*
*/
syscallret_t syscall_signal_action(int id, struct signal_action_t *action, int flags);
/**
*
*/
syscallret_t syscall_signal_return();
/**
*
*/
syscallret_t syscall_signal_raise(pid_t pid, int sigid);
/**
*
*/
syscallret_t syscall_intr_action(int id, struct signal_action_t *action, int flags);
/**
*
*/
syscallret_t syscall_intr_return();
#endif

View File

@@ -4,16 +4,25 @@
typedef enum
{
SYSCALL_TEST = 1,
SYSCALL_MMAP,
SYSCALL_MUNMAP,
SYSCALL_MAP_ANON,
SYSCALL_UNMAP_ANON,
SYSCALL_MAP_PHYS,
SYSCALL_UNMAP_PHYS,
SYSCALL_YIELD,
SYSCALL_EXIT,
SYSCALL_SEND,
SYSCALL_RECEIVE,
SYSCALL_OPEN_PORT,
SYSCALL_CLOSE_PORT
SYSCALL_CLOSE_PORT,
SYSCALL_SEND_PID,
SYSCALL_SEND_PORT,
SYSCALL_RECEIVE,
SYSCALL_CREATE_OBJECT,
SYSCALL_AQUIRE_OBJECT,
SYSCALL_RELEASE_OBJECT,
SYSCALL_GET_PID,
SYSCALL_CLONE,
SYSCALL_SIGNAL_ACTION,
SYSCALL_SIGNAL_RETURN,
SYSCALL_SIGNAL_RAISE,
SYSCALL_INTR_ACTION,
SYSCALL_INTR_RETURN
} syscall_id_t;
#endif