11.37Sandvar# $NetBSD: Makefile.bootprogs,v 1.37 2022/05/28 22:16:43 andvar Exp $
21.32Sjoerg
31.32SjoergNOMAN=			# defined
41.24Slukem
51.31Sjoerg.include <bsd.own.mk>
61.1Sthorpej
71.1SthorpejS=	${.CURDIR}/../../../..
81.1Sthorpej
91.1Sthorpej.PATH:	${.CURDIR}/../common
101.1Sthorpej
111.1SthorpejBINMODE= 444
121.1Sthorpej
131.17StsutsuiSTRIP?=	strip
141.23Ssimonb
151.23Ssimonb# XXX SHOULD NOT NEED TO DEFINE THESE!
161.23SsimonbLIBCRT0=
171.33StsutsuiLIBCRTI=
181.23SsimonbLIBC=
191.23SsimonbLIBCRTBEGIN=
201.23SsimonbLIBCRTEND=
211.1Sthorpej
221.24SlukemCHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
231.8Scgd
241.29Stsutsuirealall: ${PROG}
251.1Sthorpej
261.10ScgdAFLAGS+=	-DASSEMBLER
271.10Scgd# -I${.CURDIR}/../.. done by Makefile.inc
281.10ScgdCPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
291.21SthorpejCFLAGS=		-ffreestanding -mno-fp-regs -g
301.12Scgd
311.24SlukemNETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
321.12ScgdCPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
331.10Scgd
341.28StsutsuiCWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
351.28StsutsuiCFLAGS+=	-Werror ${CWARNFLAGS}
361.18Sjdolecek
371.36Schristos.include "${S}/conf/newvers_stand.mk"
381.36Schristos
391.1Sthorpej
401.1Sthorpej# For descriptions of regions available to bootstrap programs, see
411.1Sthorpej# section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
421.1Sthorpej# the Alpha AXP Architecture Reference Manual.
431.1Sthorpej
441.8ScgdREGION1_START=		0x20000000		# "Region 1 start"
451.8ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
461.8Scgd
471.8Scgd# our memory lauout:
481.8Scgd
491.8Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
501.8Scgd#	1 for their text+data, or text+data+bss.
511.8Scgd
521.8ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
531.8ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
541.8ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
551.8Scgd
561.8Scgd#UNIFIED_HEAP_START=	right after secondary bss
571.8ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
581.8Scgd
591.8Scgd#	two-stage boot loaders must share region 1.  The first stage
601.37Sandvar#	loads into the lowest portion, and uses the highest portion
611.8Scgd#	for its heap.  The second stage loads in between the primary image
621.8Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
631.8Scgd#	heap) for its own heap.
641.8Scgd
651.8ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
661.8Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
671.8ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
681.8Scgd
691.8Scgd# XXX SECONDARY_LOAD_ADDRESS should be
701.8Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
711.8Scgd# XXX way to do that calculation and 'ld' wants a single number.
721.8ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
731.8ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
741.8ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
751.8Scgd
761.8ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
771.8ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
781.8Scgd
791.8Scgd#SECONDARY_HEAP_START=	right after secondary bss
801.8ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
811.1Sthorpej
821.13Scgd#	standalone programs are like kernels.  They load at
831.35Sjklos#	0xfffffc0000800000 and can use the rest of memory.
841.13Scgd
851.35SjklosSTANDPROG_LOAD_ADDRESS=	0xfffffc0000800000
861.13Scgd
871.13Scgd
881.19SthorpejFILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
891.1Sthorpej
901.8ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
911.8Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
921.9Sross			${FILE_FORMAT_CPPFLAGS}
931.8Scgd
941.8ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
951.8Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
961.8Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
971.8Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
981.8Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
991.8Scgd
1001.8ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1011.8Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1021.9Sross			${FILE_FORMAT_CPPFLAGS}
1031.13Scgd
1041.13ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1051.8Scgd
1061.1Sthorpej.include <bsd.prog.mk>
1071.29Stsutsui.include <bsd.klinks.mk>
1081.20Slukem
1091.30StsutsuiSTRIPFLAG=	# override values in ${MAKECONF}
1101.20SlukemCOPTS+=-Os	# override -O supplied by user
1111.1Sthorpej
1121.1Sthorpej### find out what to use for libkern
1131.1SthorpejKERN_AS=	library
1141.1Sthorpej.include "${S}/lib/libkern/Makefile.inc"
1151.1SthorpejLIBKERN=	${KERNLIB}
1161.1Sthorpej
1171.1Sthorpej### find out what to use for libz
1181.1SthorpejZ_AS=		library
1191.1Sthorpej.include "${S}/lib/libz/Makefile.inc"
1201.1SthorpejLIBZ=		${ZLIB}
1211.1Sthorpej
1221.1Sthorpej### find out what to use for libsa
1231.1SthorpejSA_AS=		library
1241.26SsimonbSAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes
1251.1Sthorpej.include "${S}/lib/libsa/Makefile.inc"
1261.1SthorpejLIBSA=		${SALIB}
127