Unify netboot and boot (into boot).

Now boot becomes to be able to load the NFS kernel and
netboot also becomes to be able to load the local kernel.
The only difference is the default kernel which loads.
I.e., netboot's default is nfs.

Bump boot_ustar's BOOT_MAXSIZE.
This commit is contained in:
isaki 2016-06-25 14:35:58 +00:00
parent 0579302b5d
commit 721fcb5753
8 changed files with 94 additions and 198 deletions

View File

@ -1,11 +1,11 @@
# $NetBSD: Makefile,v 1.26 2014/08/08 15:19:51 isaki Exp $
# $NetBSD: Makefile,v 1.27 2016/06/25 14:35:58 isaki Exp $
NOMAN= # defined
.include <bsd.own.mk>
BOOT= Multi-boot
VERSIONFILE= ${.CURDIR}/version
VERSIONFILE= ${.CURDIR}/../boot/version
VERSION!= ${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \
END { print it }' ${VERSIONFILE}
NEWVERSWHAT= "${BOOT}"
@ -13,7 +13,10 @@ NEWVERSWHAT= "${BOOT}"
# text address
TEXT= 006000
PROG= boot
# RTC offset for netboot (XXX hardcoded for JST-9)
RTC_OFFSET= -540
PROG?= boot
BINDIR= /usr/mdec
BINMODE= 444
STRIPFLAG=
@ -21,10 +24,12 @@ STRIPFLAG=
BFDNAME= a.out-m68k-netbsd
SRCS= srt0.S boot.c conf.c switch.c exec_image.S
SRCS+= if_ne.c ne.c dp8390.c
S= ${.CURDIR}/../../../..
M= ${.CURDIR}/../..
COMMONDIR= $M/stand/common
.PATH: ${COMMONDIR}
.PATH: ${.CURDIR}/../boot
SRCS+= vers.c
CLEANFILES+= vers.c
@ -39,9 +44,11 @@ CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE
CPPFLAGS+= -DTEXTADDR="0x${TEXT}"
CPPFLAGS+= -DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\"
CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
CPPFLAGS+= -DRTC_OFFSET=${RTC_OFFSET}
CPPFLAGS+= -DSUPPORT_BOOTP -DSUPPORT_DHCP
#CPPFLAGS+= -DDEBUG
CFLAGS= -Wno-main -Os -m68020-60
LINKFLAGS= -N -static -T ${.CURDIR}/boot.ldscript
LINKFLAGS= -N -static -T ${.CURDIR}/../boot/boot.ldscript
LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
LIBSA!= cd $M/stand/libsa && ${PRINTOBJDIR}
L= ${LIBSA}/lib

View File

@ -1,4 +1,4 @@
/* $NetBSD: boot.c,v 1.26 2016/06/19 09:42:28 isaki Exp $ */
/* $NetBSD: boot.c,v 1.27 2016/06/25 14:35:58 isaki Exp $ */
/*
* Copyright (c) 2001 Minoura Makoto
@ -32,9 +32,7 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/loadfile.h>
#include <lib/libsa/ufs.h>
#ifdef NETBOOT
#include <lib/libsa/dev_net.h>
#endif
#include <lib/libkern/libkern.h>
#include "libx68k.h"
@ -50,38 +48,32 @@
#define SRAM_MEMSIZE (*((long*) 0x00ed0008))
char default_kernel[20] =
#ifndef NETBOOT
"sd0a:netbsd";
#else
#if defined(NETBOOT)
"nfs:netbsd";
#else
"sd0a:netbsd";
#endif
int mpu;
#ifndef NETBOOT
int hostadaptor;
#endif
int console_device = -1;
#ifdef DEBUG
#ifdef NETBOOT
int debug = 1;
#endif
#endif
static void help(void);
#ifndef NETBOOT
static int get_scsi_host_adapter(void);
#endif
static void doboot(const char *, int);
static void boot(char *);
#ifndef NETBOOT
static void cmd_ls(char *);
#endif
int bootmenu(void);
void bootmain(int);
extern int detectmpu(void);
extern int badbaddr(void *);
#ifndef NETBOOT
extern struct fs_ops file_system_ustarfs[];
extern struct fs_ops file_system_nfs[];
/* from boot_ufs/bootmain.c */
static int
get_scsi_host_adapter(void)
@ -104,25 +96,19 @@ get_scsi_host_adapter(void)
return ha;
}
#endif
static void
help(void)
{
printf("Usage:\n");
printf("boot [dev:][file] -[flags]\n");
#ifndef NETBOOT
printf(" dev: sd<ID><PART>, ID=0-7, PART=a-p\n");
printf(" cd<ID>a, ID=0-7\n");
printf(" fd<UNIT>a, UNIT=0-3, format is detected.\n");
#else
printf(" dev: nfs, first probed NE2000 is used.\n");
#endif
printf(" nfs, first probed NE2000 is used.\n");
printf(" file: netbsd, netbsd.gz, etc.\n");
printf(" flags: abdqsv\n");
#ifndef NETBOOT
printf("ls [dev:][directory]\n");
#endif
printf("switch [show | key=val]\n");
printf("halt\nreboot\n");
}
@ -139,6 +125,7 @@ doboot(const char *file, int flags)
char *name;
short *p;
int loadflag;
struct fs_ops *fs;
printf("Starting %s, flags 0x%x\n", file, flags);
@ -147,17 +134,18 @@ doboot(const char *file, int flags)
}
#ifdef DEBUG
#ifndef NETBOOT
printf("dev = %x, unit = %d, part = %c, name = %s\n",
dev, unit, part + 'a', name);
#else
printf("dev = %x, unit = %d, name = %s\n",
dev, unit, name);
#endif
if (file[0] == 'n') {
printf("dev = %x, unit = %d, name = %s\n",
dev, unit, name);
} else {
printf("dev = %x, unit = %d, part = %c, name = %s\n",
dev, unit, part + 'a', name);
}
#endif
#ifndef NETBOOT
if (dev == 0) { /* SCSI */
if (dev == 3) { /* netboot */
bootdev = X68K_MAKEBOOTDEV(X68K_MAJOR_NE, unit, 0);
} else if (dev == 0) { /* SCSI */
bootdev = X68K_MAKESCSIBOOTDEV(X68K_MAJOR_SD,
hostadaptor >> 4,
hostadaptor & 15,
@ -165,25 +153,40 @@ doboot(const char *file, int flags)
} else {
bootdev = X68K_MAKEBOOTDEV(X68K_MAJOR_FD, unit & 3, 0);
}
#else
bootdev = X68K_MAKEBOOTDEV(X68K_MAJOR_NE, unit, 0);
#endif
#ifdef DEBUG
printf("boot device = %x\n", bootdev);
#ifndef NETBOOT
printf("if = %d, unit = %d, id = %d, lun = %d, part = %c\n",
B_X68K_SCSI_IF(bootdev),
B_X68K_SCSI_IF_UN(bootdev),
B_X68K_SCSI_ID(bootdev),
B_X68K_SCSI_LUN(bootdev),
B_X68K_SCSI_PART(bootdev) + 'a');
#else
printf("if = %d, unit = %d\n",
B_X68K_SCSI_IF(bootdev),
B_X68K_SCSI_IF_UN(bootdev));
#endif
if (file[0] == 'n') {
printf("if = %d, unit = %d\n",
B_X68K_SCSI_IF(dev),
B_X68K_SCSI_IF_UN(dev));
} else {
printf("if = %d, unit = %d, id = %d, lun = %d, part = %c\n",
B_X68K_SCSI_IF(dev),
B_X68K_SCSI_IF_UN(dev),
B_X68K_SCSI_ID(dev),
B_X68K_SCSI_LUN(dev),
B_X68K_SCSI_PART(dev) + 'a');
}
#endif
/*
* Choose the last entry of file_system[] at runtime.
*
* file_system[] is checked in turn from the beginning at all cases.
* Trying FS_OPS(ustarfs) for non-ustarfs displays "@" (as the
* mark which read a cylinder?). OTOH, trying FS_OPS(nfs) for
* non-nfs displays "must mount first" error message.
* It is better that neither is displayed and in other words you
* should not put these two into file_system[] at the same time.
* Therefore I choose one of these here.
*/
if (file[0] == 'n') {
fs = &file_system_nfs[0];
} else {
fs = &file_system_ustarfs[0];
}
memcpy(&file_system[nfsys - 1], fs, sizeof(*fs));
loadflag = LOAD_KERNEL;
if (file[0] == 'f')
loadflag &= ~LOAD_BACKWARDS;
@ -254,7 +257,6 @@ boot(char *arg)
}
}
#ifndef NETBOOT
static void
cmd_ls(char *arg)
{
@ -275,7 +277,6 @@ cmd_ls(char *arg)
ls(filename);
devopen_open_dir = 0;
}
#endif
int
bootmenu(void)
@ -325,10 +326,8 @@ bootmenu(void)
exit(0);
else if (strcmp("switch", p) == 0)
cmd_switch(options);
#ifndef NETBOOT
else if (strcmp("ls", p) == 0)
cmd_ls(options);
#endif
else
printf("Unknown command %s\n", p);
}
@ -366,12 +365,9 @@ bootmain(int bootdev)
u_int sram_memsize;
u_int probed_memsize;
#ifndef NETBOOT
hostadaptor = get_scsi_host_adapter();
#else
rtc_offset = RTC_OFFSET;
try_bootp = 1;
#endif
mpu = detectmpu();
if (mpu < 3) { /* not tested on 68020 */
@ -387,7 +383,7 @@ bootmain(int bootdev)
console_device = consio_init(console_device);
setheap(HEAP_START, HEAP_END);
#ifndef NETBOOT
#if !defined(NETBOOT)
switch (B_TYPE(bootdev)) {
case X68K_MAJOR_FD:
default_kernel[0] = 'f';

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.10 2012/10/12 20:15:52 tsutsui Exp $ */
/* $NetBSD: conf.c,v 1.11 2016/06/25 14:35:58 isaki Exp $ */
/*
* Copyright (c) 2001 Minoura Makoto
@ -33,12 +33,17 @@
#include <lib/libsa/cd9660.h>
#include <lib/libsa/ustarfs.h>
#include <netinet/in.h>
#include <lib/libsa/nfs.h>
#include <lib/libsa/dev_net.h>
#include "libx68k.h"
struct devsw devsw[] = {
{ "sd", sdstrategy, sdopen, sdclose, noioctl },
{ "cd", cdstrategy, cdopen, cdclose, noioctl },
{ "fd", fdstrategy, fdopen, fdclose, noioctl },
{ "nfs", net_strategy, net_open, net_close, net_ioctl },
{ 0, 0, 0, 0, 0 }
};
@ -48,18 +53,36 @@ const struct devspec devspec[] = {
{ "sd", 0, 7, 0 },
{ "cd", 1, 7, 0 },
{ "fd", 2, 3, 0 },
{ "nfs", 3, 1, 1 },
{ NULL, 0, 0, 0 }
};
struct fs_ops file_system_ustarfs[] = {
FS_OPS(ustarfs),
};
struct fs_ops file_system_nfs[] = {
FS_OPS(nfs),
};
struct fs_ops file_system[] = {
FS_OPS(ffsv1),
FS_OPS(ffsv2),
FS_OPS(lfsv1),
FS_OPS(lfsv2),
FS_OPS(cd9660),
FS_OPS(ustarfs),
{ 0 }, /* ustarfs or nfs, see doboot() in boot.c */
};
int nfsys = sizeof(file_system) / sizeof(file_system[0]);
struct fs_ops file_system_net = FS_OPS(nfs);
extern struct netif_driver ne_netif_driver;
struct netif_driver *netif_drivers[] = {
&ne_netif_driver,
};
int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]);
struct open_file files[SOPEN_MAX];

