From 084eac3d5fa7deeab2296cf20653f4f7b3f75cd0 Mon Sep 17 00:00:00 2001 From: Lunaixsky Date: Mon, 5 May 2025 01:29:33 +0100 Subject: [PATCH] make rule for user header file install + and syscall header file auto generation + some clean up --- lunaix-os/.gitignore | 2 +- .../includes/asm-generic/syscall_nr.inc | 156 +++++++++--------- .../x86/{ => includes/asm}/syscall_nr.inc | 0 lunaix-os/arch/x86/syscall_lut.S | 6 +- lunaix-os/includes/lunaix/syscall.h | 2 +- lunaix-os/includes/usr/headers | 14 ++ lunaix-os/includes/usr/headers_autogen | 1 + lunaix-os/includes/usr/lunaix/lxdirent.h | 8 - lunaix-os/includes/usr/lunaix/status.h | 67 ++++---- lunaix-os/includes/usr/lunaix/syscallid.h | 79 --------- lunaix-os/install_headers.mk | 28 ++++ lunaix-os/kernel.mk | 29 +--- lunaix-os/makefile | 42 +++-- lunaix-os/makeinc/kbuild_deps.mkinc | 15 ++ lunaix-os/scripts/gen-syscall-header | 22 +++ lunaix-os/usr/.gitignore | 4 +- lunaix-os/usr/LBuild | 1 - lunaix-os/usr/includes | 1 - lunaix-os/usr/libc/arch/i386/crt0.S | 2 +- lunaix-os/usr/libc/arch/i386/trampoline.S | 4 +- lunaix-os/usr/libc/arch/x86_64/crt0.S | 2 +- lunaix-os/usr/libc/arch/x86_64/trampoline.S | 4 +- lunaix-os/usr/libc/includes/dirent.h | 6 +- lunaix-os/usr/libc/includes/errno.h | 6 +- lunaix-os/usr/libc/includes/fcntl.h | 6 +- lunaix-os/usr/libc/includes/lunaix/ioctl.h | 6 +- lunaix-os/usr/libc/includes/lunaix/lunaix.h | 6 +- lunaix-os/usr/libc/includes/lunaix/mann.h | 6 +- lunaix-os/usr/libc/includes/lunaix/mount.h | 6 +- lunaix-os/usr/libc/includes/lunaix/syscall.h | 6 +- lunaix-os/usr/libc/includes/pthread.h | 6 +- lunaix-os/usr/libc/includes/signal.h | 6 +- lunaix-os/usr/libc/includes/stdio.h | 6 +- lunaix-os/usr/libc/includes/stdlib.h | 6 +- lunaix-os/usr/libc/includes/string.h | 6 +- lunaix-os/usr/libc/includes/syscall.h | 8 + lunaix-os/usr/libc/includes/termios.h | 6 +- lunaix-os/usr/libc/includes/unistd.h | 6 +- lunaix-os/usr/libc/src/posix/dirent.c | 4 +- lunaix-os/usr/libc/src/posix/errno.c | 4 +- lunaix-os/usr/libc/src/posix/fcntl.c | 6 +- lunaix-os/usr/libc/src/posix/ioctl.c | 4 +- lunaix-os/usr/libc/src/posix/lunaix.c | 12 +- lunaix-os/usr/libc/src/posix/mann.c | 6 +- lunaix-os/usr/libc/src/posix/mount.c | 6 +- lunaix-os/usr/libc/src/posix/signal.c | 12 +- lunaix-os/usr/libc/src/posix/unistd.c | 72 ++++---- lunaix-os/usr/libc/src/pthread.c | 14 +- 48 files changed, 362 insertions(+), 365 deletions(-) rename lunaix-os/arch/x86/{ => includes/asm}/syscall_nr.inc (100%) create mode 100644 lunaix-os/includes/usr/headers create mode 100644 lunaix-os/includes/usr/headers_autogen delete mode 100644 lunaix-os/includes/usr/lunaix/lxdirent.h delete mode 100644 lunaix-os/includes/usr/lunaix/syscallid.h create mode 100644 lunaix-os/install_headers.mk create mode 100644 lunaix-os/makeinc/kbuild_deps.mkinc create mode 100755 lunaix-os/scripts/gen-syscall-header delete mode 120000 lunaix-os/usr/includes create mode 100644 lunaix-os/usr/libc/includes/syscall.h diff --git a/lunaix-os/.gitignore b/lunaix-os/.gitignore index 9a6b6a8..e70eed3 100644 --- a/lunaix-os/.gitignore +++ b/lunaix-os/.gitignore @@ -18,7 +18,7 @@ !LConfig !makefile !live_debug.sh -!kernel.mk +!*.mk *.[od] *.ld diff --git a/lunaix-os/arch/generic/includes/asm-generic/syscall_nr.inc b/lunaix-os/arch/generic/includes/asm-generic/syscall_nr.inc index 0da2e62..6429afd 100644 --- a/lunaix-os/arch/generic/includes/asm-generic/syscall_nr.inc +++ b/lunaix-os/arch/generic/includes/asm-generic/syscall_nr.inc @@ -2,81 +2,81 @@ # error "SYSCALL missing pointer type" #endif -SYSCALL 0 -SYSCALL __lxsys_fork /* 1 */ -SYSCALL __lxsys_yield -SYSCALL __lxsys_sbrk -SYSCALL __lxsys_brk -SYSCALL __lxsys_getpid /* 5 */ -SYSCALL __lxsys_getppid -SYSCALL __lxsys_sleep -SYSCALL __lxsys_exit -SYSCALL __lxsys_wait -SYSCALL __lxsys_waitpid /* 10 */ -SYSCALL __lxsys_sigreturn -SYSCALL __lxsys_sigprocmask -SYSCALL __lxsys_sys_sigaction -SYSCALL __lxsys_pause -SYSCALL __lxsys_kill /* 15 */ -SYSCALL __lxsys_alarm -SYSCALL __lxsys_sigpending -SYSCALL __lxsys_sigsuspend -SYSCALL __lxsys_open -SYSCALL __lxsys_close /* 20 */ -SYSCALL __lxsys_read -SYSCALL __lxsys_write -SYSCALL __lxsys_sys_readdir -SYSCALL __lxsys_mkdir -SYSCALL __lxsys_lseek /* 25 */ -SYSCALL __lxsys_geterrno -SYSCALL __lxsys_readlink -SYSCALL __lxsys_readlinkat -SYSCALL __lxsys_rmdir -SYSCALL __lxsys_unlink /* 30 */ -SYSCALL __lxsys_unlinkat -SYSCALL __lxsys_link -SYSCALL __lxsys_fsync -SYSCALL __lxsys_dup -SYSCALL __lxsys_dup2 /* 35 */ -SYSCALL __lxsys_realpathat -SYSCALL __lxsys_symlink -SYSCALL __lxsys_chdir -SYSCALL __lxsys_fchdir -SYSCALL __lxsys_getcwd /* 40 */ -SYSCALL __lxsys_rename -SYSCALL __lxsys_mount -SYSCALL __lxsys_unmount -SYSCALL __lxsys_getxattr -SYSCALL __lxsys_setxattr /* 45 */ -SYSCALL __lxsys_fgetxattr -SYSCALL __lxsys_fsetxattr -SYSCALL __lxsys_ioctl -SYSCALL __lxsys_getpgid -SYSCALL __lxsys_setpgid /* 50 */ -SYSCALL __lxsys_syslog -SYSCALL __lxsys_sys_mmap -SYSCALL __lxsys_munmap -SYSCALL __lxsys_execve -SYSCALL __lxsys_fstat /* 55 */ -SYSCALL __lxsys_pollctl -SYSCALL __lxsys_th_create -SYSCALL __lxsys_th_self -SYSCALL __lxsys_th_exit -SYSCALL __lxsys_th_join /* 60 */ -SYSCALL __lxsys_th_kill -SYSCALL __lxsys_th_detach -SYSCALL __lxsys_th_sigmask -SYSCALL __lxsys_getuid -SYSCALL __lxsys_getgid -SYSCALL __lxsys_geteuid -SYSCALL __lxsys_getegid -SYSCALL __lxsys_getgroups -SYSCALL __lxsys_setuid -SYSCALL __lxsys_setgid -SYSCALL __lxsys_seteuid -SYSCALL __lxsys_setegid -SYSCALL __lxsys_setgroups -SYSCALL __lxsys_chroot -SYSCALL __lxsys_fchmodat -SYSCALL __lxsys_fchownat -SYSCALL __lxsys_faccessat \ No newline at end of file +SYSCALL(0) +SYSCALL(__lxsys_fork) +SYSCALL(__lxsys_yield) +SYSCALL(__lxsys_sbrk) +SYSCALL(__lxsys_brk) +SYSCALL(__lxsys_getpid) +SYSCALL(__lxsys_getppid) +SYSCALL(__lxsys_sleep) +SYSCALL(__lxsys_exit) +SYSCALL(__lxsys_wait) +SYSCALL(__lxsys_waitpid) +SYSCALL(__lxsys_sigreturn) +SYSCALL(__lxsys_sigprocmask) +SYSCALL(__lxsys_sys_sigaction) +SYSCALL(__lxsys_pause) +SYSCALL(__lxsys_kill) +SYSCALL(__lxsys_alarm) +SYSCALL(__lxsys_sigpending) +SYSCALL(__lxsys_sigsuspend) +SYSCALL(__lxsys_open) +SYSCALL(__lxsys_close) +SYSCALL(__lxsys_read) +SYSCALL(__lxsys_write) +SYSCALL(__lxsys_sys_readdir) +SYSCALL(__lxsys_mkdir) +SYSCALL(__lxsys_lseek) +SYSCALL(__lxsys_geterrno) +SYSCALL(__lxsys_readlink) +SYSCALL(__lxsys_readlinkat) +SYSCALL(__lxsys_rmdir) +SYSCALL(__lxsys_unlink) +SYSCALL(__lxsys_unlinkat) +SYSCALL(__lxsys_link) +SYSCALL(__lxsys_fsync) +SYSCALL(__lxsys_dup) +SYSCALL(__lxsys_dup2) +SYSCALL(__lxsys_realpathat) +SYSCALL(__lxsys_symlink) +SYSCALL(__lxsys_chdir) +SYSCALL(__lxsys_fchdir) +SYSCALL(__lxsys_getcwd) +SYSCALL(__lxsys_rename) +SYSCALL(__lxsys_mount) +SYSCALL(__lxsys_unmount) +SYSCALL(__lxsys_getxattr) +SYSCALL(__lxsys_setxattr) +SYSCALL(__lxsys_fgetxattr) +SYSCALL(__lxsys_fsetxattr) +SYSCALL(__lxsys_ioctl) +SYSCALL(__lxsys_getpgid) +SYSCALL(__lxsys_setpgid) +SYSCALL(__lxsys_syslog) +SYSCALL(__lxsys_sys_mmap) +SYSCALL(__lxsys_munmap) +SYSCALL(__lxsys_execve) +SYSCALL(__lxsys_fstat) +SYSCALL(__lxsys_pollctl) +SYSCALL(__lxsys_th_create) +SYSCALL(__lxsys_th_self) +SYSCALL(__lxsys_th_exit) +SYSCALL(__lxsys_th_join) +SYSCALL(__lxsys_th_kill) +SYSCALL(__lxsys_th_detach) +SYSCALL(__lxsys_th_sigmask) +SYSCALL(__lxsys_getuid) +SYSCALL(__lxsys_getgid) +SYSCALL(__lxsys_geteuid) +SYSCALL(__lxsys_getegid) +SYSCALL(__lxsys_getgroups) +SYSCALL(__lxsys_setuid) +SYSCALL(__lxsys_setgid) +SYSCALL(__lxsys_seteuid) +SYSCALL(__lxsys_setegid) +SYSCALL(__lxsys_setgroups) +SYSCALL(__lxsys_chroot) +SYSCALL(__lxsys_fchmodat) +SYSCALL(__lxsys_fchownat) +SYSCALL(__lxsys_faccessat) diff --git a/lunaix-os/arch/x86/syscall_nr.inc b/lunaix-os/arch/x86/includes/asm/syscall_nr.inc similarity index 100% rename from lunaix-os/arch/x86/syscall_nr.inc rename to lunaix-os/arch/x86/includes/asm/syscall_nr.inc diff --git a/lunaix-os/arch/x86/syscall_lut.S b/lunaix-os/arch/x86/syscall_lut.S index 4bee0b4..d3c9b86 100644 --- a/lunaix-os/arch/x86/syscall_lut.S +++ b/lunaix-os/arch/x86/syscall_lut.S @@ -2,18 +2,18 @@ #include #ifdef CONFIG_ARCH_X86_64 -# define SYSCALL .8byte +# define SYSCALL(x) .8byte x # define SIZE 8 #else +# define SYSCALL(x) .4byte x # define SIZE 4 -# define SYSCALL .4byte #endif .section .data .global __syscall_table __syscall_table: 1: - #include "syscall_nr.inc" + #include 2: .rept __SYSCALL_MAX - (2b - 1b) / SIZE .long 0 diff --git a/lunaix-os/includes/lunaix/syscall.h b/lunaix-os/includes/lunaix/syscall.h index 1b9778f..1460013 100644 --- a/lunaix-os/includes/lunaix/syscall.h +++ b/lunaix-os/includes/lunaix/syscall.h @@ -1,7 +1,7 @@ #ifndef __LUNAIX_SYSCALL_H #define __LUNAIX_SYSCALL_H -#include +#define __SYSCALL_MAX 1024 #ifndef __ASM__ diff --git a/lunaix-os/includes/usr/headers b/lunaix-os/includes/usr/headers new file mode 100644 index 0000000..1a4af01 --- /dev/null +++ b/lunaix-os/includes/usr/headers @@ -0,0 +1,14 @@ +lunaix/fstypes.h +lunaix/status.h +lunaix/fcntl_defs.h +lunaix/signal_defs.h +lunaix/term.h +lunaix/mann_flags.h +lunaix/dirent_defs.h +lunaix/poll.h +lunaix/types.h +lunaix/serial.h +lunaix/device.h +lunaix/ioctl_defs.h +lunaix/threads.h +lunaix/gfx.h diff --git a/lunaix-os/includes/usr/headers_autogen b/lunaix-os/includes/usr/headers_autogen new file mode 100644 index 0000000..4ec2da9 --- /dev/null +++ b/lunaix-os/includes/usr/headers_autogen @@ -0,0 +1 @@ +lunaix/syscallid.h \ No newline at end of file diff --git a/lunaix-os/includes/usr/lunaix/lxdirent.h b/lunaix-os/includes/usr/lunaix/lxdirent.h deleted file mode 100644 index 6793d99..0000000 --- a/lunaix-os/includes/usr/lunaix/lxdirent.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __LUNAIX_SYS_LXDIRENT_H -#define __LUNAIX_SYS_LXDIRENT_H - -#include - -int sys_readdir(int fd, struct lx_dirent* dirent); - -#endif /* __LUNAIX_DIRENT_H */ diff --git a/lunaix-os/includes/usr/lunaix/status.h b/lunaix-os/includes/usr/lunaix/status.h index e457232..5ba3438 100644 --- a/lunaix-os/includes/usr/lunaix/status.h +++ b/lunaix-os/includes/usr/lunaix/status.h @@ -1,42 +1,35 @@ #ifndef __LUNAIX_STATUS_H #define __LUNAIX_STATUS_H -#define LXPROCFULL -(1) -#define LXHEAPFULL -(2) -#define LXINVLDPTR -(2) -#define LXOUTOFMEM -(3) -#define LXSEGFAULT -(5) -#define EINVAL -(6) - -#define EINTR -(7) - -#define EMFILE -8 -#define ENOENT -9 -#define ENAMETOOLONG -10 -#define ENOTDIR -11 -#define EEXIST -12 -#define EBADF -13 -#define ENOTSUP -14 -#define EIO -15 -#define ELOOP -16 -#define ENOTEMPTY -17 -#define EROFS -18 -#define EISDIR -19 -#define EBUSY -20 -#define EXDEV -21 -#define ENODEV -22 -#define ERANGE -23 -#define ENOMEM LXOUTOFMEM -#define ENOTDEV -24 -#define EOVERFLOW -25 -#define ENOTBLK -26 -#define ENOEXEC -27 -#define E2BIG -28 -#define ELIBBAD -29 -#define EAGAIN -30 -#define EDEADLK -31 -#define EDQUOT -32 -#define EPERM -33 -#define EACCESS -34 +#define ENOMEM -3 +#define EINVAL -6 +#define EINTR -7 +#define EMFILE -8 +#define ENOENT -9 +#define ENAMETOOLONG -10 +#define ENOTDIR -11 +#define EEXIST -12 +#define EBADF -13 +#define ENOTSUP -14 +#define EIO -15 +#define ELOOP -16 +#define ENOTEMPTY -17 +#define EROFS -18 +#define EISDIR -19 +#define EBUSY -20 +#define EXDEV -21 +#define ENODEV -22 +#define ERANGE -23 +#define ENOTDEV -24 +#define EOVERFLOW -25 +#define ENOTBLK -26 +#define ENOEXEC -27 +#define E2BIG -28 +#define ELIBBAD -29 +#define EAGAIN -30 +#define EDEADLK -31 +#define EDQUOT -32 +#define EPERM -33 +#define EACCESS -34 #endif /* __LUNAIX_STATUS_H */ diff --git a/lunaix-os/includes/usr/lunaix/syscallid.h b/lunaix-os/includes/usr/lunaix/syscallid.h deleted file mode 100644 index 7e995f1..0000000 --- a/lunaix-os/includes/usr/lunaix/syscallid.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __LUNAIX_SYSCALLID_H -#define __LUNAIX_SYSCALLID_H - -#define __SYSCALL_fork 1 -#define __SYSCALL_yield 2 -#define __SYSCALL_sbrk 3 -#define __SYSCALL_brk 4 -#define __SYSCALL_getpid 5 -#define __SYSCALL_getppid 6 -#define __SYSCALL_sleep 7 -#define __SYSCALL__exit 8 -#define __SYSCALL_wait 9 -#define __SYSCALL_waitpid 10 - -#define __SYSCALL_sigreturn 11 -#define __SYSCALL_sigprocmask 12 -#define __SYSCALL_sys_sigaction 13 -#define __SYSCALL_pause 14 -#define __SYSCALL_kill 15 -#define __SYSCALL_alarm 16 -#define __SYSCALL_sigpending 17 -#define __SYSCALL_sigsuspend 18 -#define __SYSCALL_open 19 -#define __SYSCALL_close 20 - -#define __SYSCALL_read 21 -#define __SYSCALL_write 22 -#define __SYSCALL_sys_readdir 23 -#define __SYSCALL_mkdir 24 -#define __SYSCALL_lseek 25 -#define __SYSCALL_geterrno 26 -#define __SYSCALL_readlink 27 -#define __SYSCALL_readlinkat 28 -#define __SYSCALL_rmdir 29 - -#define __SYSCALL_unlink 30 -#define __SYSCALL_unlinkat 31 -#define __SYSCALL_link 32 -#define __SYSCALL_fsync 33 -#define __SYSCALL_dup 34 -#define __SYSCALL_dup2 35 -#define __SYSCALL_realpathat 36 -#define __SYSCALL_symlink 37 -#define __SYSCALL_chdir 38 -#define __SYSCALL_fchdir 39 -#define __SYSCALL_getcwd 40 -#define __SYSCALL_rename 41 -#define __SYSCALL_mount 42 -#define __SYSCALL_unmount 43 -#define __SYSCALL_getxattr 44 -#define __SYSCALL_setxattr 45 -#define __SYSCALL_fgetxattr 46 -#define __SYSCALL_fsetxattr 47 - -#define __SYSCALL_ioctl 48 -#define __SYSCALL_getpgid 49 -#define __SYSCALL_setpgid 50 - -#define __SYSCALL_syslog 51 - -#define __SYSCALL_sys_mmap 52 -#define __SYSCALL_munmap 53 - -#define __SYSCALL_execve 54 - -#define __SYSCALL_fstat 55 -#define __SYSCALL_pollctl 56 - -#define __SYSCALL_th_create 57 -#define __SYSCALL_th_self 58 -#define __SYSCALL_th_exit 59 -#define __SYSCALL_th_join 60 -#define __SYSCALL_th_kill 61 -#define __SYSCALL_th_detach 62 -#define __SYSCALL_th_sigmask 63 - -#define __SYSCALL_MAX 0x200 - -#endif /* __LUNAIX_SYSCALLID_H */ diff --git a/lunaix-os/install_headers.mk b/lunaix-os/install_headers.mk new file mode 100644 index 0000000..d636375 --- /dev/null +++ b/lunaix-os/install_headers.mk @@ -0,0 +1,28 @@ +include kbuild_deps.mkinc + +ifndef PREFIX + $(error "Must specify PREFIX to header install location") +endif + +USR_HEADER := includes/usr + +HEADERS := $(shell cat $(USR_HEADER)/headers) +HEADERS += $(shell cat $(USR_HEADER)/headers_autogen) + +INSTALL := $(addprefix $(PREFIX)/,$(HEADERS)) + +export CFLAGS=$(kcflags) +$(PREFIX)/lunaix/syscallid.h: + @scripts/gen-syscall-header "$@" + +.SECONDEXPANSION: +.PRECIOUS: $(PREFIX)/%/ + +$(PREFIX)/%/: + @mkdir -p $@ + +$(PREFIX)/%.h : $(USR_HEADER)/%.h $$(dir $$@) + $(call status,INSTALL,$@) + @cp $< $@ + +all: $(INSTALL) \ No newline at end of file diff --git a/lunaix-os/kernel.mk b/lunaix-os/kernel.mk index bb64364..a0a2404 100644 --- a/lunaix-os/kernel.mk +++ b/lunaix-os/kernel.mk @@ -1,42 +1,31 @@ -include toolchain.mkinc -include lunabuild.mkinc - -include $(lbuild_mkinc) +include kbuild_deps.mkinc kbin_dir := $(BUILD_DIR) kbin := $(BUILD_NAME) -ksrc_objs := $(addsuffix .o,$(_LBUILD_SRCS)) -ksrc_deps := $(addsuffix .d,$(_LBUILD_SRCS)) -khdr_opts := $(addprefix -include ,$(_LBUILD_HDRS)) -kinc_opts := $(addprefix -I,$(_LBUILD_INCS)) -config_h += -include $(lbuild_config_h) - tmp_kbin := $(BUILD_DIR)/tmpk.bin klinking := link/lunaix.ld -CFLAGS += $(khdr_opts) $(kinc_opts) $(config_h) -MMD -MP - --include $(ksrc_deps) +CFLAGS += $(kcflags) -MMD -MP all_linkable = $(filter-out $(klinking),$(1)) %.S.o: %.S $(khdr_files) kernel.mk - $(call status_,AS,$<) + $(call status,AS,$<) @$(CC) $(CFLAGS) -c $< -o $@ %.c.o: %.c kernel.mk - $(call status_,CC,$<) + $(call status,CC,$<) @$(CC) $(CFLAGS) -c $< -o $@ $(klinking): link/lunaix.ldx - $(call status_,PP,$<) + $(call status,PP,$<) @$(CC) $(CFLAGS) -x c -E -P $< -o $@ $(tmp_kbin): $(klinking) $(ksrc_objs) - $(call status_,LD,$@) + $(call status,LD,$@) @$(CC) -T $(klinking) $(config_h) $(LDFLAGS) -o $@ \ $(call all_linkable,$^) @@ -47,13 +36,13 @@ ksecsmap := lunaix_ksecsmap.o kautogen := $(ksecsmap) $(ksymtable) $(ksymtable): $(tmp_kbin) - $(call status_,KSYM,$@) + $(call status,KSYM,$@) @ARCH=$(ARCH) scripts/gen-ksymtable DdRrTtAGg $< > lunaix_ksymtable.S @$(CC) $(CFLAGS) -c lunaix_ksymtable.S -o $@ $(ksecsmap): $(tmp_kbin) - $(call status_,KGEN,$@) + $(call status,KGEN,$@) @scripts/elftool.tool -p -i $< > lunaix_ksecsmap.S @$(CC) $(CFLAGS) -c lunaix_ksecsmap.S -o $@ @@ -61,7 +50,7 @@ $(ksecsmap): $(tmp_kbin) .PHONY: __do_relink __do_relink: $(klinking) $(ksrc_objs) $(kautogen) - $(call status_,LD,$(kbin)) + $(call status,LD,$(kbin)) @$(CC) -T $(klinking) $(config_h) $(LDFLAGS) -o $(kbin) \ $(call all_linkable,$^) diff --git a/lunaix-os/makefile b/lunaix-os/makefile index 9895780..5d6d2af 100644 --- a/lunaix-os/makefile +++ b/lunaix-os/makefile @@ -34,6 +34,8 @@ $(kbuild_dir): @mkdir -p $(os_img_dir)/usr .PHONY: kernel +.PHONY: rootfs all clean-user clean tool + export BUILD_DIR=$(kbin_dir) export BUILD_NAME=$(kbin) kernel: $(lbuild_mkinc) @@ -41,32 +43,32 @@ kernel: $(lbuild_mkinc) @$(MAKE) $(MKFLAGS) -I $(mkinc_dir) -f kernel.mk all -.PHONY: rootfs all clean-user clean tool - -tool: - $(call status,TASK,$@) - @$(MAKE) $(MKFLAGS) -C scripts all -I $(mkinc_dir) - .NOTPARALLEL: export LBUILD ARCH MODE all: $(kbuild_dir) tool kernel -rootfs: usr/build - $(call status,TASK,$(notdir $@)) - @./scripts/mkrootfs +# --- begin stock user --- # -usr/build: user - -prepare: $(os_img_dir) +export PREFIX=usr/includes +usr/includes: install-header export LBUILD ARCH MODE -user: +user: usr/includes $(call status,TASK,$@) @$(MAKE) $(MKFLAGS) -C usr all -I $(mkinc_dir) clean-user: @$(MAKE) -C usr clean -I $(mkinc_dir) +rootfs: usr/build + $(call status,TASK,$(notdir $@)) + @./scripts/mkrootfs + +usr/build: user + +# --- end stock user --- # + + clean: @$(MAKE) $(MKFLAGS) -C usr clean -I $(mkinc_dir) @$(MAKE) $(MKFLAGS) -C scripts clean -I $(mkinc_dir) @@ -76,6 +78,18 @@ clean: @rm -rf $(kbuild_dir) || exit 1 @rm -rf .builder || exit 1 + +# --- begin misc --- # + export CFLAGS=-include $(lbuild_config_h) unit-test: $(lbuild_config_h) - @$(MAKE) $(MKFLAGS) -C tests/units run \ No newline at end of file + @$(MAKE) $(MKFLAGS) -C tests/units run + +tool: + $(call status,TASK,$@) + @$(MAKE) $(MKFLAGS) -C scripts all -I $(mkinc_dir) + +install-header: + @$(MAKE) $(MKFLAGS) -I $(mkinc_dir) -f install_headers.mk all + +# --- end misc --- # \ No newline at end of file diff --git a/lunaix-os/makeinc/kbuild_deps.mkinc b/lunaix-os/makeinc/kbuild_deps.mkinc new file mode 100644 index 0000000..92e11b1 --- /dev/null +++ b/lunaix-os/makeinc/kbuild_deps.mkinc @@ -0,0 +1,15 @@ +include toolchain.mkinc +include lunabuild.mkinc +include utils.mkinc + +include $(lbuild_mkinc) + +ksrc_objs := $(addsuffix .o,$(_LBUILD_SRCS)) +ksrc_deps := $(addsuffix .d,$(_LBUILD_SRCS)) +khdr_opts := $(addprefix -include ,$(_LBUILD_HDRS)) +kinc_opts := $(addprefix -I,$(_LBUILD_INCS)) +config_h += -include $(lbuild_config_h) + +kcflags := $(khdr_opts) $(kinc_opts) $(config_h) + +-include $(ksrc_deps) \ No newline at end of file diff --git a/lunaix-os/scripts/gen-syscall-header b/lunaix-os/scripts/gen-syscall-header new file mode 100755 index 0000000..b32a52d --- /dev/null +++ b/lunaix-os/scripts/gen-syscall-header @@ -0,0 +1,22 @@ +#!/bin/bash + +outfile="$1" + +read -d '' payload < +EOF + +body=$(echo "$payload" \ + | gcc $CFLAGS -x none -E - -o- -nostdlib -P \ + | sed -e 's/^__NR__/#define __NR__/' \ + | sed -e '/#define/!d') + +cat < "$outfile" +#ifndef __LUNAIX_SYSCALL_H +#define __LUNAIX_SYSCALL_H + +$body + +#endif +EOF \ No newline at end of file diff --git a/lunaix-os/usr/.gitignore b/lunaix-os/usr/.gitignore index 0d76625..d9b84aa 100644 --- a/lunaix-os/usr/.gitignore +++ b/lunaix-os/usr/.gitignore @@ -2,4 +2,6 @@ build/ .vscode/ -uexec.ld \ No newline at end of file +uexec.ld + +includes/** \ No newline at end of file diff --git a/lunaix-os/usr/LBuild b/lunaix-os/usr/LBuild index 320bbeb..0561206 100644 --- a/lunaix-os/usr/LBuild +++ b/lunaix-os/usr/LBuild @@ -9,7 +9,6 @@ sources([ "maze", "mkdir", "rm", - "testfork", "fragfile", ]) diff --git a/lunaix-os/usr/includes b/lunaix-os/usr/includes deleted file mode 120000 index 6e4b52e..0000000 --- a/lunaix-os/usr/includes +++ /dev/null @@ -1 +0,0 @@ -../includes/usr \ No newline at end of file diff --git a/lunaix-os/usr/libc/arch/i386/crt0.S b/lunaix-os/usr/libc/arch/i386/crt0.S index 1418068..49fbcb7 100644 --- a/lunaix-os/usr/libc/arch/i386/crt0.S +++ b/lunaix-os/usr/libc/arch/i386/crt0.S @@ -24,7 +24,7 @@ 1: movl %eax, %ebx - movl $__SYSCALL__exit, %eax + movl $__NR__lxsys_exit, %eax int $33 ud2 // should not reach \ No newline at end of file diff --git a/lunaix-os/usr/libc/arch/i386/trampoline.S b/lunaix-os/usr/libc/arch/i386/trampoline.S index 3ff23e2..378dce4 100644 --- a/lunaix-os/usr/libc/arch/i386/trampoline.S +++ b/lunaix-os/usr/libc/arch/i386/trampoline.S @@ -15,7 +15,7 @@ addl $12, %esp - movl $__SYSCALL_sigreturn, %eax + movl $__NR__lxsys_sigreturn, %eax popl %ebx int $33 @@ -28,5 +28,5 @@ calll *%eax movl %eax, %ebx - movl $__SYSCALL_th_exit, %eax + movl $__NR__lxsys_th_exit, %eax int $33 \ No newline at end of file diff --git a/lunaix-os/usr/libc/arch/x86_64/crt0.S b/lunaix-os/usr/libc/arch/x86_64/crt0.S index 25786df..01c69db 100644 --- a/lunaix-os/usr/libc/arch/x86_64/crt0.S +++ b/lunaix-os/usr/libc/arch/x86_64/crt0.S @@ -21,7 +21,7 @@ 1: movq %rax, %rbx - movq $__SYSCALL__exit, %rax + movq $__NR__lxsys_exit, %rax int $33 ud2 // should not reach \ No newline at end of file diff --git a/lunaix-os/usr/libc/arch/x86_64/trampoline.S b/lunaix-os/usr/libc/arch/x86_64/trampoline.S index 62064c2..a820550 100644 --- a/lunaix-os/usr/libc/arch/x86_64/trampoline.S +++ b/lunaix-os/usr/libc/arch/x86_64/trampoline.S @@ -20,7 +20,7 @@ leaq 4(%rax), %rdx // (struct siguctx*)&sigact call sig_dohandling - movq $__SYSCALL_sigreturn, %rax + movq $__NR__lxsys_sigreturn, %rax popq %rbx int $33 @@ -32,5 +32,5 @@ callq *%rax movq %rax, %rbx - movq $__SYSCALL_th_exit, %rax + movq $__NR__lxsys_th_exit, %rax int $33 \ No newline at end of file diff --git a/lunaix-os/usr/libc/includes/dirent.h b/lunaix-os/usr/libc/includes/dirent.h index 9748c8c..5007d28 100644 --- a/lunaix-os/usr/libc/includes/dirent.h +++ b/lunaix-os/usr/libc/includes/dirent.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_DIRENT_H -#define __LUNAIX_SYS_DIRENT_H +#ifndef __LUNALIBC_SYS_DIRENT_H +#define __LUNALIBC_SYS_DIRENT_H #include @@ -27,4 +27,4 @@ readdir(DIR* dir); extern int sys_readdir(int fd, struct lx_dirent* dirent); -#endif /* __LUNAIX_DIRENT_H */ +#endif /* __LUNALIBC_DIRENT_H */ diff --git a/lunaix-os/usr/libc/includes/errno.h b/lunaix-os/usr/libc/includes/errno.h index 4377190..c59d539 100644 --- a/lunaix-os/usr/libc/includes/errno.h +++ b/lunaix-os/usr/libc/includes/errno.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_ERRNO_H -#define __LUNAIX_SYS_ERRNO_H +#ifndef __LUNALIBC_SYS_ERRNO_H +#define __LUNALIBC_SYS_ERRNO_H #include @@ -7,4 +7,4 @@ extern int geterrno(); #define errno (geterrno()) -#endif /* __LUNAIX_ERRNO_H */ +#endif /* __LUNALIBC_ERRNO_H */ diff --git a/lunaix-os/usr/libc/includes/fcntl.h b/lunaix-os/usr/libc/includes/fcntl.h index 7e89dc2..b818307 100644 --- a/lunaix-os/usr/libc/includes/fcntl.h +++ b/lunaix-os/usr/libc/includes/fcntl.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_FCNTL_H -#define __LUNAIX_SYS_FCNTL_H +#ifndef __LUNALIBC_SYS_FCNTL_H +#define __LUNALIBC_SYS_FCNTL_H #include #include @@ -10,4 +10,4 @@ open(const char* path, int flags); extern int fstat(int fd, struct file_stat* stat); -#endif /* __LUNAIX_FCNTL_H */ +#endif /* __LUNALIBC_FCNTL_H */ diff --git a/lunaix-os/usr/libc/includes/lunaix/ioctl.h b/lunaix-os/usr/libc/includes/lunaix/ioctl.h index b185ac2..34963cc 100644 --- a/lunaix-os/usr/libc/includes/lunaix/ioctl.h +++ b/lunaix-os/usr/libc/includes/lunaix/ioctl.h @@ -1,8 +1,8 @@ -#ifndef __LUNAIX_SYS_IOCTL_H -#define __LUNAIX_SYS_IOCTL_H +#ifndef __LUNALIBC_SYS_IOCTL_H +#define __LUNALIBC_SYS_IOCTL_H #include int ioctl(int fd, int req, ...); -#endif /* __LUNAIX_IOCTL_H */ +#endif /* __LUNALIBC_IOCTL_H */ diff --git a/lunaix-os/usr/libc/includes/lunaix/lunaix.h b/lunaix-os/usr/libc/includes/lunaix/lunaix.h index c793dad..6782969 100644 --- a/lunaix-os/usr/libc/includes/lunaix/lunaix.h +++ b/lunaix-os/usr/libc/includes/lunaix/lunaix.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_LUNAIX_H -#define __LUNAIX_SYS_LUNAIX_H +#ifndef __LUNALIBC_SYS_LUNAIX_H +#define __LUNALIBC_SYS_LUNAIX_H #include #include @@ -19,4 +19,4 @@ syslog(int level, const char* fmt, ...); int realpathat(int fd, char* buf, size_t size); -#endif /* __LUNAIX_LUNAIX_H */ +#endif /* __LUNALIBC_LUNAIX_H */ diff --git a/lunaix-os/usr/libc/includes/lunaix/mann.h b/lunaix-os/usr/libc/includes/lunaix/mann.h index 2527572..2e7f12f 100644 --- a/lunaix-os/usr/libc/includes/lunaix/mann.h +++ b/lunaix-os/usr/libc/includes/lunaix/mann.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_MANN_H -#define __LUNAIX_SYS_MANN_H +#ifndef __LUNALIBC_SYS_MANN_H +#define __LUNALIBC_SYS_MANN_H #include #include @@ -9,4 +9,4 @@ void* mmap(void* addr, size_t length, int proct, int flags, int fd, off_t offset int munmap(void* addr, size_t length); -#endif /* __LUNAIX_MANN_H */ +#endif /* __LUNALIBC_MANN_H */ diff --git a/lunaix-os/usr/libc/includes/lunaix/mount.h b/lunaix-os/usr/libc/includes/lunaix/mount.h index 4f41c70..db90f10 100644 --- a/lunaix-os/usr/libc/includes/lunaix/mount.h +++ b/lunaix-os/usr/libc/includes/lunaix/mount.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_MOUNT_H -#define __LUNAIX_SYS_MOUNT_H +#ifndef __LUNALIBC_SYS_MOUNT_H +#define __LUNALIBC_SYS_MOUNT_H #include @@ -11,4 +11,4 @@ static inline int umount(const char* target) { return unmount(target); } -#endif /* __LUNAIX_MOUNT_H */ +#endif /* __LUNALIBC_MOUNT_H */ diff --git a/lunaix-os/usr/libc/includes/lunaix/syscall.h b/lunaix-os/usr/libc/includes/lunaix/syscall.h index 26ab167..eb622e1 100644 --- a/lunaix-os/usr/libc/includes/lunaix/syscall.h +++ b/lunaix-os/usr/libc/includes/lunaix/syscall.h @@ -1,9 +1,9 @@ -#ifndef __LUNAIX_OSDEPS_SYSCALL_H -#define __LUNAIX_OSDEPS_SYSCALL_H +#ifndef __LUNALIBC_OSDEPS_SYSCALL_H +#define __LUNALIBC_OSDEPS_SYSCALL_H #include extern unsigned long do_lunaix_syscall(unsigned long call_id, ...); -#endif /* __LUNAIX_OSDEPS_SYSCALL_H */ +#endif /* __LUNALIBC_OSDEPS_SYSCALL_H */ diff --git a/lunaix-os/usr/libc/includes/pthread.h b/lunaix-os/usr/libc/includes/pthread.h index 3fc925a..8dee741 100644 --- a/lunaix-os/usr/libc/includes/pthread.h +++ b/lunaix-os/usr/libc/includes/pthread.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_PTHREAD_H -#define __LUNAIX_PTHREAD_H +#ifndef __LUNALIBC_PTHREAD_H +#define __LUNALIBC_PTHREAD_H #include @@ -30,4 +30,4 @@ pthread_t pthread_self(void); -#endif /* __LUNAIX_PTHREAD_H */ +#endif /* __LUNALIBC_PTHREAD_H */ diff --git a/lunaix-os/usr/libc/includes/signal.h b/lunaix-os/usr/libc/includes/signal.h index 4d934ef..742e5e8 100644 --- a/lunaix-os/usr/libc/includes/signal.h +++ b/lunaix-os/usr/libc/includes/signal.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_SIGNAL_H -#define __LUNAIX_SYS_SIGNAL_H +#ifndef __LUNALIBC_SYS_SIGNAL_H +#define __LUNALIBC_SYS_SIGNAL_H #include #include @@ -29,4 +29,4 @@ int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict oset); -#endif /* __LUNAIX_SIGNAL_H */ +#endif /* __LUNALIBC_SIGNAL_H */ diff --git a/lunaix-os/usr/libc/includes/stdio.h b/lunaix-os/usr/libc/includes/stdio.h index f62e46e..5aae9fa 100644 --- a/lunaix-os/usr/libc/includes/stdio.h +++ b/lunaix-os/usr/libc/includes/stdio.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_USTDIO_H -#define __LUNAIX_USTDIO_H +#ifndef __LUNALIBC_USTDIO_H +#define __LUNALIBC_USTDIO_H #include @@ -15,4 +15,4 @@ vsnprintf(char* buffer, unsigned int size, const char* fmt, va_list ap); int snprintf(char* buffer, unsigned int size, const char* fmt, ...); -#endif /* __LUNAIX_USTDIO_H */ +#endif /* __LUNALIBC_USTDIO_H */ diff --git a/lunaix-os/usr/libc/includes/stdlib.h b/lunaix-os/usr/libc/includes/stdlib.h index 72bd663..2200a91 100644 --- a/lunaix-os/usr/libc/includes/stdlib.h +++ b/lunaix-os/usr/libc/includes/stdlib.h @@ -1,6 +1,6 @@ -#ifndef __LUNAIX_STDLIB_H -#define __LUNAIX_STDLIB_H +#ifndef __LUNALIBC_STDLIB_H +#define __LUNALIBC_STDLIB_H extern char* itoa(int value, char* str, int base); -#endif /* __LUNAIX_STDLIB_H */ +#endif /* __LUNALIBC_STDLIB_H */ diff --git a/lunaix-os/usr/libc/includes/string.h b/lunaix-os/usr/libc/includes/string.h index e9313b7..3336671 100644 --- a/lunaix-os/usr/libc/includes/string.h +++ b/lunaix-os/usr/libc/includes/string.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_STRING_H -#define __LUNAIX_STRING_H +#ifndef __LUNALIBC_STRING_H +#define __LUNALIBC_STRING_H #include @@ -15,4 +15,4 @@ extern char* strcpy(char* dest, const char* src); extern int strcmp(const char* s1, const char* s2); -#endif /* __LUNAIX_STRING_H */ +#endif /* __LUNALIBC_STRING_H */ diff --git a/lunaix-os/usr/libc/includes/syscall.h b/lunaix-os/usr/libc/includes/syscall.h new file mode 100644 index 0000000..4ec2a2a --- /dev/null +++ b/lunaix-os/usr/libc/includes/syscall.h @@ -0,0 +1,8 @@ +#ifndef __LUNALIBC_SYSCALL_H +#define __LUNALIBC_SYSCALL_H + +#include + +unsigned long do_lunaix_syscall(int num, ...); + +#endif /* __LUNALIBC_SYSCALL_H */ diff --git a/lunaix-os/usr/libc/includes/termios.h b/lunaix-os/usr/libc/includes/termios.h index abdcf85..aa4478d 100644 --- a/lunaix-os/usr/libc/includes/termios.h +++ b/lunaix-os/usr/libc/includes/termios.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_TERMIOS_H -#define __LUNAIX_TERMIOS_H +#ifndef __LUNALIBC_TERMIOS_H +#define __LUNALIBC_TERMIOS_H #include @@ -118,4 +118,4 @@ int tcgetattr(int, struct termios *); int tcsendbreak(int, int); int tcsetattr(int, int, const struct termios *); -#endif /* __LUNAIX_TERMIOS_H */ +#endif /* __LUNALIBC_TERMIOS_H */ diff --git a/lunaix-os/usr/libc/includes/unistd.h b/lunaix-os/usr/libc/includes/unistd.h index fc607fa..d42b575 100644 --- a/lunaix-os/usr/libc/includes/unistd.h +++ b/lunaix-os/usr/libc/includes/unistd.h @@ -1,5 +1,5 @@ -#ifndef __LUNAIX_SYS_UNISTD_H -#define __LUNAIX_SYS_UNISTD_H +#ifndef __LUNALIBC_SYS_UNISTD_H +#define __LUNALIBC_SYS_UNISTD_H #include #include @@ -111,4 +111,4 @@ fsetxattr(int fd, const char* name, void* value, size_t len); extern int execve(const char* filename, const char* argv[], const char* envp[]); -#endif /* __LUNAIX_UNISTD_H */ +#endif /* __LUNALIBC_UNISTD_H */ diff --git a/lunaix-os/usr/libc/src/posix/dirent.c b/lunaix-os/usr/libc/src/posix/dirent.c index 6651d5e..c9e1636 100644 --- a/lunaix-os/usr/libc/src/posix/dirent.c +++ b/lunaix-os/usr/libc/src/posix/dirent.c @@ -1,8 +1,8 @@ -#include +#include #include int sys_readdir(int fd, struct lx_dirent* dirent) { - return do_lunaix_syscall(__SYSCALL_sys_readdir, fd, dirent); + return do_lunaix_syscall(__NR__lxsys_sys_readdir, fd, dirent); } \ No newline at end of file diff --git a/lunaix-os/usr/libc/src/posix/errno.c b/lunaix-os/usr/libc/src/posix/errno.c index 1652995..b81b84b 100644 --- a/lunaix-os/usr/libc/src/posix/errno.c +++ b/lunaix-os/usr/libc/src/posix/errno.c @@ -1,8 +1,8 @@ -#include +#include #include int geterrno() { - return do_lunaix_syscall(__SYSCALL_geterrno); + return do_lunaix_syscall(__NR__lxsys_geterrno); } \ No newline at end of file diff --git a/lunaix-os/usr/libc/src/posix/fcntl.c b/lunaix-os/usr/libc/src/posix/fcntl.c index 28f1ff3..f8c319e 100644 --- a/lunaix-os/usr/libc/src/posix/fcntl.c +++ b/lunaix-os/usr/libc/src/posix/fcntl.c @@ -1,14 +1,14 @@ -#include +#include #include int open(const char* path, int options) { - return do_lunaix_syscall(__SYSCALL_open, path, options); + return do_lunaix_syscall(__NR__lxsys_open, path, options); } int fstat(int fd, struct file_stat* stat) { - return do_lunaix_syscall(__SYSCALL_fstat, fd, stat); + return do_lunaix_syscall(__NR__lxsys_fstat, fd, stat); } \ No newline at end of file diff --git a/lunaix-os/usr/libc/src/posix/ioctl.c b/lunaix-os/usr/libc/src/posix/ioctl.c index d3a89a8..1eb5062 100644 --- a/lunaix-os/usr/libc/src/posix/ioctl.c +++ b/lunaix-os/usr/libc/src/posix/ioctl.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,7 +8,7 @@ ioctl(int fd, int req, ...) va_list ap; va_start(ap, req); - int ret = do_lunaix_syscall(__SYSCALL_ioctl, fd, req, &ap); + int ret = do_lunaix_syscall(__NR__lxsys_ioctl, fd, req, &ap); va_end(ap); return ret; diff --git a/lunaix-os/usr/libc/src/posix/lunaix.c b/lunaix-os/usr/libc/src/posix/lunaix.c index 452f02d..7558ef7 100644 --- a/lunaix-os/usr/libc/src/posix/lunaix.c +++ b/lunaix-os/usr/libc/src/posix/lunaix.c @@ -1,23 +1,23 @@ -#include +#include #include #include void yield() { - do_lunaix_syscall(__SYSCALL_yield); + do_lunaix_syscall(__NR__lxsys_yield); } pid_t wait(int* status) { - return do_lunaix_syscall(__SYSCALL_wait, status); + return do_lunaix_syscall(__NR__lxsys_wait, status); } pid_t waitpid(pid_t pid, int* status, int options) { - return do_lunaix_syscall(__SYSCALL_waitpid, pid, status, options); + return do_lunaix_syscall(__NR__lxsys_waitpid, pid, status, options); } void @@ -28,7 +28,7 @@ syslog(int level, const char* fmt, ...) va_start(ap, fmt); unsigned int size = vsnprintf(buf, 1024, fmt, ap); - do_lunaix_syscall(__SYSCALL_syslog, level, buf, size); + do_lunaix_syscall(__NR__lxsys_syslog, level, buf, size); va_end(ap); } @@ -36,5 +36,5 @@ syslog(int level, const char* fmt, ...) int realpathat(int fd, char* buf, size_t size) { - return do_lunaix_syscall(__SYSCALL_realpathat, fd, buf, size); + return do_lunaix_syscall(__NR__lxsys_realpathat, fd, buf, size); } \ No newline at end of file diff --git a/lunaix-os/usr/libc/src/posix/mann.c b/lunaix-os/usr/libc/src/posix/mann.c index f2fe186..b7756fa 100644 --- a/lunaix-os/usr/libc/src/posix/mann.c +++ b/lunaix-os/usr/libc/src/posix/mann.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -14,11 +14,11 @@ mmap(void* addr, size_t length, int proct, int flags, int fd, off_t offset) .offset = offset }; - return (void*)do_lunaix_syscall(__SYSCALL_sys_mmap, &mparam); + return (void*)do_lunaix_syscall(__NR__lxsys_sys_mmap, &mparam); } int munmap(void* addr, size_t length) { - return do_lunaix_syscall(__SYSCALL_munmap, addr, length); + return do_lunaix_syscall(__NR__lxsys_munmap, addr, length); } diff --git a/lunaix-os/usr/libc/src/posix/mount.c b/lunaix-os/usr/libc/src/posix/mount.c index 930930c..a44a879 100644 --- a/lunaix-os/usr/libc/src/posix/mount.c +++ b/lunaix-os/usr/libc/src/posix/mount.c @@ -1,14 +1,14 @@ -#include +#include int mount(const char* source, const char* target, const char* fstype, int options) { - return do_lunaix_syscall(__SYSCALL_mount, source, target, fstype, options); + return do_lunaix_syscall(__NR__lxsys_mount, source, target, fstype, options); } int unmount(const char* target) { - return do_lunaix_syscall(__SYSCALL_unmount, target); + return do_lunaix_syscall(__NR__lxsys_unmount, target); } \ No newline at end of file diff --git a/lunaix-os/usr/libc/src/posix/signal.c b/lunaix-os/usr/libc/src/posix/signal.c index 8c93fa2..25b8101 100644 --- a/lunaix-os/usr/libc/src/posix/signal.c +++ b/lunaix-os/usr/libc/src/posix/signal.c @@ -1,35 +1,35 @@ -#include +#include #include #include int sigpending(sigset_t *set) { - return do_lunaix_syscall(__SYSCALL_sigpending, set); + return do_lunaix_syscall(__NR__lxsys_sigpending, set); } int sigsuspend(const sigset_t *mask) { - return do_lunaix_syscall(__SYSCALL_sigsuspend, mask); + return do_lunaix_syscall(__NR__lxsys_sigsuspend, mask); } int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { - return do_lunaix_syscall(__SYSCALL_sigprocmask, how, set, oldset); + return do_lunaix_syscall(__NR__lxsys_sigprocmask, how, set, oldset); } int sys_sigaction(int signum, struct sigaction* action) { - return do_lunaix_syscall(__SYSCALL_sys_sigaction, signum, action); + return do_lunaix_syscall(__NR__lxsys_sys_sigaction, signum, action); } int kill(pid_t pid, int signum) { - return do_lunaix_syscall(__SYSCALL_kill, pid, signum); + return do_lunaix_syscall(__NR__lxsys_kill, pid, signum); } extern void diff --git a/lunaix-os/usr/libc/src/posix/unistd.c b/lunaix-os/usr/libc/src/posix/unistd.c index 8e17324..e3cd16c 100644 --- a/lunaix-os/usr/libc/src/posix/unistd.c +++ b/lunaix-os/usr/libc/src/posix/unistd.c @@ -1,211 +1,211 @@ -#include +#include #include pid_t fork() { - return do_lunaix_syscall(__SYSCALL_fork); + return do_lunaix_syscall(__NR__lxsys_fork); } int brk(void* addr) { - return do_lunaix_syscall(__SYSCALL_brk, addr); + return do_lunaix_syscall(__NR__lxsys_brk, addr); } void* sbrk(ssize_t size) { - return (void*)do_lunaix_syscall(__SYSCALL_sbrk, size); + return (void*)do_lunaix_syscall(__NR__lxsys_sbrk, size); } pid_t getpid() { - return do_lunaix_syscall(__SYSCALL_getpid); + return do_lunaix_syscall(__NR__lxsys_getpid); } pid_t getppid() { - return do_lunaix_syscall(__SYSCALL_getppid); + return do_lunaix_syscall(__NR__lxsys_getppid); } pid_t getpgid() { - return do_lunaix_syscall(__SYSCALL_getpgid); + return do_lunaix_syscall(__NR__lxsys_getpgid); } pid_t setpgid(pid_t pid, pid_t pgid) { - return do_lunaix_syscall(__SYSCALL_setpgid, pid, pgid); + return do_lunaix_syscall(__NR__lxsys_setpgid, pid, pgid); } void _exit(int status) { - do_lunaix_syscall(__SYSCALL__exit, status); + do_lunaix_syscall(__NR__lxsys_exit, status); } unsigned int sleep(unsigned int seconds) { - return do_lunaix_syscall(__SYSCALL_sleep, seconds); + return do_lunaix_syscall(__NR__lxsys_sleep, seconds); } int pause() { - return do_lunaix_syscall(__SYSCALL_pause); + return do_lunaix_syscall(__NR__lxsys_pause); } unsigned int alarm(unsigned int seconds) { - return do_lunaix_syscall(__SYSCALL_alarm, seconds); + return do_lunaix_syscall(__NR__lxsys_alarm, seconds); } int link(const char* oldpath, const char* newpath) { - return do_lunaix_syscall(__SYSCALL_link, oldpath, newpath); + return do_lunaix_syscall(__NR__lxsys_link, oldpath, newpath); } int rmdir(const char* pathname) { - return do_lunaix_syscall(__SYSCALL_rmdir, pathname); + return do_lunaix_syscall(__NR__lxsys_rmdir, pathname); } int read(int fd, void* buf, size_t count) { - return do_lunaix_syscall(__SYSCALL_read, fd, buf, count); + return do_lunaix_syscall(__NR__lxsys_read, fd, buf, count); } int write(int fd, void* buf, size_t count) { - return do_lunaix_syscall(__SYSCALL_write, fd, buf, count); + return do_lunaix_syscall(__NR__lxsys_write, fd, buf, count); } int readlink(const char* path, char* buf, size_t size) { - return do_lunaix_syscall(__SYSCALL_readlink, path, buf, size); + return do_lunaix_syscall(__NR__lxsys_readlink, path, buf, size); } int lseek(int fd, off_t offset, int options) { - return do_lunaix_syscall(__SYSCALL_lseek, fd, offset, options); + return do_lunaix_syscall(__NR__lxsys_lseek, fd, offset, options); } int unlink(const char* pathname) { - return do_lunaix_syscall(__SYSCALL_unlink, pathname); + return do_lunaix_syscall(__NR__lxsys_unlink, pathname); } int close(int fd) { - return do_lunaix_syscall(__SYSCALL_close, fd); + return do_lunaix_syscall(__NR__lxsys_close, fd); } int dup2(int oldfd, int newfd) { - return do_lunaix_syscall(__SYSCALL_dup2, oldfd, newfd); + return do_lunaix_syscall(__NR__lxsys_dup2, oldfd, newfd); } int dup(int oldfd) { - return do_lunaix_syscall(__SYSCALL_dup, oldfd); + return do_lunaix_syscall(__NR__lxsys_dup, oldfd); } int fsync(int fildes) { - return do_lunaix_syscall(__SYSCALL_fsync, fildes); + return do_lunaix_syscall(__NR__lxsys_fsync, fildes); } int symlink(const char* pathname, const char* link_target) { - return do_lunaix_syscall(__SYSCALL_symlink, pathname, link_target); + return do_lunaix_syscall(__NR__lxsys_symlink, pathname, link_target); } int chdir(const char* path) { - return do_lunaix_syscall(__SYSCALL_chdir, path); + return do_lunaix_syscall(__NR__lxsys_chdir, path); } int fchdir(int fd) { - return do_lunaix_syscall(__SYSCALL_fchdir, fd); + return do_lunaix_syscall(__NR__lxsys_fchdir, fd); } char* getcwd(char* buf, size_t size) { - return (char*)do_lunaix_syscall(__SYSCALL_getcwd, buf, size); + return (char*)do_lunaix_syscall(__NR__lxsys_getcwd, buf, size); } int rename(const char* oldpath, const char* newpath) { - return do_lunaix_syscall(__SYSCALL_rename, oldpath, newpath); + return do_lunaix_syscall(__NR__lxsys_rename, oldpath, newpath); } int getxattr(const char* path, const char* name, void* value, size_t len) { - return do_lunaix_syscall(__SYSCALL_getxattr, path, name, value, len); + return do_lunaix_syscall(__NR__lxsys_getxattr, path, name, value, len); } int setxattr(const char* path, const char* name, void* value, size_t len) { - return do_lunaix_syscall(__SYSCALL_setxattr, path, name, value, len); + return do_lunaix_syscall(__NR__lxsys_setxattr, path, name, value, len); } int fgetxattr(int fd, const char* name, void* value, size_t len) { - return do_lunaix_syscall(__SYSCALL_fgetxattr, fd, name, value, len); + return do_lunaix_syscall(__NR__lxsys_fgetxattr, fd, name, value, len); } int fsetxattr(int fd, const char* name, void* value, size_t len) { - return do_lunaix_syscall(__SYSCALL_fsetxattr, fd, name, value, len); + return do_lunaix_syscall(__NR__lxsys_fsetxattr, fd, name, value, len); } int readlinkat(int dirfd, const char* pathname, char* buf, size_t size) { - return do_lunaix_syscall(__SYSCALL_readlinkat, dirfd, pathname, buf, size); + return do_lunaix_syscall(__NR__lxsys_readlinkat, dirfd, pathname, buf, size); } int unlinkat(int fd, const char* pathname) { - return do_lunaix_syscall(__SYSCALL_unlinkat, fd, pathname); + return do_lunaix_syscall(__NR__lxsys_unlinkat, fd, pathname); } int mkdir(const char* path) { - return do_lunaix_syscall(__SYSCALL_mkdir, path); + return do_lunaix_syscall(__NR__lxsys_mkdir, path); } int execve(const char* filename, const char** argv, const char** envp) { - return do_lunaix_syscall(__SYSCALL_execve, filename, argv, envp); + return do_lunaix_syscall(__NR__lxsys_execve, filename, argv, envp); } diff --git a/lunaix-os/usr/libc/src/pthread.c b/lunaix-os/usr/libc/src/pthread.c index 26d6abf..5a51b1c 100644 --- a/lunaix-os/usr/libc/src/pthread.c +++ b/lunaix-os/usr/libc/src/pthread.c @@ -1,4 +1,4 @@ -#include +#include #include int @@ -14,7 +14,7 @@ pthread_create(pthread_t* thread, th_param.arg1 = arg; extern void th_trampoline(); - ret = do_lunaix_syscall(__SYSCALL_th_create, thread, + ret = do_lunaix_syscall(__NR__lxsys_th_create, thread, &th_param, th_trampoline); return ret; } @@ -22,29 +22,29 @@ pthread_create(pthread_t* thread, int pthread_detach(pthread_t thread) { - return do_lunaix_syscall(__SYSCALL_th_detach, thread); + return do_lunaix_syscall(__NR__lxsys_th_detach, thread); } void pthread_exit(void *value_ptr) { - do_lunaix_syscall(__SYSCALL_th_exit, value_ptr); + do_lunaix_syscall(__NR__lxsys_th_exit, value_ptr); } int pthread_join(pthread_t thread, void **value_ptr) { - return do_lunaix_syscall(__SYSCALL_th_join, thread, value_ptr); + return do_lunaix_syscall(__NR__lxsys_th_join, thread, value_ptr); } int pthread_kill(pthread_t thread, int sig) { - return do_lunaix_syscall(__SYSCALL_th_kill, thread, sig); + return do_lunaix_syscall(__NR__lxsys_th_kill, thread, sig); } pthread_t pthread_self(void) { - return do_lunaix_syscall(__SYSCALL_th_self); + return do_lunaix_syscall(__NR__lxsys_th_self); } -- 2.27.0