Loader moved into new build workflow

This commit is contained in:
shockrah 2023-03-30 22:17:49 -07:00
parent ee7e44fbaf
commit 044d5a75b5
3 changed files with 22 additions and 19 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ rand/
COM1.out COM1.out
bx_enh_dbg.ini bx_enh_dbg.ini
.vscode/ .vscode/
build/

View File

@ -1,4 +1,4 @@
; since we have no stack we have to create one for the OS ; Since we have no stack we have to create one for the OS
global loader global loader
@ -7,7 +7,7 @@ MAGIC_NUMBER equ 0x1BADB002
FLAGS equ 0x0 FLAGS equ 0x0
CHECKSUM equ -MAGIC_NUMBER CHECKSUM equ -MAGIC_NUMBER
extern kmain ; extern kmain
section .text section .text
; align all instructions to 4 byte boundary by the x86 instruction set law ; align all instructions to 4 byte boundary by the x86 instruction set law
@ -19,11 +19,13 @@ align 4
; sets up our gdt and segment selectors for later use ; sets up our gdt and segment selectors for later use
;loader:
; call kmain
loader: loader:
call kmain .loop:
mov eax, 0xfeedbeef
jmp .loop
mov eax, 0xfeedbeef
.loop:
mov eax, 0xfeedbeef
jmp .loop
mov eax, 0xfeedbeef

View File

@ -3,19 +3,21 @@ ASM=nasm
LINK=ld LINK=ld
ISO=genisoimage ISO=genisoimage
OBJECTS=mem.o kernel.o gdt_seg.o gdt.o interrupts.o loader.o serial.o \ BUILD_DIR=build
framebuffer.o ports.o stlio.o tests.o interrupt_entry.o pit.o kbd.o\
shell.o COMPONENTS=loader
# Rebuild the components var to be usable in recipes
OBJECTS := $(addprefix build/,$(addsuffix .o,$(COMPONENTS)))
AFLAGS=-f elf32 AFLAGS=-f elf32
CFLAGS=-masm=intel -O2 -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \ CFLAGS=-masm=intel -O2 -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \
-nodefaultlibs -Wall -Wextra -c #-Werror -c -nodefaultlibs -Wall -Wextra -c #-Werror -c
all: kernel.elf compile: kernel.elf
# Link objects together to produce the kernel object # Link objects together to produce the kernel object
kernel.elf: $(OBJECTS) kernel.elf: $(COMPONENTS)
$(LINK) -T link.ld -melf_i386 $(OBJECTS) -o kernel.elf $(LINK) -T link.ld -melf_i386 $(OBJECTS) -o build/$@
# Builds image of our os # Builds image of our os
jos.iso: kernel.elf jos.iso: kernel.elf
@ -30,17 +32,15 @@ jos.iso: kernel.elf
-o jos.iso \ -o jos.iso \
iso iso
# Builind asm objects # Components which make up the OS
%.o: %.s loader: loader/main.s
$(ASM) $(AFLAGS) $< -o $@ $(ASM) $(AFLAGS) $< -o $(BUILD_DIR)/$@.o
# Building C objecets
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
# Running (no recipes called) # Running (no recipes called)
run: jos.iso run: jos.iso
bochs -f bochsrc.conf -q bochs -f bochsrc.conf -q
clean: clean:
rm -f build/*
rm -rf *.o kernel.elf jos.iso bochslog.txt rm -rf *.o kernel.elf jos.iso bochslog.txt