Replace the generated individual system calls with a generic syscall() function,...
authorcoderain <coderain@sdf.org>
Sun, 2 Apr 2017 18:22:50 +0000 (20:22 +0200)
committercoderain <coderain@sdf.org>
Sun, 2 Apr 2017 18:22:50 +0000 (20:22 +0200)
library/Makefile
library/gen_syscalls.sh [deleted file]
library/src/syscall.asm

index d39686ca29b07919da9665e606922a283ef242b7..c60ed3e05ce8f9aa5d334496ff065e7f54a0c5dd 100644 (file)
@@ -42,8 +42,7 @@ else
 endif
 
 # Input and output files
-SOURCES =  $(SRCDIR)/syscall.asm
-SOURCES += $(wildcard $(SRCDIR)/*.c)
+SOURCES =  $(wildcard $(SRCDIR)/*.c)
 SOURCES += $(wildcard $(SRCDIR)/*.asm)
 
 DEPENDS = $(shell find $(DEPDIR) -type f -name \*.d)
@@ -61,9 +60,6 @@ $(OBJDIR):
 $(DEPDIR):
        mkdir -p $(DEPDIR)
 
-$(SRCDIR)/syscall.asm : ../kernel/include/syscalls.h gen_syscalls.sh
-       ./gen_syscalls.sh < $< > $@
-
 $(OBJDIR)/%.o: $(SRCDIR)/%.c Makefile
        mkdir -p $(dir $@)
        mkdir -p $(dir $(@:$(OBJDIR)/%.o=$(DEPDIR)/%.d))
diff --git a/library/gen_syscalls.sh b/library/gen_syscalls.sh
deleted file mode 100755 (executable)
index 28b3147..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-WIDTH=28
-
-echo '; *******************************************************************************'
-echo "; File generated by $0"
-echo '; *******************************************************************************'
-echo
-echo 'bits 32'
-echo
-
-syscall_names=`egrep '^[ \t]*SYSCALL_' | sed 's/^[ \t]*SYSCALL_//' | sed 's/,$//' | tr A-Z a-z`
-number=0
-
-for name in $syscall_names; do
-    echo "global $name"
-
-    printf "\n%-${WIDTH}spush ebp\n" "$name:"
-    printf "%${WIDTH}cmov ebp, esp\n" ' '
-    printf "%${WIDTH}cmov eax, $number\n" ' '
-    printf "%${WIDTH}clea edx, [ebp + 8]\n" ' '
-    printf "%${WIDTH}cint 0xE5\n" ' '
-    printf "%${WIDTH}cleave\n" ' '
-    printf "%${WIDTH}cret\n\n" ' '
-    number=$(($number + 1))
-done
index 63f9f720e67e6c54f28d4fe48dfc3ebefa28fe8b..0958e1463cac1cab1b85a9ae76581065def35c37 100644 (file)
-; *******************************************************************************
-; File generated by ./gen_syscalls.sh
-; *******************************************************************************
+;
+; syscall.asm
+;
+; Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU Affero General Public License as
+; published by the Free Software Foundation, either version 3 of the
+; License, or (at your option) any later version.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU Affero General Public License for more details.
+;
+; You should have received a copy of the GNU Affero General Public License
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;
 
 bits 32
 
-global alloc_memory
+global syscall
 
-alloc_memory:               push ebp
+syscall:                    push ebp
                             mov ebp, esp
-                            mov eax, 0
-                            lea edx, [ebp + 8]
+                            mov eax, [ebp + 8]
+                            lea edx, [ebp + 12]
                             int 0xE5
                             leave
                             ret
-
-global clock_get_time
-
-clock_get_time:             push ebp
-                            mov ebp, esp
-                            mov eax, 1
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global clock_set_time
-
-clock_set_time:             push ebp
-                            mov ebp, esp
-                            mov eax, 2
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global close_object
-
-close_object:               push ebp
-                            mov ebp, esp
-                            mov eax, 3
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global commit_memory
-
-commit_memory:              push ebp
-                            mov ebp, esp
-                            mov eax, 4
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global create_memory_section
-
-create_memory_section:      push ebp
-                            mov ebp, esp
-                            mov eax, 5
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global create_process
-
-create_process:             push ebp
-                            mov ebp, esp
-                            mov eax, 6
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global create_semaphore
-
-create_semaphore:           push ebp
-                            mov ebp, esp
-                            mov eax, 7
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global create_thread
-
-create_thread:              push ebp
-                            mov ebp, esp
-                            mov eax, 8
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global create_user
-
-create_user:                push ebp
-                            mov ebp, esp
-                            mov eax, 9
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global delete_file
-
-delete_file:                push ebp
-                            mov ebp, esp
-                            mov eax, 10
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global delete_user
-
-delete_user:                push ebp
-                            mov ebp, esp
-                            mov eax, 11
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global device_ioctl
-
-device_ioctl:               push ebp
-                            mov ebp, esp
-                            mov eax, 12
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global duplicate_handle
-
-duplicate_handle:           push ebp
-                            mov ebp, esp
-                            mov eax, 13
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global enum_processes
-
-enum_processes:             push ebp
-                            mov ebp, esp
-                            mov eax, 14
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global flush_memory_section
-
-flush_memory_section:       push ebp
-                            mov ebp, esp
-                            mov eax, 15
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global free_memory
-
-free_memory:                push ebp
-                            mov ebp, esp
-                            mov eax, 16
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global get_exception_info
-
-get_exception_info:         push ebp
-                            mov ebp, esp
-                            mov eax, 17
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global get_milliseconds
-
-get_milliseconds:           push ebp
-                            mov ebp, esp
-                            mov eax, 18
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global get_nanoseconds
-
-get_nanoseconds:            push ebp
-                            mov ebp, esp
-                            mov eax, 19
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global get_process_id
-
-get_process_id:             push ebp
-                            mov ebp, esp
-                            mov eax, 20
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global get_thread_id
-
-get_thread_id:              push ebp
-                            mov ebp, esp
-                            mov eax, 21
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global get_user_id
-
-get_user_id:                push ebp
-                            mov ebp, esp
-                            mov eax, 22
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global list_directory
-
-list_directory:             push ebp
-                            mov ebp, esp
-                            mov eax, 23
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global logon_user
-
-logon_user:                 push ebp
-                            mov ebp, esp
-                            mov eax, 24
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global map_memory_section
-
-map_memory_section:         push ebp
-                            mov ebp, esp
-                            mov eax, 25
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global mount
-
-mount:                      push ebp
-                            mov ebp, esp
-                            mov eax, 26
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global open_file
-
-open_file:                  push ebp
-                            mov ebp, esp
-                            mov eax, 27
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global open_memory_section
-
-open_memory_section:        push ebp
-                            mov ebp, esp
-                            mov eax, 28
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global open_pipe
-
-open_pipe:                  push ebp
-                            mov ebp, esp
-                            mov eax, 29
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global open_process
-
-open_process:               push ebp
-                            mov ebp, esp
-                            mov eax, 30
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global open_thread
-
-open_thread:                push ebp
-                            mov ebp, esp
-                            mov eax, 31
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global power_control
-
-power_control:              push ebp
-                            mov ebp, esp
-                            mov eax, 32
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global query_file
-
-query_file:                 push ebp
-                            mov ebp, esp
-                            mov eax, 33
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global query_handle
-
-query_handle:               push ebp
-                            mov ebp, esp
-                            mov eax, 34
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global query_process
-
-query_process:              push ebp
-                            mov ebp, esp
-                            mov eax, 35
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global query_thread
-
-query_thread:               push ebp
-                            mov ebp, esp
-                            mov eax, 36
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global query_user
-
-query_user:                 push ebp
-                            mov ebp, esp
-                            mov eax, 37
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global raise_exception
-
-raise_exception:            push ebp
-                            mov ebp, esp
-                            mov eax, 38
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global read_file
-
-read_file:                  push ebp
-                            mov ebp, esp
-                            mov eax, 39
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global read_memory
-
-read_memory:                push ebp
-                            mov ebp, esp
-                            mov eax, 40
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global read_pipe
-
-read_pipe:                  push ebp
-                            mov ebp, esp
-                            mov eax, 41
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global release_semaphore
-
-release_semaphore:          push ebp
-                            mov ebp, esp
-                            mov eax, 42
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global restore_exception_handler
-
-restore_exception_handler:  push ebp
-                            mov ebp, esp
-                            mov eax, 43
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global revert_user
-
-revert_user:                push ebp
-                            mov ebp, esp
-                            mov eax, 44
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global save_exception_handler
-
-save_exception_handler:     push ebp
-                            mov ebp, esp
-                            mov eax, 45
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global set_memory_flags
-
-set_memory_flags:           push ebp
-                            mov ebp, esp
-                            mov eax, 46
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global set_user_id
-
-set_user_id:                push ebp
-                            mov ebp, esp
-                            mov eax, 47
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global sleep
-
-sleep:                      push ebp
-                            mov ebp, esp
-                            mov eax, 48
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global terminate
-
-terminate:                  push ebp
-                            mov ebp, esp
-                            mov eax, 49
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global terminate_thread
-
-terminate_thread:           push ebp
-                            mov ebp, esp
-                            mov eax, 50
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global uncommit_memory
-
-uncommit_memory:            push ebp
-                            mov ebp, esp
-                            mov eax, 51
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global unmount
-
-unmount:                    push ebp
-                            mov ebp, esp
-                            mov eax, 52
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global wait_process
-
-wait_process:               push ebp
-                            mov ebp, esp
-                            mov eax, 53
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global wait_semaphore
-
-wait_semaphore:             push ebp
-                            mov ebp, esp
-                            mov eax, 54
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global wait_thread
-
-wait_thread:                push ebp
-                            mov ebp, esp
-                            mov eax, 55
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global write_file
-
-write_file:                 push ebp
-                            mov ebp, esp
-                            mov eax, 56
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global write_memory
-
-write_memory:               push ebp
-                            mov ebp, esp
-                            mov eax, 57
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global write_pipe
-
-write_pipe:                 push ebp
-                            mov ebp, esp
-                            mov eax, 58
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-
-global yield_quantum
-
-yield_quantum:              push ebp
-                            mov ebp, esp
-                            mov eax, 59
-                            lea edx, [ebp + 8]
-                            int 0xE5
-                            leave
-                            ret
-