Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 May 1997 11:46:22 +0200 (CEST)
From:      Luigi Rizzo <luigi@iet.unipi.it>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   i386/3505: New features (and manpage) for netboot
Message-ID:  <199705050946.LAA01266@prova.iet.unipi.it>
Resent-Message-ID: <199705051000.DAA15948@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         3505
>Category:       i386
>Synopsis:       New features (and manpage) for netboot
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon May  5 03:00:03 PDT 1997
>Last-Modified:
>Originator:     Luigi Rizzo
>Organization:
DEIT
>Release:        FreeBSD 2.2.1-RELEASE i386
>Environment:

	FreeBSD 2.2.1-RELEASE i386

>Description:

	Enclosed are a set of changes to netboot so that booting
	parameters can be acquired using bootp instead of TFTP
	(which becomes totally useless at this point).  This saves
	a lot of troubles to administrators since all info on
	booting are in one place instead of two.

	The patch are relatively short, and I have tried to write a
	manpage for netboot as well (although that must be revised --
	I am not fluent at all with nroff macros).

	This patch has been tested with 2.2.1-R (and we have been
	using it for months with 2.1.7)

>How-To-Repeat:

	--

>Fix:

	Encloses is a patch for /sys/i386/boot/netboot against
	2.2.1-R files.


diff --new-file -ubwr netboot.22R/Makefile netboot/Makefile
--- netboot.22R/Makefile	Wed Apr  3 21:01:29 1996
+++ netboot/Makefile	Sat May  3 23:19:29 1997
@@ -36,7 +36,6 @@
 CFLAGS += -DPCI -DPCI_VENDOR=${PCI_VENDOR} -DPCI_DEVICE=${PCI_DEVICE}
 CFLAGS += -DPCI_CLASS=${PCI_CLASS} -DASK_BOOT
 #NS8390=		-DINCLUDE_WD -DWD_DEFAULT_MEM=0xD0000
-#NS8390=		-DINCLUDE_WD -DWD_DEFAULT_MEM=0xD0000
 NS8390=	-DINCLUDE_NE
 #NS8390+=	-DINCLUDE_3COM -D_3COM_BASE=0x300
 CLEANFILES+=	netboot.com
