implement multi-architecure stuff
This commit is contained in:
parent
03ed46212d
commit
08a80c7731
|
|
@ -1,27 +1,33 @@
|
||||||
|
ARCH ?= $(shell uname -m)
|
||||||
|
|
||||||
|
CC = zig cc -target $(ARCH)-freestanding
|
||||||
|
LD = ld -m elf_$(ARCH)
|
||||||
|
|
||||||
|
-include make.$(ARCH).config
|
||||||
|
|
||||||
|
CFLAGS ?= -O2
|
||||||
|
CFLAGS := $(CFLAGS) $(ARCH_CFLAGS) \
|
||||||
|
-Wall -Wextra -pedantic -Wno-language-extension-token -std=gnu11 -I../ext/limine/stivale -fPIE
|
||||||
|
LDFLAGS := $(LDFLAGS) -T linker.ld
|
||||||
|
|
||||||
|
|
||||||
TARGET := kernel
|
TARGET := kernel
|
||||||
|
|
||||||
CC = zig cc -target x86_64-freestanding
|
CFILES := $(shell find src -path src/arch -prune -o -type f -name '*.c' -print)
|
||||||
CFLAGS = -O2 -Wall -Wextra -Wno-language-extension-token -pedantic -std=gnu11 -pedantic
|
ARCHFILES := $(shell find src/arch/$(ARCH) -type f -name '*.c' -print)
|
||||||
LD = ld -m elf_x86_64
|
|
||||||
QEMU = qemu-system-x86_64
|
|
||||||
QEMUFLAGS = -m 1G -enable-kvm -cpu host
|
|
||||||
LDINTERNALFLAGS := -Tlinker.ld
|
|
||||||
INTERNALCFLAGS := -I../ext/limine/stivale -mcmodel=kernel
|
|
||||||
|
|
||||||
CFILES := $(shell find src -type f -name '*.c')
|
|
||||||
HFILES := $(shell find src -type f -name '*.h')
|
HFILES := $(shell find src -type f -name '*.h')
|
||||||
OBJ := $(patsubst src/%.c,obj/%.o,$(CFILES))
|
OBJ := $(patsubst src/%.c,obj/%.o,$(CFILES) $(ARCHFILES))
|
||||||
|
|
||||||
.PHONY: all clean obj
|
.PHONY: all clean obj
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(OBJ)
|
$(TARGET): $(OBJ)
|
||||||
$(LD) $(LDINTERNALFLAGS) $(OBJ) -o $@
|
$(LD) $(LDFLAGS) $(OBJ) -o $@
|
||||||
|
|
||||||
obj/%.o: src/%.c $(HFILES)
|
obj/%.o: src/%.c $(HFILES)
|
||||||
@mkdir -p obj
|
@mkdir -p obj/arch/$(ARCH)
|
||||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(TARGET) obj zig-cache
|
rm -rf $(TARGET) obj zig-cache
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
LD=arm-none-eabi-ld
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ARCH_CFLAGS = -mcmodel=kernel
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "../../main.h"
|
||||||
|
|
||||||
static uint8_t stack[4096] = {0};
|
static uint8_t stack[4096] = {0};
|
||||||
void stivale2_main(struct stivale2_struct *info);
|
void stivale2_main(struct stivale2_struct *info);
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
void halt_catch_fire() {
|
||||||
|
asm volatile ("cli");
|
||||||
|
while(1) asm volatile ("hlt");
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
void halt_catch_fire();
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "vga.h"
|
#include "arch/x86_64/vga.h"
|
||||||
|
#include "hal/ops.h"
|
||||||
|
|
||||||
void kmain(int argc, char **argv) {
|
void kmain(int argc, char **argv) {
|
||||||
vga_puts("Kernel initialized!\n");
|
vga_puts("Kernel initialized!\n");
|
||||||
|
|
@ -10,5 +11,5 @@ void kmain(int argc, char **argv) {
|
||||||
|
|
||||||
vga_setcolor(VGA_DARK_GRAY);
|
vga_setcolor(VGA_DARK_GRAY);
|
||||||
vga_write_elsewhere("(c) Quinten Kock 2020 (MIT License)", 24, 0);
|
vga_write_elsewhere("(c) Quinten Kock 2020 (MIT License)", 24, 0);
|
||||||
asm volatile ("hlt");
|
halt_catch_fire();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue