ad010d9d1f
from projects/mips to head by hand: r197015 | imp | 2009-09-08 21:59:46 -0600 (Tue, 08 Sep 2009) | 2 lines Prefer PTR_LA over a naked la to work with 64-bits.. r197012 | imp | 2009-09-08 21:46:04 -0600 (Tue, 08 Sep 2009) | 3 lines Use proper set of flags to build the tramp. this gets 64-bit almost building and lets me debug the 'almost' :) r197004 | imp | 2009-09-08 18:47:12 -0600 (Tue, 08 Sep 2009) | 2 lines Use ${LDSCRIPT_NAME} in preference to ldscript.$M. r195669 | gonzo | 2009-07-13 17:03:44 -0600 (Mon, 13 Jul 2009) | 3 lines - Remove -mno-dsp from CFLAGS. MIPS DSP ASE is off by default now (as it should be) r195533 | imp | 2009-07-10 01:21:26 -0600 (Fri, 10 Jul 2009) | 4 lines Add in the emulation selection when linking... We're still not 100% of the way there, but we're better with it. hack.so build now, but we die when we try to link it in. r191079 | gonzo | 2009-04-14 16:53:22 -0600 (Tue, 14 Apr 2009) | 2 lines - Revert changes accidentally killed by merge operation r187418 | gonzo | 2009-01-18 19:37:10 -0700 (Sun, 18 Jan 2009) | 4 lines - Add trampoline stuff for bootloaders that do not support ELF - Replace arm'ish KERNPHYSADDR/KERNVIRTADDR with KERNLOADADDR/TRAMPLOADADDR and clean configs
129 lines
3.3 KiB
Makefile
129 lines
3.3 KiB
Makefile
# 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}}
|
|
|
|
# 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 -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
|
|
.if defined(TARGET_64BIT)
|
|
SYSTEM_LD+=-m elf64btsmip_fbsd
|
|
HACK_EXTRA_FLAGS+=-Wl,-m,elf64btsmip_fbsd
|
|
.endif
|
|
.else
|
|
CFLAGS+=-EL
|
|
SYSTEM_LD+=-EL
|
|
EXTRA_FLAGS+=-EL
|
|
TRAMP_LDFLAGS+=-Wl,-EL
|
|
HACK_EXTRA_FLAGS+=-EL -Wl,-EL
|
|
.if defined(TARGET_64BIT)
|
|
SYSTEM_LD+=-m elf64ltsmip_fbsd
|
|
HACK_EXTRA_FLAGS+=-Wl,-m,elf64ltsmip_fbsd
|
|
.endif
|
|
.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+=${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"
|