[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 2/2] Syscalls: Reimplementieren der Syscall-Aufrufe



* Dieser Commit reimplementiert alle Syscall-Aufrufe mithilfe den
  neuen allgemeinen Syscall-Funktionen.

Signed-off-by: Nico Mayer <mayerNico256@xxxxxxxxx>
---
 src/modules/lib/syscalls/add_intr_handler.c |  10 +-
 src/modules/lib/syscalls/create_process.c   |  42 ++--
 src/modules/lib/syscalls/create_thread.c    |  18 +-
 src/modules/lib/syscalls/debug.c            |   9 +-
 src/modules/lib/syscalls/enumerate_tasks.c  |   7 +-
 src/modules/lib/syscalls/get_phys_addr.c    |   8 +-
 src/modules/lib/syscalls/get_tick_count.c   |   9 +-
 src/modules/lib/syscalls/get_uid.c          |  11 +-
 src/modules/lib/syscalls/init_child_page.c  |  34 +--
 src/modules/lib/syscalls/lio_server.c       |  83 ++-----
 src/modules/lib/syscalls/lostio.c           | 240 ++++----------------
 src/modules/lib/syscalls/mem_allocate.c     |  41 +---
 src/modules/lib/syscalls/memory_info.c      |   6 +-
 src/modules/lib/syscalls/mutex.c            |  17 +-
 src/modules/lib/syscalls/ports.c            |  31 +--
 src/modules/lib/syscalls/puts.c             |  39 +++-
 src/modules/lib/syscalls/pv.c               |  45 +++-
 src/modules/lib/syscalls/rpc.c              |  23 +-
 src/modules/lib/syscalls/set_rpc_handler.c  |  38 +++-
 src/modules/lib/syscalls/shared_memory.c    |  59 +++--
 src/modules/lib/syscalls/sleep.c            |   8 +-
 src/modules/lib/syscalls/timer.c            |  12 +-
 src/modules/lib/syscalls/unblock_process.c  |  39 +++-
 src/modules/lib/syscalls/vm86.c             |  20 +-
 src/modules/lib/syscalls/wait_for_rpc.c     |  42 +++-
 25 files changed, 348 insertions(+), 543 deletions(-)

diff --git a/src/modules/lib/syscalls/add_intr_handler.c b/src/modules/lib/syscalls/add_intr_handler.c
index 0f1a1bed..d730329c 100644
--- a/src/modules/lib/syscalls/add_intr_handler.c
+++ b/src/modules/lib/syscalls/add_intr_handler.c
@@ -28,13 +28,11 @@
 
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 void add_intr_handler(uint32_t intr)
 {
-    asm(
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : : "i" (SYSCALL_ADD_INTERRUPT_HANDLER), "r" (intr));
+    int result;
+
+    SYSCALL1(SYSCALL_ADD_INTERRUPT_HANDLER, intr, result);
 }
diff --git a/src/modules/lib/syscalls/create_process.c b/src/modules/lib/syscalls/create_process.c
index 7774b208..2f0c58b5 100644
--- a/src/modules/lib/syscalls/create_process.c
+++ b/src/modules/lib/syscalls/create_process.c
@@ -28,7 +28,7 @@
 
 #include <stdint.h>
 #include "syscall.h"
-
+#include "syscallx.h"
 
 /**
  * Prozessnummer des aktuellen Prozesses abfragen.
@@ -38,11 +38,9 @@
 pid_t get_pid()
 {
     pid_t pid;
-    asm(
-        "mov %1, %%eax;"
-        "int $0x30;"
-        : "=a" (pid) : "i" (SYSCALL_PM_GET_PID));
-    
+
+    SYSCALL0(SYSCALL_PM_GET_PID, pid);
+
     return pid;
 }
 
@@ -55,12 +53,9 @@ pid_t get_pid()
 pid_t get_parent_pid(pid_t pid)
 {
     pid_t result;
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "addl $4, %%esp;"
-        : "=a" (result) : "i" (SYSCALL_PM_GET_PARENT_PID), "r" (pid));
+
+    SYSCALL1(SYSCALL_PM_GET_PARENT_PID, pid, result);
+
     return result;
 }
 
@@ -86,15 +81,8 @@ pid_t create_process(uint32_t initial_eip, uid_t uid, const char* args,
 {
     pid_t pid;
 
-    asm(
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-        : "=a" (pid) : "i" (SYSCALL_PM_CREATE_PROCESS), "r" (initial_eip), "r" (uid), "r" (args), "r" (parent));
+    SYSCALL4(SYSCALL_PM_CREATE_PROCESS, initial_eip, uid, args, parent, pid);
+
     return pid;
 }
 
@@ -105,9 +93,9 @@ pid_t create_process(uint32_t initial_eip, uid_t uid, const char* args,
  */
 void destroy_process()
 {
-    asm(    "mov %0, %%eax;"
-            "int $0x30;"
-        : : "i" (SYSCALL_PM_EXIT_PROCESS));
+    int result;
+
+    SYSCALL0(SYSCALL_PM_EXIT_PROCESS, result);
 }
 
 
@@ -121,10 +109,8 @@ void destroy_process()
 char* get_cmdline()
 {
     char* result;
-    asm(
-        "mov %1, %%eax;"
-        "int $0x30;"
-        : "=a" (result) : "i" (SYSCALL_PM_GET_CMDLINE));
+
+    SYSCALL0(SYSCALL_PM_GET_CMDLINE, result);
 
     return result;
 }
