Skip to content

Commit

Permalink
help
Browse files Browse the repository at this point in the history
  • Loading branch information
rtos-devbox committed Dec 16, 2023
1 parent 4be4b1e commit c371c44
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 21 deletions.
65 changes: 44 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,60 @@
PREFIX = /opt/cross/x86_64-elf/bin/x86_64-elf-
CC = $(PREFIX)gcc
AS = $(PREFIX)as
LK = $(PREFIX)gcc
OC = $(PREFIX)objcopy
ARCH = x86
SUBSYSTEM = 10

ifeq ($(shell uname -m),x86_64)
MINGW_HOST = w64
else
MINGW_HOST = w32
endif

ifeq ($(ARCH),x64)
GNUEFI_ARCH = x86_64
GCC_ARCH = x86_64
QEMU_ARCH = x86_64
FW_BASE = OVMF
CROSS_COMPILE = $(GCC_ARCH)-$(MINGW_HOST)-mingw32-
EP_PREFIX =
C_FLAGS = -m64 -mno-red-zone
LD_FLAGS = -Wl,-dll -Wl,--subsystem,$(SUBSYSTEM)
endif

CC := $(CROSS_COMPILE)gcc
OBJCOPY := $(CROSS_COMPILE)objcopy
AS := $(CROSS_COMPILE)as
LK := $(CROSS_COMPILE)gcc
OC := $(CROSS_COMPILE)objcopy

CC_DIR = src/arch/$(ARCH)/c
INC_DIR = src/arch/$(ARCH)/h
AS_DIR = src/arch/$(ARCH)/s
OBJ_DIR = bin/arch/$(ARCH)/o

GNUEFI_DIR = ../gnu-efi

C_FLAGS += -fno-stack-protector -Wshadow -Wall -Wunused -Wextra -Wpedantic -Werror-implicit-function-declaration -ffreestanding
C_INC = -I$(GNUEFI_DIR)/inc -I$(GNUEFI_DIR)/inc/$(GNUEFI_ARCH) -I$(GNUEFI_DIR)/inc/protocol
C_DEFS = -DCONFIG_$(GNUEFI_ARCH) -D__MAKEWITH_GNUEFI -DGNU_EFI_USE_MS_ABI

LD_FLAGS += -s -Wl,-Bsymbolic -nostdlib -shared
LD_LIB += -L$(GNUEFI_DIR)/$(GNUEFI_ARCH)/lib -e $(EP_PREFIX)efi_main
LIBS = -lefi $(CRT0_LIBS)

GNU_EFI_INC_DIR = /usr/include/efi
GNU_EFI_DIR = ../gnu-efi

CC_FLAGS = -ffreestanding -fpic -fno-stack-protector -fshort-wchar -mgeneral-regs-only -Wall -Wextra -Wpedantic -mno-red-zone -mabi=ms

LK_DOC = $(GNU_EFI_DIR)/gnuefi/elf_x86_64_efi.lds
LK_DOC = linker.ld
LK_FLAGS = -nostdlib -shared -Wl,-T,$(LK_DOC) -Wl,-Bsymbolic -Wl,-znocombreloc
LK_FLAGS = -nostdlib -shared,-T,$(LK_DOC) -Wl,-Bsymbolic -Wl,-znocombreloc
LIB_SEARCH = -L$(GNU_EFI_DIR)/x86_64/lib -L$(GNU_EFI_DIR)/x86_64/gnuefi

CC_DIR = src/c
INC_DIR = src/h
AS_DIR = src/s
OBJ_DIR = bin/o

CC_FILES_IN := $(wildcard $(CC_DIR)/*.c)
AS_FILES_IN := $(wildcard $(AS_DIR)/*.s)

CC_FILES_OUT=$(patsubst $(CC_DIR)/%.c, $(OBJ_DIR)/%.o, $(CC_FILES_IN))
AS_FILES_OUT=$(patsubst $(AS_DIR)/%.s, $(OBJ_DIR)/%.o, $(AS_FILES_IN))

BIN = rtos
BIN = novos
BIN_OUT = bin/$(BIN)
EFI_OUT = bin/BOOTX64.EFI
EFI_OUT = bin/arch/$(ARCH)/BOOTX64.EFI

ISO = $(BIN_OUT).iso
FAT_IMG = $(BIN_OUT).img
Expand All @@ -43,11 +70,7 @@ obj_dir:

$(OBJ_DIR)/%.o: $(CC_DIR)/%.c obj_dir
@echo Compiling $<...
@$(CC) $(CC_FLAGS) -I$(INC_DIR) -I$(GNU_EFI_INC_DIR) -o $@ -c $<

$(OBJ_DIR)/%.o: $(AS_DIR)/%.s obj_dir
@echo Compiling $<...
@$(AS) $< -o $@
@$(CC) $(C_FLAGS) $(C_INC) $(C_DEFS) -o $@ -c $<

build: $(CC_FILES_OUT) $(AS_FILES_OUT) obj_dir
@echo Linking...
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions old/src/s/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
g�$C
1 change: 1 addition & 0 deletions old/src/s/test.s
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jmp [eax*2 + ebx]

0 comments on commit c371c44

Please sign in to comment.