build: Add build pipeline groundwork

Signed-off-by: Chloe M. <chloe@yiffware.org>
This commit is contained in:
2026-07-10 01:10:15 +00:00
parent 59553afdec
commit 662252ae18
13 changed files with 368 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
#
# Copyright (c) 2026, Chloe M.
# Provided under the BSD-3 clause
#
# Description: Kernel build script
# Author: Chloe M.
#
include ../mk/ptos.mk
.PHONY: all
all: machine
.PHONY: machine
machine:
cd arch/$(PT_TARGET_ARCH)/; $(MAKE) $(PASSDOWN_ARGS)
+48
View File
@@ -0,0 +1,48 @@
#
# Copyright (c) 2026, Chloe M.
# Provided under the BSD-3 clause
#
# Description: AMD64 port build script
# Author: Chloe M.
#
.SILENT:
include ../../../mk/ptos.mk
ASMFILES = $(shell find . -name "*.S")
ASMOFILES = $(ASMFILES:.S=.S.o)
CFILES = $(shell find . -name "*.c")
OFILES = $(CFILES:.c=.o)
CDFILES = $(OFILES:.o.d)
ASMDFILES = $(ASMOFILES:.S.o=.S.d)
MISC_OFILES = $(shell find $(PT_PROJECT_ROOT)/service/ptos/ -name "*.o")
KERNEL_PATH = \
$(PT_PROJECT_ROOT)/artifacts/ptsv.sys
CFLAGS = \
$(SYS_CFLAGS) \
-I../../target \
-I../../head/ \
-D_KERNEL \
-MMD \
-I$(PT_PROJECT_ROOT)/sdk/head \
.PHONY: all
all: bin
.PHONY: bin
bin: $(OFILES) $(ASMOFILES)
$(PROMPT) "LD" $(KERNEL_PATH)
$(SYS_LD) -Tdev/link.ld $(MISC_OFILES) -o $(KERNEL_PATH)
-include $(CDFILES)
%.o: %.c
$(PROMPT) "CC" $<
$(SYS_CC) -c $< $(CFLAGS) -o $@
-include $(ASMDFILES)
%.S.o: %.S
$(PROMPT) "AS" $<
$(SYS_CC) -c $< $(CFLAGS) -o $@
+14
View File
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Low-level AMD64 processor init
* Author: Chloe M.
*/
.text
.globl MdBspEntry
MdBspEntry:
cli
hlt
jmp MdBspEntry
+60
View File
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Kernel linker script
* Author: Chloe M.
*/
OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
ENTRY(MdBspEntry)
PHDRS {
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ;
rodata PT_LOAD FLAGS((1 << 2)) ;
data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ;
}
SECTIONS
{
. = 0xFFFFFFFF80000000;
__KernelStart = .;
.text : {
*(.text .text.*)
} :text
. += CONSTANT(MAXPAGESIZE);
.rodata : {
*(.rodata .rodata.*)
} :rodata
. += CONSTANT(MAXPAGESIZE);
.driver : {
__driver_start = .;
KEEP(*(.driver .driver));
__driver_end = .;
}
. += CONSTANT(MAXPAGESIZE);
.data : {
*(.data)
} :data
.bss : {
*(COMMON)
*(.bss .bss.*)
} :data
__KernelEnd = .;
. += CONSTANT(MAXPAGESIZE);
/DISCARD/ : {
*(.eh_frame .eh_frame.*)
*(.note .note.*)
}
}