From c63f340d90800895f007de64b7d2d14624263331 Mon Sep 17 00:00:00 2001 From: nthnluu Date: Sun, 28 Jan 2024 21:20:27 -0500 Subject: Created student weenix repository --- user/include/weenix/config.h | 1 + user/include/weenix/debug.h | 12 ++++++++++++ user/include/weenix/syscall.h | 1 + user/include/weenix/trap.h | 26 ++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 120000 user/include/weenix/config.h create mode 100644 user/include/weenix/debug.h create mode 120000 user/include/weenix/syscall.h create mode 100644 user/include/weenix/trap.h (limited to 'user/include/weenix') diff --git a/user/include/weenix/config.h b/user/include/weenix/config.h new file mode 120000 index 0000000..a92e33c --- /dev/null +++ b/user/include/weenix/config.h @@ -0,0 +1 @@ +../../../kernel/include/config.h \ No newline at end of file diff --git a/user/include/weenix/debug.h b/user/include/weenix/debug.h new file mode 100644 index 0000000..a30641e --- /dev/null +++ b/user/include/weenix/debug.h @@ -0,0 +1,12 @@ +#include "stdio.h" + +int debug(const char *str); + +#define dbg(fmt, args...) \ + do \ + { \ + char temp[2048]; \ + snprintf(temp, sizeof(temp), "%s:%d %s(): " fmt, __FILE__, __LINE__, \ + __func__, ##args); \ + debug(temp); \ + } while (0); diff --git a/user/include/weenix/syscall.h b/user/include/weenix/syscall.h new file mode 120000 index 0000000..0a85ee5 --- /dev/null +++ b/user/include/weenix/syscall.h @@ -0,0 +1 @@ +../../../kernel/include/api/syscall.h \ No newline at end of file diff --git a/user/include/weenix/trap.h b/user/include/weenix/trap.h new file mode 100644 index 0000000..fade1eb --- /dev/null +++ b/user/include/weenix/trap.h @@ -0,0 +1,26 @@ +#pragma once + +#include "errno.h" +#include "stddef.h" +#include "sys/types.h" +#include "weenix/syscall.h" + +#define TRAP_INTR_STRING QUOTE(INTR_SYSCALL) + +/* ssize_t will be 32 bits or 64 bits wide as appropriate. + args are passed via %(r/e)ax and %(r/e)dx, so they need + to be the size of a register. */ + +static inline ssize_t trap(ssize_t num, ssize_t arg) +{ + ssize_t ret; + __asm__ volatile("int $" TRAP_INTR_STRING + : "=a"(ret) + : "a"(num), "d"(arg)); + + /* Copy in errno */ + __asm__ volatile("int $" TRAP_INTR_STRING + : "=a"(errno) + : "a"(SYS_errno)); + return ret; +} -- cgit v1.2.3-70-g09d2