summaryrefslogtreecommitdiff
path: root/Makefile
blob: 78cad75850215a257d5fc623111ebc8f47ab7d63 (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
# tashaboot
#
# build: make CROSS=aarch64-linux-gnu-
# run:   make run  (qemu virt, semihosting, Image on the host)
#
# arm64 only. the architecture contract comes from the ARM ARM
# (DDI 0487), the payload protocol from the kernel booting docs.

CROSS	?= aarch64-linux-gnu-
CC	:= $(CROSS)gcc
LD	:= $(CROSS)ld
OBJCOPY	:= $(CROSS)objcopy

CFLAGS	:= -nostdlib -ffreestanding -mgeneral-regs-only \
	   -fno-builtin -fno-stack-protector -fno-pie -no-pie \
	   -Wall -Werror -O2  \
	   -Iinclude -Iarch/arm64/include

LDFLAGS	:= -T arch/arm64/kernel/tashaboot.lds

OBJS	:= arch/arm64/kernel/start.o \
	   arch/arm64/kernel/exceptions.o \
	   arch/arm64/kernel/halt.o \
	   arch/arm64/kernel/boot.o \
	   arch/arm64/lib/cache.o \
	   arch/arm64/lib/semihosting.o \
	   arch/arm64/lib/mmu.o \
	   arch/arm64/lib/psci.o \
	   arch/arm64/lib/system.o \
	   arch/arm64/lib/cache_va.o \
	   arch/arm64/lib/timer.o \
	   common/main.o common/console.o common/image.o common/load.o \
	   common/mmutest.o common/dtb_patch.o common/dtb_reloc.o \
	   common/dtb_grow.o \
	   lib/printf.o lib/itoa.o lib/semihosting.o \
	   $(patsubst %.c,%.o,$(wildcard lib/string/*.c))

all: build/tashaboot.bin

build/tashaboot.elf: $(OBJS) arch/arm64/kernel/tashaboot.lds
	mkdir -p build
	$(LD) $(LDFLAGS) -o $@ $(OBJS)

build/tashaboot.bin: build/tashaboot.elf
	$(OBJCOPY) -O binary $< $@
	python3 tools/fillsize.py $@

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

%.o: %.S
	$(CC) $(CFLAGS) -c -o $@ $<

run: all
	qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -no-reboot \
		-semihosting -kernel build/tashaboot.bin

clean:
	rm -rf build $(OBJS)

.PHONY: all run clean