diff --new-file -ubwr netboot.22R/main.c netboot/main.c
--- netboot.22R/main.c	Sat Nov  2 21:32:14 1996
+++ netboot/main.c	Sat May  3 23:53:28 1997
@@ -31,18 +31,11 @@
 extern	int packetlen, rpc_id;
 char	broadcast[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
 
-/**************************************************************************
-MAIN - Kick off routine
-**************************************************************************/
-main()
+ask(char *s)
 {
 	int c;
-	char *p;
-	extern char edata[], end[];
-	for (p=edata; p<end; p++) *p = 0;	/* Zero BSS */
-#ifdef ASK_BOOT
 	while (1) {
-		printf("\n\rBoot from Network (Y/N) ? ");
+                printf("%s ? ",s);
 		c = getchar();
 		if ((c >= 'a') && (c <= 'z')) c &= 0x5F;
 		if (c == '\r') break;
@@ -53,6 +46,25 @@
 			break;
 		printf(" - bad response\n\r");
 	}
+}
+
+/**************************************************************************
+MAIN - Kick off routine
+**************************************************************************/
+main()
+{
+	int c;
+	char *p;
+	extern char edata[], end[];
+	for (p=edata; p<end; p++) *p = 0;	/* Zero BSS */
+#if 0
+	{
+	static char *argv[]= {"scanpci", NULL};
+	scanpci(1, argv);
+	}
+#endif
+#ifdef ASK_BOOT
+	ask("\n\rBoot from Network (Y/N) ? ");
 #endif
 
 	/* get the bios's idea about the disks geometry */
@@ -60,10 +72,10 @@
 		bootinfo.bi_bios_geom[c] = get_diskinfo(c + 0x80);
 
 	gateA20();
-	printf("\r\nBOOTP/TFTP/NFS bootstrap loader    ESC for menu\n\r");
-	printf("\r\nSearching for adapter...");
+	printf("\nBOOTP/TFTP/NFS bootstrap loader    ESC for menu\n"
+		"\nSearching for adapter...");
 	if (!eth_probe()) {
-		printf("No adapter found.\r\n");
+		printf("No adapter found.\n");
 		exit(0);
 	}
 	kernel = DEFAULT_BOOTFILE;
@@ -113,6 +125,7 @@
 	long	addr, broadcast;
 	unsigned long pad;
 
+	config_buffer[0]='\0'; /* clear; bootp might fill this up */
 /* Initialize this early on */
 
         nfsdiskless.root_args.rsize = 8192;
@@ -142,6 +155,10 @@
 	printf("\n=>>"); getchar();
 #endif
 
+	/*** check if have got info from bootp ***/
+	if (config_buffer[0])
+		goto cfg_done;
+#ifdef USE_TFTP
 	/* Now use TFTP to load configuration file */
 	sprintf(cfg,"/tftpboot/freebsd.%I",arptable[ARP_CLIENT].ipaddr);
 	if (tftp(cfg) || tftp(cfg+10))
@@ -152,6 +169,8 @@
 	sprintf(cfg,"/tftpboot/cfg.%I",arptable[ARP_CLIENT].ipaddr);
 	if (tftp(cfg) || tftp(cfg+10))
 		goto cfg_done;
+#endif
+	/* not found; using default values... */
 	sprintf(config_buffer,"rootfs %I:/usr/diskless_root",
 		arptable[ARP_SERVER].ipaddr);
 	printf("Unable to load config file, guessing:\r\n\t%s\r\n",
@@ -587,6 +606,17 @@
 	return(0);
 }
 
+void
+bootp_string(char *name, char *bootp_ptr)
+{       
+	char tmp_buf[512]; /* oversized, but who cares ! */
+	bzero(tmp_buf, sizeof(tmp_buf));
+	bcopy(bootp_ptr+2, tmp_buf, TAG_LEN(bootp_ptr));
+	sprintf(config_buffer+strlen(config_buffer),
+	    "%s %s\n", name, tmp_buf);
+}
+
+
 /**************************************************************************
 DECODE_RFC1048 - Decodes RFC1048 header
 **************************************************************************/
@@ -598,6 +628,7 @@
 	if (bcompare(p, rfc1048_cookie, 4)) { /* RFC 1048 header */
 		p += 4;
 		while(p < end) {
+			int len;
 			switch (*p) {
 			case RFC1048_PAD:
 				p++;
@@ -613,8 +644,23 @@
 				bcopy(p+2,&netmask,4);
 				break;
 			case RFC1048_HOSTNAME:
-				bcopy(p+2, &nfsdiskless.my_hostnam, TAG_LEN(p));
-				hostnamelen = (TAG_LEN(p) + 3) & ~3;
+				bootp_string("hostname", p);
+				break;
+			case RFC1048_ROOT_PATH: /* XXX check len */
+				bootp_string("rootfs", p);
+				break;
+			case RFC1048_SWAP_PATH:
+				bootp_string("swapfs", p);
+				break;
+			case RFC1048_SWAP_LEN: /* T129 */
+				sprintf(config_buffer+strlen(config_buffer),
+				    "swapsize %d\n", ntohl(*(long *)(p+2)) );
+				break;
+			case 130:       /* root mount options */
+				bootp_string("rootopts", p);
+				break;
+			case 131:       /* swap mount options */
+				bootp_string("swapopts", p);
 				break;
 			default:
 				printf("Unknown RFC1048-tag ");
diff --new-file -ubwr netboot.22R/netboot.8 netboot/netboot.8
--- netboot.22R/netboot.8	Thu Jan  1 01:00:00 1970
+++ netboot/netboot.8	Mon May  5 11:33:38 1997
@@ -0,0 +1,92 @@
+.\"	$Id: netboot.8,v 1.3.2.1 1996/12/10 16:43:01 joerg Exp $
+.Dd May 5, 1997
+.Dt NETBOOT 8
+.\".Os BSD 4
+.Sh NAME
+.Nm netboot
+.Nd Allows remote booting of the operating system
+.Sh SYNOPSIS
+.Nm
+.It Fl b
+is used for booting the operating system over a network card. The
+program is either loaded into a ROM, or run from DOS.
+.Pp
+.Sh DESCRIPTION
+.Nm
+loads parameters such as IP addresses, kernel name and filesystem
+names from a bootp server, tries to mount the specified root and swap
+filesystems,
+loads the specified kernel from the root filesystem using NFSv2, and
+then gives control to the kernel.
+.Pp
+The bootp server must be configured appropriately. An example
+configuration for /etc/bootptab is the following:
+.Bd -literal
+  .default:\\
+	:sm=255.255.255.0:\\
+	:gw=your.gateway.ip:\\
+	:ds=your.nameserver.ip:\\
+	:hn:ht=1:vm=rfc1048:\\
+	:sw=server.ip:\\
+	:rp="rootfs.ip:/rootfs/path":\\
+	:T128="swapfs.ip:/swapfs/path":\\
+	:T129=swapsize:\\
+	:T130="root,mount,options":\\
+	:T131="swap,mount,options":
+  .client01:bf="kernel.300":ha=00400530d6d9:tc=.default:
+  .client02:bf="kernel.280":ha=00400530d6d3:tc=.default:
+.Ed
+.Pp
+For a precise description of the bootptab parameters, see
+bootptab (5) .
+.Pp
+The
+.Nm
+code uses options as follows.
+.Pp
+sm indicates the subnet mask.
+.Pp
+gw is the ip address of the gateway.
+.Pp
+ds is the ip address of the name server.
+.Pp
+hn instructs the bootp server to send the hostname in the reply.
+.Pp
+ht=1 indicates that the hardware is ethernet.
+.Pp
+vm=rfc1048 indicates the use of rfc1048 extensions.
+.Pp
+sw indicates the ip address of the NFS server, and is used for both
+the root filesystem and the swap filesystem server. It is optional in
+that it can be overridden from what is specified in the "rp" and "T128"
+options.
+.Pp
+rp specifies the path to the root partition. Optionally, the IP
+address of the server can be specified, followed by a :
+.Pp
+T128 specifies the path to the swap partition. Optionally, the IP
+address of the server can be specified, followed by a : . The
+actual swapfile is a file named swap.X.Y.Z.T where X.Y.Z.T is the
+IP address of the client. In both "rp" and "T128" options
+the sequence %I can be used which is replaced with the IP address of
+the client. The swap partition is optional. If specified, the swap
+file must exist and have at least the size specified with T129.
+.Pp
+T129 specifies the size of the swap file, in KB. Must be specified as
+an octal number. Th
+.Pp
+T130 specified root mount options (e.g. noatime,tcp, ...).
+.Pp
+T131 specified swap mount options.
+.Pp
+bf is the name of the kernel. If not specified, it defaults to
+"kernel".
+
+.Sh SEE ALSO
+.Xr bootd 8 ,
+.Xr bootptab 5
+.Sh BUGS
+The T129 option should not be necessary, since the size of the
+swapfile could be inferred using NFS calls.
+The T130 and T131 options are still unsupported.
+
diff --new-file -ubwr netboot.22R/netboot.h netboot/netboot.h
--- netboot.22R/netboot.h	Sat Dec 14 15:32:05 1996
+++ netboot/netboot.h	Sat May  3 23:42:39 1997
@@ -96,10 +96,20 @@
 #define RFC1048_COOKIE		{ 99, 130, 83, 99 }
 #define RFC1048_PAD		0
 #define RFC1048_NETMASK		1
+#define RFC1048_TIME_OFFSET	2
 #define RFC1048_GATEWAY		3
+#define RFC1048_TIME_SERVER	4
+#define RFC1048_NAME_SERVER	5
+#define RFC1048_DOMAIN_SERVER	6
 #define RFC1048_HOSTNAME	12
+#define RFC1048_BOOT_SIZE	12	/* XXX */
+#define RFC1048_SWAP_SERVER	16
+#define RFC1048_ROOT_PATH	17
+#define RFC1048_SWAP_PATH	128	/* T128 */
+#define RFC1048_SWAP_LEN	129	/* T129 */
+
 #define RFC1048_END		255
-#define BOOTP_VENDOR_LEN	64
+#define BOOTP_VENDOR_LEN	256
 
 #define TFTP_RRQ	1
 #define TFTP_WRQ	2
@@ -188,7 +198,7 @@
 	char bp_hwaddr[16];
 	char bp_sname[64];
 	char bp_file[128];
-	char bp_vend[64];
+	char bp_vend[BOOTP_VENDOR_LEN];
 };
 
 struct tftp_t {
diff --new-file -ubwr netboot.22R/ns8390.c netboot/ns8390.c
--- netboot.22R/ns8390.c	Sat Dec 14 15:32:06 1996
+++ netboot/ns8390.c	Sat May  3 23:49:17 1997
@@ -19,6 +19,12 @@
 
 **************************************************************************/
 
+/* #define GWETHER */
+DELAY(int x)
+{ volatile long a, b, l;
+   for (x; x>0; x--) b=a;
+}  
+
 #include "netboot.h"
 #include "ns8390.h"
 
@@ -284,13 +290,19 @@
 ne_again:
 		eth_asic_base = *tent_base + NE_ASIC_OFFSET;
 		eth_nic_base = *tent_base;
+		printf("Looking for NE1000/NE2000 at 0x%x\n", eth_nic_base);
 
 		eth_vendor = VENDOR_NOVELL;
 		eth_flags = FLAG_PIO;
 		eth_memsize = MEM_16384;
 		eth_tx_start = 32;
+#ifdef GWETHER
+		outb(eth_asic_base + NE_RESET, 0);
+		DELAY(200);
+#endif
 		c = inb(eth_asic_base + NE_RESET);
 		outb(eth_asic_base + NE_RESET, c);
+		DELAY(5000);
 	        inb(0x84);
 		outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_STP |
 			D8390_COMMAND_RD2);
@@ -317,7 +329,8 @@
 					return (0);
 		}
 		eth_pio_read(0, romdata, 16);
-		printf("\r\nNE1000/NE2000 base 0x%x, addr ", eth_nic_base);
+		printf("\nNE1000/NE2000 (%d bit) base 0x%x, addr ",
+			eth_flags & FLAG_16BIT ? 16:8, eth_nic_base);
 		for (i=0; i<6; i++) {
 			printf("%b",(int)(arptable[ARP_CLIENT].node[i] = romdata[i
 				+ ((eth_flags & FLAG_16BIT) ? i : 0)]));
diff --new-file -ubwr netboot.22R/start2.S netboot/start2.S
--- netboot.22R/start2.S	Tue Nov 12 09:02:24 1996
+++ netboot/start2.S	Sat May  3 23:54:24 1997
@@ -26,6 +26,9 @@
 	.word	PCI_DEVICE		/* device ID */
 	.word	0			/* vital product data */
 	.word	0x0018			/* PCI data structure */
+#if 0
+    	.word   0       /* XXX check the spec. I don't understand this */
+#endif
 	.byte	0			/* PCI data struct. rev -- 0 */
 	.byte	PCI_CLASS		/* Class code */
 	.word	(ROMSIZE>>9)            /* no. of 512B blocks */
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705050946.LAA01266>