head	1.21;
access;
symbols
	netbsd-11-0-RC4:1.21
	netbsd-11-0-RC3:1.21
	netbsd-11-0-RC2:1.21
	netbsd-11-0-RC1:1.21
	perseant-exfatfs-base-20250801:1.21
	netbsd-11:1.21.0.4
	netbsd-11-base:1.21
	netbsd-10-1-RELEASE:1.20
	perseant-exfatfs-base-20240630:1.21
	perseant-exfatfs:1.21.0.2
	perseant-exfatfs-base:1.21
	netbsd-8-3-RELEASE:1.4
	netbsd-9-4-RELEASE:1.4
	netbsd-10-0-RELEASE:1.20
	netbsd-10-0-RC6:1.20
	netbsd-10-0-RC5:1.20
	netbsd-10-0-RC4:1.20
	netbsd-10-0-RC3:1.20
	netbsd-10-0-RC2:1.20
	thorpej-ifq:1.20.0.8
	thorpej-ifq-base:1.20
	thorpej-altq-separation:1.20.0.6
	thorpej-altq-separation-base:1.20
	netbsd-10-0-RC1:1.20
	netbsd-10:1.20.0.4
	netbsd-10-base:1.20
	bouyer-sunxi-drm:1.20.0.2
	bouyer-sunxi-drm-base:1.20
	netbsd-9-3-RELEASE:1.4
	thorpej-i2c-spi-conf2:1.18.0.16
	thorpej-i2c-spi-conf2-base:1.18
	thorpej-futex2:1.18.0.14
	thorpej-futex2-base:1.18
	thorpej-cfargs2:1.18.0.12
	thorpej-cfargs2-base:1.18
	cjep_sun2x-base1:1.18
	cjep_sun2x:1.18.0.10
	cjep_sun2x-base:1.18
	cjep_staticlib_x-base1:1.18
	netbsd-9-2-RELEASE:1.4
	cjep_staticlib_x:1.18.0.8
	cjep_staticlib_x-base:1.18
	thorpej-i2c-spi-conf:1.18.0.6
	thorpej-i2c-spi-conf-base:1.18
	thorpej-cfargs:1.18.0.4
	thorpej-cfargs-base:1.18
	thorpej-futex:1.18.0.2
	thorpej-futex-base:1.18
	netbsd-9-1-RELEASE:1.4
	bouyer-xenpvh-base2:1.12
	phil-wifi-20200421:1.12
	bouyer-xenpvh-base1:1.12
	phil-wifi-20200411:1.12
	bouyer-xenpvh:1.12.0.4
	bouyer-xenpvh-base:1.12
	is-mlppp:1.12.0.2
	is-mlppp-base:1.12
	phil-wifi-20200406:1.12
	netbsd-8-2-RELEASE:1.4
	ad-namecache-base3:1.12
	netbsd-9-0-RELEASE:1.4
	netbsd-9-0-RC2:1.4
	ad-namecache-base2:1.11
	ad-namecache-base1:1.6
	ad-namecache:1.4.0.20
	ad-namecache-base:1.4
	netbsd-9-0-RC1:1.4
	phil-wifi-20191119:1.4
	netbsd-9:1.4.0.18
	netbsd-9-base:1.4
	phil-wifi-20190609:1.4
	netbsd-8-1-RELEASE:1.4
	netbsd-8-1-RC1:1.4
	isaki-audio2:1.4.0.16
	isaki-audio2-base:1.4
	pgoyette-compat-merge-20190127:1.4
	pgoyette-compat-20190127:1.4
	pgoyette-compat-20190118:1.4
	pgoyette-compat-1226:1.4
	pgoyette-compat-1126:1.4
	pgoyette-compat-1020:1.4
	pgoyette-compat-0930:1.4
	pgoyette-compat-0906:1.4
	netbsd-7-2-RELEASE:1.3
	pgoyette-compat-0728:1.4
	netbsd-8-0-RELEASE:1.4
	phil-wifi:1.4.0.14
	phil-wifi-base:1.4
	pgoyette-compat-0625:1.4
	netbsd-8-0-RC2:1.4
	pgoyette-compat-0521:1.4
	pgoyette-compat-0502:1.4
	pgoyette-compat-0422:1.4
	netbsd-8-0-RC1:1.4
	pgoyette-compat-0415:1.4
	pgoyette-compat-0407:1.4
	pgoyette-compat-0330:1.4
	pgoyette-compat-0322:1.4
	pgoyette-compat-0315:1.4
	netbsd-7-1-2-RELEASE:1.3
	pgoyette-compat:1.4.0.12
	pgoyette-compat-base:1.4
	netbsd-7-1-1-RELEASE:1.3
	tls-maxphys-base-20171202:1.4
	matt-nb8-mediatek:1.4.0.10
	matt-nb8-mediatek-base:1.4
	nick-nhusb-base-20170825:1.4
	perseant-stdc-iso10646:1.4.0.8
	perseant-stdc-iso10646-base:1.4
	netbsd-8:1.4.0.6
	netbsd-8-base:1.4
	prg-localcount2-base3:1.4
	prg-localcount2-base2:1.4
	prg-localcount2-base1:1.4
	prg-localcount2:1.4.0.4
	prg-localcount2-base:1.4
	pgoyette-localcount-20170426:1.4
	bouyer-socketcan-base1:1.4
	jdolecek-ncq:1.4.0.2
	jdolecek-ncq-base:1.4
	pgoyette-localcount-20170320:1.3
	netbsd-7-1:1.3.0.14
	netbsd-7-1-RELEASE:1.3
	netbsd-7-1-RC2:1.3
	nick-nhusb-base-20170204:1.3
	netbsd-7-nhusb-base-20170116:1.3
	bouyer-socketcan:1.3.0.12
	bouyer-socketcan-base:1.3
	pgoyette-localcount-20170107:1.3
	netbsd-7-1-RC1:1.3
	nick-nhusb-base-20161204:1.3
	pgoyette-localcount-20161104:1.3
	netbsd-7-0-2-RELEASE:1.3
	nick-nhusb-base-20161004:1.3
	localcount-20160914:1.3
	netbsd-7-nhusb:1.3.0.10
	netbsd-7-nhusb-base:1.3
	pgoyette-localcount-20160806:1.3
	pgoyette-localcount-20160726:1.3
	pgoyette-localcount:1.3.0.8
	pgoyette-localcount-base:1.3
	nick-nhusb-base-20160907:1.3
	nick-nhusb-base-20160529:1.3
	netbsd-7-0-1-RELEASE:1.3
	nick-nhusb-base-20160422:1.3
	nick-nhusb-base-20160319:1.3
	nick-nhusb-base-20151226:1.3
	netbsd-7-0:1.3.0.6
	netbsd-7-0-RELEASE:1.3
	nick-nhusb-base-20150921:1.3
	netbsd-7-0-RC3:1.3
	netbsd-7-0-RC2:1.3
	netbsd-7-0-RC1:1.3
	nick-nhusb-base-20150606:1.3
	nick-nhusb-base-20150406:1.3
	nick-nhusb:1.3.0.4
	nick-nhusb-base:1.3
	netbsd-6-1-5-RELEASE:1.1.6.2
	netbsd-7:1.3.0.2
	netbsd-7-base:1.3
	yamt-pagecache-base9:1.2
	yamt-pagecache-tag8:1.1.2.2
	netbsd-6-1-4-RELEASE:1.1.6.2
	tls-earlyentropy:1.2.0.2
	tls-earlyentropy-base:1.3
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.2
	riastradh-drm2-base3:1.2
	netbsd-6-1-3-RELEASE:1.1.6.2
	netbsd-6-1-2-RELEASE:1.1.6.2
	rmind-smpnet-nbase:1.2
	netbsd-6-1-1-RELEASE:1.1.6.2
	riastradh-drm2-base2:1.1
	riastradh-drm2-base1:1.1
	riastradh-drm2:1.1.0.14
	riastradh-drm2-base:1.1
	rmind-smpnet:1.1.0.8
	rmind-smpnet-base:1.2
	netbsd-6-1:1.1.6.2.0.2
	netbsd-6-1-RELEASE:1.1.6.2
	khorben-n900:1.1.0.12
	netbsd-6-1-RC4:1.1.6.2
	netbsd-6-1-RC3:1.1.6.2
	agc-symver:1.1.0.10
	agc-symver-base:1.1
	netbsd-6-1-RC2:1.1.6.2
	netbsd-6-1-RC1:1.1.6.2
	yamt-pagecache-base8:1.1
	yamt-pagecache-base7:1.1
	netbsd-6:1.1.0.6
	yamt-pagecache-base6:1.1
	tls-maxphys:1.1.0.4
	tls-maxphys-base:1.3
	jmcneill-usbmp-base10:1.1
	yamt-pagecache-base5:1.1
	jmcneill-usbmp-base9:1.1
	yamt-pagecache:1.1.0.2
	yamt-pagecache-base4:1.1
	jmcneill-usbmp-base8:1.1;
