build: Add initial build files

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-03-25 00:09:48 -04:00
parent 1f58ed49a9
commit 75c7300480
6 changed files with 128 additions and 0 deletions

12
host/build.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
#
# Copyright (c) 2026, Mirocom Laboratories
# Provided under the BSD-3 clause
#
build() {
cd src/; make -j1
}
build

11
src/Makefile Normal file
View File

@@ -0,0 +1,11 @@
#
# Copyright (c) 2026, Mirocom Laboratories
# Provided under the BSD-3 clause
#
.PHONY: all
all: m1x
.PHONY: m1x
m1x:
cd m1x/; make

13
src/m1x/Makefile Normal file
View File

@@ -0,0 +1,13 @@
#
# Copyright (c) 2026, Mirocom Laboratories
# Provided under the BSD-3 clause
#
include ../mk/default.mk
.PHONY: all
all: arch
.PHONY: arch
arch:
cd arch/$(ARCH_TARGET)/; make $(PASSDOWN_ARGS)

View File

@@ -0,0 +1,34 @@
#
# Copyright (c) 2026, Mirocom Laboratories
# Provided under the BSD-3 clause
#
MISC_OFILES = $(shell find ../../ -name "*.o")
ASMFILES = $(shell find . -name "*.S" | grep -v "boot")
ASMOFILES = $(ASMFILES:.S=.S.o)
CFILES = $(shell find . -name "*.c")
OFILES = $(CFILES:.c=.o)
DFILES = $(shell find . -name "*.d")
KERN_BIN = ../../m1x.sys
LD = ../../../$(SYS_LD)
CC = ../../../$(SYS_CC)
CFLAGS = \
$(SYS_CFLAGS) \
-D_KERNEL \
-I../../target/ \
-I../../include/ \
.PHONY: all
all: $(OFILES) $(ASMOFILES)
$(LD) $(MISC_OFILES) -Tconf/link.ld -o $(KERN_BIN) $(LDFLAGS)
%.S.o: %.S
$(CC) -c $< $(CFLAGS) -o $@
-include $(DFILES)
%.o: %.c
$(CC) -c $< $(CFLAGS) -I../../inc/ -MMD -o $@

View File

@@ -0,0 +1,43 @@
OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
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;
.text : {
*(.text .text.*)
} :text
. += CONSTANT(MAXPAGESIZE);
.rodata : {
*(.rodata .rodata.*)
} :rodata
. += CONSTANT(MAXPAGESIZE);
.data : {
*(.data)
} :data
.bss : {
*(COMMON)
*(.bss .bss.*)
} :data
. += CONSTANT(MAXPAGESIZE);
/DISCARD/ : {
*(.eh_frame .eh_frame.*)
*(.note .note.*)
}
}

View File

@@ -0,0 +1,15 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* Provided under the BSD-3 clause
*/
.text
.globl _start
_start:
cli
cld
xor %rbp, %rbp
1: hlt
jmp 1b