Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

# $NetBSD: Makefile.booters,v 1.7 2017/04/08 19:53:20 christos Exp $

NOMAN=1
.include <bsd.own.mk>

# $S must correspond to the top of the 'sys' tree
S=	${.CURDIR}/../../../..

BINMODE?=	444

# XXX SHOULD NOT NEED TO DEFINE THESE!
LIBCRT0=
LIBCRTI=
LIBC=
LIBCRTBEGIN=
LIBCRTEND=

.PATH:		${.CURDIR}/../common
AFLAGS+=	-D_LOCORE -D_KERNEL -mno-abicalls
# -I${.CURDIR}/../.. done by Makefile.inc
CPPFLAGS+=	-nostdinc -D_STANDALONE -DNO_ABICALLS -D_NO_PROM_DEFINES \
		-I${.OBJDIR} -I${S}
# compiler flags for smallest code size
CFLAGS=		-ffreestanding -Os -mmemcpy -mno-abicalls -G 128
LDBUG=		-T $S/arch/mips/conf/stand.ldscript

NETBSD_VERS!=	${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
CPPFLAGS+=	-DNETBSD_VERS='"${NETBSD_VERS}"'

PRIMARY_LOAD_ADDRESS?=	0x80000000
SECONDARY_LOAD_ADDRESS?=0x80000000

NOMAN=		# defined

.if defined(PRIMARY_PROG)
PROG=		${PRIMARY_PROG}
SRCS =		start.S bootxx.c
SRCS+=		devopen.c conf.c ace.c printf.c putchar.c

LOAD_ADDRESS=	${PRIMARY_LOAD_ADDRESS}
# Pick a number, any number...
PRIMARY_MAX_TOTAL!=	expr 16 \* 1024

CPPFLAGS+=	-DPRIMARY_BOOTBLOCK \
		-DPRIMARY_LOAD_ADDRESS="${PRIMARY_LOAD_ADDRESS}" \
		-DNO_GETCHAR \
		-DLIBSA_NO_FS_SYMLINK -DLIBSA_NO_FS_WRITE \
		-DLIBSA_NO_FS_CLOSE \
		-DLIBSA_NO_DEV_CLOSE \
		-DLIBSA_SINGLE_DEVICE=ace \
		-D"aceioctl(x,y,z)=EINVAL" -D"aceclose(f)=0" \
		-DLIBSA_NO_TWIDDLE \
		-DLIBSA_NO_FD_CHECKING \
		-DLIBSA_NO_RAW_ACCESS \
		-DLIBSA_NO_DISKLABEL_MSGS \
		-DALLOC_FIRST_FIT \
		-DLIBSA_USE_MEMCPY -DLIBSA_USE_MEMSET

CHECKSIZE_CMD?=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh

.elif defined(SECONDARY_PROG)
PROG=		${SECONDARY_PROG}
LOAD_ADDRESS=	${SECONDARY_LOAD_ADDRESS}
CPPFLAGS+=	-DSECONDARY_BOOTBLOCK -DHEAP_VARIABLE

.include "${S}/conf/newvers_stand.mk"
.else
# XXX ?
.endif

### find out what to use for libkern
KERN_AS=	library
.include "${S}/lib/libkern/Makefile.inc"
LIBKERN=	${KERNLIB}

### find out what to use for libz
.if defined(PRIMARY_PROG)
LIBZ=
.else
Z_AS=		library
.include "${S}/lib/libz/Makefile.inc"
LIBZ=		${ZLIB}
.endif

### find out what to use for libsa
SA_AS=		library
.if defined(PRIMARY_PROG)
SAMISCMAKEFLAGS+=SA_INCLUDE_NET=no
.endif
.if defined(SECONDARY_PROG)
SAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes SA_USE_CREAD=yes
SAMISCMAKEFLAGS+=SA_INCLUDE_NET=yes
.endif
.include "${S}/lib/libsa/Makefile.inc"
LIBSA=		${SALIB}

LIBS=		${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN}

.include <bsd.own.mk>

${PROG}: ${OBJS} ${LIBS}
	${_MKTARGET_LINK}
	${LD} -Map ${PROG}.map -N -x -Ttext ${LOAD_ADDRESS} \
	    ${LDBUG} -e start -o ${PROG}.elf ${OBJS} ${LIBS}
	@${SIZE} ${PROG}.elf
.if defined(CHECKSIZE_CMD)
	@${CHECKSIZE_CMD} ${PROG}.elf ${PRIMARY_MAX_LOAD} ${PRIMARY_MAX_TOTAL} || \
	    (rm -f ${PROG}.elf ; false)
.endif
	@${OBJCOPY} --output-target=binary ${PROG}.elf ${PROG}.bin
	dd if=${PROG}.bin of=${PROG} bs=512 conv=sync

.include <bsd.prog.mk>
.include <bsd.klinks.mk>

CLEANFILES+=	${PROG}.map

cleandir distclean: cleanlibdir

cleanlibdir:
	-rm -rf lib