Skip to content

Commit

Permalink
Merge pull request #10 from albertarielw/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
albertarielw authored Jul 9, 2023
2 parents 9f8bbe9 + 9721f24 commit fd7e984
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 14 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
build/**
33 changes: 22 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
ASM = nasm
CC = gcc

SRC_DIR = src
BUILD_DIR = build

BOOTSTRAP_FILE = bootstrap.asm
INIT_KERNEL_FILES = starter.asm
KERNEL_FILES = main.c
KERNEL_FLAGS = -Wall -m32 -c -ffreestanding -fno-asynchronous-unwind-tables -fno-pie
KERNEL_OBJECT = -o kernel.elf
KERNEL_OBJECT = kernel.elf

.PHONY: build link run clean

build: $(SRC_DIR)/$(BOOTSTRAP_FILE) $(BUILD_DIR)/$(KERNEL_FILE)
$(ASM) -f bin $(SRC_DIR)/$(BOOTSTRAP_FILE) -o $(BUILD_DIR)/bootstrap.o
$(ASM) -f elf32 $(SRC_DIR)/$(INIT_KERNEL_FILES) -o $(BUILD_DIR)/starter.o
$(CC) $(KERNEL_FLAGS) $(SRC_DIR)/$(KERNEL_FILES) -o $(BUILD_DIR)/$(KERNEL_OBJECT)
ld -melf_i386 -Tlinker.ld $(BUILD_DIR)/starter.o $(BUILD_DIR)/kernel.elf -o $(BUILD_DIR)/minios.elf
objcopy -O binary $(BUILD_DIR)/minios.elf $(BUILD_DIR)/minios.bin
dd if=$(BUILD_DIR)/bootstrap.o of=$(BUILD_DIR)/kernel.img
dd seek=1 conv=sync if=$(BUILD_DIR)/minios.bin of=$(BUILD_DIR)/kernel.img bs=512 count=5
dd seek=6 conv=sync if=/dev/zero of=$(BUILD_DIR)/kernel.img bs=512 count=2046

run:
qemu-system-x86_64 -s $(BUILD_DIR)/kernel.img

build: $(BOOTSTRAP_FILE) $(KERNEL_FILE)
$(ASM) -f bin $(BOOTSTRAP_FILE) -o bootstrap.o
$(ASM) -f elf32 $(INIT_KERNEL_FILES) -o starter.o
$(CC) $(KERNEL_FLAGS) $(KERNEL_FILES) $(KERNEL_OBJECT)
ld -melf_i386 -Tlinker.ld starter.o kernel.elf -o minios.elf
objcopy -O binary minios.elf minios.bin
dd if=bootstrap.o of=kernel.img
dd seek=1 conv=sync if=minios.bin of=kernel.img bs=512 count=5
dd seek=6 conv=sync if=/dev/zero of=kernel.img bs=512 count=2046
qemu-system-x86_64 -s kernel.img
clean:
rm -rf $(BUILD_DIR)/*.o $(BUILD_DIR)/*.img $(BUILD_DIR)/*.bin $(BUILD_DIR)/*.elf
Binary file added asset/v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed bootstrap.o → build/bootstrap.o
Binary file not shown.
File renamed without changes.
Binary file renamed kernel.img → build/kernel.img
Binary file not shown.
File renamed without changes.
Binary file renamed minios.elf → build/minios.elf
Binary file not shown.
Binary file added build/starter.o
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions starter.asm → src/starter.asm
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,5 @@ start_kernel:
call kernel_main
%include "gdt.asm"
%include "idt.asm"
%include "src/gdt.asm"
%include "src/idt.asm"
Binary file removed starter.o
Binary file not shown.

0 comments on commit fd7e984

Please sign in to comment.