diff --git a/src/modules/lib/syscalls/create_thread.c b/src/modules/lib/syscalls/create_thread.c
index 5789df58..f1adcd4f 100644
--- a/src/modules/lib/syscalls/create_thread.c
+++ b/src/modules/lib/syscalls/create_thread.c
@@ -29,6 +29,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 /**
  * ID des aktuellen Threads abfragen.
@@ -84,27 +85,20 @@ tid_t create_thread(uint32_t start, void *arg)
 {
     tid_t tid;
 
+    // Speicher wird durch die Funktion ct_start wieder freigegeben
     ct_parameter_t *ct_arg = malloc(sizeof(ct_parameter_t));
 
     ct_arg->func = (void *(*)(void *))start;
     ct_arg->arg = arg;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x08, %%esp;"
-        : "=a" (tid)
-        : "i" (SYSCALL_PM_CREATE_THREAD), "r" (ct_start), "r" (ct_arg));
+    SYSCALL2(SYSCALL_PM_CREATE_THREAD, ct_start, ct_arg, tid);
 
     return tid;
 }
 
 void exit_thread(void)
 {
-    asm(
-        "mov %0, %%eax;"
-        "int $0x30;"
-        : : "i" (SYSCALL_PM_EXIT_THREAD));
+    int result;
+
+    SYSCALL0(SYSCALL_PM_EXIT_THREAD, result);
 }
diff --git a/src/modules/lib/syscalls/debug.c b/src/modules/lib/syscalls/debug.c
index 26f82c20..fc930f51 100644
--- a/src/modules/lib/syscalls/debug.c
+++ b/src/modules/lib/syscalls/debug.c
@@ -27,6 +27,7 @@
  */
 #include <types.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 /**
  * Stackbacktrace eines Tasks zu Debugging-Zwecken anzeigen
@@ -35,10 +36,8 @@
  */
 void syscall_debug_stacktrace(pid_t pid)
 {
-    asm("push %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp" 
-    : : "i" (SYSCALL_DEBUG_STACKTRACE) , "r" (pid));
+    int result;
+
+    SYSCALL1(SYSCALL_DEBUG_STACKTRACE, pid, result);
 }
 
diff --git a/src/modules/lib/syscalls/enumerate_tasks.c b/src/modules/lib/syscalls/enumerate_tasks.c
index dc051219..19d36cbc 100644
--- a/src/modules/lib/syscalls/enumerate_tasks.c
+++ b/src/modules/lib/syscalls/enumerate_tasks.c
@@ -28,14 +28,13 @@
 
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 task_info_t* enumerate_tasks()
 {
     uint32_t addr;
-    asm(
-        "mov %1, %%eax;"
-        "int $0x30;"
-    : "=a" (addr) : "i" (SYSCALL_PM_ENUMERATE_TASKS));
+
+    SYSCALL0(SYSCALL_PM_ENUMERATE_TASKS, addr);
 
     return (task_info_t*) addr;
 }
diff --git a/src/modules/lib/syscalls/get_phys_addr.c b/src/modules/lib/syscalls/get_phys_addr.c
index 5ce0e884..aef1da4c 100644
--- a/src/modules/lib/syscalls/get_phys_addr.c
+++ b/src/modules/lib/syscalls/get_phys_addr.c
@@ -27,17 +27,13 @@
  */
 
 #include <syscall.h>
+#include "syscallx.h"
 
 void* get_phys_addr(void* address)
 {
     void* ptr;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (ptr) : "i" (SYSCALL_MEM_RESOLVE_VADDR), "r" (address));
+    SYSCALL1(SYSCALL_MEM_RESOLVE_VADDR, address, ptr);
 
     return ptr;
 }
diff --git a/src/modules/lib/syscalls/get_tick_count.c b/src/modules/lib/syscalls/get_tick_count.c
index fa07b06a..28df625a 100644
--- a/src/modules/lib/syscalls/get_tick_count.c
+++ b/src/modules/lib/syscalls/get_tick_count.c
@@ -28,16 +28,13 @@
 
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 uint64_t get_tick_count()
 {
     uint32_t eax, edx;
-    asm(
-        "mov %2, %%eax;"
-        "int $0x30;"
-        : "=a" (eax), "=d" (edx) : "i" (SYSCALL_GET_TICK_COUNT));
-    
+
+    SYSCALL0_TWO_RESULTS(SYSCALL_GET_TICK_COUNT, eax, edx);
 
     return (uint64_t)((uint64_t)eax | ((uint64_t)edx << 32));
 }
-                                                        
diff --git a/src/modules/lib/syscalls/get_uid.c b/src/modules/lib/syscalls/get_uid.c
index 3b335010..519279cc 100644
--- a/src/modules/lib/syscalls/get_uid.c
+++ b/src/modules/lib/syscalls/get_uid.c
@@ -28,16 +28,13 @@
 
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
-uint32_t get_uid(uint32_t pid) {
+uint32_t get_uid(uint32_t pid)
+{
     uint32_t uid;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (uid) : "i" (SYSCALL_PM_GET_UID), "r" (pid));
+    SYSCALL1(SYSCALL_PM_GET_UID, pid, uid);
 
     return uid;
 }
diff --git a/src/modules/lib/syscalls/init_child_page.c b/src/modules/lib/syscalls/init_child_page.c
index 43148cea..5390fd0c 100644
--- a/src/modules/lib/syscalls/init_child_page.c
+++ b/src/modules/lib/syscalls/init_child_page.c
@@ -27,46 +27,28 @@
  */
 
 #include "syscall.h"
