Skip to content

Commit

Permalink
add source for example elf
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamos82 committed Nov 13, 2024
1 parent c973b6a commit 58399e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ ISO_IMAGE_FILENAME := $(IMAGE_BASE_NAME)-$(ARCH_PREFIX)-$(VERSION).iso

default: build

.PHONY: default build run clean debug tests gdb todolist
.PHONY: default build run clean debug tests gdb todolist examples

build: $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME)
build: examples $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME)

clean:
-rm -rf $(BUILD_FOLDER)
Expand All @@ -53,6 +53,12 @@ clean:
run: $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME)
$(QEMU_SYSTEM) -cdrom $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME)

examples:
echo "Building Examples"
mkdir -p $(BUILD_FOLDER)/examples
${ASM_COMPILER} -g -felf64 -Fdwarf examples/example_syscall.s -o $(BUILD_FOLDER)/examples/example_syscall.o
$(X_LD) -g $(BUILD_FOLDER)/examples/example_syscall.o -o $(BUILD_FOLDER)/examples/example_syscall.elf -e loop -T examples/linker_script_$(SMALL_PAGES).ld

debug: DEBUG=1
debug: CFLAGS += $(C_DEBUG_FLAGS)
debug: ASM_FLAGS += $(ASM_DEBUG_FLAGS)
Expand All @@ -61,12 +67,12 @@ debug: $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME)
# qemu-system-x86_64 -monitor unix:qemu-monitor-socket,server,nowait -cpu qemu64,+x2apic -cdrom $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME) -serial file:dreamos64.log -m 1G -d int -no-reboot -no-shutdown
$(QEMU_SYSTEM) -monitor unix:qemu-monitor-socket,server,nowait -cpu qemu64,+x2apic -cdrom $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME) -serial stdio -m 2G -no-reboot -no-shutdown

$(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME): $(BUILD_FOLDER)/kernel.bin grub.cfg
$(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME): examples $(BUILD_FOLDER)/kernel.bin grub.cfg
mkdir -p $(BUILD_FOLDER)/isofiles/boot/grub
cp grub.cfg $(BUILD_FOLDER)/isofiles/boot/grub
cp $(BUILD_FOLDER)/kernel.bin $(BUILD_FOLDER)/isofiles/boot
cp $(BUILD_FOLDER)/kernel.map $(BUILD_FOLDER)/isofiles/boot
cp example_syscall.elf $(BUILD_FOLDER)/isofiles
cp $(BUILD_FOLDER)/examples/example_syscall.elf $(BUILD_FOLDER)/isofiles
grub-mkrescue -o $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME) $(BUILD_FOLDER)/isofiles

$(BUILD_FOLDER)/%.o: src/%.s
Expand Down
7 changes: 7 additions & 0 deletions examples/example_syscall.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extern loop
[bits 64]
loop:
mov rdi, 0x63
mov rsi, 0x1
int 0x80
jmp loop

0 comments on commit 58399e0

Please sign in to comment.