locks; strict;
comment	@# @;


1.21
date	2024.01.07.07.58.34;	author isaki;	state Exp;
branches;
next	1.20;
commitid	K3WZoGM8wmc9uuTE;

1.20
date	2022.04.25.15.12.07;	author mlelstv;	state Exp;
branches;
next	1.19;
commitid	cp6pH65ay4t9RABD;

1.19
date	2022.02.04.06.16.03;	author isaki;	state Exp;
branches;
next	1.18;
commitid	P5x182YF3xWYtgrD;

1.18
date	2020.08.16.06.43.43;	author isaki;	state Exp;
branches;
next	1.17;
commitid	NhoqG20ypCcvTfkC;

1.17
date	2020.08.14.03.54.46;	author isaki;	state Exp;
branches;
next	1.16;
commitid	XeRxKHZXfIlG1ZjC;

1.16
date	2020.08.14.03.40.47;	author isaki;	state Exp;
branches;
next	1.15;
commitid	C5k9QYeiAEMWWYjC;

1.15
date	2020.08.14.03.29.23;	author isaki;	state Exp;
branches;
next	1.14;
commitid	gHlhA39GjF23TYjC;

1.14
date	2020.08.14.03.25.39;	author isaki;	state Exp;
branches;
next	1.13;
commitid	VyW3iyNBCOnFRYjC;

1.13
date	2020.08.10.07.00.49;	author rin;	state Exp;
branches;
next	1.12;
commitid	q1iqePjBPcgjbujC;

1.12
date	2020.01.28.12.02.02;	author isaki;	state Exp;
branches;
next	1.11;
commitid	tblgC2aDcP9w7sUB;

1.11
date	2020.01.18.07.25.12;	author isaki;	state Exp;
branches;
next	1.10;
commitid	PPqwBdvc4CpqU8TB;

1.10
date	2020.01.18.06.44.23;	author isaki;	state Exp;
branches;
next	1.9;
commitid	E0Lbsv0VGE4pG8TB;

1.9
date	2020.01.18.06.34.30;	author isaki;	state Exp;
branches;
next	1.8;
commitid	1KDxQaSnPyAVC8TB;

1.8
date	2020.01.18.05.46.26;	author isaki;	state Exp;
branches;
next	1.7;
commitid	wruNcpj2d5Hzm8TB;

1.7
date	2020.01.18.05.41.49;	author isaki;	state Exp;
branches;
next	1.6;
commitid	1JB4qeziIBLPk8TB;

1.6
date	2020.01.16.13.15.47;	author isaki;	state Exp;
branches;
next	1.5;
commitid	VpgZ8bOwSQICUUSB;

1.5
date	2020.01.16.12.54.16;	author isaki;	state Exp;
branches;
next	1.4;
commitid	5ZGmiyygu6LlNUSB;