+#include "syscallx.h"
 
 
 void init_child_page (pid_t pid, void* dest, void* src, size_t size)
 {
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-    : : "i" (SYSCALL_PM_INIT_PAGE), "r"(pid), "r" (dest), "r" (src), "r" (size));
+    int result;
+
+    SYSCALL4(SYSCALL_PM_INIT_PAGE, pid, dest, src, size, result);
 }
 
 void init_child_page_copy (pid_t pid, void* dest, void* src, size_t size)
 {
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-    : : "i" (SYSCALL_PM_INIT_PAGE_COPY), "r"(pid), "r" (dest), "r" (src), "r" (size));
+    int result;
+
+    SYSCALL4(SYSCALL_PM_INIT_PAGE_COPY, pid, dest, src, size, result);
 }
 
 int init_child_ppb(pid_t pid, int shm)
 {
     int ret;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x08, %%esp;"
-    : "=a" (ret)
-    : "i" (SYSCALL_PM_INIT_PROC_PARAM_BLOCK), "r"(pid), "r" (shm));
+    SYSCALL2(SYSCALL_PM_INIT_PROC_PARAM_BLOCK, pid, shm, ret);
 
     return ret;
 }
diff --git a/src/modules/lib/syscalls/lio_server.c b/src/modules/lib/syscalls/lio_server.c
index 6079f536..b6ba0f50 100644
--- a/src/modules/lib/syscalls/lio_server.c
+++ b/src/modules/lib/syscalls/lio_server.c
@@ -28,6 +28,7 @@
 
 #include <string.h>
 #include <syscall.h>
+#include "syscallx.h"
 
 /**
  * Neuen LIO-Service registrieren.
@@ -43,20 +44,10 @@
 int lio_srv_service_register(const char* name, void* buffer, size_t size)
 {
     int result;
-    size_t name_len;
+    size_t name_len = strlen(name);
 
-    name_len = strlen(name);
-    asm volatile(
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-        : "=a" (result)
-        : "i" (SYSCALL_LIO_SRV_SERVICE_REGISTER), "r" (name), "r" (name_len),
-          "r" (buffer), "r" (size));
+    SYSCALL4(SYSCALL_LIO_SRV_SERVICE_REGISTER,
+             name, name_len, buffer, size, result);
 
     return result;
 }
@@ -78,17 +69,7 @@ int lio_srv_tree_set_ring(lio_usp_tree_t tree, tid_t tid,
 {
     int result;
 
-    asm volatile(
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-        : "=a" (result)
-        : "i" (SYSCALL_LIO_SRV_TREE_SET_RING), "r" (&tree),
-          "r" (tid), "r" (buffer), "r" (size) : "memory");
+    SYSCALL4(SYSCALL_LIO_SRV_TREE_SET_RING, &tree, tid, buffer, size, result);
 
     return result;
 }
@@ -102,13 +83,7 @@ int lio_srv_res_upload(struct lio_server_resource* resource)
 {
     int result;
 
-    asm volatile(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-        : "=a" (result)
-        : "i" (SYSCALL_LIO_SRV_RES_UPLOAD), "r" (resource));
+    SYSCALL1(SYSCALL_LIO_SRV_RES_UPLOAD, resource, result);
 
     return result;
 }
@@ -127,17 +102,9 @@ int lio_srv_node_add(lio_usp_resource_t parent, lio_usp_resource_t resource,
     size_t name_len;
 
     name_len = strlen(name);
-    asm volatile(
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-        : "=a" (result)
-        : "i" (SYSCALL_LIO_SRV_NODE_ADD), "r" (&parent), "r" (&resource),
-          "r" (name), "r" (name_len) : "memory");
+
+    SYSCALL4(SYSCALL_LIO_SRV_NODE_ADD, &parent,
+             &resource, name, name_len, result);
 
     return result;
 }
@@ -156,16 +123,8 @@ int lio_srv_node_remove(lio_usp_resource_t parent, const char* name)
     size_t name_len;
 
     name_len = strlen(name);
-    asm volatile(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0xc, %%esp;"
-        : "=a" (result)
-        : "i" (SYSCALL_LIO_SRV_NODE_REMOVE), "r" (&parent), "r" (name),
-          "r" (name_len) : "memory");
+
+    SYSCALL3(SYSCALL_LIO_SRV_NODE_REMOVE, &parent, name, name_len, result);
 
     return result;
 
@@ -179,16 +138,9 @@ int lio_srv_node_remove(lio_usp_resource_t parent, const char* name)
  */
 void lio_srv_op_done(struct lio_op* op, int status, uint64_t result)
 {
-    asm volatile(
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x0c, %%esp;"
-        : : "i" (SYSCALL_LIO_SRV_OP_DONE),
-            "r" (op), "r" (status), "r" (&result)
-        : "memory");
+    int ret;
+
+    SYSCALL3(SYSCALL_LIO_SRV_OP_DONE, op, status, &result, ret);
 }
 
 /**
@@ -197,8 +149,7 @@ void lio_srv_op_done(struct lio_op* op, int status, uint64_t result)
  */
 void lio_srv_wait(void)
 {
-    asm volatile(
-        "mov %0, %%eax;"
-        "int $0x30;"
-        :: "i" (SYSCALL_LIO_SRV_WAIT));
+    int result;
+
+    SYSCALL0(SYSCALL_LIO_SRV_WAIT, result);
 }
diff --git a/src/modules/lib/syscalls/lostio.c b/src/modules/lib/syscalls/lostio.c
index decbcb35..edba44a0 100644
--- a/src/modules/lib/syscalls/lostio.c
+++ b/src/modules/lib/syscalls/lostio.c
@@ -28,6 +28,7 @@
 
 #include <syscall.h>
 #include <string.h>