View File

@ -1,4 +1,4 @@
$NetBSD: version,v 1.7 2016/01/17 04:47:59 tsutsui Exp $
$NetBSD: version,v 1.8 2016/06/25 14:35:58 isaki Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
@ -13,3 +13,4 @@ is taken as the current.
1.5: Make key interrupt to get boot menu works properly even after
non ASCII keys (CTRL, OPT.1 etc.) are pressed during boot.
1.6: Disable slow gunzip CRC32 calculation.
1.7: Integrate netboot.

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.22 2016/06/25 04:08:57 isaki Exp $
# $NetBSD: Makefile,v 1.23 2016/06/25 14:35:58 isaki Exp $
NOMAN= # defined
@ -14,7 +14,7 @@ NEWVERSWHAT= "${BOOT}"
TEXT= 002000 # Primary (me)
BOOT_TEXT= 006000 # Secondary (/boot)
BOOT_MAXSIZE= 56832 # size enough to read /boot whole
BOOT_MAXSIZE= 65536 # size enough to read /boot whole
PROG= fd$(BOOT)
BINDIR= /usr/mdec

View File

@ -1,71 +1,9 @@
# $NetBSD: Makefile,v 1.6 2014/08/08 15:19:51 isaki Exp $
# $NetBSD: Makefile,v 1.7 2016/06/25 14:35:58 isaki Exp $
NOMAN= # defined
.include <bsd.own.mk>
BOOT= Netboot
VERSIONFILE= ${.CURDIR}/version
VERSION!= ${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \
END { print it }' ${VERSIONFILE}
NEWVERSWHAT= "${BOOT}"
# text address
TEXT= 006000
# RTC offset
RTC_OFFSET= -540
# stand/netboot is identical with stand/boot
# except that the default kernel which loads is nfs.
PROG= netboot
BINDIR= /usr/mdec
BINMODE= 444
STRIPFLAG=
BFDNAME= a.out-m68k-netbsd
# XXX shared sources should be in COMMONDIR
BOOTDIR= ${.CURDIR}/../boot
.PATH: ${BOOTDIR}
SRCS= srt0.S boot.c conf.c switch.c exec_image.S if_ne.c ne.c dp8390.c
S= ${.CURDIR}/../../../..
M= ${.CURDIR}/../..
COMMONDIR= $M/stand/common
.PATH: ${COMMONDIR}
SRCS+= vers.c
CLEANFILES+= vers.c
vers.c: ${VERSIONFILE}
${_MKTARGET_CREATE}
${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
${.ALLSRC} ${MACHINE} ${NEWVERSWHAT}
CPPFLAGS+= -nostdinc -I$S -I${.OBJDIR} -I$M/stand/libsa
CPPFLAGS+= -I$M/stand/libiocs -I${COMMONDIR}
CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE
CPPFLAGS+= -DTEXTADDR="0x${TEXT}"
CPPFLAGS+= -DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\"
CPPFLAGS+= -DNETBOOT
CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
CPPFLAGS+= -DRTC_OFFSET=${RTC_OFFSET}
CPPFLAGS+= -DSUPPORT_BOOTP -DSUPPORT_DHCP
#CPPFLAGS+= -DDEBUG
CFLAGS= -Wno-main -Os -m68020-60
LINKFLAGS= -N -static -T ${BOOTDIR}/boot.ldscript
LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
LIBSA!= cd $M/stand/libsa && ${PRINTOBJDIR}
L= ${LIBSA}/lib
LDLIBS= ${L}/sa/libsa.a ${L}/kern/libkern.a ${L}/z/libz.a
LDLIBS+= ${LIBIOCS}/libiocs.a
.include "../Makefile.booters"
realall: ${PROG}
${PROG}: ${OBJS} ${LDLIBS}
${_MKTARGET_LINK}
${LD} ${LINKFLAGS} -o ${PROG}.sym ${OBJS} ${LDLIBS}
${STRIP} -F ${BFDNAME} -o ${PROG} ${PROG}.sym
CLEANFILES+= ${PROG}.sym
.include <bsd.prog.mk>
.include "../boot/Makefile"

View File

@ -1,61 +0,0 @@
/* $NetBSD: conf.c,v 1.3 2013/01/13 14:27:06 tsutsui Exp $ */
/*
* Copyright (c) 2001 Minoura Makoto
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/param.h>
#include <lib/libsa/stand.h>
#include <lib/libsa/dev_net.h>
#include <netinet/in.h>
#include <lib/libsa/nfs.h>
#include <lib/libsa/ufs.h>
#include <lib/libsa/lfs.h>
#include <lib/libsa/cd9660.h>
#include <lib/libsa/ustarfs.h>
#include "libx68k.h"
struct devsw devsw[] = {
{ "nfs", net_strategy, net_open, net_close, net_ioctl },
};
int ndevs = sizeof(devsw) / sizeof(devsw[0]);
const struct devspec devspec[] = {
{ "nfs", 0, 1, 1 },
{ 0, 0, 0, 0 },
};
struct fs_ops file_system[] = {
FS_OPS(nfs),
};
int nfsys = sizeof(file_system) / sizeof(file_system[0]);
extern struct netif_driver ne_netif_driver;
struct netif_driver *netif_drivers[] = {
&ne_netif_driver,
};
int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]);

View File

@ -1,8 +0,0 @@
$NetBSD: version,v 1.2 2016/01/17 04:47:59 tsutsui Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
is taken as the current.
0.1: Initial netboot
0.2: Disable slow gunzip CRC32 calculation.