1.4
date	2017.04.08.19.53.23;	author christos;	state Exp;
branches
	1.4.14.1
	1.4.20.1;
next	1.3;
commitid	mAo8FJwd588QFLMz;

1.3
date	2014.08.08.15.20.10;	author isaki;	state Exp;
branches
	1.3.4.1
	1.3.8.1
	1.3.12.1;
next	1.2;
commitid	2hoFToqDb63htzLx;

1.2
date	2013.08.12.16.34.05;	author joerg;	state Exp;
branches
	1.2.2.1;
next	1.1;
commitid	0lF17wwiaZaNtb1x;

1.1
date	2012.03.20.13.01.32;	author minoura;	state Exp;
branches
	1.1.2.1
	1.1.4.1
	1.1.6.1
	1.1.8.1;
next	;

1.4.14.1
date	2020.04.08.14.07.58;	author martin;	state Exp;
branches;
next	;
commitid	Qli2aW9E74UFuA3C;

1.4.20.1
date	2020.01.17.21.47.28;	author ad;	state Exp;
branches;
next	1.4.20.2;
commitid	T9pwLWote7xbI5TB;

1.4.20.2
date	2020.01.25.22.38.44;	author ad;	state Exp;
branches;
next	1.4.20.3;
commitid	ethRERRmx7bMJ7UB;

1.4.20.3
date	2020.02.29.20.18.33;	author ad;	state Exp;
branches;
next	;
commitid	3HPOJ2wqM6gUPBYB;

1.3.4.1
date	2017.08.28.17.51.56;	author skrll;	state Exp;
branches;
next	;
commitid	UQQpnjvcNkUZn05A;

1.3.8.1
date	2017.04.26.02.53.08;	author pgoyette;	state Exp;
branches;
next	;
commitid	ojV02aOSdzvBqZOz;

1.3.12.1
date	2017.04.21.16.53.38;	author bouyer;	state Exp;
branches;
next	;
commitid	dUG7nkTKALCadqOz;

1.2.2.1
date	2014.08.10.06.54.10;	author tls;	state Exp;
branches;
next	;
commitid	7fY3uHKSIbCABMLx;

1.1.2.1
date	2012.03.20.13.01.32;	author yamt;	state dead;
branches;
next	1.1.2.2;

1.1.2.2
date	2012.04.17.00.07.03;	author yamt;	state Exp;
branches;
next	1.1.2.3;

1.1.2.3
date	2014.05.22.11.40.13;	author yamt;	state Exp;
branches;
next	;
commitid	VUUXuyNWnt3AKwBx;

1.1.4.1
date	2014.08.20.00.03.29;	author tls;	state Exp;
branches;
next	1.1.4.2;
commitid	jTnpym9Qu0o4R1Nx;

1.1.4.2
date	2017.12.03.11.36.49;	author jdolecek;	state Exp;
branches;
next	;
commitid	XcIYRZTAh1LmerhA;

1.1.6.1
date	2012.03.20.13.01.32;	author riz;	state dead;
branches;
next	1.1.6.2;

1.1.6.2
date	2012.11.18.19.05.17;	author riz;	state Exp;
branches;
next	;

1.1.8.1
date	2013.08.28.23.59.23;	author rmind;	state Exp;
branches;
next	;
commitid	cbp9Ov2uYijlqh3x;


desc
@@


1.21
log
@TAB/space/indent cleanup.
@
text
@#	$NetBSD: Makefile.xxboot,v 1.20 2022/04/25 15:12:07 mlelstv Exp $

NOMAN=		# defined

.include <bsd.own.mk>

