-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
151 lines (122 loc) · 3.61 KB
/
Makefile
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
INC = ./include
LIB = ./lib/include
TOOLCHAIN=@aarch64-linux-gnu-
CC = $(TOOLCHAIN)gcc
AS = $(TOOLCHAIN)as
LD = $(TOOLCHAIN)ld
OBJCOPY = $(TOOLCHAIN)objcopy
OBJDUMP = $(TOOLCHAIN)objdump
CFLAGS = -g -ffreestanding -nostdlib -nostartfiles -Wall -I$(INC) -I$(LIB)
ASMFLAGS = -g -I$(INC)
.PHONY: all deltaV
all: deltaV omega.bin
OBJ += ./build/boot/boot.S.o
OBJ += ./build/monitor/monitor_main.o
OBJ += ./build/monitor/irq.S.o
OBJ += ./build/monitor/irq.o
OBJ += ./build/monitor/exceptions.S.o
OBJ += ./build/monitor/delay.o
OBJ += ./build/monitor/context.o
OBJ += ./build/monitor/context.S.o
OBJ += ./build/monitor/sync.o
OBJ += ./build/monitor/misc.S.o
OBJ += ./build/monitor/bl33_loader.o
OBJ += ./build/mm/mm.o
OBJ += ./build/mm/mm.S.o
OBJ += ./build/mm/paging.S.o
OBJ += ./build/mm/paging.o
OBJ += ./build/drivers/uart.o
OBJ += ./build/drivers/sd.o
OBJ += ./build/lib/stdio.o
OBJ += ./build/lib/memory.o
OBJ += ./build/lib/string.o
OBJ += ./build/lib/stdlib.o
OBJ += ./build/debug/debug.o
OBJ += ./build/fs/diskio.o
OBJ += ./build/fs/ff.o
OBJ += ./build/auth/auth.o
OBJ += ./build/crypto/crypto.o
OBJ += ./build/crypto/crypto.S.o
OBJ += ./build/ocom/ocom.o
./build/boot/%.S.o: ./boot/%.S
@echo CC $@
$(CC) $(ASMFLAGS) -c $< -o $@
./build/monitor/%.S.o: ./monitor/%.S
@echo CC $@
$(CC) $(ASMFLAGS) -c $< -o $@
./build/monitor/%.o: ./monitor/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/drivers/%.o: ./drivers/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/mm/%.o: ./mm/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/lib/%.o: ./lib/src/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/debug/%.o: ./debug/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/fs/%.o: ./fs/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/mm/%.S.o: ./mm/%.S
@echo CC $@
$(CC) $(ASMFLAGS) -c $< -o $@
./build/auth/%.o: ./auth/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/crypto/%.o: ./crypto/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
./build/crypto/%.S.o: ./crypto/%.S
@echo CC $@
$(CC) $(ASMFLAGS) -c $< -o $@
./build/ocom/%.o: ./ocom/%.c
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@
omega.bin: sdcard $(OBJ)
$(LD) -T linker.ld -o ./omega.elf $(OBJ_C) $(OBJ)
$(OBJCOPY) ./omega.elf -O binary ./omega.bin
ifeq ($(shell test -e ./sdcard.img && echo -n yes),yes)
SDCARD_IMAGE_EXISTS=1
endif
ifdef SDCARD_IMAGE_EXISTS
sdcard:
else
sdcard: deltaV
sudo modprobe nbd max_part=8
qemu-img create sdcard.img 128m
sudo qemu-nbd -c /dev/nbd0 --format=raw sdcard.img
(echo o; echo n; echo p; echo 1; echo ; echo ;echo w; echo q) | sudo fdisk /dev/nbd0
@sudo mkfs.fat -F32 /dev/nbd0p1
mkdir temp || true
sudo mount -o user /dev/nbd0p1 temp/
sudo cp ./deltaV/kernel8.img temp/
sudo cp -r ./deltaV/guests temp/
sleep 1s
sudo umount temp/
rmdir temp/ || true
@sudo qemu-nbd -d /dev/nbd0
(echo t; echo c; echo w; echo q) | sudo fdisk sdcard.img
endif
deltaV:
cd deltaV && OMEGA=1 make
run: omega.bin
qemu-system-aarch64 -M raspi3b -nographic -serial null -serial mon:stdio -m 1024 -drive file=./sdcard.img,if=sd,format=raw -kernel ./omega.bin
debug: omega.bin
qemu-system-aarch64 -M raspi3b -nographic -serial null -serial mon:stdio -m 1024 -drive file=./sdcard.img,if=sd,format=raw -kernel ./omega.bin -s -S
gdb:
gdb-multiarch -ex "target remote localhost:1234" -ex "add-symbol-file omega.elf" -ex "add-symbol-file ./deltaV/deltaV.elf" -ex "add-symbol-file ./deltaV/guests/deltaOS/deltaOS.elf"
list: omega.bin
aarch64-linux-gnu-objdump -D omega.elf > omega.list
clean:
cd deltaV && make clean
rm -f *.elf
rm -f *.img
rm -f *.bin
find ./build -name '*.o' -delete
find ./build -name '*.d' -delete
rm -f *.list