libsys stub

This commit is contained in:
Alex 2022-12-15 02:58:07 +02:00
parent 06eb5a1467
commit 741e1e908f
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
4 changed files with 78 additions and 0 deletions

View File

@ -3,8 +3,10 @@ build:
make --quiet -C libgcc build make --quiet -C libgcc build
make --quiet -C libinit build make --quiet -C libinit build
make --quiet -C libssp build make --quiet -C libssp build
make --quiet -C libsys build
clean: clean:
make -C libgcc clean make -C libgcc clean
make -C libinit clean make -C libinit clean
make -C libssp clean make -C libssp clean
make -C libsys clean

17
libs/include/syslib.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef __FENNIX_LIBS_SYS_H__
#define __FENNIX_LIBS_SYS_H__
#include <types.h>
enum KCtl
{
KCTL_NULL,
KCTL_GETPID,
KCTL_GETTID,
KCTL_GETUID,
KCTL_GETGID,
};
long DoCtl(uint64_t Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4);
#endif // !__FENNIX_LIBS_SYS_H__

51
libs/libsys/Makefile Normal file
View File

@ -0,0 +1,51 @@
# Config file
include ../../../Makefile.conf
NAME=sys
OBJECT_NAME=lib$(NAME).so
SO_NAME=libsys
OUTPUT_DIR=../../out/system/lib/
SYSROOT = --sysroot=../../out/system/
CC = ../../../$(TC_COMPILER_PATH)/$(TC_COMPILER_ARCH)gcc
AS = ../../../$(TC_COMPILER_PATH)/$(TC_COMPILER_ARCH)as
AR = ../../../$(TC_COMPILER_PATH)/$(TC_COMPILER_ARCH)ar
OBJDUMP = ../../../$(TC_COMPILER_PATH)/$(TC_COMPILER_ARCH)objdump
NASM = /usr/bin/nasm
C_SOURCES = $(shell find ./ -type f -name '*.c')
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
S_SOURCES = $(shell find ./ -type f -name '*.S')
ASM_SOURCES = $(shell find ./ -type f -name '*.asm')
OBJ = ${C_SOURCES:.c=.o} ${CPP_SOURCES:.cpp=.o} ${ASM_SOURCES:.asm=.o} ${S_SOURCES:.S=.o}
ifeq ($(OSARCH), amd64)
ASM_ARCH := elf64
else ifeq ($(OSARCH), i686)
ASM_ARCH := elf32
endif
CFLAGS := -fPIC -I../include -I../../libc/include
build: $(OBJECT_NAME)
$(OBJECT_NAME): $(OBJ)
$(CC) -nostdlib -shared -fPIC -Wl,-soname,$(SO_NAME) $(SYSROOT) $(OBJ) -o $(OUTPUT_DIR)$@
$(OBJDUMP) -d $(OUTPUT_DIR)$@ > file_dump.map
%.o: %.c
$(CC) $(CFLAGS) -std=c17 -c $< -o $@
%.o: %.cpp
$(CC) $(CFLAGS) -std=c++20 -c $< -o $@
%.o: %.S
$(AS) -c $< -o $@
%.o: %.asm
$(NASM) $< -f $(ASM_ARCH) -o $@
clean:
rm -f file_dump.map $(OBJ)

8
libs/libsys/kcall.c Normal file
View File

@ -0,0 +1,8 @@
#include <syslib.h>
#include "../../../Kernel/syscalls.h"
long DoCtl(uint64_t Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4)
{
return syscall5(_KernelCTL, Command, Arg1, Arg2, Arg3, Arg4);
}