diff options
Diffstat (limited to 'sys/conf/Makefile.mips')
-rw-r--r-- | sys/conf/Makefile.mips | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/sys/conf/Makefile.mips b/sys/conf/Makefile.mips index 443065a..e03432c 100644 --- a/sys/conf/Makefile.mips +++ b/sys/conf/Makefile.mips @@ -28,35 +28,73 @@ S= ../../.. .endif .include "$S/conf/kern.pre.mk" +SYSTEM_LD:= ${SYSTEM_LD:$S/conf/ldscript.$M=ldscript.$M} +SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M} + # XXX: Such sweeping assumptions... MACHINE=mips MACHINE_ARCH=mips +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 -mno-dsp -G0 HACK_EXTRA_FLAGS=-shared .if defined(TARGET_BIG_ENDIAN) CFLAGS+=-EB SYSTEM_LD+=-EB +EXTRA_FLAGS+=-EB +TRAMP_LDFLAGS+=-Wl,-EB HACK_EXTRA_FLAGS+=-EB -Wl,-EB .else CFLAGS+=-EL SYSTEM_LD+=-EL +EXTRA_FLAGS+=-EL +TRAMP_LDFLAGS+=-Wl,-EL HACK_EXTRA_FLAGS+=-EL -Wl,-EL .endif # 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+=-fno-pic -mno-abicalls -G0 $(ARCH_FLAGS) -HACK_EXTRA_FLAGS+=-fno-pic -mno-abicalls -G0 $(ARCH_FLAGS) +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.$M | \ + sed s/" + SIZEOF_HEADERS"// > ldscript.$M.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 "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 "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 ${EXTRA_FLAGS} ${TRAMP_LDFLAGS} -Xlinker \ + -T -Xlinker ldscript.$M.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 @@ -69,6 +107,12 @@ ASM_CFLAGS+=${CFLAGS} -D_LOCORE -DLOCORE %CLEAN +CLEAN+= ldscript.$M ldscript.$M.tramp.noheader \ + ${KERNEL_KO}.tramp.noheader ${KERNEL_KO}.tramp.bin + +ldscript.$M: $S/conf/ldscript.$M + cat $S/conf/ldscript.$M|sed s/KERNLOADADDR/${KERNLOADADDR}/g \ + > ldscript.$M %RULES .include "$S/conf/kern.post.mk" |