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