Compare commits

..

3 Commits

Author SHA1 Message Date
Quinten Kock 64b01f8433 store arch info in NASM (as test) 2020-12-07 01:55:12 +01:00
Quinten Kock 12d1092753 Add support for NASM assembler 2020-12-07 01:54:57 +01:00
Quinten Kock 6721d5b485 fix definition of kmain 2020-12-06 23:55:57 +01:00
10 changed files with 26 additions and 10 deletions

View File

@ -19,7 +19,7 @@ TARGET := kernel
CFILES := $(shell find src -path src/arch -prune -o -type f -name '*.c' -print) CFILES := $(shell find src -path src/arch -prune -o -type f -name '*.c' -print)
ARCHFILES := $(ARCHFILES) $(shell find src/arch/$(ARCH) -type f -name '*.c' -print) ARCHFILES := $(ARCHFILES) $(shell find src/arch/$(ARCH) -type f -name '*.c' -print)
HFILES := $(shell find src -type f -name '*.h') HFILES := $(shell find src -type f -name '*.h')
OBJ := $(patsubst src/%.c,obj/$(ARCH)/%.o,$(CFILES) $(ARCHFILES)) OBJ := $(patsubst src/%,obj/$(ARCH)/%.o,$(CFILES) $(ARCHFILES))
.PHONY: all clean obj $(ARCHES) .PHONY: all clean obj $(ARCHES)
@ -32,9 +32,9 @@ $(ARCHES):
bin/$(TARGET)-$(ARCH): $(OBJ) bin/$(TARGET)-$(ARCH): $(OBJ)
@mkdir -p $(@D) @mkdir -p $(@D)
@echo Linking $@ @echo Linking $@
@$(LD) $(LDFLAGS) $(OBJ) -o $@ $(LD) $(LDFLAGS) $(OBJ) -o $@
obj/$(ARCH)/%.o: src/%.c $(HFILES) obj/$(ARCH)/%.c.o: src/%.c $(HFILES)
@mkdir -p $(@D) @mkdir -p $(@D)
@echo $(CC) $< @echo $(CC) $<
@$(CC) $(CFLAGS) -c $< -o $@ @$(CC) $(CFLAGS) -c $< -o $@

View File

@ -1 +1,3 @@
-include make/x86/make.config -include make/x86/make.config
NASM := nasm -felf32

View File

@ -1,2 +1,9 @@
ARCHFILES := $(shell find src/arch/x86 -type f -name '*.c' -print) ARCHFILES := $(shell find src/arch/x86 -type f -name '*.c' -print) \
ARCH_CFLAGS := -masm=intel $(shell find src/arch/x86 -type f -name '*.nasm' -print) \
$(shell find src/arch/$(ARCH) -type f -name '*.nasm' -print)
ARCH_CFLAGS := -masm=intel
obj/$(ARCH)/%.nasm.o: src/%.nasm
@mkdir -p $(@D)
@echo nasm $<
@$(NASM) $(NASMFLAGS) $< -o $@

View File

@ -1,3 +1,4 @@
-include make/x86/make.config -include make/x86/make.config
NASM := nasm -felf64
ARCH_CFLAGS := $(ARCH_CFLAGS) -mcmodel=kernel ARCH_CFLAGS := $(ARCH_CFLAGS) -mcmodel=kernel

View File

@ -29,6 +29,5 @@ void stivale2_main(struct stivale2_struct *info) {
); );
printf("PAGE TABLE AT: %x\n", cr3); printf("PAGE TABLE AT: %x\n", cr3);
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version}; kmain();
kmain(3, argv);
} }

View File

@ -1 +1,2 @@
const char *arch = "i386"; extern char archval;
const char *arch = &archval;

View File

@ -0,0 +1,2 @@
global archval
archval db "i386-nasm", 0

View File

@ -1 +1,3 @@
const char *arch = "x86_64"; extern char archval;
const char *arch = &archval;

View File

@ -0,0 +1,2 @@
global archval
archval db "x86_64-nasm", 0

View File

@ -1 +1 @@
void kmain(int argc, char** argv); void kmain();