+#include "syscallx.h"
 
 /**
  * Sucht eine Ressource anhand eines Pfads und gibt ihre ID zurück.
@@ -43,20 +44,14 @@
  */
 lio_resource_t lio_resource(const char* path, bool follow_symlink)
 {
+    int ret;
     volatile lio_resource_t result;
     size_t len;
 
     len = strlen(path) + 1;
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-    : : "i" (SYSCALL_LIO_RESOURCE), "r" (path), "r" (len),
-        "r" ((uint32_t) follow_symlink), "r" (&result) : "memory");
+
+    SYSCALL4(SYSCALL_LIO_RESOURCE, path, len,
+             (uint32_t)follow_symlink, &result, ret);
 
     return result;
 }
@@ -78,17 +73,7 @@ int lio_pipe(lio_stream_t* reader, lio_stream_t* writer, bool bidirectional)
     volatile lio_stream_t wr;
     int result;
 
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0xc, %%esp;"
-    : "=a" (result)
-    : "i" (SYSCALL_LIO_PIPE), "r" (&rd), "r" (&wr),
-      "r" ((uint32_t) bidirectional)
-    : "memory");
+    SYSCALL3(SYSCALL_LIO_PIPE, &rd, &wr, (uint32_t)bidirectional, result);
 
     if (result == 0) {
         *reader = rd;
@@ -111,17 +96,10 @@ int lio_pipe(lio_stream_t* reader, lio_stream_t* writer, bool bidirectional)
  */
 lio_stream_t lio_open(lio_resource_t resource, int flags)
 {
+    int ret;
     volatile lio_stream_t result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0xc, %%esp;"
-    : : "i" (SYSCALL_LIO_OPEN), "r" (&resource), "r" (flags), "r" (&result)
-    : "memory");
+    SYSCALL3(SYSCALL_LIO_OPEN, &resource, flags, &result, ret);
 
     return result;
 }
@@ -137,17 +115,7 @@ lio_stream_t lio_composite_stream(lio_stream_t read, lio_stream_t write)
     volatile lio_stream_t composite;
     int result;
 
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0xc, %%esp;"
-    : "=a" (result)
-    : "i" (SYSCALL_LIO_COMPOSITE_STREAM), "r" (&read), "r" (&write),
-      "r" (&composite)
-    : "memory");
+    SYSCALL3(SYSCALL_LIO_COMPOSITE_STREAM, &read, &write, &composite, result);
 
     if (result < 0) {
         return result;
@@ -170,14 +138,7 @@ int lio_stat(lio_resource_t resource, struct lio_stat* sbuf)
 {
     int result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a" (result) : "i" (SYSCALL_LIO_STAT), "r" (&resource), "r" (sbuf)
-    : "memory");
+    SYSCALL2(SYSCALL_LIO_STAT, &resource, sbuf, result);
 
     return result;
 }
@@ -199,14 +160,7 @@ lio_stream_t lio_dup(lio_stream_t source, lio_stream_t dest)
     volatile lio_stream_t d = dest;
     int result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a" (result) : "i" (SYSCALL_LIO_DUP), "r" (&source), "r" (&d)
-    : "memory");
+    SYSCALL2(SYSCALL_LIO_DUP, &source, &d, result);
 
     if (result < 0) {
         return result;
@@ -225,12 +179,7 @@ int lio_close(lio_stream_t s)
 {
     int result;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (result): "i" (SYSCALL_LIO_CLOSE), "r" (&s) : "memory");
+    SYSCALL1(SYSCALL_LIO_CLOSE, &s, result);
 
     return result;
 }
@@ -253,14 +202,7 @@ lio_stream_t lio_pass_fd(lio_stream_t s, pid_t pid)
     volatile lio_stream_t stream = s;
     int result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a" (result) : "i" (SYSCALL_LIO_PASS_FD), "r" (&stream), "r" (pid)
-    : "memory");
+    SYSCALL2(SYSCALL_LIO_PASS_FD, &stream, pid, result);
 
     if (result < 0) {
         return result;
@@ -284,12 +226,7 @@ int lio_stream_origin(lio_stream_t s)
 {
     int result;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (result): "i" (SYSCALL_LIO_STREAM_ORIGIN), "r" (&s) : "memory");
+    SYSCALL1(SYSCALL_LIO_STREAM_ORIGIN, &s, result);
 
     return result;
 }
@@ -298,19 +235,9 @@ ssize_t lio_readf(lio_stream_t s, uint64_t offset, size_t bytes,
     void* buf, int flags)
 {
     volatile ssize_t result;
+    int ret;
 
-    asm(
-        "pushl %6;"
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x18, %%esp;"
-    : : "i" (SYSCALL_LIO_READ), "r" (&s), "r" (&offset), "r" (bytes),
-        "r" (buf), "r" (flags), "g" (&result) : "memory");
+    SYSCALL6(SYSCALL_LIO_READ, &s, &offset, bytes, buf, flags, &result, ret);
 
     return result;
 }
@@ -351,19 +278,10 @@ static ssize_t write_syscall(lio_stream_t s, uint64_t offset, size_t bytes,
     const void* buf, int updatepos)
 {
     volatile ssize_t result;
+    int ret;
 
-    asm(
-        "pushl %6;"
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x18, %%esp;"
-    : : "i" (SYSCALL_LIO_WRITE), "r" (&s), "r" (&offset), "r" (bytes),
-        "r" (buf), "r" (updatepos), "g" (&result) : "memory");
+    SYSCALL6(SYSCALL_LIO_WRITE, &s, &offset,
+             bytes, buf, updatepos, &result, ret);
 
     return result;
 }
@@ -415,17 +333,9 @@ ssize_t lio_pwrite(lio_stream_t s, uint64_t offset, size_t bytes,
 int64_t lio_seek(lio_stream_t s, uint64_t offset, int whence)
 {
     volatile int64_t result;
+    int ret;
 
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-    : : "i" (SYSCALL_LIO_SEEK), "r" (&s), "r" (&offset), "r" (whence),
-        "r" (&result) : "memory");
+    SYSCALL4(SYSCALL_LIO_SEEK, &s, &offset, whence, &result, ret);
 
     return result;
 }
@@ -443,15 +353,7 @@ int lio_truncate(lio_stream_t s, uint64_t size)
 {
     int result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x08, %%esp;"
-    : "=a" (result)
-    : "i" (SYSCALL_LIO_TRUNCATE), "r" (&s), "r" (&size)
-    : "memory");
+    SYSCALL2(SYSCALL_LIO_TRUNCATE, &s, &size, result);
 
     return result;
 }
@@ -468,15 +370,7 @@ int lio_ioctl(lio_stream_t s, int cmd)
 {
     int result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-    : "=a" (result)
-    : "i" (SYSCALL_LIO_IOCTL), "r" (&s), "r" (cmd)
-    : "memory");
+    SYSCALL2(SYSCALL_LIO_IOCTL, &s, cmd, result);
 
     return result;
 }
@@ -497,18 +391,9 @@ ssize_t lio_read_dir(lio_resource_t res, size_t start, size_t num,
     struct lio_dir_entry* buf)
 {
     volatile ssize_t result;
+    int ret;
 
-    asm(
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x14, %%esp;"
-    : : "i" (SYSCALL_LIO_READ_DIR), "r" (&res), "r" (start), "r" (num),
-        "r" (buf), "r" (&result) : "memory");
+    SYSCALL5(SYSCALL_LIO_READ_DIR, &res, start, num, buf, &result, ret);
 
     return result;
 
@@ -526,18 +411,11 @@ lio_resource_t lio_mkfile(lio_resource_t parent, const char* name)
 {
     volatile lio_resource_t result;
     size_t len;
+    int ret;
 
     len = strlen(name) + 1;
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-    : : "i" (SYSCALL_LIO_MKFILE), "r" (&parent), "r" (name), "r" (len),
-        "r" (&result) : "memory");
+
+    SYSCALL4(SYSCALL_LIO_MKFILE, &parent, name, len, &result, ret);
 
     return result;
 }
@@ -555,18 +433,11 @@ lio_resource_t lio_mkdir(lio_resource_t parent, const char* name)
 {
     volatile lio_resource_t result;
     size_t len;
+    int ret;
 
     len = strlen(name) + 1;
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x10, %%esp;"
-    : : "i" (SYSCALL_LIO_MKDIR), "r" (&parent), "r" (name), "r" (len),
-        "r" (&result) : "memory");
+
+    SYSCALL4(SYSCALL_LIO_MKDIR, &parent, name, len, &result, ret);
 
     return result;
 }
@@ -586,21 +457,13 @@ lio_resource_t lio_mksymlink(lio_resource_t parent,
     volatile lio_resource_t result;
     size_t name_len;
     size_t target_len;
+    int ret;
 
     name_len = strlen(name) + 1;
     target_len = strlen(target) + 1;
-    asm(
-        "pushl %6;"
-        "pushl %5;"
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x18, %%esp;"
-    : : "i" (SYSCALL_LIO_MKSYMLINK), "r" (&parent), "r" (name), "r" (name_len),
-        "r" (target), "r" (target_len), "g" (&result) : "memory");
+
+    SYSCALL6(SYSCALL_LIO_MKSYMLINK, &parent, name,
+            name_len, target, target_len, &result, ret);
 
     return result;
 }
@@ -619,12 +482,7 @@ int lio_sync(lio_stream_t s)
 {
     int result;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (result): "i" (SYSCALL_LIO_SYNC), "r" (&s) : "memory");
+    SYSCALL1(SYSCALL_LIO_SYNC, &s, result);
 
     return result;
 }
@@ -645,15 +503,8 @@ int lio_unlink(lio_resource_t parent, const char* name)
     size_t name_len;
 
     name_len = strlen(name) + 1;
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0xc, %%esp;"
-    : "=a" (result) : "i" (SYSCALL_LIO_UNLINK), "r" (&parent), "r" (name),
-        "r" (name_len) : "memory");
+
+    SYSCALL3(SYSCALL_LIO_UNLINK, &parent, name, name_len, result);
 
     return result;
 }
@@ -667,11 +518,7 @@ int lio_sync_all(void)
 {
     int result;
 
-    asm(
-        "pushl $0;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (result) : "0" (SYSCALL_LIO_SYNC_ALL));
+    SYSCALL1(SYSCALL_LIO_SYNC_ALL, 0, result);
 
     return result;
 }
@@ -686,14 +533,7 @@ int lio_probe_service(lio_resource_t res, struct lio_probe_service_result* ret)
 {
     int result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a" (result) : "i" (SYSCALL_LIO_PROBE_SERVICE), "r" (&res), "r" (ret)
-    : "memory");
+    SYSCALL2(SYSCALL_LIO_PROBE_SERVICE, &res, ret, result);
 
     return result;
 }
