diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/user/app/main.c (renamed from src/init/main.c) | 12 | ||||
-rw-r--r-- | src/user/app/shell.c (renamed from src/init/shell.c) | 6 | ||||
-rw-r--r-- | src/user/app/shell.h (renamed from src/init/shell.h) | 0 | ||||
-rw-r--r-- | src/user/driver/ansiterm.c (renamed from src/init/driver/ansiterm.c) | 2 | ||||
-rw-r--r-- | src/user/driver/driver.h (renamed from src/init/driver/driver.h) | 0 | ||||
-rw-r--r-- | src/user/driver/ps2.c (renamed from src/init/driver/ps2.c) | 2 | ||||
-rw-r--r-- | src/user/driver/tmpfs.c (renamed from src/init/driver/tmpfs.c) | 2 | ||||
-rw-r--r-- | src/user/fs/misc.c (renamed from src/init/fs/misc.c) | 4 | ||||
-rw-r--r-- | src/user/fs/misc.h (renamed from src/init/fs/misc.h) | 2 | ||||
-rw-r--r-- | src/user/fs/tar.c (renamed from src/init/tar.c) | 2 | ||||
-rw-r--r-- | src/user/fs/tar.h (renamed from src/init/tar.h) | 0 | ||||
-rw-r--r-- | src/user/lib/esemaphore.c (renamed from src/init/lib/esemaphore.c) | 4 | ||||
-rw-r--r-- | src/user/lib/esemaphore.h (renamed from src/init/lib/esemaphore.h) | 0 | ||||
-rw-r--r-- | src/user/lib/malloc.c (renamed from src/init/malloc.c) | 4 | ||||
-rw-r--r-- | src/user/lib/malloc.h (renamed from src/init/malloc.h) | 0 | ||||
-rw-r--r-- | src/user/lib/stdlib.c (renamed from src/init/stdlib.c) | 2 | ||||
-rw-r--r-- | src/user/lib/stdlib.h (renamed from src/init/stdlib.h) | 2 | ||||
-rw-r--r-- | src/user/lib/syscall.c (renamed from src/init/syscalls.c) | 4 | ||||
-rw-r--r-- | src/user/lib/syscall.c.awk | 51 | ||||
-rw-r--r-- | src/user/lib/syscall.s (renamed from src/init/syscall.s) | 0 | ||||
-rw-r--r-- | src/user/linker.ld (renamed from src/init/linker.ld) | 0 | ||||
-rw-r--r-- | src/user/tests/main.c (renamed from src/init/tests/main.c) | 4 | ||||
-rw-r--r-- | src/user/tests/main.h (renamed from src/init/tests/main.h) | 0 | ||||
-rw-r--r-- | src/user/tests/pipe.c (renamed from src/init/tests/pipe.c) | 4 | ||||
-rw-r--r-- | src/user/tests/semaphore.c (renamed from src/init/tests/semaphore.c) | 6 | ||||
-rw-r--r-- | src/user/tests/stress.c (renamed from src/init/tests/stress.c) | 4 |
26 files changed, 84 insertions, 33 deletions
diff --git a/src/init/main.c b/src/user/app/main.c index 88553e9..e59b5a6 100644 --- a/src/init/main.c +++ b/src/user/app/main.c @@ -1,9 +1,9 @@ -#include <init/driver/driver.h> -#include <init/fs/misc.h> -#include <init/shell.h> -#include <init/stdlib.h> -#include <init/tar.h> -#include <init/tests/main.h> +#include <user/driver/driver.h> +#include <user/fs/misc.h> +#include <user/app/shell.h> +#include <user/lib/stdlib.h> +#include <user/fs/tar.h> +#include <user/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> #include <stdint.h> diff --git a/src/init/shell.c b/src/user/app/shell.c index a4e96f9..0a8c44f 100644 --- a/src/init/shell.c +++ b/src/user/app/shell.c @@ -1,6 +1,6 @@ -#include <init/shell.h> -#include <init/stdlib.h> -#include <init/tests/main.h> +#include <user/app/shell.h> +#include <user/lib/stdlib.h> +#include <user/tests/main.h> #include <shared/syscalls.h> #include <stdbool.h> diff --git a/src/init/shell.h b/src/user/app/shell.h index fb27410..fb27410 100644 --- a/src/init/shell.h +++ b/src/user/app/shell.h diff --git a/src/init/driver/ansiterm.c b/src/user/driver/ansiterm.c index b7f0b04..e332ca2 100644 --- a/src/init/driver/ansiterm.c +++ b/src/user/driver/ansiterm.c @@ -1,4 +1,4 @@ -#include <init/driver/driver.h> +#include <user/driver/driver.h> #include <shared/syscalls.h> #include <stdbool.h> diff --git a/src/init/driver/driver.h b/src/user/driver/driver.h index 69c4529..69c4529 100644 --- a/src/init/driver/driver.h +++ b/src/user/driver/driver.h diff --git a/src/init/driver/ps2.c b/src/user/driver/ps2.c index d01c522..b2811c3 100644 --- a/src/init/driver/ps2.c +++ b/src/user/driver/ps2.c @@ -1,4 +1,4 @@ -#include <init/driver/driver.h> +#include <user/driver/driver.h> #include <shared/container/ring.h> #include <shared/syscalls.h> #include <stdbool.h> diff --git a/src/init/driver/tmpfs.c b/src/user/driver/tmpfs.c index bbed095..225204b 100644 --- a/src/init/driver/tmpfs.c +++ b/src/user/driver/tmpfs.c @@ -1,4 +1,4 @@ -#include <init/malloc.h> +#include <user/lib/malloc.h> #include <shared/mem.h> #include <shared/syscalls.h> #include <stddef.h> diff --git a/src/init/fs/misc.c b/src/user/fs/misc.c index a218bf5..bf09718 100644 --- a/src/init/fs/misc.c +++ b/src/user/fs/misc.c @@ -1,5 +1,5 @@ -#include <init/fs/misc.h> -#include <init/stdlib.h> +#include <user/fs/misc.h> +#include <user/lib/stdlib.h> #include <shared/flags.h> #include <shared/mem.h> #include <shared/syscalls.h> diff --git a/src/init/fs/misc.h b/src/user/fs/misc.h index d64ab1e..3a8b071 100644 --- a/src/init/fs/misc.h +++ b/src/user/fs/misc.h @@ -1,5 +1,5 @@ #pragma once -#include <init/stdlib.h> +#include <user/lib/stdlib.h> #include <stdbool.h> bool fork2_n_mount(const char *path); diff --git a/src/init/tar.c b/src/user/fs/tar.c index 87236ae..4b4a9a3 100644 --- a/src/init/tar.c +++ b/src/user/fs/tar.c @@ -1,4 +1,4 @@ -#include <init/stdlib.h> +#include <user/lib/stdlib.h> #include <shared/flags.h> #include <shared/syscalls.h> #include <stdint.h> diff --git a/src/init/tar.h b/src/user/fs/tar.h index c1dee78..c1dee78 100644 --- a/src/init/tar.h +++ b/src/user/fs/tar.h diff --git a/src/init/lib/esemaphore.c b/src/user/lib/esemaphore.c index ac65b02..ed42ee9 100644 --- a/src/init/lib/esemaphore.c +++ b/src/user/lib/esemaphore.c @@ -1,5 +1,5 @@ -#include <init/lib/esemaphore.h> -#include <init/stdlib.h> +#include <user/lib/esemaphore.h> +#include <user/lib/stdlib.h> #include <shared/flags.h> #include <shared/syscalls.h> diff --git a/src/init/lib/esemaphore.h b/src/user/lib/esemaphore.h index e746bd7..e746bd7 100644 --- a/src/init/lib/esemaphore.h +++ b/src/user/lib/esemaphore.h diff --git a/src/init/malloc.c b/src/user/lib/malloc.c index eb63d82..5157e91 100644 --- a/src/init/malloc.c +++ b/src/user/lib/malloc.c @@ -1,9 +1,9 @@ -#include <init/malloc.h> +#include <user/lib/malloc.h> #include <shared/flags.h> #include <shared/syscalls.h> #include <stdbool.h> -#include <init/stdlib.h> +#include <user/lib/stdlib.h> #define MBLOCK_MAGIC 0x1337BABE diff --git a/src/init/malloc.h b/src/user/lib/malloc.h index 5916ebc..5916ebc 100644 --- a/src/init/malloc.h +++ b/src/user/lib/malloc.h diff --git a/src/init/stdlib.c b/src/user/lib/stdlib.c index 4d26c2e..c055d04 100644 --- a/src/init/stdlib.c +++ b/src/user/lib/stdlib.c @@ -1,4 +1,4 @@ -#include <init/stdlib.h> +#include <user/lib/stdlib.h> #include <shared/printf.h> #include <shared/syscalls.h> diff --git a/src/init/stdlib.h b/src/user/lib/stdlib.h index e1e753d..9bbcc5f 100644 --- a/src/init/stdlib.h +++ b/src/user/lib/stdlib.h @@ -1,5 +1,5 @@ #pragma once -#include <init/malloc.h> +#include <user/lib/malloc.h> #include <shared/mem.h> #include <stdbool.h> #include <stddef.h> diff --git a/src/init/syscalls.c b/src/user/lib/syscall.c index 7c2bb68..d86df19 100644 --- a/src/init/syscalls.c +++ b/src/user/lib/syscall.c @@ -1,6 +1,6 @@ -/* generated by tools/syscall_wrappers.awk +/* generated by syscall.c.awk * don't modify manually, instead run: - * make src/init/syscalls.c + * make src/user/lib/syscall.c */ #include <shared/syscalls.h> diff --git a/src/user/lib/syscall.c.awk b/src/user/lib/syscall.c.awk new file mode 100644 index 0000000..a8dd22b --- /dev/null +++ b/src/user/lib/syscall.c.awk @@ -0,0 +1,51 @@ +BEGIN { + print "\ +/* generated by syscall.c.awk\n\ + * don't modify manually, instead run:\n\ + * make src/user/lib/syscall.c\n\ + */\n\ +#include <shared/syscalls.h>\n\ +\n"; +} + +/_syscall\(/ { next; } # skipping _syscall(), it's implemented elsewhere + +/\);/ { + sub(/;/, " {"); + print $0; + + name = substr($0, match($0, /_syscall_[^(]+/), RLENGTH); + rets = substr($0, 0, RSTART - 1); + sub(/ *$/, "", rets) + + params = substr($0, match($0, /\(.+\)/) + 1, RLENGTH - 2); + gsub(/\[[^\]]\]/, "", params); + if (params == "void") params = "" + + split(params, p, /,/); + for (i = 0; i <= 4; i += 1) { + if (p[i]) { + # p[i] is a parameter, convert it into an expression to pass to _syscall() + sub(/^ */, "", p[i]); # strip + split(p[i], words, / /); + if (length(words) != 1) { + var = words[length(words)]; + sub(/\*/, "", var); + if (words[1] != "int") var = "(int)" var; + } + p[i] = var; + } else { + p[i] = 0; + } + } + + printf "\t"; + if (!index($0, "_Noreturn")) { + printf "return "; + if (rets != "int") printf "(%s)", rets; + } + printf "_syscall(%s, %s, %s, %s, %s);\n", toupper(name), p[1], p[2], p[3], p[4]; + if (index($0, "_Noreturn")) print "\t__builtin_unreachable();"; + + print "}\n"; +} diff --git a/src/init/syscall.s b/src/user/lib/syscall.s index 0af49f3..0af49f3 100644 --- a/src/init/syscall.s +++ b/src/user/lib/syscall.s diff --git a/src/init/linker.ld b/src/user/linker.ld index f2c9d24..f2c9d24 100644 --- a/src/init/linker.ld +++ b/src/user/linker.ld diff --git a/src/init/tests/main.c b/src/user/tests/main.c index 97ed798..fd5ffca 100644 --- a/src/init/tests/main.c +++ b/src/user/tests/main.c @@ -1,6 +1,6 @@ #define TEST_MACROS -#include <init/stdlib.h> -#include <init/tests/main.h> +#include <user/lib/stdlib.h> +#include <user/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> diff --git a/src/init/tests/main.h b/src/user/tests/main.h index ed11c5e..ed11c5e 100644 --- a/src/init/tests/main.h +++ b/src/user/tests/main.h diff --git a/src/init/tests/pipe.c b/src/user/tests/pipe.c index 8e9d243..e973993 100644 --- a/src/init/tests/pipe.c +++ b/src/user/tests/pipe.c @@ -1,6 +1,6 @@ #define TEST_MACROS -#include <init/stdlib.h> -#include <init/tests/main.h> +#include <user/lib/stdlib.h> +#include <user/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> diff --git a/src/init/tests/semaphore.c b/src/user/tests/semaphore.c index cb47d41..e5aacaa 100644 --- a/src/init/tests/semaphore.c +++ b/src/user/tests/semaphore.c @@ -1,7 +1,7 @@ #define TEST_MACROS -#include <init/lib/esemaphore.h> -#include <init/stdlib.h> -#include <init/tests/main.h> +#include <user/lib/esemaphore.h> +#include <user/lib/stdlib.h> +#include <user/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> diff --git a/src/init/tests/stress.c b/src/user/tests/stress.c index 11c30cb..51b9c4e 100644 --- a/src/init/tests/stress.c +++ b/src/user/tests/stress.c @@ -1,6 +1,6 @@ #define TEST_MACROS -#include <init/stdlib.h> -#include <init/tests/main.h> +#include <user/lib/stdlib.h> +#include <user/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> |