-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (64 loc) · 2.01 KB
/
Makefile
File metadata and controls
79 lines (64 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
CC := aarch64-elf-gcc
OBJCOPY := aarch64-elf-objcopy
LD := aarch64-elf-ld
# Target specifications
CFLAGS := -Wall -Wextra -O2 -mgeneral-regs-only -ffreestanding -nostdinc -c
ASFLAGS := -c
LDFLAGS := -T linker.ld -nostdlib --nmagic
# Source files
SOURCES := boot.S uart.c kernel.c mem.c ds.c keyboard.c string.c terminal.c gpu.c fb.c graphics.c vfs.c gui.c virtio_input.c virtio_rng.c editor.c
OBJECTS := $(SOURCES:.S=.o)
OBJECTS := $(OBJECTS:.c=.o)
# Output binary
KERNEL := oneos.bin
ELF := oneos.elf
UIMAGE := oneos.uimage
BOOTSCR := boot.scr
# Default target
all: $(KERNEL) $(UIMAGE)
# Link the kernel
$(ELF): $(OBJECTS)
$(LD) $(LDFLAGS) -o $@ $^
# Convert ELF to binary
$(KERNEL): $(ELF)
$(OBJCOPY) -O binary $< $@
# Create U-Boot image (uImage format)
$(UIMAGE): $(KERNEL)
mkimage -A arm64 -T kernel -C none -O linux -a 0x40100000 -e 0x40100000 -n "OneOS-ARM 1" -d $(KERNEL) $@
# Compile boot script
$(BOOTSCR): boot.scr.txt
mkimage -A arm64 -T script -C none -n "OneOS Boot Script" -d boot.scr.txt $@
# Compile assembly
%.o: %.S
$(CC) $(ASFLAGS) -o $@ $<
# Compile C
%.o: %.c
$(CC) $(CFLAGS) -o $@ $<
# Run in QEMU with U-Boot
run: $(KERNEL)
qemu-system-aarch64 -M virt -cpu cortex-a72 -m 256M \
-serial file:serial_log.txt \
-device bochs-display \
-device qemu-xhci \
-device usb-tablet \
-device virtio-keyboard-device \
-device virtio-mouse-device \
-device virtio-rng-device \
-display cocoa \
-kernel $(KERNEL)
# Run with serial attached to terminal (no GUI keyboard)
run-serial: $(KERNEL)
qemu-system-aarch64 -M virt -cpu cortex-a72 -m 256M -serial mon:stdio -device bochs-display -kernel $(KERNEL)
# Run with serial console for UTM or testing
run-utm: $(KERNEL)
qemu-system-aarch64 -M virt -cpu cortex-a72 -m 256M \
-serial mon:stdio \
-device bochs-display \
-device virtio-keyboard-device \
-device virtio-rng-device \
-display cocoa \
-kernel $(KERNEL)
# Clean build artifacts
clean:
rm -f $(OBJECTS) $(ELF) $(KERNEL) $(UIMAGE) $(BOOTSCR)
.PHONY: all run run-serial run-utm clean