mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-05-28 15:34:26 +00:00
Update files
This commit is contained in:
parent
e022af99e5
commit
e9808d726a
100
apps/system/init/Makefile
Normal file
100
apps/system/init/Makefile
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# Config file
|
||||||
|
include ../../../Makefile.conf
|
||||||
|
|
||||||
|
FILENAME = init.fex
|
||||||
|
|
||||||
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||||
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||||
|
LD = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)ld
|
||||||
|
AS = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)as
|
||||||
|
OBJDUMP = ../../../$(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/i686/*" -not -path "./arch/aarch64/*")
|
||||||
|
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/i686/*" -not -path "./arch/aarch64/*")
|
||||||
|
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/i686/*" -not -path "./arch/aarch64/*")
|
||||||
|
else ifeq ($(OSARCH), i686)
|
||||||
|
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/i686/*")
|
||||||
|
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/i686/*")
|
||||||
|
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/i686/*")
|
||||||
|
endif
|
||||||
|
HEADERS = $(sort $(dir $(wildcard ./include/*)))
|
||||||
|
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)
|
||||||
|
INCLUDE_DIR = ./include
|
||||||
|
|
||||||
|
LDFLAGS := \
|
||||||
|
-fPIC -fno-pie \
|
||||||
|
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||||
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
|
-zmax-page-size=0x1000 \
|
||||||
|
-Wl,-Map file.map -shared
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
CFLAGS := \
|
||||||
|
-I$(INCLUDE_DIR) \
|
||||||
|
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
||||||
|
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"'
|
||||||
|
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
|
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
|
-march=x86-64 -pipe \
|
||||||
|
-mcmodel=kernel -msoft-float -fno-builtin
|
||||||
|
LDFLAGS += -Tarch/amd64/linker.ld
|
||||||
|
|
||||||
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
|
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
|
LDFLAGS += -Tarch/i686/linker.ld
|
||||||
|
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
|
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
build: $(FILENAME)
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
$(OBJDUMP) -b binary -D -m i386:x86-64 -d $(FILENAME) > file_dump.map
|
||||||
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
|
endif
|
||||||
|
mv $(FILENAME) ../../out/$(FILENAME)
|
||||||
|
|
||||||
|
$(FILENAME): $(OBJ)
|
||||||
|
$(CC) $(LDFLAGS) $(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 $<)
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
else ifeq ($(OSARCH), i686)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o file.map file_dump.map $(OBJ)
|
41
apps/system/init/arch/amd64/linker.ld
Normal file
41
apps/system/init/arch/amd64/linker.ld
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* EXPERIMENTAL */
|
||||||
|
|
||||||
|
OUTPUT_FORMAT(binary)
|
||||||
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.header :
|
||||||
|
{
|
||||||
|
*(.header .header.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.eh_frame)
|
||||||
|
*(.note .note.*)
|
||||||
|
}
|
||||||
|
}
|
39
apps/system/init/init.cpp
Normal file
39
apps/system/init/init.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// EXPERIMENTAL
|
||||||
|
|
||||||
|
enum FexFormatType
|
||||||
|
{
|
||||||
|
FexFormatType_Unknown,
|
||||||
|
FexFormatType_Executable,
|
||||||
|
FexFormatType_Driver
|
||||||
|
/* ... */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum FexOSType
|
||||||
|
{
|
||||||
|
FexOSType_Unknown,
|
||||||
|
FexOSType_Fennix,
|
||||||
|
FexOSType_Linux
|
||||||
|
/* ... */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Fex
|
||||||
|
{
|
||||||
|
char Magic[4];
|
||||||
|
int Type;
|
||||||
|
int OS;
|
||||||
|
unsigned long Pointer;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" int _start();
|
||||||
|
|
||||||
|
__attribute__((section(".header")))
|
||||||
|
Fex header = {
|
||||||
|
.Magic = {'F', 'E', 'X', '\0'},
|
||||||
|
.Type = FexFormatType_Executable,
|
||||||
|
.OS = FexOSType_Fennix,
|
||||||
|
.Pointer = (unsigned long)_start};
|
||||||
|
|
||||||
|
extern "C" int _start()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user