urt: Add user run-time library groundwork
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -68,6 +68,10 @@ build() {
|
|||||||
service/host \
|
service/host \
|
||||||
"Building host utils..."
|
"Building host utils..."
|
||||||
|
|
||||||
|
make_build \
|
||||||
|
service/urt/ \
|
||||||
|
"Building user runtime lib..."
|
||||||
|
|
||||||
make_build \
|
make_build \
|
||||||
service/ptos/ \
|
service/ptos/ \
|
||||||
"Building kernel..."
|
"Building kernel..."
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
export PT_PROJECT_ROOT=$PT_PROJECT_ROOT
|
export PT_PROJECT_ROOT=$PT_PROJECT_ROOT
|
||||||
export PT_TARGET_ARCH=$PT_TARGET_ARCH
|
export PT_TARGET_ARCH=$PT_TARGET_ARCH
|
||||||
export PT_BOOT_PROTO=$PT_BOOT_PROTO
|
export PT_BOOT_PROTO=$PT_BOOT_PROTO
|
||||||
|
export PT_URT_LIB=$PT_URT_LIB
|
||||||
|
export PT_URT_CRT=$PT_URT_CRT
|
||||||
|
|
||||||
if [ "$PT_BUILD_SOURCED" != "1" ]
|
if [ "$PT_BUILD_SOURCED" != "1" ]
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -9,3 +9,5 @@
|
|||||||
PT_PROJECT_ROOT=$(pwd)
|
PT_PROJECT_ROOT=$(pwd)
|
||||||
PT_TARGET_ARCH=amd64
|
PT_TARGET_ARCH=amd64
|
||||||
PT_BOOT_PROTO=limine
|
PT_BOOT_PROTO=limine
|
||||||
|
PT_URT_LIB=$PT_PROJECT_ROOT/service/urt/
|
||||||
|
PT_URT_CRT=$PT_PROJECT_ROOT/service/urt/arch/$PT_TARGET_ARCH
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2026, Chloe M.
|
||||||
|
# Provided under the BSD-3 clause
|
||||||
|
#
|
||||||
|
# Description: User build flags, etc
|
||||||
|
# Author: Chloe M.
|
||||||
|
#
|
||||||
|
|
||||||
|
.SILENT:
|
||||||
|
PROMPT := printf "%s\t\t%s\n"
|
||||||
|
|
||||||
|
ifeq ($(PT_TARGET_ARCH), amd64)
|
||||||
|
CC_TARGET = x86_64-unknown-elf
|
||||||
|
else
|
||||||
|
CC_TARGET =
|
||||||
|
endif
|
||||||
|
|
||||||
|
CC = \
|
||||||
|
clang
|
||||||
|
ld = \
|
||||||
|
ld
|
||||||
|
|
||||||
|
SYS_CFLAGS = \
|
||||||
|
-nostdlib \
|
||||||
|
-nostdinc \
|
||||||
|
-ffreestanding \
|
||||||
|
-fexceptions \
|
||||||
|
-target $(CC_TARGET)\
|
||||||
|
-Wno-attributes \
|
||||||
|
-Wno-multichar \
|
||||||
|
-fno-stack-protector\
|
||||||
|
-I$(PT_PROJECT_ROOT)/sdk/head
|
||||||
|
|
||||||
|
ifeq ($(PT_TARGET_ARCH),amd64)
|
||||||
|
SYS_CFLAGS += \
|
||||||
|
-mno-sse \
|
||||||
|
-mno-sse2 \
|
||||||
|
-mno-sse3 \
|
||||||
|
-mno-avx \
|
||||||
|
-mno-avx2 \
|
||||||
|
-mno-80387 \
|
||||||
|
-mno-3dnow \
|
||||||
|
-mno-mmx
|
||||||
|
endif
|
||||||
|
|
||||||
|
PASSDOWN_ARGS = \
|
||||||
|
ARCH=$(PT_TARGET_ARCH) \
|
||||||
|
SYS_CC=$(CC) \
|
||||||
|
SYS_LD=$(LD) \
|
||||||
|
SYS_CFLAGS="$(SYS_CFLAGS)" \
|
||||||
|
USER_LDS=$(PT_PROJECT_ROOT)/service/urt/dev/link.ld
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2026, Chloe M.
|
||||||
|
# Provided under the BSD-3 clause
|
||||||
|
#
|
||||||
|
# Description: User run-time build script
|
||||||
|
# Author: Chloe M.
|
||||||
|
#
|
||||||
|
|
||||||
|
include ../mk/user.mk
|
||||||
|
|
||||||
|
.PHONY: urt
|
||||||
|
urt: machine
|
||||||
|
|
||||||
|
.PHONY: machine
|
||||||
|
machine:
|
||||||
|
cd arch/$(PT_TARGET_ARCH)/; $(MAKE) $(PASSDOWN_ARGS)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2026, Chloe M.
|
||||||
|
# Provided under the BSD-3 clause
|
||||||
|
#
|
||||||
|
# Description: User run-time machdep build script
|
||||||
|
# Author: Chloe M.
|
||||||
|
#
|
||||||
|
|
||||||
|
ASMFILES = $(shell find . -name "*.S")
|
||||||
|
ASMOFILES = $(ASMFILES:.S=.S.o)
|
||||||
|
|
||||||
|
CFLAGS = $(SYS_CFLAGS)
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: $(ASMOFILES)
|
||||||
|
|
||||||
|
%.S.o: %.S
|
||||||
|
$(SYS_CC) -c $< $(CFLAGS) -o $@
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026, Chloe M.
|
||||||
|
* Provided under the BSD-3 clause.
|
||||||
|
*
|
||||||
|
* Description: C-runtime entry
|
||||||
|
* Author: Chloe M.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.text
|
||||||
|
.globl _start
|
||||||
|
_start:
|
||||||
|
xor %rbp, %rbp /* Terminate callstack */
|
||||||
|
call Main /* Enter program main */
|
||||||
|
1: pause
|
||||||
|
jmp 1b
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026, Chloe M.
|
||||||
|
* Provided under the BSD-3 clause.
|
||||||
|
*
|
||||||
|
* Description: User linker script
|
||||||
|
* Author: Chloe M.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
SECTIONS {
|
||||||
|
/* User programs live here */
|
||||||
|
. = 0x9000;
|
||||||
|
|
||||||
|
.text : {
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss : {
|
||||||
|
*(.bss .bss.*)
|
||||||
|
*(COMMON)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata : {
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.eh_frame .eh_frame.*)
|
||||||
|
*(.note .note.*)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user