diff --git a/src/modules/lib/syscalls/mem_allocate.c b/src/modules/lib/syscalls/mem_allocate.c
index 67749391..6371997b 100644
--- a/src/modules/lib/syscalls/mem_allocate.c
+++ b/src/modules/lib/syscalls/mem_allocate.c
@@ -28,21 +28,13 @@
 
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 dma_mem_ptr_t mem_dma_allocate(uint32_t size, uint32_t flags)
 {
     dma_mem_ptr_t ptr;
 
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0xc, %%esp;"
-    : "=a" (ptr.virt)
-    : "i" (SYSCALL_MEM_ALLOCATE), "r" (size), "r" (flags), "r" (&ptr.phys)
-    : "memory");
+    SYSCALL3(SYSCALL_MEM_ALLOCATE, size, flags, &ptr.phys, ptr.virt);
 
     return ptr;
 }
@@ -57,14 +49,7 @@ void *mem_allocate_physical(uint32_t size, uint32_t position, uint32_t flags)
 {
     dma_mem_ptr_t ptr;
 
-    asm(
-            "pushl %4;"
-            "pushl %3;"
-            "pushl %2;"
-            "mov %1, %%eax;"
-            "int $0x30;"
-            "add $0xC, %%esp;"
-    : "=a" (ptr.virt) : "i" (SYSCALL_MEM_ALLOCATE_PHYSICAL), "r" (size), "r" (position), "r" (flags));
+    SYSCALL3(SYSCALL_MEM_ALLOCATE_PHYSICAL, size, position, flags, ptr.virt);
 
     return ptr.virt;
 }
@@ -72,24 +57,16 @@ void *mem_allocate_physical(uint32_t size, uint32_t position, uint32_t flags)
 bool mem_free(void* address, uint32_t size)
 {
     uint32_t result;
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a" (result) : "i" (SYSCALL_MEM_FREE), "r" (address), "r" (size));
+
+    SYSCALL2(SYSCALL_MEM_FREE, address, size, result);
 
     return result;
 }
 
 void mem_free_physical(void* address, uint32_t size)
 {
-    asm(
-            "pushl %2;"
-            "pushl %1;"
-            "mov %0, %%eax;"
-            "int $0x30;"
-            "add $0x8, %%esp;"
-    : : "i" (SYSCALL_MEM_FREE_PHYSICAL), "r" (address), "r" (size));
+    int result;
+
+    SYSCALL2(SYSCALL_MEM_FREE_PHYSICAL, address, size, result);
+
 }
diff --git a/src/modules/lib/syscalls/memory_info.c b/src/modules/lib/syscalls/memory_info.c
index ca7aab26..107623bb 100644
--- a/src/modules/lib/syscalls/memory_info.c
+++ b/src/modules/lib/syscalls/memory_info.c
@@ -27,15 +27,13 @@
  */
 
 #include "syscall.h"
+#include "syscallx.h"
 
 memory_info_t memory_info()
 {
     memory_info_t result;
 
-    asm(
-        "mov %2, %%eax;"
-        "int $0x30;"
-    : "=a" (result.total), "=d" (result.free): "i" (SYSCALL_MEM_INFO));
+    SYSCALL0_TWO_RESULTS(SYSCALL_MEM_INFO, result.total, result.free);
 
     return result;
 }
diff --git a/src/modules/lib/syscalls/mutex.c b/src/modules/lib/syscalls/mutex.c
index 50b6b493..89469198 100644
--- a/src/modules/lib/syscalls/mutex.c
+++ b/src/modules/lib/syscalls/mutex.c
@@ -29,21 +29,18 @@
 #include <stdint.h>
 #include <lock.h>
 #include <syscall.h>
