summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/Makefile17
-rw-r--r--sys/arch/amd64/boot.S5
-rw-r--r--sys/arch/amd64/conf/link.ld42
3 files changed, 64 insertions, 0 deletions
diff --git a/sys/arch/amd64/Makefile b/sys/arch/amd64/Makefile
new file mode 100644
index 0000000..1090a38
--- /dev/null
+++ b/sys/arch/amd64/Makefile
@@ -0,0 +1,17 @@
+CC =
+LD =
+SYS_CFLAGS =
+ASMFILES = $(shell find . -name "*.S")
+ASMOBJS = $(ASMFILES:.S=.S.o)
+MISC_OFILES = $(shell find ../../ -name "*.o")
+
+.PHONY: all
+all: $(ASMOBJS)
+ $(LD) -Tconf/link.ld $(MISC_OFILES) -o ../../rv7
+
+%.S.o: %.S
+ $(CC) -c $(SYS_CFLAGS) $< -o $@
+
+.PHONY: clean
+clean:
+ rm $(MISC_OFILES)
diff --git a/sys/arch/amd64/boot.S b/sys/arch/amd64/boot.S
new file mode 100644
index 0000000..0d2e0d2
--- /dev/null
+++ b/sys/arch/amd64/boot.S
@@ -0,0 +1,5 @@
+ .globl _start
+_start:
+1: cli
+ hlt
+ jmp 1b
diff --git a/sys/arch/amd64/conf/link.ld b/sys/arch/amd64/conf/link.ld
new file mode 100644
index 0000000..92222b0
--- /dev/null
+++ b/sys/arch/amd64/conf/link.ld
@@ -0,0 +1,42 @@
+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
+
+ /DISCARD/ : {
+ *(.eh_frame .eh_frame.*)
+ *(.note .note.*)
+ }
+}
+