summaryrefslogtreecommitdiff
path: root/src/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/arch')
-rw-r--r--src/sys/arch/i386/Makefile34
-rw-r--r--src/sys/arch/i386/conf/sys.ld35
-rw-r--r--src/sys/arch/i386/locore.S19
3 files changed, 88 insertions, 0 deletions
diff --git a/src/sys/arch/i386/Makefile b/src/sys/arch/i386/Makefile
new file mode 100644
index 0000000..2db5f9a
--- /dev/null
+++ b/src/sys/arch/i386/Makefile
@@ -0,0 +1,34 @@
+include ../../conf/sys.mk
+
+.SILENT:
+override PROMPT := printf "%s\t\t%s\n"
+
+TARGET = ../../l5
+TARGET_INC = -I../../target/header/
+CFLAGS = -I../../include/ -I../../include/lib/ $(TARGET_INC) $(MI_CFLAGS) $(MD_CFLAGS)
+CFILES = $(shell find . -name "*.c")
+
+ASMFILES = $(shell find . -name "*.S")
+ASMOBJECTS = $(ASMFILES:.S=.S.o)
+
+DEPS = $(CFILES:.c=.d)
+ASMDEPS = $(ASMFILES:.S=.S.d)
+OBJECTS = $(CFILES:%.c=%.o)
+LD_FLAGS = -Tconf/sys.ld
+
+.PHONY: all
+all: $(OBJECTS) $(ASMOBJECTS)
+ $(LD) $(OBJECTS) $(ASMOBJECTS) -o $(TARGET) $(LD_FLAGS)
+
+-include $(DEPS)
+%.o: %.c
+ $(CC) -c $(CFLAGS) $< -o $@
+
+-include $(ASMDEPS)
+%.S.o: %.S
+ $(PROMPT) " MD.AS " $<
+ $(CC) -c $< -o $@ $(CFLAGS) $(MD_CFLAGS)
+
+.PHONY: clean
+clean:
+ rm -f $(DEPS) $(ASMDEPS) $(OBJECTS) $(ASMOBJECTS)
diff --git a/src/sys/arch/i386/conf/sys.ld b/src/sys/arch/i386/conf/sys.ld
new file mode 100644
index 0000000..b5d1cf0
--- /dev/null
+++ b/src/sys/arch/i386/conf/sys.ld
@@ -0,0 +1,35 @@
+ENTRY(_start)
+
+SECTIONS {
+ . = 1M;
+
+ .boot :
+ {
+ *(.multiboot_header)
+ }
+
+ . = ALIGN(4K);
+ .text :
+ {
+ *(.text .text.*)
+ }
+
+ . = ALIGN(4K);
+ .rodata :
+ {
+ *(.rodata .rodata.*)
+ }
+
+ . = ALIGN(4K);
+ .data :
+ {
+ *(.data .data.*)
+ }
+
+ . = ALIGN(4K);
+ .bss :
+ {
+ *(.bss .bss.*)
+ }
+}
+
diff --git a/src/sys/arch/i386/locore.S b/src/sys/arch/i386/locore.S
new file mode 100644
index 0000000..5cbdbc2
--- /dev/null
+++ b/src/sys/arch/i386/locore.S
@@ -0,0 +1,19 @@
+ .set MAGIC, 0xe85250d6
+ .set ARCH, 0x00 // i386, protected mode
+ .set LEN, hdr_end - hdr_start
+ .set CHECKSUM, 0x100000000 - (0xe85250d6 + 0 + (hdr_end - hdr_start))
+
+ .section .multiboot
+ .align 4
+hdr_start:
+ .long MAGIC
+ .long ARCH
+ .long LEN
+ .long CHECKSUM
+hdr_end:
+
+ .text
+ .code32
+ .globl _start
+_start:
+ jmp .