Skip to content

Commit

Permalink
Merge pull request #6 from alexs-sh/minor-updates
Browse files Browse the repository at this point in the history
Minor updates
  • Loading branch information
FRosner authored Jan 18, 2024
2 parents d50cb34 + 197868c commit 65897c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build
on: [push]

jobs:
linux:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install tools
run: sudo apt-get -y install -y gcc make nasm

- name: Build
run: make os-image.bin
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ C_SOURCES = $(wildcard kernel/*.c drivers/*.c cpu/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h cpu/*.h)
OBJ_FILES = ${C_SOURCES:.c=.o cpu/interrupt.o}

CC ?= x86_64-elf-gcc
LD ?= x86_64-elf-ld

# First rule is the one executed when no parameters are fed to the Makefile
all: run

# Notice how dependencies are built as needed
kernel.bin: boot/kernel_entry.o ${OBJ_FILES}
x86_64-elf-ld -m elf_i386 -o $@ -Ttext 0x1000 $^ --oformat binary
$(LD) -m elf_i386 -o $@ -Ttext 0x1000 $^ --oformat binary

os-image.bin: boot/mbr.bin kernel.bin
cat $^ > $@
Expand All @@ -25,14 +28,14 @@ echo: os-image.bin

# only for debug
kernel.elf: boot/kernel_entry.o ${OBJ_FILES}
x86_64-elf-ld -m elf_i386 -o $@ -Ttext 0x1000 $^
$(LD) -m elf_i386 -o $@ -Ttext 0x1000 $^

debug: os-image.bin kernel.elf
qemu-system-i386 -s -S -fda os-image.bin -d guest_errors,int &
i386-elf-gdb -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"

%.o: %.c ${HEADERS}
x86_64-elf-gcc -g -m32 -ffreestanding -c $< -o $@ # -g for debugging
$(CC) -g -m32 -ffreestanding -fno-pie -fno-stack-protector -c $< -o $@ # -g for debugging

%.o: %.asm
nasm $< -f elf -o $@
Expand Down

0 comments on commit 65897c6

Please sign in to comment.