BOOT=	xxboot_$(FS)
VERSIONFILE=	${.CURDIR}/../version
VERSION!=	${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \
			END { print it }' ${VERSIONFILE}
NEWVERSWHAT=	"${BOOT}"

# text and bss addresses
TEXT=		0x003000	# Primary (me)
TEXTDATASIZE=	0x002000	# 8KB for UFS at maximum
				# 30KB (=(16-1)*2048) for ISO9660 at max.
				# but should use up to 8KB.  See boot.S
BOOT_TEXT=	0x006000	# Secondary (/boot)

PROG=		$(BOOT)
BINDIR=		/usr/mdec
STRIPFLAG=
BINMODE=	444

S=		${.CURDIR}/../../../../..
M=		$S/arch/x68k
.PATH:		${.CURDIR}/..
SRCS=	boot.S bootmain.c xx.c
SRCS+=	ashrdi3.S
SRCS+=	ashldi3.S
SRCS+=	memcpy.S
SRCS+=	memset.S
SRCS+=	memcmp.S

.include "${S}/conf/newvers_stand.mk"

CFLAGS=	-Os -fomit-frame-pointer -fno-unwind-tables -Wno-attributes
CFLAGS+= -m68020-60
#CFLAGS+= -Wall
CPPFLAGS+= -D_STANDALONE
CPPFLAGS+= -DTEXTADDR="$(TEXT)" -DBOOT_TEXTADDR="$(BOOT_TEXT)"
CPPFLAGS+= -DTDSIZE="$(TEXTDATASIZE)"
CPPFLAGS+= -DPROG=\"$(PROG)\" -DBOOT_VERS=\"$(VERSION)\"
CPPFLAGS+= -DBOOT_STAGE1 $(BOOTCPPFLAGS)
CPPFLAGS+= -DHEAP_START=0x00100000
CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
AFLAGS=	   ${CFLAGS:M-[ID]*}
AFLAGS+=   -Wa,-l
LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript
LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
LINKFLAGS+=  --defsym=BOOT_TEXTADDR=$(BOOT_TEXT)
LINKFLAGS+=  --defsym=TEXTDATASIZE=$(TEXTDATASIZE)
LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
LIBSA!=	  cd $M/stand/libsa && ${PRINTOBJDIR}
LDLIBS=	  -L ${LIBSA}/lib/kern -lkern
LDLIBS+=  -L${LIBIOCS} -liocs

.PATH: $S/lib/libsa
CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=$(FS)
CPPFLAGS+= -DLIBSA_SINGLE_DEVICE=xx
CPPFLAGS+= -DLIBSA_NO_FD_CHECKING
CPPFLAGS+= -DLIBSA_NO_FS_WRITE
CPPFLAGS+= -DLIBSA_NO_RAW_ACCESS
CPPFLAGS+= -DLIBSA_NO_TWIDDLE
CPPFLAGS+= -DUSTAR_SECT_PER_CYL=30
SRCS+=	open.c close.c read.c lseek.c loadfile.c loadfile_aout.c alloc.c
SRCS+=	errno.c globals.c files.c
SRCS+=	$(FS).c
SRCS+=	${BOOTSRCS}

.PATH: $M/stand/common
SRCS+=	exec_image.S

.include "${.CURDIR}/../../Makefile.booters"

CLEANFILES+=	${PROG}.map


${PROG}: $(OBJS)
	${_MKTARGET_LINK}
	$(LD) $(LINKFLAGS) -Map=${PROG}.map -o ${PROG} $(OBJS) $(LDLIBS)
	: Print some addresses for convenience
	@@${TOOL_AWK} '/first_kbyte$$/ { print "\t\t" $$2 "\t" $$1 }' ${PROG}.map
	@@echo "		filesize	"`${TOOL_STAT} -f %z ${PROG}`
	@@if [ `${TOOL_STAT} -f %z ${PROG}` -gt 8192 ]; then \
	    echo "${PROG} filesize exceeds 8192 bytes"; \
		exit 1; \
	fi
	${TOUCHPROG}

.include <bsd.prog.mk>
@


1.20
log
@libsa now needs ioctl to support media with large sectors. Provide
missing functions.

libsa defines files[] array itself, just reference it.
This also adds another global variable that tracks the root
filesystem module.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.19 2022/02/04 06:16:03 isaki Exp $
d69 1
a69 1
SRCS+=  $(FS).c
@


1.19
log
@Add missing -m68020-60 option.  This makes xxboot_ustarfs work even on 68060.
Problem reported by Makoto Kamada.  Confirmed on XEiJ (68060 mode).
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.18 2020/08/16 06:43:43 isaki Exp $
d28 1
a28 1
SRCS=	boot.S bootmain.c conf.c xx.c
d68 1
a68 1
SRCS+=	errno.c globals.c
@


1.18
log
@Overhaul xxboot.  And merge floppy boot, taken from boot_ustar.
- Rewrite boot.S completely.
  boot.S now supports boot from SCSI HD/CD and floppy.
- Use IOCS call to identify the floppy format, instead of chkfmt.s which
  accesses hardware directly.
- Import print_hex() debug function from boot_ufs.
- Import a feature that displays initial registers (for debug) from boot_ufs,
  and restore it (this in boot_ufs has been broken).
- Add size optimized alternatives for some libkern routines.
- Stop linking libsa to prevent to link unexpected objects.
- Bump version to 2.0.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.17 2020/08/14 03:54:46 isaki Exp $
d38 1
@


1.17
log
@Reduce binary size as possible.  These reduce filesize about 20 words.
- Use word alignment (rather than longword alignment) for text/data section.
- Use short reference.  In the bootloader, all symbols can be expressed in
  short.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.16 2020/08/14 03:40:47 isaki Exp $
d28 6
a33 1
SRCS=	boot.S bootmain.c conf.c consio1.c xx.c
d55 1
a55 1
LDLIBS=	  -L${LIBSA}/lib/sa -lsa -L ${LIBSA}/lib/kern -lkern
d65 1
d67 1
d69 1
@


1.16
log
@Use fixed 'xx' instead of DEV and DEVDRV for simplicity.
There is no choice other than xx for now.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.15 2020/08/14 03:29:23 isaki Exp $
d43 1
@


1.15
log
@Style fixes.  One entry per line for some parts.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.14 2020/08/14 03:25:39 isaki Exp $
d7 1
a7 1
BOOT=	$(DEV)boot_$(FS)
d28 1
a28 1
SRCS=	boot.S bootmain.c conf.c consio1.c $(DEVDRV).c
d54 1
a54 1
CPPFLAGS+= -DLIBSA_SINGLE_DEVICE=$(DEV)
@


1.14
log
@- Restore display of first_kbyte.  This is helpful for development.
- Check the filesize of resulting file instead of section sizes.
  If there is a gap between sections, the filesize may be exceeded even
  though the section total is not exceeded.  Of course that doesn't
  usually happen but I've experienced this during development.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.13 2020/08/10 07:00:49 rin Exp $
d55 4
a58 1
CPPFLAGS+= -DLIBSA_NO_TWIDDLE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS -DLIBSA_NO_FS_WRITE
@


1.13
log
@Make x68k/stand compile with GCC8. Tested with XEiJ.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.12 2020/01/28 12:02:02 isaki Exp $
d64 2
d69 8
a76 1
	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS)
@


