summaryrefslogtreecommitdiffstats
path: root/sys/conf/Makefile.mips
blob: 57e1dfebcc82c46887b77889ef197913c250ff62 (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
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
# Makefile.mips
# $FreeBSD$
#
# Makefile for FreeBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/mips/conf/``machineid''
# after which you should do
#	 config machineid
# Generic makefile changes should be made in
#	/sys/conf/Makefile.mips
# after which config should be rerun for all machines.
#

# Which version of config(8) is required.
%VERSREQ=	600004

STD8X16FONT?=	iso

.if !defined(S)
.if exists(./@/.)
S=	./@
.else
S=	../../..
.endif
.endif
.include "$S/conf/kern.pre.mk"

LDSCRIPT_NAME?=ldscript.$M
SYSTEM_LD:= ${SYSTEM_LD:$S/conf/${LDSCRIPT_NAME}=${LDSCRIPT_NAME}}
SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/${LDSCRIPT_NAME}=${LDSCRIPT_NAME}}

KERNLOADADDR?=0x80001000
# This obscure value is defined by CFE for WR160N
# To be changed later
TRAMPLOADADDR?=0x807963c0

MKMODULESENV+=	MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH}

# We default to the MIPS32 ISA, if none specified in the
# kernel configuration file.
ARCH_FLAGS?=-march=mips32
EXTRA_FLAGS=-fno-pic -mno-abicalls -G0

HACK_EXTRA_FLAGS=-shared

# We add the -fno-pic flag to kernels because otherwise performance
# is extremely poor, as well as -mno-abicalls to force no ABI usage.
CFLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)
HACK_EXTRA_FLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)

# XXX hardcoded kernel entry point
ASM_CFLAGS+=${CFLAGS} -D_LOCORE -DLOCORE

KERNEL_EXTRA=trampoline
trampoline: ${KERNEL_KO}.tramp.bin
${KERNEL_KO}.tramp.bin: ${KERNEL_KO} $S/$M/$M/elf_trampoline.c \
	$S/$M/$M/inckern.S 
	${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
	-g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
	sed s/${KERNLOADADDR}/${TRAMPLOADADDR}/ ${LDSCRIPT_NAME} | \
		sed s/" + SIZEOF_HEADERS"//  > ${LDSCRIPT_NAME}.tramp.noheader
	# Generate .S file that setups stack and jumps to trampoline
	echo "#include <machine/asm.h>" >tmphack.S
	echo "ENTRY(_start)" >>tmphack.S
	echo "PTR_LA t0, kernel_end" >>tmphack.S
	echo "move sp, t0" >>tmphack.S
	echo "add sp, 0x2000" >>tmphack.S
	echo "and sp, ~0x7" >>tmphack.S
	echo "PTR_LA t0, _startC" >>tmphack.S
	echo "j t0" >>tmphack.S
	echo "END(_start)" >>tmphack.S
	echo "#define KERNNAME \"${KERNEL_KO}.tmp\""  >opt_kernname.h 
	${CC} -O -nostdlib -I. -I$S ${HACK_EXTRA_FLAGS} ${TRAMP_LDFLAGS} -Xlinker \
		-T -Xlinker ${LDSCRIPT_NAME}.tramp.noheader tmphack.S \
		$S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
		-o ${KERNEL_KO}.tramp.noheader 
	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
		${KERNEL_KO}.tramp.bin \

%BEFORE_DEPEND

%OBJS

%FILES.c

%FILES.s

%FILES.m

%CLEAN

CLEAN+=	${LDSCRIPT_NAME} ${LDSCRIPT_NAME}.tramp.noheader \
	${KERNEL_KO}.tramp.noheader ${KERNEL_KO}.tramp.bin

${LDSCRIPT_NAME}: $S/conf/${LDSCRIPT_NAME}
	cat $S/conf/${LDSCRIPT_NAME}|sed s/KERNLOADADDR/${KERNLOADADDR}/g \
		> ${LDSCRIPT_NAME}
%RULES

.include "$S/conf/kern.post.mk"
OpenPOWER on IntegriCloud