Update userspace

This commit is contained in:
Alex
2023-08-06 04:52:48 +03:00
parent 0f8cb900cb
commit 2fd23205db
49 changed files with 437 additions and 525 deletions

View File

@ -1,5 +1,38 @@
cwd := $(CURDIR)
CACHE_DIR := $(cwd)/../../cache
PREFIX := $(cwd)/../../out/
TARGET := x86_64-fennix
export CC := $(cwd)/../../../tools/cross/bin/$(TARGET)-gcc
export LD := $(cwd)/../../../tools/cross/bin/$(TARGET)-ld
export AR := $(cwd)/../../../tools/cross/bin/$(TARGET)-ar
export STRIP := $(cwd)/../../../tools/cross/bin/$(TARGET)-strip
export RANLIB := $(cwd)/../../../tools/cross/bin/$(TARGET)-ranlib
export LD_LIBRARY_PATH := $(cwd)/../../out/lib/
ifeq ($(DEBUG), 1)
export CFLAGS := --sysroot=$(cwd)/../../out/ -I$(cwd)/../../out/include/ -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fverbose-asm
export LDFLAGS := -ggdb3 -O0
else
export CFLAGS := --sysroot=$(cwd)/../../out/ -I$(cwd)/../../out/include/
endif
build_bash:
ifeq ($(wildcard $(CACHE_DIR)/bash),)
mkdir -p $(CACHE_DIR)/bash
cd $(CACHE_DIR)/bash && \
../../apps/base/bash/configure --prefix=$(PREFIX) \
--host=$(TARGET) \
--enable-minimal-config
endif
make -C $(CACHE_DIR)/bash -j$(shell nproc)
make -C $(CACHE_DIR)/bash install
build:
make -C echo build
make -C fsh build
# $(MAKE) build_bash
clean:
make -C echo clean
make -C fsh clean

1
apps/base/bash Submodule

Submodule apps/base/bash added at 07d7e00817

View File

@ -30,10 +30,10 @@ OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURC
SYSROOT = --sysroot=$(WORKSPACE)out/
FILENAME = echo
HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/usr/include/*)))
HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/include/*)))
LDFLAGS =
CFLAGS = -I$(WORKSPACE)out/usr/include \
CFLAGS = -I$(WORKSPACE)out/include \
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"'
WARNCFLAG = -Wall -Wextra

View File

@ -3,9 +3,7 @@
int main(int argc, char *argv[])
{
for (int i = 1; i < argc; i++)
{
printf("%s ", argv[i]);
}
printf("\n");
return 0;
}

66
apps/base/fsh/Makefile Normal file
View File

@ -0,0 +1,66 @@
WORKSPACE := ../../../
# Config file
include ../$(WORKSPACE)Makefile.conf
CC = ../$(WORKSPACE)$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
CPP = ../$(WORKSPACE)$(COMPILER_PATH)/$(COMPILER_ARCH)g++
LD = ../$(WORKSPACE)$(COMPILER_PATH)/$(COMPILER_ARCH)ld
AS = ../$(WORKSPACE)$(COMPILER_PATH)/$(COMPILER_ARCH)as
OBJDUMP = ../$(WORKSPACE)$(COMPILER_PATH)/$(COMPILER_ARCH)objdump
GIT_COMMIT = $(shell git rev-parse HEAD)
GIT_COMMIT_SHORT = $(shell git rev-parse --short HEAD)
ifeq ($(OSARCH), amd64)
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
else ifeq ($(OSARCH), i386)
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
else ifeq ($(OSARCH), aarch64)
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
endif
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
SYSROOT = --sysroot=$(WORKSPACE)out/
FILENAME = fsh
HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/include/*)))
LDFLAGS =
CFLAGS = -I$(WORKSPACE)out/include \
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"'
WARNCFLAG = -Wall -Wextra
ifeq ($(DEBUG), 1)
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fverbose-asm
LDFLAGS += -ggdb3 -O0
endif
build: $(FILENAME)
mv $(FILENAME) $(WORKSPACE)out/bin/$(FILENAME)
$(FILENAME): $(OBJ)
$(info Linking $@)
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@
%.o: %.c $(HEADERS)
$(info Compiling $<)
$(CC) $(CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
%.o: %.cpp $(HEADERS)
$(info Compiling $<)
$(CPP) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@ -fno-rtti
%.o: %.S
$(info Compiling $<)
$(AS) -o $@ $<
clean:
rm -f $(OBJ)

7
apps/base/fsh/fsh.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main(int argc, char *argv[], char *envp[])
{
printf("Hello, world!\n");
return 0;
}

View File

@ -30,10 +30,10 @@ OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURC
SYSROOT = --sysroot=$(WORKSPACE)out/
FILENAME = init
HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/usr/include/*)))
HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/include/*)))
LDFLAGS =
CFLAGS = -I$(WORKSPACE)out/usr/include \
CFLAGS = -I$(WORKSPACE)out/include \
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"'
WARNCFLAG = -Wall -Wextra

69
apps/system/init/aux.h Normal file
View File

@ -0,0 +1,69 @@
#ifndef __FENNIX_LIBC_AUX_H__
#define __FENNIX_LIBC_AUX_H__
#include <stddef.h>
#define AT_NULL 0
#define AT_IGNORE 1
#define AT_EXECFD 2
#define AT_PHDR 3
#define AT_PHENT 4
#define AT_PHNUM 5
#define AT_PAGESZ 6
#define AT_BASE 7
#define AT_FLAGS 8
#define AT_ENTRY 9
#define AT_NOTELF 10
#define AT_UID 11
#define AT_EUID 12
#define AT_GID 13
#define AT_EGID 14
#define AT_PLATFORM 15
#define AT_HWCAP 16
#define AT_CLKTCK 17
#define AT_SECURE 23
#define AT_BASE_PLATFORM 24
#define AT_RANDOM 25
#define AT_HWCAP2 26
#define AT_EXECFN 31
#define AT_SYSINFO 32
#define AT_SYSINFO_EHDR 33
#define AT_L1I_CACHESHAPE 34
#define AT_L1D_CACHESHAPE 35
#define AT_L2_CACHESHAPE 36
#define AT_L3_CACHESHAPE 37
#define AT_L1I_CACHESIZE 40
#define AT_L1I_CACHEGEOMETRY 41
#define AT_L1D_CACHESIZE 42
#define AT_L1D_CACHEGEOMETRY 43
#define AT_L2_CACHESIZE 44
#define AT_L2_CACHEGEOMETRY 45
#define AT_L3_CACHESIZE 46
#define AT_L3_CACHEGEOMETRY 47
#define AT_MINSIGSTKSZ 51
typedef struct
{
uint32_t a_type;
union
{
uint32_t a_val;
} a_un;
} Elf32_auxv_t;
typedef struct
{
uint64_t a_type;
union
{
uint64_t a_val;
} a_un;
} Elf64_auxv_t;
#ifdef __LP64__
#define Elf_auxv_t Elf64_auxv_t
#else
#define Elf_auxv_t Elf32_auxv_t
#endif
#endif // !__FENNIX_LIBC_AUX_H__

View File

@ -1,8 +1,9 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/wait.h>
#include <aux.h>
#include "aux.h"
#include <libinit/init.h>
#define print(m, ...) init_log(m, ##__VA_ARGS__)