+#include "syscallx.h"
 
 void mutex_lock(mutex_t* mutex)
 {
-    asm(
-        "pushl %1;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : : "a" (SYSCALL_MUTEX_LOCK), "r" (mutex) : "memory");
+    int result;
+
+    SYSCALL1(SYSCALL_MUTEX_LOCK, mutex, result);
 }
 
 void mutex_unlock(mutex_t* mutex)
 {
-    asm(
-        "pushl %1;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : : "a" (SYSCALL_MUTEX_UNLOCK), "r" (mutex) : "memory");
+    int result;
+
+    SYSCALL1(SYSCALL_MUTEX_UNLOCK, mutex, result);
 }
diff --git a/src/modules/lib/syscalls/ports.c b/src/modules/lib/syscalls/ports.c
index 4eed4379..417787cc 100644
--- a/src/modules/lib/syscalls/ports.c
+++ b/src/modules/lib/syscalls/ports.c
@@ -28,31 +28,22 @@
 
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 bool request_ports(uint32_t port, uint32_t length)
 {
-    uint32_t eax;
-    asm(
-        "push %2;"
-        "push %1;"
-        "mov %3, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a" (eax) : "g" (port), "g" (length), "i" (SYSCALL_PM_REQUEST_PORT));
-    
-    return eax;
+    uint32_t ret;
+
+    SYSCALL2(SYSCALL_PM_REQUEST_PORT, port, length, ret);
+
+    return ret;
 }
 
 bool release_ports(uint32_t port, uint32_t length)
 {
-    uint32_t eax;
-    asm(
-        "push %2;"
-        "push %1;"
-        "mov %3, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a" (eax) : "g" (port), "g" (length), "i" (SYSCALL_PM_RELEASE_PORT));
-    
-    return eax;
+    uint32_t ret;
+
+    SYSCALL2(SYSCALL_PM_RELEASE_PORT, port, length, ret);
+
+    return ret;
 }
diff --git a/src/modules/lib/syscalls/puts.c b/src/modules/lib/syscalls/puts.c
index da08fdc3..57b18f80 100644
--- a/src/modules/lib/syscalls/puts.c
+++ b/src/modules/lib/syscalls/puts.c
@@ -1,13 +1,38 @@
+/*
+ * Copyright (c) 2020 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Nico Mayer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 #include "syscall.h"
+#include "syscallx.h"
 
 int syscall_putsn(unsigned int n, const char* s) {
-    
-    asm("push %2;"
-        "push %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp" 
-    : : "i" (SYSCALL_PUTSN) , "r" (n) , "r" (s));
+
+    int result;
+
+    SYSCALL2(SYSCALL_PUTSN, n, s, result);
 
     return 1;
 }
diff --git a/src/modules/lib/syscalls/pv.c b/src/modules/lib/syscalls/pv.c
index e8c425bf..c8a9c46c 100644
--- a/src/modules/lib/syscalls/pv.c
+++ b/src/modules/lib/syscalls/pv.c
@@ -1,19 +1,44 @@
+/*
+ * Copyright (c) 2020 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Nico Mayer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 #include "syscall.h"
+#include "syscallx.h"
 
 void syscall_p()
 {
-    asm(
-        "mov %0, %%eax;"
-        "int $0x30;"
-    : : "i" (SYSCALL_PM_P) : "eax");
+    int result;
+
+    SYSCALL0(SYSCALL_PM_P, result);
 }
 
 void syscall_v()
 {
-    asm(
-        "mov %0, %%eax;"
-        "push $0;"
-        "int $0x30;"
-        "add $4, %%esp;"
-    : : "i" (SYSCALL_PM_V) : "eax");
+
+    int result;
+
+    SYSCALL1(SYSCALL_PM_V, 0, result);
 }
diff --git a/src/modules/lib/syscalls/rpc.c b/src/modules/lib/syscalls/rpc.c
index bb1f62b2..94acde16 100644
--- a/src/modules/lib/syscalls/rpc.c
+++ b/src/modules/lib/syscalls/rpc.c
@@ -29,19 +29,14 @@
 #include <stdint.h>
 #include <syscall.h>
 #include <errno.h>
+#include "syscallx.h"
 
 void rpc(pid_t pid)
 {
     uint32_t result = 0;
 
     do {
-        asm(
-            "pushl $0;"
-            "pushl %1;"
-            "mov $51, %%eax;"
-            "int $0x30;"
-            "add $0x8, %%esp;"
-        : "=a" (result) : "g" (pid), "0" (result));
+        SYSCALL2(SYSCALL_RPC, pid, 0, result);
     } while (result != 0);
 }
 
@@ -58,19 +53,7 @@ int send_message(pid_t pid, uint32_t function, uint32_t correlation_id,
     volatile uint32_t metadata[2] = { function, correlation_id };
 
     do {
-        asm(
-            "pushl %6;"
-            "pushl %5;"
-            "pushl %4;"
-            "pushl %3;"
-            "pushl %2;"
-            "mov %1, %%eax;"
-            "int $0x30;"
-            "add $0x14, %%esp;"
-        : "=a" (result)
-        : "i" (SYSCALL_FASTRPC), "g" (pid), "i" (0x8), "g" (metadata),
-            "g" (len), "g" (data), "0" (result));
-
+        SYSCALL5(SYSCALL_FASTRPC, pid, 0x8, metadata, len, data, result);
     } while (result == -EAGAIN);
 
     return result;
diff --git a/src/modules/lib/syscalls/set_rpc_handler.c b/src/modules/lib/syscalls/set_rpc_handler.c
index a8890a5e..9c133365 100644
--- a/src/modules/lib/syscalls/set_rpc_handler.c
+++ b/src/modules/lib/syscalls/set_rpc_handler.c
@@ -1,11 +1,37 @@
+/*
+ * Copyright (c) 2020 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Nico Mayer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include "syscall.h"
+#include "syscallx.h"
 
 void set_rpc_handler(void (*rpc_handler)(void))
 {
-    asm(
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : : "i" (SYSCALL_SET_RPC_HANDLER), "r" (rpc_handler));
+    int result;
+
+    SYSCALL1(SYSCALL_SET_RPC_HANDLER, rpc_handler, result);
 }
diff --git a/src/modules/lib/syscalls/shared_memory.c b/src/modules/lib/syscalls/shared_memory.c
index 6c1609e8..b28e49d7 100644
--- a/src/modules/lib/syscalls/shared_memory.c
+++ b/src/modules/lib/syscalls/shared_memory.c
@@ -1,16 +1,40 @@
+/*
+ * Copyright (c) 2020 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Nico Mayer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 uint32_t create_shared_memory(uint32_t size)
 {
     uint32_t id;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (id) : "i" (SYSCALL_SHM_CREATE), "r" (size));
+    SYSCALL1(SYSCALL_SHM_CREATE, size, id);
 
     return id;
 }
@@ -19,12 +43,7 @@ void *open_shared_memory(uint32_t id)
 {
     vaddr_t addr;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (addr) : "i" (SYSCALL_SHM_ATTACH), "r" (id));
+    SYSCALL1(SYSCALL_SHM_ATTACH, id, addr);
 
     return addr;
 }
@@ -33,22 +52,14 @@ ssize_t shared_memory_size(uint32_t id)
 {
     int32_t size;
 
-    asm(
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    : "=a" (size) : "i" (SYSCALL_SHM_SIZE), "r" (id));
+    SYSCALL1(SYSCALL_SHM_SIZE, id, size);
 
     return size;
 }
 
 void close_shared_memory(uint32_t id)
 {
-    asm(
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-    :: "i" (SYSCALL_SHM_DETACH), "r" (id));
+    int result;
+
+    SYSCALL1(SYSCALL_SHM_DETACH, id, result);
 }
diff --git a/src/modules/lib/syscalls/sleep.c b/src/modules/lib/syscalls/sleep.c
index acc6a8ed..4f418afe 100644
--- a/src/modules/lib/syscalls/sleep.c
+++ b/src/modules/lib/syscalls/sleep.c
@@ -1,9 +1,9 @@
 #include "syscall.h"
+#include "syscallx.h"
 
 void yield()
 {
-    asm(
-        "mov %0, %%eax;"
-        "int $0x30;"
-    : : "i" (SYSCALL_PM_SLEEP) : "eax");
+    int result;
+
+    SYSCALL0(SYSCALL_PM_SLEEP, result);
 }
diff --git a/src/modules/lib/syscalls/timer.c b/src/modules/lib/syscalls/timer.c
index 766440df..f110b67c 100644
--- a/src/modules/lib/syscalls/timer.c
+++ b/src/modules/lib/syscalls/timer.c
@@ -28,15 +28,11 @@
 
 #include <stdint.h>
 #include "syscall.h"
+#include "syscallx.h"
 
 void syscall_timer(uint32_t timer_id, uint32_t usec)
 {
-    asm(
-        "mov %0, %%eax;"
-        "push %2;"
-        "push %1;"
-        "int $0x30;"
-        "add $8, %%esp;"
-    : : "i" (SYSCALL_ADD_TIMER), "g" (timer_id), "g" (usec) : "eax");
+    int result;
+
+    SYSCALL2(SYSCALL_ADD_TIMER, timer_id, usec, result);
 }
-                                                        
diff --git a/src/modules/lib/syscalls/unblock_process.c b/src/modules/lib/syscalls/unblock_process.c
index 0ffc73ba..5bf91bca 100644
--- a/src/modules/lib/syscalls/unblock_process.c
+++ b/src/modules/lib/syscalls/unblock_process.c
@@ -1,12 +1,37 @@
-#include "syscall.h"
+/*
+ * Copyright (c) 2020 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Nico Mayer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
+#include "syscall.h"
+#include "syscallx.h"
 
 void unblock_process(pid_t pid)
 {
-    asm(
-        "pushl %1;"
-        "mov %0, %%eax;"
-        "int $0x30;"
-        "add $0x4, %%esp;"
-        : : "i" (SYSCALL_PM_V), "r" (pid));
+    int result;
+
+    SYSCALL1(SYSCALL_PM_V, pid, result);
 }
diff --git a/src/modules/lib/syscalls/vm86.c b/src/modules/lib/syscalls/vm86.c
index 40ef2d41..ccc76b51 100644
--- a/src/modules/lib/syscalls/vm86.c
+++ b/src/modules/lib/syscalls/vm86.c
@@ -29,21 +29,13 @@
 #include <stdbool.h>
 #include <syscall.h>
 #include <errno.h>
+#include "syscallx.h"
 
 int bios_int(int intr, vm86_regs_t* regs, uint32_t* shm)
 {
     int result;
 
-    asm(
-        "pushl %4;"
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0xc, %%esp;"
-    : "=a"(result)
-    : "i" (SYSCALL_VM86_BIOS_INT), "r" (intr), "r"(regs), "r"(shm)
-    : "memory");
+    SYSCALL3(SYSCALL_VM86_BIOS_INT, intr, regs, shm, result);
 
     return result;
 }
@@ -52,13 +44,7 @@ bool vm86_int(vm86_regs_t *regs, uint32_t *shm)
 {
     int result;
 
-    asm(
-        "pushl %3;"
-        "pushl %2;"
-        "mov %1, %%eax;"
-        "int $0x30;"
-        "add $0x8, %%esp;"
-    : "=a"(result): "i" (SYSCALL_VM86), "r"(regs), "r"(shm) : "memory");
+    SYSCALL2(SYSCALL_VM86, regs, shm, result);
 
     if (result == -ENOSYS) {
         return bios_int(0x10, regs, shm);
diff --git a/src/modules/lib/syscalls/wait_for_rpc.c b/src/modules/lib/syscalls/wait_for_rpc.c
index 7ea2e97c..12f36be4 100644
--- a/src/modules/lib/syscalls/wait_for_rpc.c
+++ b/src/modules/lib/syscalls/wait_for_rpc.c
@@ -1,17 +1,43 @@
+/*
+ * Copyright (c) 2020 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Nico Mayer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 #include "syscall.h"
+#include "syscallx.h"
 
 void wait_for_rpc()
 {
-    asm(
-        "mov %0, %%eax;"
-        "int $0x30;"
-    : : "i" (SYSCALL_PM_WAIT_FOR_RPC) : "eax");
+    int result;
+
+    SYSCALL0(SYSCALL_PM_WAIT_FOR_RPC, result);
 }
 
 void v_and_wait_for_rpc()
 {
-    asm(
-        "mov %0, %%eax;"
-        "int $0x30;"
-    : : "i" (SYSCALL_PM_V_AND_WAIT_FOR_RPC) : "eax");
+    int result;
+
+    SYSCALL0(SYSCALL_PM_V_AND_WAIT_FOR_RPC, result);
 }
-- 
2.29.2