GNUmakefile
3.02 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
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
include $(ROOT)/usr/include/make/commondefs
include $(ROOT)/usr/include/make/PRdefs
# XXX: it would be optimal to obtain these from bcp.h
# instead of hard-coding here.
SK_LINK_START_ADDR = 0x9fc00000
SK_LINK_END_ADDR = 0x9fc10000
TARGETS = sk.aes sk_bpki.aes sk_fpki.aes
CFILES = skapi.c boot.c timer.c cert.c rl.c util.c handler.c \
nvram.c skreencrypt.c rand.c
ASFILES = entry.s invaldcache.s
OBJECTS_BETA = $(OBJECTS) rootbeta.o
OBJECTS_FINAL = $(OBJECTS) rootfinal.o
ifdef SK_ROOT_LOCAL
OBJECTS_LOCAL = $(OBJECTS) rootlocal.o
else
OBJECTS_LOCAL = $(OBJECTS_BETA)
endif
OBJCOPY = mips-linux-objcopy
OBJCOPY_REMOVE_SECTS = -R .reginfo -R .note -R .comment -R .mdebug
OBJCOPY_PAD = --pad-to $(SK_LINK_END_ADDR)
OBJCOPY_FLAGS = $(OBJCOPY_PAD) -O binary -S $(OBJCOPY_REMOVE_SECTS)
OPTIMIZER=
LCOPTS += -Wall -fno-builtin
LASOPTS +=
LCOPTS += -mips2 -G 0
LASOPTS += -mips2 -G 0
ifdef DEBUG
LCOPTS += -DDEBUG -g
LASOPTS += -DDEBUG -g
else
LCOPTS += -Os -g
LASOPTS +=-Os -g
endif
ifdef SK_LOG_MEM
LCOPTS += -DSK_LOG_MEM
LASOPTS += -DSK_LOG_MEM
else
ifdef SK_LOG_IDE
LCOPTS += -DSK_LOG_IDE
LASOPTS += -DSK_LOG_IDE
endif
ifdef SK_LOG_RDB
LCOPTS += -DSK_LOG_RDB
LASOPTS += -DSK_LOG_RDB
endif
endif
LLDOPTS += -Ttext $(SK_LINK_START_ADDR) -N
LLDLIBS += -lcrypto
LDIRT += cpu.log*
LDIRT += sk*.elf sk*.bin sk*.hex
LDIRT += bbcdbbcb.* j.j *.bin flash.img ticket.sys v2.hex romsimos.elf virage2.in virage2_bpki.in virage2_fpki.in final/*.bin
.PRECIOUS: %.bin %.hex
# arrange rules in this way to control SK_DEVELOP define.
# ONLY the local (sk.elf) sk will be built with SK_DEVELOP.
# to produce such a build use "make LCDEFS=-DSK_DEVELOP".
default: cleansk
make sk.aes
rm -f skapi.o
make LCDEFS= sk_bpki.aes
make LCDEFS= sk_fpki.aes
sk.elf: $(OBJECTS_LOCAL)
$(CCF) -o $@ $(OBJECTS_LOCAL) $(LDFLAGS)
@if [ `size sk.elf | tail -1 | awk '{print $$4}'` -gt 65536 ]; then \
echo "SECURE KERNEL TOO LARGE"; \
size sk.elf; \
rm -f sk.elf; \
exit 1; \
fi \
sk_bpki.elf: $(OBJECTS_BETA)
$(CCF) -o $@ $(OBJECTS_BETA) $(LDFLAGS)
sk_fpki.elf: $(OBJECTS_FINAL)
$(CCF) -o $@ $(OBJECTS_FINAL) $(LDFLAGS)
%.bin: %.elf
$(OBJCOPY) $(OBJCOPY_FLAGS) $< $@
%.hex: %.bin
od -v -w4 -An -tx1 $< | tr -d " " > $@
AES_TOOL=$(ROOT)/usr/sbin/aes_encode
SK_IV=-i a438b3410298747b0c089d8f6d2991a8
SK_KEY=-k a81902767e25db170f3449c5d94b162f
%.aes: %.hex
$(AES_TOOL) $(SK_IV) $(SK_KEY) $*.bin $@
cleansk:
rm -f sk.hex sk.bin
include $(COMMONRULES)
headers:
V2CONST_TOOL=$(ROOT)/usr/sbin/v2Const
exports install: final/sk.bin final/sk_bpki.bin final/sk_fpki.bin
$(V2CONST_TOOL) -e final/sk.bin virage2.in
$(V2CONST_TOOL) -e final/sk_bpki.bin virage2_beta.in
$(V2CONST_TOOL) -e final/sk_fpki.bin virage2_final.in
$(INSTALL) -m 444 -F /usr/host_data virage2.in
$(INSTALL) -m 444 -F /usr/host_data virage2_beta.in
$(INSTALL) -m 444 -F /usr/host_data virage2_final.in
$(INSTALL) -m 444 -F /usr/host_data final/sk.aes
$(INSTALL) -m 444 -F /usr/host_data final/sk_bpki.aes
$(INSTALL) -m 444 -F /usr/host_data final/sk_fpki.aes