Module Name: src
Committed By: isaki
Date: Sat Jun 25 14:35:59 UTC 2016
Modified Files:
src/sys/arch/x68k/stand/boot: Makefile boot.c conf.c version
src/sys/arch/x68k/stand/boot_ustar: Makefile
src/sys/arch/x68k/stand/netboot: Makefile
Removed Files:
src/sys/arch/x68k/stand/netboot: conf.c version
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x68k/stand/boot/Makefile \
src/sys/arch/x68k/stand/boot/boot.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x68k/stand/boot/conf.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x68k/stand/boot/version
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x68k/stand/netboot/Makefile
cvs rdiff -u -r1.3 -r0 src/sys/arch/x68k/stand/netboot/conf.c
cvs rdiff -u -r1.2 -r0 src/sys/arch/x68k/stand/netboot/version
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x68k/stand/boot/Makefile
diff -u src/sys/arch/x68k/stand/boot/Makefile:1.26 src/sys/arch/x68k/stand/boot/Makefile:1.27
--- src/sys/arch/x68k/stand/boot/Makefile:1.26 Fri Aug 8 15:19:51 2014
+++ src/sys/arch/x68k/stand/boot/Makefile Sat Jun 25 14:35:58 2016
@@ -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
Index: src/sys/arch/x68k/stand/boot/boot.c
diff -u src/sys/arch/x68k/stand/boot/boot.c:1.26 src/sys/arch/x68k/stand/boot/boot.c:1.27
--- src/sys/arch/x68k/stand/boot/boot.c:1.26 Sun Jun 19 09:42:28 2016
+++ src/sys/arch/x68k/stand/boot/boot.c Sat Jun 25 14:35:58 2016
@@ -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';
Index: src/sys/arch/x68k/stand/boot/conf.c
diff -u src/sys/arch/x68k/stand/boot/conf.c:1.10 src/sys/arch/x68k/stand/boot/conf.c:1.11
--- src/sys/arch/x68k/stand/boot/conf.c:1.10 Fri Oct 12 20:15:52 2012
+++ src/sys/arch/x68k/stand/boot/conf.c Sat Jun 25 14:35:58 2016
@@ -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];
Index: src/sys/arch/x68k/stand/boot/version
diff -u src/sys/arch/x68k/stand/boot/version:1.7 src/sys/arch/x68k/stand/boot/version:1.8
--- src/sys/arch/x68k/stand/boot/version:1.7 Sun Jan 17 04:47:59 2016
+++ src/sys/arch/x68k/stand/boot/version Sat Jun 25 14:35:58 2016
@@ -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.
Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.22 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.23
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.22 Sat Jun 25 04:08:57 2016
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile Sat Jun 25 14:35:58 2016
@@ -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
Index: src/sys/arch/x68k/stand/netboot/Makefile
diff -u src/sys/arch/x68k/stand/netboot/Makefile:1.6 src/sys/arch/x68k/stand/netboot/Makefile:1.7
--- src/sys/arch/x68k/stand/netboot/Makefile:1.6 Fri Aug 8 15:19:51 2014
+++ src/sys/arch/x68k/stand/netboot/Makefile Sat Jun 25 14:35:58 2016
@@ -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"