1.12
log
@Set heap area explicitly.
Until the load address was moved, the heap was placed at _end (it's default)
and it was large space.  After moving, this default space was too small.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.11 2020/01/18 07:25:12 isaki Exp $
d32 1
a32 1
CFLAGS=	-Os -fomit-frame-pointer -fno-unwind-tables
@


1.11
log
@Check whether the text+data+bss doesn't reach 0x6000 where secondary
bootloader should be.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.10 2020/01/18 06:44:23 isaki Exp $
d39 1
@


1.10
log
@Use ASSERT() in ldscript to check first_kbyte (etc) restrictions,
rather than complicated shell expressions in Makefile.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.9 2020/01/18 06:34:30 isaki Exp $
d44 1
@


1.9
log
@Change primary bootloader's load address from 0x0f0000 to 0x003000.
- Moving addresses closer eliminates bunch of this linker errors:
    in function `entry0':
    relocation truncated to fit: R_68K_16 against `edata'+ffffffffffff8000
    :
- By this change, harmful -noinhibit-exec option can also be removed.
  Finally, we can break the builds when assemble error occurs!
- Load address of secondary is 0x6000, so that this change limits
  text+data+bss 12KB or less.  Current actual size is 5~7KB.
  I think it should be fine.
- cd9660 can have up to 30KB text+data in its bootarea.  Even in this
  case, this change limits text+data+bss 12KB or less (currently, it's
  about 6KB).  However, I take breaking the builds on errors rather than
  future size limitation.
There is no user visible changes or interface changes.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.8 2020/01/18 05:46:26 isaki Exp $
d42 1
a42 1
LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript -M
a61 2
CLEANFILES+=	${PROG}.x $(PROG).map ${PROG}

d65 1
a65 16
	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
	@@grep first_kbyte $(PROG).map
	@@if [ `${TOOL_AWK}						   \
	    '/first_kbyte/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'	   \
	    $(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
	    rm $(PROG) ; exit 1; 					   \
	fi
	@@if [ `${TOOL_AWK}						   \
	    '/_edata/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'	   \
	    $(PROG).map | ${TOOL_M4} -`					   \
	    -gt								   \
	    `echo 'eval($(TEXTDATASIZE))' | ${TOOL_M4} -` ];		   \
	then echo '$(BOOT): text+data is too large';			   \
	    rm $(PROG) ; exit 1; 					   \
	fi
@


1.8
log
@Add 0x prefix when defining variables, not when using it.
This was necessary for bc(1) but it's no longer necessary.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.7 2020/01/18 05:41:49 isaki Exp $
d14 1
a14 1
TEXT=		0x0f0000	# Primary (me)
d16 2
a17 1
		  		# 30KB (=(16-1)*2048) for ISO9660 at max.
a44 1
LINKFLAGS+=  -noinhibit-exec	# XXX
@


1.7
log
@Pass address constants from Makefile to ldscript.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.6 2020/01/16 13:15:47 isaki Exp $
d13 3
a15 3
# text and bss addresses in hex
TEXT=		0f0000		# Primary (me)
TEXTDATASIZE=	  2000		# 8KB for UFS at maximum
d17 1
a17 1
BOOT_TEXT=	006000		# Secondary (/boot)
d34 2
a35 2
CPPFLAGS+= -DTEXTADDR="0x$(TEXT)" -DBOOT_TEXTADDR="0x$(BOOT_TEXT)"
CPPFLAGS+= -DTDSIZE="0x$(TEXTDATASIZE)"
d42 2
a43 2
LINKFLAGS+=  --defsym=TEXTADDR=0x$(TEXT)
LINKFLAGS+=  --defsym=TEXTDATASIZE=0x$(TEXTDATASIZE)
d70 1
a70 1
	    '/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
d76 1
a76 1
	    '/_edata/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'	   \
d79 1
a79 1
	    `echo 'eval(0x$(TEXTDATASIZE))' | ${TOOL_M4} -` ];		   \
@


1.6
log
@Rewrite limit check using cross-build tools.
This eliminates use of hosts tr(1) and bc(1).
(But I'm going to remove this again soon due to other reason)
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.5 2020/01/16 12:54:16 isaki Exp $
d42 2
@


1.5
log
@Remove .else part of .if OBJECT_FMT == ELF.
All similar parts in other Makefiles are removed in 2010.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.4 2017/04/08 19:53:23 christos Exp $
d67 3
a69 5
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'    \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
d73 5
a77 5
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-$(TEXTDATASIZE)/p' \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
@


1.4
log
@centralize vers.c building for standalone programs.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.3 2014/08/08 15:20:10 isaki Exp $
a40 1
.if ${OBJECT_FMT} == "ELF"
a42 3
.else
LINKFLAGS=   -n -Bstatic -Ttext ${TEXT} -M
.endif
a66 1
.if ${OBJECT_FMT} == "ELF"
a82 21
.else
	mv $(PROG) $(PROG).x
	$(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG)
	@@rm -f $(PROG).x
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/  first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p'	   \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
	    rm $(PROG) ; exit 1; 					   \
	fi
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/  _edata:.*0x\(.*\),.*$$/\1-$(TEXT)-$(TEXTDATASIZE)/p'  \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): text+data is too large';			   \
	    rm $(PROG) ; exit 1; 					   \
	fi
.endif
@


1.4.14.1
log
@Merge changes from current as of 20200406
@
text
@d1 1
a1 1
#	$NetBSD$
d13 5
a17 6
# text and bss addresses
TEXT=		0x003000	# Primary (me)
TEXTDATASIZE=	0x002000	# 8KB for UFS at maximum
				# 30KB (=(16-1)*2048) for ISO9660 at max.
				# but should use up to 8KB.  See boot.S
BOOT_TEXT=	0x006000	# Secondary (/boot)
d34 2
a35 2
CPPFLAGS+= -DTEXTADDR="$(TEXT)" -DBOOT_TEXTADDR="$(BOOT_TEXT)"
CPPFLAGS+= -DTDSIZE="$(TEXTDATASIZE)"
a37 1
CPPFLAGS+= -DHEAP_START=0x00100000
d41 6
a46 4
LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript
LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
LINKFLAGS+=  --defsym=BOOT_TEXTADDR=$(BOOT_TEXT)
LINKFLAGS+=  --defsym=TEXTDATASIZE=$(TEXTDATASIZE)
d64 2
d69 40
a108 1
	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS)
@


1.4.20.1
log
@Sync with head.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.6 2020/01/16 13:15:47 isaki Exp $
d41 1
d44 3
d71 6
a76 3
	@@if [ `${TOOL_AWK}						   \
	    '/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
	    $(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
d80 5
a84 5
	@@if [ `${TOOL_AWK}						   \
	    '/_edata/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'	   \
	    $(PROG).map | ${TOOL_M4} -`					   \
	    -gt								   \
	    `echo 'eval(0x$(TEXTDATASIZE))' | ${TOOL_M4} -` ];		   \
d88 21
@


1.4.20.2
log
@Sync with head.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.4.20.1 2020/01/17 21:47:28 ad Exp $
d13 5
a17 6
# text and bss addresses
TEXT=		0x003000	# Primary (me)
TEXTDATASIZE=	0x002000	# 8KB for UFS at maximum
				# 30KB (=(16-1)*2048) for ISO9660 at max.
				# but should use up to 8KB.  See boot.S
BOOT_TEXT=	0x006000	# Secondary (/boot)
d34 2
a35 2
CPPFLAGS+= -DTEXTADDR="$(TEXT)" -DBOOT_TEXTADDR="$(BOOT_TEXT)"
CPPFLAGS+= -DTDSIZE="$(TEXTDATASIZE)"
d41 2
a42 4
LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript
LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
LINKFLAGS+=  --defsym=BOOT_TEXTADDR=$(BOOT_TEXT)
LINKFLAGS+=  --defsym=TEXTDATASIZE=$(TEXTDATASIZE)
d60 2
d65 16
a80 1
	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS)
@


1.4.20.3
log
@Sync with head.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.12 2020/01/28 12:02:02 isaki Exp $
a38 1
CPPFLAGS+= -DHEAP_START=0x00100000
@


1.3
log
@Remove OBJCOPY?=objcopy.
Falling back to the hosttool is not a good way now.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.2 2013/08/12 16:34:05 joerg Exp $
d29 1
a29 5
SRCS+=		vers.c
CLEANFILES+=	vers.c
vers.c:	${VERSIONFILE}
	${_MKTARGET_CREATE}
	${HOST_SH} ${S}/conf/newvers_stand.sh ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT}
@


1.3.4.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.4 2017/04/08 19:53:23 christos Exp $
d29 5
a33 1
.include "${S}/conf/newvers_stand.mk"
@


1.3.8.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.4 2017/04/08 19:53:23 christos Exp $
d29 5
a33 1
.include "${S}/conf/newvers_stand.mk"
@


1.3.12.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.4 2017/04/08 19:53:23 christos Exp $
d29 5
a33 1
.include "${S}/conf/newvers_stand.mk"
@


1.2
log
@Build boot loaders without unwind tables.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.1 2012/03/20 13:01:32 minoura Exp $
a49 1
OBJCOPY?=  objcopy
@


1.2.2.1
log
@Rebase.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.3 2014/08/08 15:20:10 isaki Exp $
d50 1
@


1.1
log
@Initial support for xxboot (cdboot_cd9660, specifically).
@
text
@d1 1
a1 1
#	$NetBSD$
d35 1
a35 1
CFLAGS=	-Os -fomit-frame-pointer
@


1.1.4.1
log
@Rebase to HEAD as of a few days ago.
@
text
@d35 1
a35 1
CFLAGS=	-Os -fomit-frame-pointer -fno-unwind-tables
d50 1
@


1.1.4.2
log
@update from HEAD
@
text
@d29 5
a33 1
.include "${S}/conf/newvers_stand.mk"
@


1.1.8.1
log
@sync with head
@
text
@d35 1
a35 1
CFLAGS=	-Os -fomit-frame-pointer -fno-unwind-tables
@


1.1.6.1
log
@file Makefile.xxboot was added on branch netbsd-6 on 2012-11-18 19:05:17 +0000
@
text
@d1 116
@


1.1.6.2
log
@Pull up following revision(s) (requested by tsutsui in ticket #645):
	sys/arch/x68k/stand/newdisk/newdisk.c: revision 1.10
	sys/arch/x68k/stand/xxboot/xxboot_ffsv1/Makefile: revision 1.1
	sys/arch/x68k/stand/xxboot/xx.c: revision 1.1
	sys/arch/x68k/stand/Makefile: revision 1.10
	sys/arch/x68k/stand/Makefile: revision 1.11
	sys/arch/x68k/stand/boot/conf.c: revision 1.9
	sys/arch/x68k/stand/Makefile: revision 1.12
	sys/arch/x68k/stand/Makefile: revision 1.13
	sys/arch/x68k/include/loadfile_machdep.h: revision 1.7
	sys/arch/x68k/stand/xxboot/consio1.c: revision 1.1
	sys/arch/x68k/stand/libsa/sdcd.c: revision 1.12
	sys/arch/x68k/stand/libsa/libx68k.h: revision 1.6
	sys/arch/x68k/stand/boot/ne.c: revision 1.1
	sys/arch/x68k/stand/xxboot/boot.S: revision 1.1
	sys/arch/x68k/stand/libsa/sdcd.c: revision 1.13
	sys/arch/x68k/stand/netboot/boot.c: revision 1.1
	sys/arch/x68k/stand/libsa/devopen.c: revision 1.6
	sys/arch/x68k/stand/libsa/clock.c: revision 1.1
	sys/arch/x68k/stand/boot/ne.h: revision 1.1
	sys/arch/x68k/stand/netboot/conf.c: revision 1.1
	sys/arch/x68k/stand/boot/version: revision 1.5
	sys/arch/x68k/stand/boot/version: revision 1.6
	sys/arch/x68k/stand/netboot/version: revision 1.1
	sys/arch/x68k/stand/xxboot/Makefile.xxboot: revision 1.1
	sys/arch/x68k/stand/boot/if_ne.c: revision 1.1
	sys/arch/x68k/stand/boot/dp8390.h: revision 1.1
	sys/arch/x68k/stand/xxboot/xxboot_lfsv2/Makefile: revision 1.1
	sys/arch/x68k/stand/boot/dp8390.c: revision 1.1
	sys/arch/x68k/stand/xxboot/bootmain.c: revision 1.1
	sys/arch/x68k/stand/installboot/installboot.c: revision 1.6
	sys/arch/x68k/stand/xxboot/conf.c: revision 1.1
	sys/arch/x68k/stand/xxboot/xxboot_lfsv1/Makefile: revision 1.1
	sys/arch/x68k/stand/libsa/Makefile.inc: revision 1.2
	distrib/sets/lists/base/md.x68k: revision 1.44
	sys/arch/x68k/stand/boot/conf.c: revision 1.10
	sys/arch/x68k/stand/boot/boot.ldscript: revision 1.3
	distrib/sets/lists/base/md.x68k: revision 1.45
	sys/arch/x68k/stand/xxboot/xxboot.ldscript: revision 1.1
	sys/arch/x68k/stand/xxboot/Makefile: revision 1.15
	sys/arch/x68k/stand/libsa/Makefile: revision 1.29
	sys/arch/x68k/stand/xxboot/cdboot_cd9660/Makefile: revision 1.1
	sys/arch/x68k/stand/netboot/Makefile: revision 1.1
	sys/arch/x68k/stand/libsa/consio.c: revision 1.10
	sys/arch/x68k/stand/xxboot/version: revision 1.1
	sys/arch/x68k/stand/xxboot/xxboot_ffsv2/Makefile: revision 1.1
Comment fix.
Add FFSv2 support.
Fix CD support.
Initial support for xxboot (cdboot_cd9660, specifically).
Add xxboot (stage1) support.
put library first.
Fix CD support (again!).
Descend to xxboot.
Add xxboot_?fsv?.
Change to the 2-clauses license.
Tweak SUBDIR build order and add comments about each dir.
Fix a bug in check_getchar() (called from awaitkey_1sec()).
It didn't clear input key data when non ASCII keys (CTRL, OPT.1 etc)
were pressed so it couldn't detect further key inputs and
"any other key for boot menu" interrupt during boot didn't work
in that case.
The problem was tracked by Y.Sugahara,
and tested on X68030 and XM6i by me.
Bump version to denote check_getchar() bug fix.
First cut at x68k network bootloader via NE2000 on Neptune-X and Nereid.
Written by isaki@@ back in 2003 based on x86's NE2000 netboot, and
misc debug and improvements by tsutsui@@ and Y.Sugahara.
Tested on XM6i (emulating Nereid Ethernet) and X68030 + Neptune-X by me,
also on X68030 + Nereid and X68000 PRO-II + Xellent30 + Nereid by isaki@@.
Note:
- X680x0 IPLROM doesn't support bootstrap from Neptune-X or Nereid,
  so this network bootloader needs to be loaded from floppy or harddisk.
- Currently netboot support is not merged into the secondary Multi-boot
  (/usr/mdec/boot) due to size restriction.
- Primary loaders assumes that the secondary bootloader name is /boot,
  so /usr/mdec/netboot needs to be installed as /boot into the target
  bootstrap device.
Add new /usr/mdec/netboot.
Check lp->d_npartitions before calling dkcksum()
(which is in src/sbin/disklabel/dkcksum.c) because
it doesn't check range and could cause coredump during
installboot against floppy that includes garbage in LABELSECTOR.
@
text
@a0 116
#	$NetBSD: Makefile.xxboot,v 1.1 2012/03/20 13:01:32 minoura Exp $

NOMAN=		# defined

.include <bsd.own.mk>

BOOT=	$(DEV)boot_$(FS)
VERSIONFILE=	${.CURDIR}/../version
VERSION!=	${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \
			END { print it }' ${VERSIONFILE}
NEWVERSWHAT=	"${BOOT}"

# text and bss addresses in hex
TEXT=		0f0000		# Primary (me)
TEXTDATASIZE=	  2000		# 8KB for UFS at maximum
		  		# 30KB (=(16-1)*2048) for ISO9660 at max.
BOOT_TEXT=	006000		# Secondary (/boot)

PROG=		$(BOOT)
BINDIR=		/usr/mdec
STRIPFLAG=
BINMODE=	444

S=		${.CURDIR}/../../../../..
M=		$S/arch/x68k
.PATH:		${.CURDIR}/..
SRCS=	boot.S bootmain.c conf.c consio1.c $(DEVDRV).c

SRCS+=		vers.c
CLEANFILES+=	vers.c
vers.c:	${VERSIONFILE}
	${_MKTARGET_CREATE}
	${HOST_SH} ${S}/conf/newvers_stand.sh ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT}

CFLAGS=	-Os -fomit-frame-pointer
#CFLAGS+= -Wall
CPPFLAGS+= -D_STANDALONE
CPPFLAGS+= -DTEXTADDR="0x$(TEXT)" -DBOOT_TEXTADDR="0x$(BOOT_TEXT)"
CPPFLAGS+= -DTDSIZE="0x$(TEXTDATASIZE)"
CPPFLAGS+= -DPROG=\"$(PROG)\" -DBOOT_VERS=\"$(VERSION)\"
CPPFLAGS+= -DBOOT_STAGE1 $(BOOTCPPFLAGS)
CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
AFLAGS=	   ${CFLAGS:M-[ID]*}
.if ${OBJECT_FMT} == "ELF"
LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript -M
LINKFLAGS+=  -noinhibit-exec	# XXX
.else
LINKFLAGS=   -n -Bstatic -Ttext ${TEXT} -M
OBJCOPY?=  objcopy
.endif
LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
LIBSA!=	  cd $M/stand/libsa && ${PRINTOBJDIR}
LDLIBS=	  -L${LIBSA}/lib/sa -lsa -L ${LIBSA}/lib/kern -lkern
LDLIBS+=  -L${LIBIOCS} -liocs

.PATH: $S/lib/libsa
CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=$(FS)
CPPFLAGS+= -DLIBSA_SINGLE_DEVICE=$(DEV)
CPPFLAGS+= -DLIBSA_NO_TWIDDLE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS -DLIBSA_NO_FS_WRITE
SRCS+=	open.c close.c read.c lseek.c loadfile.c loadfile_aout.c alloc.c
SRCS+=  $(FS).c

.PATH: $M/stand/common
SRCS+=	exec_image.S

.include "${.CURDIR}/../../Makefile.booters"

CLEANFILES+=	${PROG}.x $(PROG).map ${PROG}


${PROG}: $(OBJS)
	${_MKTARGET_LINK}
	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
	@@grep first_kbyte $(PROG).map
.if ${OBJECT_FMT} == "ELF"
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'    \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
	    rm $(PROG) ; exit 1; 					   \
	fi
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-$(TEXTDATASIZE)/p' \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): text+data is too large';			   \
	    rm $(PROG) ; exit 1; 					   \
	fi
.else
	mv $(PROG) $(PROG).x
	$(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG)
	@@rm -f $(PROG).x
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/  first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p'	   \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
	    rm $(PROG) ; exit 1; 					   \
	fi
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/  _edata:.*0x\(.*\),.*$$/\1-$(TEXT)-$(TEXTDATASIZE)/p'  \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): text+data is too large';			   \
	    rm $(PROG) ; exit 1; 					   \
	fi
.endif
	${TOUCHPROG}

.include <bsd.prog.mk>
@


1.1.2.1
log
@file Makefile.xxboot was added on branch yamt-pagecache on 2012-04-17 00:07:03 +0000
@
text
@d1 116
@


1.1.2.2
log
@sync with head
@
text
@a0 116
#	$NetBSD$

NOMAN=		# defined

.include <bsd.own.mk>

BOOT=	$(DEV)boot_$(FS)
VERSIONFILE=	${.CURDIR}/../version
VERSION!=	${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \
			END { print it }' ${VERSIONFILE}
NEWVERSWHAT=	"${BOOT}"

# text and bss addresses in hex
TEXT=		0f0000		# Primary (me)
TEXTDATASIZE=	  2000		# 8KB for UFS at maximum
		  		# 30KB (=(16-1)*2048) for ISO9660 at max.
BOOT_TEXT=	006000		# Secondary (/boot)

PROG=		$(BOOT)
BINDIR=		/usr/mdec
STRIPFLAG=
BINMODE=	444

S=		${.CURDIR}/../../../../..
M=		$S/arch/x68k
.PATH:		${.CURDIR}/..
SRCS=	boot.S bootmain.c conf.c consio1.c $(DEVDRV).c

SRCS+=		vers.c
CLEANFILES+=	vers.c
vers.c:	${VERSIONFILE}
	${_MKTARGET_CREATE}
	${HOST_SH} ${S}/conf/newvers_stand.sh ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT}

CFLAGS=	-Os -fomit-frame-pointer
#CFLAGS+= -Wall
CPPFLAGS+= -D_STANDALONE
CPPFLAGS+= -DTEXTADDR="0x$(TEXT)" -DBOOT_TEXTADDR="0x$(BOOT_TEXT)"
CPPFLAGS+= -DTDSIZE="0x$(TEXTDATASIZE)"
CPPFLAGS+= -DPROG=\"$(PROG)\" -DBOOT_VERS=\"$(VERSION)\"
CPPFLAGS+= -DBOOT_STAGE1 $(BOOTCPPFLAGS)
CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
AFLAGS=	   ${CFLAGS:M-[ID]*}
.if ${OBJECT_FMT} == "ELF"
LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript -M
LINKFLAGS+=  -noinhibit-exec	# XXX
.else
LINKFLAGS=   -n -Bstatic -Ttext ${TEXT} -M
OBJCOPY?=  objcopy
.endif
LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
LIBSA!=	  cd $M/stand/libsa && ${PRINTOBJDIR}
LDLIBS=	  -L${LIBSA}/lib/sa -lsa -L ${LIBSA}/lib/kern -lkern
LDLIBS+=  -L${LIBIOCS} -liocs

.PATH: $S/lib/libsa
CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=$(FS)
CPPFLAGS+= -DLIBSA_SINGLE_DEVICE=$(DEV)
CPPFLAGS+= -DLIBSA_NO_TWIDDLE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS -DLIBSA_NO_FS_WRITE
SRCS+=	open.c close.c read.c lseek.c loadfile.c loadfile_aout.c alloc.c
SRCS+=  $(FS).c

.PATH: $M/stand/common
SRCS+=	exec_image.S

.include "${.CURDIR}/../../Makefile.booters"

CLEANFILES+=	${PROG}.x $(PROG).map ${PROG}


${PROG}: $(OBJS)
	${_MKTARGET_LINK}
	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
	@@grep first_kbyte $(PROG).map
.if ${OBJECT_FMT} == "ELF"
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'    \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
	    rm $(PROG) ; exit 1; 					   \
	fi
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-$(TEXTDATASIZE)/p' \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): text+data is too large';			   \
	    rm $(PROG) ; exit 1; 					   \
	fi
.else
	mv $(PROG) $(PROG).x
	$(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG)
	@@rm -f $(PROG).x
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/  first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p'	   \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
	    rm $(PROG) ; exit 1; 					   \
	fi
	@@if [ `(echo ibase=16; 						   \
	    ${TOOL_SED} -n						   \
		's/  _edata:.*0x\(.*\),.*$$/\1-$(TEXT)-$(TEXTDATASIZE)/p'  \
		$(PROG).map | 						   \
	    tr a-f A-F) | bc` -gt 0 ]; 					   \
	then echo '$(BOOT): text+data is too large';			   \
	    rm $(PROG) ; exit 1; 					   \
	fi
.endif
	${TOUCHPROG}

.include <bsd.prog.mk>
@


1.1.2.3
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.xxboot,v 1.1.2.2 2012/04/17 00:07:03 yamt Exp $
d35 1
a35 1
CFLAGS=	-Os -fomit-frame-pointer -fno-unwind-tables
@


