Skip to content

how do we pass arguments? They should be present on the stack at this point, bu... #15

@github-actions

Description

@github-actions

https://github.com/hyperfocusaurus/cottage/blob/04f57205228261ac811daa99ba8b13c845c7b807/kernel/src/sys/syscall.c#L21


#include "syscall.h"
#include <panic.h>
#include <klog/klog.h>
#include <proc/proc.h>

#define SYSCALL_NUM_ENTRIES 1

typedef void (*syscall_fn_t)();

syscall_fn_t syscall_table[SYSCALL_NUM_ENTRIES];

void syscall_entry()
{
    // get syscall number from current thread
    thread_t* current_thread = get_current_thread();
    if (current_thread->syscall_num >= SYSCALL_NUM_ENTRIES) {
        // todo: probably shouldn't panic?
        panic("Unrecognised syscall %d", current_thread->syscall_num);
    } else {
        // call the entry from the syscall table
        // todo: how do we pass arguments?  They should be present on the stack at this point, but uh...
        syscall_table[current_thread->syscall_num]();
    }
}

void syscall_init()
{
    syscall_table[SYS_KLOG] = (syscall_fn_t) syscall_klog;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions