summaryrefslogtreecommitdiffhomepage
path: root/src/arm64/makefile
blob: a85553bdb3fac6f1d4ba49313a8ac58e12846e00 (plain)
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
 #
 #	========================================================
 #
 #	NeBoot
 # 	Date Added: 08/11/2023
 # 	Copyright 2024, Amlal El Mahrouss, all rights reserved.
 #
 # 	========================================================
 #

CC=aarch64-elf-gcc
AS=aarch64-elf-as

COREBOOT=core-boot.elf
FIRMWARE=boot.rom
STAGE2=bootstg2.rom

FLAGS=-c -D__COMPILE_ARM64__ -I../../ -Wall -c -nostdlib -ffreestanding -fno-builtin \
		-D__BSTRICT__ -D__BDEBUG__

C_SRC=$(wildcard *.c) $(wildcard ../*.c) -c

AS_FLAGS= -c -I../../

LD=aarch64-elf-ld
OBJ=*.o
FLAGS_LD= --script=script.lds -o core-boot.elf -nostdlib
OBJCOPY=aarch64-elf-objcopy

EMU=qemu-system-aarch64
EMU_FLAGS=-M virt -cpu cortex-a57 -bios $(FIRMWARE) -m 256M -d int -smp 2

WAIT=sleep 1

.PHONY: all
all: firmware-link
	@echo "[NeBoot] build done."

.PHONY: firmware-link
firmware-link: firmware-compile
	$(LD) $(OBJ) $(FLAGS_LD)

.PHONY: rom
rom:
	qemu-img create -f qcow2 epm.img 256M
	qemu-img create -f raw bootstg2.rom 64M
	$(OBJCOPY) --strip-all -O binary $(COREBOOT) $(FIRMWARE)

# compile firmware
.PHONY: firmware-compile
firmware-compile:
	$(CC) $(FLAGS) $(C_SRC)
	$(AS) arm64-start-context.S -o arm64-start-context.o
	$(AS) arm64-boot.S -o arm64-boot.o
	

# launch qemu rule
.PHONY: run
run:
	$(EMU) $(EMU_FLAGS)

# launch qemu with attached debugger
.PHONY: run-dbg
run-dbg:
	$(EMU) -s -S $(EMU_FLAGS)

# remove object files
.PHONY: clean
clean:
	rm -f $(wildcard *.o) $(wildcard *.elf) $(wildcard *.rom) $(wildcard *.epm)