summaryrefslogtreecommitdiffstats
path: root/sys/i386/boot/netboot
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386/boot/netboot')
-rw-r--r--sys/i386/boot/netboot/3c509.c602
-rw-r--r--sys/i386/boot/netboot/3c509.h383
-rw-r--r--sys/i386/boot/netboot/Makefile98
-rw-r--r--sys/i386/boot/netboot/bootmenu.c377
-rw-r--r--sys/i386/boot/netboot/main.c715
-rw-r--r--sys/i386/boot/netboot/makerom.c53
-rw-r--r--sys/i386/boot/netboot/misc.c286
-rw-r--r--sys/i386/boot/netboot/netboot.8101
-rw-r--r--sys/i386/boot/netboot/netboot.h258
-rw-r--r--sys/i386/boot/netboot/ns8390.c668
-rw-r--r--sys/i386/boot/netboot/ns8390.h246
-rw-r--r--sys/i386/boot/netboot/opt_nfs.h1
-rw-r--r--sys/i386/boot/netboot/rpc.c190
-rw-r--r--sys/i386/boot/netboot/start2.S447
14 files changed, 0 insertions, 4425 deletions
diff --git a/sys/i386/boot/netboot/3c509.c b/sys/i386/boot/netboot/3c509.c
deleted file mode 100644
index accc948..0000000
--- a/sys/i386/boot/netboot/3c509.c
+++ /dev/null
@@ -1,602 +0,0 @@
-/**************************************************************************
-NETBOOT - BOOTP/TFTP Bootstrap Program
-
-Author: Martin Renters.
- Date: Mar 22 1995
-
- This code is based heavily on David Greenman's if_ed.c driver and
- Andres Vega Garcia's if_ep.c driver.
-
- Copyright (C) 1993-1994, David Greenman, Martin Renters.
- Copyright (C) 1993-1995, Andres Vega Garcia.
- Copyright (C) 1995, Serge Babkin.
- This software may be used, modified, copied, distributed, and sold, in
- both source and binary form provided that the above copyright and these
- terms are retained. Under no circumstances are the authors responsible for
- the proper functioning of this software, nor do the authors assume any
- responsibility for damages incurred with its use.
-
-3c509 support added by Serge Babkin (babkin@hq.icb.chel.su)
-
-$FreeBSD$
-
-***************************************************************************/
-
-/* #define EDEBUG */
-
-#include "netboot.h"
-#include "3c509.h"
-
-short aui;
-char bnc=0, utp=0; /* for 3C509 */
-unsigned short eth_nic_base;
-unsigned short eth_asic_base;
-unsigned short eth_base;
-unsigned char eth_tx_start;
-unsigned char eth_laar;
-unsigned char eth_flags;
-unsigned char eth_vendor;
-unsigned char eth_memsize;
-unsigned char *eth_bmem;
-unsigned char *eth_rmem;
-unsigned char *eth_node_addr;
-
-static send_ID_sequence();
-static get_eeprom_data();
-static get_e();
-
-/**************************************************************************
-The following two variables are used externally
-***************************************************************************/
-char packet[ETHER_MAX_LEN];
-int packetlen;
-
-/*********************** Name of driver *********************************/
-
-char eth_driver[]="ep0";
-
-/**************************************************************************
-ETH_PROBE - Look for an adapter
-***************************************************************************/
-eth_probe()
-{
- /* common variables */
- int i;
- /* variables for 3C509 */
- int data, j, io_base, id_port = EP_ID_PORT;
- int nisa = 0, neisa = 0;
- u_short k;
- int ep_current_tag = EP_LAST_TAG + 1;
- short *p;
-
- eth_vendor = VENDOR_NONE;
-
- /*********************************************************
- Search for 3Com 509 card
- ***********************************************************/
-
- /* Look for the EISA boards, leave them activated */
- /* search for the first card, ignore all others */
- for(j = 1; j < 16 && eth_vendor==VENDOR_NONE ; j++) {
- io_base = (j * EP_EISA_START) | EP_EISA_W0;
- if (inw(io_base + EP_W0_MFG_ID) != MFG_ID)
- continue;
-
- /* we must found 0x1f if the board is EISA configurated */
- if ((inw(io_base + EP_W0_ADDRESS_CFG) & 0x1f) != 0x1f)
- continue;
-
- /* Reset and Enable the card */
- outb(io_base + EP_W0_CONFIG_CTRL, W0_P4_CMD_RESET_ADAPTER);
- DELAY(1000); /* we must wait at least 1 ms */
- outb(io_base + EP_W0_CONFIG_CTRL, W0_P4_CMD_ENABLE_ADAPTER);
-
- /*
- * Once activated, all the registers are mapped in the range
- * x000 - x00F, where x is the slot number.
- */
- eth_base = j * EP_EISA_START;
- eth_vendor = VENDOR_3C509;
- }
- ep_current_tag--;
-
- /* Look for the ISA boards. Init and leave them actived */
- /* search for the first card, ignore all others */
- outb(id_port, 0xc0); /* Global reset */
- DELAY(1000);
- for (i = 0; i < EP_MAX_BOARDS && eth_vendor==VENDOR_NONE; i++) {
- outb(id_port, 0);
- outb(id_port, 0);
- send_ID_sequence(id_port);
-
- data = get_eeprom_data(id_port, EEPROM_MFG_ID);
- if (data != MFG_ID)
- break;
-
- /* resolve contention using the Ethernet address */
- for (j = 0; j < 3; j++)
- data = get_eeprom_data(id_port, j);
-
- eth_base =
- (get_eeprom_data(id_port, EEPROM_ADDR_CFG) & 0x1f) * 0x10 + 0x200;
- outb(id_port, ep_current_tag); /* tags board */
- outb(id_port, ACTIVATE_ADAPTER_TO_CONFIG);
- eth_vendor = VENDOR_3C509;
- ep_current_tag--;
- }
-
- if(eth_vendor != VENDOR_3C509)
- goto no3c509;
-
- /*
- * The iobase was found and MFG_ID was 0x6d50. PROD_ID should be
- * 0x9[0-f]50
- */
- GO_WINDOW(0);
- k = get_e(EEPROM_PROD_ID);
- if ((k & 0xf0ff) != (PROD_ID & 0xf0ff))
- goto no3c509;
-
- if(eth_base >= EP_EISA_START) {
- printf("3C5x9 board on EISA at 0x%x - ",eth_base);
- } else {
- printf("3C5x9 board on ISA at 0x%x - ",eth_base);
- }
-
- /* test for presence of connectors */
- i = inw(IS_BASE + EP_W0_CONFIG_CTRL);
- j = inw(IS_BASE + EP_W0_ADDRESS_CFG) >> 14;
-
- switch(j) {
- case 0:
- if(i & IS_UTP) {
- printf("10baseT\r\n");
- utp=1;
- }
- else {
- printf("10baseT not present\r\n");
- eth_vendor=VENDOR_NONE;
- goto no3c509;
- }
-
- break;
- case 1:
- if(i & IS_AUI)
- printf("10base5\r\n");
- else {
- printf("10base5 not present\r\n");
- eth_vendor=VENDOR_NONE;
- goto no3c509;
- }
-
- break;
- case 3:
- if(i & IS_BNC) {
- printf("10base2\r\n");
- bnc=1;
- }
- else {
- printf("10base2 not present\r\n");
- eth_vendor=VENDOR_NONE;
- goto no3c509;
- }
-
- break;
- default:
- printf("unknown connector\r\n");
- eth_vendor=VENDOR_NONE;
- goto no3c509;
- }
- /*
- * Read the station address from the eeprom
- */
- p = (u_short *) arptable[ARP_CLIENT].node;
- for (i = 0; i < 3; i++) {
- GO_WINDOW(0);
- p[i] = htons(get_e(i));
- GO_WINDOW(2);
- outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
- }
-
- printf("Ethernet address: ");
- for(i=0; i<5; i++) {
- printf("%b:",arptable[ARP_CLIENT].node[i]);
- }
- printf("%b\n",arptable[ARP_CLIENT].node[i]);
-
- eth_node_addr = arptable[ARP_CLIENT].node;
- eth_reset();
- return eth_vendor;
-no3c509:
- eth_vendor = VENDOR_NONE;
-
- return VENDOR_NONE;
-}
-
-/**************************************************************************
-ETH_RESET - Reset adapter
-***************************************************************************/
-eth_reset()
-{
- int s, i;
-
- /***********************************************************
- Reset 3Com 509 card
- *************************************************************/
-
- if(eth_vendor != VENDOR_3C509)
- goto no3c509;
-
- /* stop card */
- outw(BASE + EP_COMMAND, RX_DISABLE);
- outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- outw(BASE + EP_COMMAND, TX_DISABLE);
- outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
- outw(BASE + EP_COMMAND, RX_RESET);
- outw(BASE + EP_COMMAND, TX_RESET);
- outw(BASE + EP_COMMAND, C_INTR_LATCH);
- outw(BASE + EP_COMMAND, SET_RD_0_MASK);
- outw(BASE + EP_COMMAND, SET_INTR_MASK);
- outw(BASE + EP_COMMAND, SET_RX_FILTER);
-
- /*
- /* initialize card
- */
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
-
- GO_WINDOW(0);
-
- /* Disable the card */
- outw(BASE + EP_W0_CONFIG_CTRL, 0);
-
- /* Configure IRQ to none */
- outw(BASE + EP_W0_RESOURCE_CFG, SET_IRQ(0));
-
- /* Enable the card */
- outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ);
-
- GO_WINDOW(2);
-
- /* Reload the ether_addr. */
- for (i = 0; i < 6; i++)
- outb(BASE + EP_W2_ADDR_0 + i, arptable[ARP_CLIENT].node[i]);
-
- outw(BASE + EP_COMMAND, RX_RESET);
- outw(BASE + EP_COMMAND, TX_RESET);
-
- /* Window 1 is operating window */
- GO_WINDOW(1);
- for (i = 0; i < 31; i++)
- inb(BASE + EP_W1_TX_STATUS);
-
- /* get rid of stray intr's */
- outw(BASE + EP_COMMAND, ACK_INTR | 0xff);
-
- outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS);
-
- outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
-
- outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
- FIL_BRDCST);
-
- /* configure BNC */
- if(bnc) {
- outw(BASE + EP_COMMAND, START_TRANSCEIVER);
- DELAY(1000);
- }
- /* configure UTP */
- if(utp) {
- GO_WINDOW(4);
- outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
- GO_WINDOW(1);
- }
-
- /* start tranciever and receiver */
- outw(BASE + EP_COMMAND, RX_ENABLE);
- outw(BASE + EP_COMMAND, TX_ENABLE);
-
- /* set early threshold for minimal packet length */
- outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | 64);
-
- outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16);
-
- return 1;
-no3c509:
-
-}
-
-/**************************************************************************
-ETH_TRANSMIT - Transmit a frame
-***************************************************************************/
-static const char padmap[] = {
- 0, 3, 2, 1};
-
-eth_transmit(d,t,s,p)
-char *d; /* Destination */
-unsigned short t; /* Type */
-unsigned short s; /* size */
-char *p; /* Packet */
-{
- register u_int len;
- int pad;
- int status;
- unsigned char c;
-
- if(eth_vendor != VENDOR_3C509)
- goto no3c509;
-
-#ifdef EDEBUG
- printf("{l=%d,t=%x}",s+14,t);
-#endif
-
- /* swap bytes of type */
- t=(( t&0xFF )<<8) | ((t>>8) & 0xFF);
-
- len=s+14; /* actual length of packet */
- pad = padmap[len & 3];
-
- /*
- * The 3c509 automatically pads short packets to minimum ethernet length,
- * but we drop packets that are too large. Perhaps we should truncate
- * them instead?
- */
- if (len + pad > ETHER_MAX_LEN) {
- return 0;
- }
-
- /* drop acknowledgements */
- while(( status=inb(BASE + EP_W1_TX_STATUS) )& TXS_COMPLETE ) {
- if(status & (TXS_UNDERRUN|TXS_MAX_COLLISION|TXS_STATUS_OVERFLOW)) {
- outw(BASE + EP_COMMAND, TX_RESET);
- outw(BASE + EP_COMMAND, TX_ENABLE);
- }
-
- outb(BASE + EP_W1_TX_STATUS, 0x0);
- }
-
- while (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
- /* no room in FIFO */
- }
-
- outw(BASE + EP_W1_TX_PIO_WR_1, len);
- outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */
-
- /* write packet */
- outsw(BASE + EP_W1_TX_PIO_WR_1, d, 3);
- outsw(BASE + EP_W1_TX_PIO_WR_1, eth_node_addr, 3);
- outw(BASE + EP_W1_TX_PIO_WR_1, t);
- outsw(BASE + EP_W1_TX_PIO_WR_1, p, s / 2);
- if (s & 1)
- outb(BASE + EP_W1_TX_PIO_WR_1, *(p+s - 1));
-
- while (pad--)
- outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */
-
- /* timeout after sending */
- DELAY(1000);
- return 0;
-no3c509:
-}
-
-/**************************************************************************
-ETH_POLL - Wait for a frame
-***************************************************************************/
-eth_poll()
-{
- /* common variables */
- unsigned short type = 0;
- unsigned short len;
- /* variables for 3C509 */
- struct ether_header *eh;
- int lenthisone;
- short rx_fifo2, status, cst;
- register short rx_fifo;
-
- if(eth_vendor!=VENDOR_3C509)
- goto no3c509;
-
- cst=inw(BASE + EP_STATUS);
-
-#ifdef EDEBUG
- if(cst & 0x1FFF)
- printf("-%x-",cst);
-#endif
-
- if( (cst & (S_RX_COMPLETE|S_RX_EARLY) )==0 ) {
- /* acknowledge everything */
- outw(BASE + EP_COMMAND, ACK_INTR| (cst & S_5_INTS));
- outw(BASE + EP_COMMAND, C_INTR_LATCH);
-
- return 0;
- }
-
- status = inw(BASE + EP_W1_RX_STATUS);
-#ifdef EDEBUG
- printf("*%x*",status);
-#endif
-
- if (status & ERR_RX) {
- outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
- return 0;
- }
-
- rx_fifo = status & RX_BYTES_MASK;
- if (rx_fifo==0)
- return 0;
-
- /* read packet */
-#ifdef EDEBUG
- printf("[l=%d",rx_fifo);
-#endif
- insw(BASE + EP_W1_RX_PIO_RD_1, packet, rx_fifo / 2);
- if(rx_fifo & 1)
- packet[rx_fifo-1]=inb(BASE + EP_W1_RX_PIO_RD_1);
- packetlen=rx_fifo;
-
- while(1) {
- status = inw(BASE + EP_W1_RX_STATUS);
-#ifdef EDEBUG
- printf("*%x*",status);
-#endif
- rx_fifo = status & RX_BYTES_MASK;
-
- if(rx_fifo>0) {
- insw(BASE + EP_W1_RX_PIO_RD_1, packet+packetlen, rx_fifo / 2);
- if(rx_fifo & 1)
- packet[packetlen+rx_fifo-1]=inb(BASE + EP_W1_RX_PIO_RD_1);
- packetlen+=rx_fifo;
-#ifdef EDEBUG
- printf("+%d",rx_fifo);
-#endif
- }
-
- if(( status & RX_INCOMPLETE )==0) {
-#ifdef EDEBUG
- printf("=%d",packetlen);
-#endif
- break;
- }
-
- DELAY(1000);
- }
-
- /* acknowledge reception of packet */
- outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
-
- type = (packet[12]<<8) | packet[13];
-
-#ifdef EDEBUG
- if(packet[0]+packet[1]+packet[2]+packet[3]+packet[4]+
- packet[5] == 0xFF*6)
- printf(",t=0x%x,b]",type);
- else
- printf(",t=0x%x]",type);
-#endif
-
-
- if (type == ARP) {
- struct arprequest *arpreq;
- unsigned long reqip;
-
- arpreq = (struct arprequest *)&packet[ETHER_HDR_LEN];
-
-#ifdef EDEBUG
- printf("(ARP %I->%I)",ntohl(*(int*)arpreq->sipaddr),
- ntohl(*(int*)arpreq->tipaddr));
-#endif
-
- convert_ipaddr(&reqip, arpreq->tipaddr);
- if ((ntohs(arpreq->opcode) == ARP_REQUEST) &&
- (reqip == arptable[ARP_CLIENT].ipaddr)) {
- arpreq->opcode = htons(ARP_REPLY);
- bcopy(arpreq->sipaddr, arpreq->tipaddr, 4);
- bcopy(arpreq->shwaddr, arpreq->thwaddr, 6);
- bcopy(arptable[ARP_CLIENT].node, arpreq->shwaddr, 6);
- convert_ipaddr(arpreq->sipaddr, &reqip);
- eth_transmit(arpreq->thwaddr, ARP, sizeof(struct arprequest),
- arpreq);
- return(0);
- }
- } else if(type==IP) {
- struct iphdr *iph;
-
- iph = (struct iphdr *)&packet[ETHER_HDR_LEN];
-#ifdef EDEBUG
- printf("(IP %I-%d->%I)",ntohl(*(int*)iph->src),
- ntohs(iph->protocol),ntohl(*(int*)iph->dest));
-#endif
- }
-
- return 1;
-
-no3c509:
-}
-
-
-/*************************************************************************
- 3Com 509 - specific routines
-**************************************************************************/
-
-static int
-eeprom_rdy()
-{
- int i;
-
- for (i = 0; is_eeprom_busy(IS_BASE) && i < MAX_EEPROMBUSY; i++);
- if (i >= MAX_EEPROMBUSY) {
- printf("3c509: eeprom failed to come ready.\r\n");
- return (0);
- }
- return (1);
-}
-
-/*
- * get_e: gets a 16 bits word from the EEPROM. we must have set the window
- * before
- */
-static int
-get_e(offset)
-int offset;
-{
- if (!eeprom_rdy())
- return (0xffff);
- outw(IS_BASE + EP_W0_EEPROM_COMMAND, EEPROM_CMD_RD | offset);
- if (!eeprom_rdy())
- return (0xffff);
- return (inw(IS_BASE + EP_W0_EEPROM_DATA));
-}
-
-static int
-send_ID_sequence(port)
-int port;
-{
- int cx, al;
-
- for (al = 0xff, cx = 0; cx < 255; cx++) {
- outb(port, al);
- al <<= 1;
- if (al & 0x100)
- al ^= 0xcf;
- }
- return (1);
-}
-
-
-/*
- * We get eeprom data from the id_port given an offset into the eeprom.
- * Basically; after the ID_sequence is sent to all of the cards; they enter
- * the ID_CMD state where they will accept command requests. 0x80-0xbf loads
- * the eeprom data. We then read the port 16 times and with every read; the
- * cards check for contention (ie: if one card writes a 0 bit and another
- * writes a 1 bit then the host sees a 0. At the end of the cycle; each card
- * compares the data on the bus; if there is a difference then that card goes
- * into ID_WAIT state again). In the meantime; one bit of data is returned in
- * the AX register which is conveniently returned to us by inb(). Hence; we
- * read 16 times getting one bit of data with each read.
- */
-static int
-get_eeprom_data(id_port, offset)
-int id_port;
-int offset;
-{
- int i, data = 0;
- outb(id_port, 0x80 + offset);
- DELAY(1000);
- for (i = 0; i < 16; i++)
- data = (data << 1) | (inw(id_port) & 1);
- return (data);
-}
-
-/* a surrogate */
-
-DELAY(val)
-{
- int c;
-
- for(c=0; c<val; c+=20) {
- twiddle();
- }
-}
-
diff --git a/sys/i386/boot/netboot/3c509.h b/sys/i386/boot/netboot/3c509.h
deleted file mode 100644
index 19cc637..0000000
--- a/sys/i386/boot/netboot/3c509.h
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) 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. The name
- * of the author may not be used to endorse or promote products derived from
- * this software withough specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- *
- * if_epreg.h,v 1.4 1994/11/13 10:12:37 gibbs Exp Modified by:
- *
- October 2, 1994
-
- Modified by: Andres Vega Garcia
-
- INRIA - Sophia Antipolis, France
- e-mail: avega@sophia.inria.fr
- finger: avega@pax.inria.fr
-
- */
-
-/*
- * Ethernet software status per interface.
- */
-/*
- * Some global constants
- */
-
-#define TX_INIT_RATE 16
-#define TX_INIT_MAX_RATE 64
-#define RX_INIT_LATENCY 64
-#define RX_INIT_EARLY_THRESH 64
-#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */
-#define MIN_RX_EARLY_THRESHL 4
-
-#define EEPROMSIZE 0x40
-#define MAX_EEPROMBUSY 1000
-#define EP_LAST_TAG 0xd7
-#define EP_MAX_BOARDS 16
-#define EP_ID_PORT 0x110
-
-/*
- * some macros to acces long named fields
- */
-#define IS_BASE (eth_base)
-#define BASE (eth_base)
-
-/*
- * Commands to read/write EEPROM trough EEPROM command register (Window 0,
- * Offset 0xa)
- */
-#define EEPROM_CMD_RD 0x0080 /* Read: Address required (5 bits) */
-#define EEPROM_CMD_WR 0x0040 /* Write: Address required (5 bits) */
-#define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */
-#define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */
-
-#define EEPROM_BUSY (1<<15)
-#define EEPROM_TST_MODE (1<<14)
-
-/*
- * Some short functions, worth to let them be a macro
- */
-#define is_eeprom_busy(b) (inw((b)+EP_W0_EEPROM_COMMAND)&EEPROM_BUSY)
-#define GO_WINDOW(x) outw(BASE+EP_COMMAND, WINDOW_SELECT|(x))
-
-/**************************************************************************
- * *
- * These define the EEPROM data structure. They are used in the probe
- * function to verify the existance of the adapter after having sent
- * the ID_Sequence.
- *
- * There are others but only the ones we use are defined here.
- *
- **************************************************************************/
-
-#define EEPROM_NODE_ADDR_0 0x0 /* Word */
-#define EEPROM_NODE_ADDR_1 0x1 /* Word */
-#define EEPROM_NODE_ADDR_2 0x2 /* Word */
-#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */
-#define EEPROM_MFG_ID 0x7 /* 0x6d50 */
-#define EEPROM_ADDR_CFG 0x8 /* Base addr */
-#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */
-
-/**************************************************************************
- * *
- * These are the registers for the 3Com 3c509 and their bit patterns when *
- * applicable. They have been taken out the the "EtherLink III Parallel *
- * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual *
- * from 3com. *
- * *
- **************************************************************************/
-
-#define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a
- * command reg. */
-#define EP_STATUS 0x0e /* Read. BASE+0x0e is always status
- * reg. */
-#define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window
- * reg. */
-/*
- * Window 0 registers. Setup.
- */
-/* Write */
-#define EP_W0_EEPROM_DATA 0x0c
-#define EP_W0_EEPROM_COMMAND 0x0a
-#define EP_W0_RESOURCE_CFG 0x08
-#define EP_W0_ADDRESS_CFG 0x06
-#define EP_W0_CONFIG_CTRL 0x04
-/* Read */
-#define EP_W0_PRODUCT_ID 0x02
-#define EP_W0_MFG_ID 0x00
-
-/*
- * Window 1 registers. Operating Set.
- */
-/* Write */
-#define EP_W1_TX_PIO_WR_2 0x02
-#define EP_W1_TX_PIO_WR_1 0x00
-/* Read */
-#define EP_W1_FREE_TX 0x0c
-#define EP_W1_TX_STATUS 0x0b /* byte */
-#define EP_W1_TIMER 0x0a /* byte */
-#define EP_W1_RX_STATUS 0x08
-#define EP_W1_RX_PIO_RD_2 0x02
-#define EP_W1_RX_PIO_RD_1 0x00
-
-/*
- * Window 2 registers. Station Address Setup/Read
- */
-/* Read/Write */
-#define EP_W2_ADDR_5 0x05
-#define EP_W2_ADDR_4 0x04
-#define EP_W2_ADDR_3 0x03
-#define EP_W2_ADDR_2 0x02
-#define EP_W2_ADDR_1 0x01
-#define EP_W2_ADDR_0 0x00
-
-/*
- * Window 3 registers. FIFO Management.
- */
-/* Read */
-#define EP_W3_FREE_TX 0x0c
-#define EP_W3_FREE_RX 0x0a
-
-/*
- * Window 4 registers. Diagnostics.
- */
-/* Read/Write */
-#define EP_W4_MEDIA_TYPE 0x0a
-#define EP_W4_CTRLR_STATUS 0x08
-#define EP_W4_NET_DIAG 0x06
-#define EP_W4_FIFO_DIAG 0x04
-#define EP_W4_HOST_DIAG 0x02
-#define EP_W4_TX_DIAG 0x00
-
-/*
- * Window 5 Registers. Results and Internal status.
- */
-/* Read */
-#define EP_W5_READ_0_MASK 0x0c
-#define EP_W5_INTR_MASK 0x0a
-#define EP_W5_RX_FILTER 0x08
-#define EP_W5_RX_EARLY_THRESH 0x06
-#define EP_W5_TX_AVAIL_THRESH 0x02
-#define EP_W5_TX_START_THRESH 0x00
-
-/*
- * Window 6 registers. Statistics.
- */
-/* Read/Write */
-#define TX_TOTAL_OK 0x0c
-#define RX_TOTAL_OK 0x0a
-#define TX_DEFERRALS 0x08
-#define RX_FRAMES_OK 0x07
-#define TX_FRAMES_OK 0x06
-#define RX_OVERRUNS 0x05
-#define TX_COLLISIONS 0x04
-#define TX_AFTER_1_COLLISION 0x03
-#define TX_AFTER_X_COLLISIONS 0x02
-#define TX_NO_SQE 0x01
-#define TX_CD_LOST 0x00
-
-/****************************************
- *
- * Register definitions.
- *
- ****************************************/
-
-/*
- * Command register. All windows.
- *
- * 16 bit register.
- * 15-11: 5-bit code for command to be executed.
- * 10-0: 11-bit arg if any. For commands with no args;
- * this can be set to anything.
- */
-#define GLOBAL_RESET (u_short) 0x0000 /* Wait at least 1ms
- * after issuing */
-#define WINDOW_SELECT (u_short) (0x1<<11)
-#define START_TRANSCEIVER (u_short) (0x2<<11) /* Read ADDR_CFG reg to
- * determine whether
- * this is needed. If
- * so; wait 800 uSec
- * before using trans-
- * ceiver. */
-#define RX_DISABLE (u_short) (0x3<<11) /* state disabled on
- * power-up */
-#define RX_ENABLE (u_short) (0x4<<11)
-#define RX_RESET (u_short) (0x5<<11)
-#define RX_DISCARD_TOP_PACK (u_short) (0x8<<11)
-#define TX_ENABLE (u_short) (0x9<<11)
-#define TX_DISABLE (u_short) (0xa<<11)
-#define TX_RESET (u_short) (0xb<<11)
-#define REQ_INTR (u_short) (0xc<<11)
-#define SET_INTR_MASK (u_short) (0xe<<11)
-#define SET_RD_0_MASK (u_short) (0xf<<11)
-#define SET_RX_FILTER (u_short) (0x10<<11)
-#define FIL_INDIVIDUAL (u_short) (0x1)
-#define FIL_GROUP (u_short) (0x2)
-#define FIL_BRDCST (u_short) (0x4)
-#define FIL_ALL (u_short) (0x8)
-#define SET_RX_EARLY_THRESH (u_short) (0x11<<11)
-#define SET_TX_AVAIL_THRESH (u_short) (0x12<<11)
-#define SET_TX_START_THRESH (u_short) (0x13<<11)
-#define STATS_ENABLE (u_short) (0x15<<11)
-#define STATS_DISABLE (u_short) (0x16<<11)
-#define STOP_TRANSCEIVER (u_short) (0x17<<11)
-/*
- * The following C_* acknowledge the various interrupts. Some of them don't
- * do anything. See the manual.
- */
-#define ACK_INTR (u_short) (0x6800)
-#define C_INTR_LATCH (u_short) (ACK_INTR|0x1)
-#define C_CARD_FAILURE (u_short) (ACK_INTR|0x2)
-#define C_TX_COMPLETE (u_short) (ACK_INTR|0x4)
-#define C_TX_AVAIL (u_short) (ACK_INTR|0x8)
-#define C_RX_COMPLETE (u_short) (ACK_INTR|0x10)
-#define C_RX_EARLY (u_short) (ACK_INTR|0x20)
-#define C_INT_RQD (u_short) (ACK_INTR|0x40)
-#define C_UPD_STATS (u_short) (ACK_INTR|0x80)
-
-/*
- * Status register. All windows.
- *
- * 15-13: Window number(0-7).
- * 12: Command_in_progress.
- * 11: reserved.
- * 10: reserved.
- * 9: reserved.
- * 8: reserved.
- * 7: Update Statistics.
- * 6: Interrupt Requested.
- * 5: RX Early.
- * 4: RX Complete.
- * 3: TX Available.
- * 2: TX Complete.
- * 1: Adapter Failure.
- * 0: Interrupt Latch.
- */
-#define S_INTR_LATCH (u_short) (0x1)
-#define S_CARD_FAILURE (u_short) (0x2)
-#define S_TX_COMPLETE (u_short) (0x4)
-#define S_TX_AVAIL (u_short) (0x8)
-#define S_RX_COMPLETE (u_short) (0x10)
-#define S_RX_EARLY (u_short) (0x20)
-#define S_INT_RQD (u_short) (0x40)
-#define S_UPD_STATS (u_short) (0x80)
-#define S_5_INTS (S_CARD_FAILURE|S_TX_COMPLETE|\
- S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY)
-#define S_COMMAND_IN_PROGRESS (u_short) (0x1000)
-
-/*
- * FIFO Registers.
- * RX Status. Window 1/Port 08
- *
- * 15: Incomplete or FIFO empty.
- * 14: 1: Error in RX Packet 0: Incomplete or no error.
- * 13-11: Type of error.
- * 1000 = Overrun.
- * 1011 = Run Packet Error.
- * 1100 = Alignment Error.
- * 1101 = CRC Error.
- * 1001 = Oversize Packet Error (>1514 bytes)
- * 0010 = Dribble Bits.
- * (all other error codes, no errors.)
- *
- * 10-0: RX Bytes (0-1514)
- */
-#define ERR_RX_INCOMPLETE (u_short) (0x1<<15)
-#define ERR_RX (u_short) (0x1<<14)
-#define ERR_RX_OVERRUN (u_short) (0x8<<11)
-#define ERR_RX_RUN_PKT (u_short) (0xb<<11)
-#define ERR_RX_ALIGN (u_short) (0xc<<11)
-#define ERR_RX_CRC (u_short) (0xd<<11)
-#define ERR_RX_OVERSIZE (u_short) (0x9<<11)
-#define ERR_RX_DRIBBLE (u_short) (0x2<<11)
-
-/*
- * FIFO Registers.
- * TX Status. Window 1/Port 0B
- *
- * Reports the transmit status of a completed transmission. Writing this
- * register pops the transmit completion stack.
- *
- * Window 1/Port 0x0b.
- *
- * 7: Complete
- * 6: Interrupt on successful transmission requested.
- * 5: Jabber Error (TP Only, TX Reset required. )
- * 4: Underrun (TX Reset required. )
- * 3: Maximum Collisions.
- * 2: TX Status Overflow.
- * 1-0: Undefined.
- *
- */
-#define TXS_COMPLETE 0x80
-#define TXS_SUCCES_INTR_REQ 0x40
-#define TXS_JABBER 0x20
-#define TXS_UNDERRUN 0x10
-#define TXS_MAX_COLLISION 0x8
-#define TXS_STATUS_OVERFLOW 0x4
-
-/*
- * Configuration control register.
- * Window 0/Port 04
- */
-/* Read */
-#define IS_AUI (1<<13)
-#define IS_BNC (1<<12)
-#define IS_UTP (1<<9)
-/* Write */
-#define ENABLE_DRQ_IRQ 0x0001
-#define W0_P4_CMD_RESET_ADAPTER 0x4
-#define W0_P4_CMD_ENABLE_ADAPTER 0x1
-/*
- * Media type and status.
- * Window 4/Port 0A
- */
-#define ENABLE_UTP 0xc0
-#define DISABLE_UTP 0x0
-
-/*
- * Resource control register
- */
-
-#define SET_IRQ(i) ( ((i)<<12) | 0xF00) /* set IRQ i */
-
-/*
- * Receive status register
- */
-
-#define RX_BYTES_MASK (u_short) (0x07ff)
-#define RX_ERROR 0x4000
-#define RX_INCOMPLETE 0x8000
-
-
-/*
- * Misc defines for various things.
- */
-#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */
-#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */
-#define PROD_ID 0x9150
-
-#define AUI 0x1
-#define BNC 0x2
-#define UTP 0x4
-
-#define RX_BYTES_MASK (u_short) (0x07ff)
-
- /* EISA support */
-#define EP_EISA_START 0x1000
-#define EP_EISA_W0 0x0c80
diff --git a/sys/i386/boot/netboot/Makefile b/sys/i386/boot/netboot/Makefile
deleted file mode 100644
index 84d3d97..0000000
--- a/sys/i386/boot/netboot/Makefile
+++ /dev/null
@@ -1,98 +0,0 @@
-# $FreeBSD$
-#
-# Makefile for NETBOOT
-#
-# Basic Options:
-# -DSECURE_BOOT - Disable 'boot>' prompt completely
-# -DASK_BOOT - Ask "Boot from Network (Y/N) ?" at startup
-# -DROMSIZE - Size of EPROM - Must be set (even for .COM files)
-# -DRELOC - Relocation address (usually 0x90000)
-#
-# NS8390 Options:
-# -DINCLUDE_WD - Include Western Digital/SMC support
-# -DINCLUDE_NE - Include NE1000/NE2000 support
-# -DINCLUDE_3COM - Include 3c503 support
-# -D_3COM_USE_AUI - Disable transceiver on 3c503 by default
-# -DNE_BASE - Base I/O address for NE1000/NE2000
-# -D_3COM_BASE - Base I/O address for 3c503
-# -DWD_DEFAULT_MEM- Default memory location for WD/SMC cards
-# XXX nothing depends on this Makefile so you must run `make clean' after
-# changing an option.
-#
-
-### options for PCI cards
-###
-PCI_VENDOR=0x10ec
-PCI_DEVICE=0x8029
-PCI_CLASS=0x02,0x00,0x00
-
-PROG= nb8390.com nb3c509.com nb8390.rom nb3c509.rom
-# Order is very important on the SRCS line for this prog
-SRCS= start2.S main.c misc.c bootmenu.c rpc.c
-
-BINMODE= 555
-#CFLAGS= -O2 -DNFS -DROMSIZE=${ROMSIZE} -DRELOC=${RELOCADDR} -DASK_BOOT
-CFLAGS= -O2 -DNFS -DROMSIZE=${ROMSIZE} -DRELOC=${RELOCADDR} # -DASK_BOOT
-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_NE
-#NS8390+= -DINCLUDE_3COM -D_3COM_BASE=0x300
-CLEANFILES+= netboot.com
-CLEANFILES+= makerom start2.ro 3c509.o ns8390.o
-ROMLDFLAGS= ${LDFLAGS} -aout -N -T ${RELOCADDR} -e _start -nostdlib
-NOSHARED= YES
-MAN8= netboot.8
-SIZE= size -aout
-STRIP=
-STRIPCMD= strip -aout
-
-ROMSIZE=16384
-RELOCADDR=0x90000
-
-.SUFFIXES: .ro
-
-.S.ro:
- ${CC} ${CFLAGS} -DBOOTROM -o ${.TARGET} -c ${.IMPSRC}
-
-build-tools: makerom
-
-ns8390.o: ns8390.c
- ${CC} ${CFLAGS} $(NS8390) -o ${.TARGET} -c $<
-
-makerom: makerom.c
- ${CC} ${CFLAGS} -DROMSIZE=${ROMSIZE} ${LDFLAGS} -o ${.TARGET} \
- ${.CURDIR}/makerom.c
-
-nb8390.rom: makerom start2.ro ${SRCS:N*.h:R:S/$/.o/g} ns8390.o
- ${LD} ${ROMLDFLAGS} -o ${.TARGET} ${OBJS:S/start2.o/start2.ro/} ns8390.o
- ${STRIPCMD} ${.TARGET}
- ${SIZE} ${.TARGET}
- ${.OBJDIR}/makerom ${.TARGET}
-
-nb3c509.rom: makerom start2.ro ${SRCS:N*.h:R:S/$/.o/g} 3c509.o
- ${LD} ${ROMLDFLAGS} -o ${.TARGET} ${OBJS:S/start2.o/start2.ro/} 3c509.o
- ${STRIPCMD} ${.TARGET}
- ${SIZE} ${.TARGET}
- ${.OBJDIR}/makerom ${.TARGET}
-
-nb8390.com: makerom start2.ro ${SRCS:N*.h:R:S/$/.o/g} ns8390.o
- ${LD} ${ROMLDFLAGS} -o ${.TARGET}.tmp ${OBJS} ns8390.o
- ${STRIPCMD} ${.TARGET}.tmp
- ${SIZE} ${.TARGET}.tmp
- dd ibs=32 skip=1 if=${.TARGET}.tmp of=${.TARGET}
- rm -f ${.TARGET}.tmp
-
-nb3c509.com: start2.o ${SRCS:N*.h:R:S/$/.o/g} 3c509.o
- ${LD} ${ROMLDFLAGS} -o ${.TARGET}.tmp ${OBJS} 3c509.o
- ${STRIPCMD} ${.TARGET}.tmp
- ${SIZE} ${.TARGET}.tmp
- dd ibs=32 skip=1 if=${.TARGET}.tmp of=${.TARGET}
- rm -f ${.TARGET}.tmp
-
-# This force the creation of the "machine" symlink. These objects are
-# specially handled in this file, and thus can't be taken care of in
-# ../Makefile.inc
-3c509.o makerom ns8390.o start2.ro: machine
-
-.include <bsd.prog.mk>
diff --git a/sys/i386/boot/netboot/bootmenu.c b/sys/i386/boot/netboot/bootmenu.c
deleted file mode 100644
index 71b350b..0000000
--- a/sys/i386/boot/netboot/bootmenu.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/**************************************************************************
-NETBOOT - BOOTP/TFTP Bootstrap Program
-
-Author: Martin Renters
- Date: Dec/93
-
-**************************************************************************/
-#include "netboot.h"
-
-extern struct nfs_diskless nfsdiskless;
-extern int hostnamelen;
-extern unsigned long netmask;
-extern eth_reset();
-extern short aui;
-extern int howto;
-
-int cmd_ip(), cmd_server(), cmd_kernel(), cmd_help(), exit();
-int cmd_rootfs(), cmd_swapfs(), cmd_interface(), cmd_hostname();
-int cmd_netmask(), cmd_swapsize(), cmd_swapopts(), cmd_rootopts();
-int cmd_aui(), cmd_gateway(), cmd_flags();
-
-struct bootcmds_t {
- char *name;
- int (*func)();
- char *help;
-} bootcmds[] = {
- {"?", cmd_help, " this list"},
- {"help", cmd_help, " this list"},
- {"ip", cmd_ip, "<addr> set my IP addr"},
- {"server", cmd_server, "<addr> set TFTP server IP addr"},
- {"gateway", cmd_gateway, "<addr> set default router"},
- {"netmask", cmd_netmask, "<addr> set network mask"},
- {"hostname", cmd_hostname, "<name> set hostname"},
- {"kernel", cmd_kernel, "<file> set boot filename"},
- {"rootfs", cmd_rootfs, "[ip:]/fs set root filesystem"},
- {"swapfs", cmd_swapfs, "[ip:]/fs set swap filesystem"},
- {"swapsize", cmd_swapsize, "<nblks> set swap size"},
- {"swapopts", cmd_swapopts, "<options> swap mount options"},
- {"rootopts", cmd_rootopts, "<options> root mount options"},
- {"diskboot", exit, " boot from disk"},
- {"autoboot", NULL, " continue"},
- {"trans", cmd_aui, "<on|off> turn transceiver on|off"},
- {"flags", cmd_flags, "[bcdghsv] set boot flags"},
- {NULL, NULL, NULL}
-};
-
-/**************************************************************************
-CMD_HELP - Display help screen
-**************************************************************************/
-cmd_help()
-{
- struct bootcmds_t *cmd = bootcmds;
- printf("\r\n");
- while (cmd->name) {
- printf("%s %s\n\r",cmd->name,cmd->help);
- cmd++;
- }
-}
-
-/**************************************************************************
-CMD_IP - Set my IP address
-**************************************************************************/
-cmd_ip(p)
- char *p;
-{
- int i;
- if (!setip(p, &arptable[ARP_CLIENT].ipaddr)) {
- printf("IP address is %I\r\n",
- arptable[ARP_CLIENT].ipaddr);
- } else default_netmask();
-}
-
-/**************************************************************************
-CMD_AUI - Turn on-board transceiver on or off
-**************************************************************************/
-cmd_aui(p)
- char *p;
-{
- if (*(p+1) == 'f') {
- aui = 1;
- eth_reset();
- return(0);
- }
- if (*(p+1) == 'n') {
- aui = 0;
- eth_reset();
- return(0);
- }
- printf ("Transceiver is %s\r\n",aui ? "off" : "on");
-}
-
-/**************************************************************************
-CMD_GATEWAY - Set routers IP address
-**************************************************************************/
-cmd_gateway(p)
- char *p;
-{
- int i;
- if (!setip(p, &arptable[ARP_GATEWAY].ipaddr)) {
- printf("Server IP address is %I\r\n",
- arptable[ARP_GATEWAY].ipaddr);
- } else /* Need to clear arp entry if we change IP address */
- for (i=0; i<6; i++) arptable[ARP_GATEWAY].node[i] = 0;
-}
-
-/**************************************************************************
-CMD_SERVER - Set server's IP address
-**************************************************************************/
-cmd_server(p)
- char *p;
-{
- int i;
- if (!setip(p, &arptable[ARP_SERVER].ipaddr)) {
- printf("Server IP address is %I\r\n",
- arptable[ARP_SERVER].ipaddr);
- } else /* Need to clear arp entry if we change IP address */
- for (i=0; i<6; i++) arptable[ARP_SERVER].node[i] = 0;
-}
-
-/**************************************************************************
-CMD_NETMASK - Set network mask
-**************************************************************************/
-cmd_netmask(p)
- char *p;
-{
- int i;
- if (!setip(p, &netmask)) {
- netmask = ntohl(netmask);
- printf("netmask is %I\r\n", netmask);
- }
- netmask = htonl(netmask);
-}
-
-/**************************************************************************
-CMD_SWAPSIZE - Set number of blocks for swap
-**************************************************************************/
-cmd_swapsize(p)
- char *p;
-{
- int blks = getdec(&p);
- if (blks > 0) nfsdiskless.swap_nblks = blks;
- else printf("Swap size is: %d blocks\r\n",nfsdiskless.swap_nblks);
-}
-
-extern char kernel_buf[], *kernel;
-/**************************************************************************
-CMD_KERNEL - set kernel filename
-**************************************************************************/
-cmd_kernel(p)
- char *p;
-{
- if (*p) sprintf(kernel = kernel_buf,"%s",p);
- printf("Bootfile is: %s\r\n", kernel);
-}
-
-
-/**************************************************************************
-CMD_ROOTFS - Set root filesystem name
-**************************************************************************/
-cmd_rootfs(p)
- char *p;
-{
- if (*p == '/') {
- bcopy(&arptable[ARP_SERVER].ipaddr,
- &arptable[ARP_ROOTSERVER].ipaddr, 4);
- } else if (!setip(p, &arptable[ARP_ROOTSERVER].ipaddr)) {
- printf("Root filesystem is %I:%s\r\n",
- nfsdiskless.root_saddr.sin_addr,
- nfsdiskless.root_hostnam);
- return;
- } else {
- while (*p && (*p != ':')) p++;
- if (*p == ':') p++;
- }
-
- bcopy(&arptable[ARP_ROOTSERVER].ipaddr,
- &nfsdiskless.root_saddr.sin_addr, 4);
- sprintf(&nfsdiskless.root_hostnam, "%s", p);
-}
-
-/**************************************************************************
-CMD_SWAPFS - Set swap filesystem name
-**************************************************************************/
-cmd_swapfs(p)
- char *p;
-{
- if (*p == '/') {
- bcopy(&arptable[ARP_SERVER].ipaddr,
- &arptable[ARP_SWAPSERVER].ipaddr, 4);
- } else if (!setip(p, &arptable[ARP_SWAPSERVER].ipaddr)) {
- printf("Swap filesystem is %I:%s\r\n",
- nfsdiskless.swap_saddr.sin_addr,
- nfsdiskless.swap_hostnam);
- return;
- } else {
- while (*p && (*p != ':')) p++;
- if (*p == ':') p++;
- }
-
- bcopy(&arptable[ARP_SWAPSERVER].ipaddr,
- &nfsdiskless.swap_saddr.sin_addr, 4);
- sprintf(&nfsdiskless.swap_hostnam, "%s", p);
-}
-
-/**************************************************************************
-CMD_HOSTNAME - Set my hostname
-**************************************************************************/
-cmd_hostname(p)
- char *p;
-{
- if (*p)
- hostnamelen = ((sprintf(&nfsdiskless.my_hostnam,"%s",p) -
- (char*)&nfsdiskless.my_hostnam) + 3) & ~3;
- else printf("Hostname is: %s\r\n",nfsdiskless.my_hostnam);
-}
-
-static void mountopts(prefix,args,p)
- char *prefix;
- struct onfs_args *args;
- char *p;
-{
- char *tmp;
-
- if (*p) {
- args->flags = NFSMNT_RSIZE | NFSMNT_WSIZE | NFSMNT_RESVPORT;
- args->sotype = SOCK_DGRAM;
- if ((tmp = (char *)substr(p,"rsize=")))
- args->rsize=getdec(&tmp);
- if ((tmp = (char *)substr(p,"wsize=")))
- args->wsize=getdec(&tmp);
- if ((tmp = (char *)substr(p,"intr")))
- args->flags |= NFSMNT_INT;
- if ((tmp = (char *)substr(p,"soft")))
- args->flags |= NFSMNT_SOFT;
- if ((tmp = (char *)substr(p,"noconn")))
- args->flags |= NFSMNT_NOCONN;
- if ((tmp = (char *)substr(p, "tcp")))
- args->sotype = SOCK_STREAM;
- } else {
- printf("%s mount options: rsize=%d,wsize=%d,resvport",
- prefix,
- args->rsize,
- args->wsize);
- if (args->flags & NFSMNT_INT)
- printf (",intr");
- if (args->flags & NFSMNT_SOFT)
- printf (",soft");
- if (args->flags & NFSMNT_NOCONN)
- printf (",noconn");
- if (args->sotype == SOCK_STREAM)
- printf (",tcp");
- else
- printf (",udp");
- printf ("\r\n");
- }
-}
-
-/**************************************************************************
-CMD_ROOTOPTS - Set root mount options
-**************************************************************************/
-cmd_rootopts(p)
- char *p;
-{
- mountopts("Rootfs",&nfsdiskless.root_args,p);
-}
-
-/**************************************************************************
-CMD_SWAPOPTS - Set swap mount options
-**************************************************************************/
-cmd_swapopts(p)
- char *p;
-{
- mountopts("Swapfs",&nfsdiskless.swap_args,p);
-}
-
-/**************************************************************************
-CMD_FLAGS - Set boot flags
-**************************************************************************/
-cmd_flags(buf)
- char *buf;
-{
- char p;
- int flags = 0;
-
- while ((p = *buf++))
- switch (p) {
- case 'b': flags |= RB_HALT; break;
- case 'c': flags |= RB_CONFIG; break;
- case 'd': flags |= RB_KDB; break;
- case 'g': flags |= RB_GDB; break;
- case 'h': flags ^= RB_SERIAL; break;
- case 's': flags |= RB_SINGLE; break;
- case 'v': flags |= RB_VERBOSE; break;
- case ' ':
- case '\t': break;
- default: printf("Unknown boot flag: %c\n", p);
- }
-
- howto = flags;
- return(0);
-}
-
-/**************************************************************************
-EXECUTE - Decode command
-**************************************************************************/
-execute(buf)
- char *buf;
-{
- char *p, *q;
- struct bootcmds_t *cmd = bootcmds;
- while (*buf == ' ' || *buf == '\t')
- buf++;
- if ((!(*buf)) || (*buf == '#'))
- return(0);
- while(cmd->name) {
- p = buf;
- q = cmd->name;
- while (*q && *q == *p++)
- q++;
- if ((!(*q)) && ((*p == ' ') || (*p == '\t') || (!(*p)))) {
- if (!cmd->func)
- return(1);
- while (*p == ' ' || *p == '\t')
- p++;
- (cmd->func)(p);
- return(0);
- } else
- cmd++;
- }
- printf("bad command - type 'help' for list\n\r");
- return(0);
-}
-
-/**************************************************************************
-BOOTMENU - Present boot options
-**************************************************************************/
-bootmenu()
-{
- char cmd[80];
- int ptr, c;
-#ifdef SECURE_BOOT
- char *p;
-
- printf("\r\n");
-
- printf("Press any key to retry:");
- while (iskey())
- getchar();
- getchar();
- printf("\r\n");
- eth_probe();
-#else
- printf("\r\n");
- while (1) {
- ptr = 0;
- printf("boot> ");
- while (ptr < 80) {
- c = getchar();
- if (c == '\r')
- break;
- else if (c == '\b') {
- if (ptr > 0) {
- ptr--;
- printf("\b \b");
- }
- } else {
- cmd[ptr++] = c;
- putchar(c);
- }
- }
- cmd[ptr] = 0;
- printf("\r\n");
- if (execute(cmd)) break;
- }
-#endif
- eth_reset();
-}
diff --git a/sys/i386/boot/netboot/main.c b/sys/i386/boot/netboot/main.c
deleted file mode 100644
index ba8885c..0000000
--- a/sys/i386/boot/netboot/main.c
+++ /dev/null
@@ -1,715 +0,0 @@
-/**************************************************************************
-NETBOOT - BOOTP/TFTP Bootstrap Program
-
-Author: Martin Renters
- Date: Dec/93
-
-**************************************************************************/
-
-/* #define MDEBUG */
-
-#include "netboot.h"
-
-int jmp_bootmenu[10];
-
-struct exec head;
-char *loadpoint;
-char *kernel;
-char kernel_buf[128];
-void (*kernelentry)();
-struct nfs_diskless nfsdiskless;
-int hostnamelen;
-char config_buffer[512]; /* Max TFTP packet */
-struct bootinfo bootinfo;
-int root_nfs_port;
-unsigned long netmask;
-char kernel_handle[32];
-int offset, howto;
-
-extern char eth_driver[];
-extern char packet[];
-extern int packetlen, rpc_id;
-char broadcast[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
-
-/**************************************************************************
-MAIN - Kick off routine
-**************************************************************************/
-main()
-{
- int c;
- extern char edata[], end[];
- bzero(edata,end-edata); /* Zero BSS */
-#ifdef ASK_BOOT
- while (1) {
- printf("\nBoot from Network (Y/N) ? ");
- c = getchar();
- if ((c >= 'a') && (c <= 'z')) c &= 0x5F;
- if (c == '\r') break;
- putchar(c);
- if (c == 'N')
- exit(0);
- if (c == 'Y')
- break;
- printf(" - bad response\n\r");
- }
-#endif
-
- /* get the bios's idea about the disks geometry */
- for(c = 0; c < N_BIOS_GEOM; c ++)
- bootinfo.bi_bios_geom[c] = get_diskinfo(c + 0x80);
-
- gateA20();
- printf("\nBOOTP/TFTP/NFS bootstrap loader ESC for menu\n"
- "\nSearching for adapter...");
- if (!eth_probe()) {
- printf("No adapter found.\n");
- exit(0);
- }
- kernel = DEFAULT_BOOTFILE;
- while (1) {
- if (setjmp(jmp_bootmenu))
- bootmenu();
- else
- load();
- }
-}
-
-void
-nfsload(length)
-{
- int err, read_size;
-
- while (length > 0) {
- read_size = length > NFS_READ_SIZE ?
- NFS_READ_SIZE : length;
- if ((err = nfs_read(ARP_ROOTSERVER, root_nfs_port,
- &kernel_handle, offset, read_size, loadpoint)) !=
- read_size) {
- if (err < 0) {
- printf("Unable to read data: ");
- nfs_err(err);
- }
- longjmp(jmp_bootmenu, 1);
- }
- loadpoint += err;
- length -= err;
- offset += err;
- }
-}
-
-/**************************************************************************
-LOAD - Try to get booted
-**************************************************************************/
-load()
-{
- char *p,*q;
- char cfg[64];
- int root_mount_port;
- int swap_nfs_port;
- int swap_mount_port;
- char cmd_line[80];
- int err, read_size, i;
- long addr, broadcast;
- int swsize;
- unsigned long pad;
-
- config_buffer[0]='\0'; /* clear; bootp might fill this up */
-/* Initialize this early on */
-
- nfsdiskless.root_args.rsize = 8192;
- nfsdiskless.root_args.wsize = 8192;
- nfsdiskless.swap_args.rsize = 8192;
- nfsdiskless.swap_args.wsize = 8192;
- nfsdiskless.root_args.sotype = SOCK_DGRAM;
- nfsdiskless.root_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE |
- NFSMNT_RESVPORT);
- nfsdiskless.swap_args.sotype = SOCK_DGRAM;
- nfsdiskless.swap_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE |
- NFSMNT_RESVPORT);
-
-
- /* Find a server to get BOOTP reply from */
- if (!arptable[ARP_CLIENT].ipaddr || !arptable[ARP_SERVER].ipaddr) {
- printf("\r\nSearching for server...\r\n");
- if (!bootp()) {
- printf("No Server found.\r\n");
- longjmp(jmp_bootmenu,1);
- }
- }
- printf("My IP %I, Server IP %I, GW IP %I\r\n",
- arptable[ARP_CLIENT].ipaddr,
- arptable[ARP_SERVER].ipaddr,
- arptable[ARP_GATEWAY].ipaddr);
-
-#ifdef MDEBUG
- printf("\n=>>"); getchar();
-#endif
-
- /*** check if have got info from bootp ***/
- if (config_buffer[0])
- goto cfg_done;
-#ifndef NO_TFTP
- /* Now use TFTP to load configuration file */
- sprintf(cfg,"/tftpboot/freebsd.%I",arptable[ARP_CLIENT].ipaddr);
- if (tftp(cfg) || tftp(cfg+10))
- goto cfg_done;
- cfg[17]='\0';
- if (tftp(cfg) || tftp(cfg+10))
- goto cfg_done;
- 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",
- config_buffer);
-
-cfg_done:
-#ifdef MDEBUG
- printf("\n=>>"); getchar();
-#endif
-
- p = config_buffer;
- while(*p) {
- q = cmd_line;
- while ((*p != '\n') && (*p)) *(q++) = *(p++);
- *q = 0;
- printf("%s\r\n",cmd_line);
- execute(cmd_line);
- if (*p) p++;
- }
-
-#ifdef MDEBUG
- printf("\n=>>"); getchar();
-#endif
-
- /* Check to make sure we've got a rootfs */
- if (!arptable[ARP_ROOTSERVER].ipaddr) {
- printf("No ROOT filesystem server!\r\n");
- longjmp(jmp_bootmenu,1);
- }
-
- /* Fill in nfsdiskless.myif */
- sprintf(&nfsdiskless.myif.ifra_name,eth_driver);
- nfsdiskless.myif.ifra_addr.sa_len = sizeof(struct sockaddr);
- nfsdiskless.myif.ifra_addr.sa_family = AF_INET;
- addr = htonl(arptable[ARP_CLIENT].ipaddr);
- bcopy(&addr, &nfsdiskless.myif.ifra_addr.sa_data[2], 4);
- broadcast = (addr & netmask) | ~netmask;
- nfsdiskless.myif.ifra_broadaddr.sa_len = sizeof(struct sockaddr);
- nfsdiskless.myif.ifra_broadaddr.sa_family = AF_INET;
- bcopy(&broadcast, &nfsdiskless.myif.ifra_broadaddr.sa_data[2], 4);
- addr = htonl(arptable[ARP_GATEWAY].ipaddr);
- if (addr) {
- nfsdiskless.mygateway.sin_len = sizeof(struct sockaddr);
- nfsdiskless.mygateway.sin_family = AF_INET;
- bcopy(&addr, &nfsdiskless.mygateway.sin_addr, 4);
- } else {
- nfsdiskless.mygateway.sin_len = 0;
- }
- nfsdiskless.myif.ifra_mask.sa_len = sizeof(struct sockaddr);
- nfsdiskless.myif.ifra_mask.sa_family = AF_UNSPEC;
- bcopy(&netmask, &nfsdiskless.myif.ifra_mask.sa_data[2], 4);
-
- rpc_id = currticks();
-
- /* Lookup NFS/MOUNTD ports for SWAP using PORTMAP */
- if (arptable[ARP_SWAPSERVER].ipaddr) {
- char swapfs_fh[32], swapfile[32];
- swap_nfs_port = rpclookup(ARP_SWAPSERVER, PROG_NFS, 2);
- swap_mount_port = rpclookup(ARP_SWAPSERVER, PROG_MOUNT, 1);
- if ((swap_nfs_port == -1) || (swap_mount_port == -1)) {
- printf("Unable to get SWAP NFS/MOUNT ports\r\n");
- longjmp(jmp_bootmenu,1);
- }
- if (err = nfs_mount(ARP_SWAPSERVER, swap_mount_port,
- nfsdiskless.swap_hostnam, &swapfs_fh)) {
- printf("Unable to mount SWAP filesystem: ");
- nfs_err(err);
- longjmp(jmp_bootmenu,1);
- }
- sprintf(swapfile,"swap.%I",arptable[ARP_CLIENT].ipaddr);
- if (err = nfs_lookup(ARP_SWAPSERVER, swap_nfs_port,
- &swapfs_fh, swapfile, &nfsdiskless.swap_fh, &swsize)) {
- printf("Unable to open %s: ",swapfile);
- nfs_err(err);
- longjmp(jmp_bootmenu,1);
- }
- if (!nfsdiskless.swap_nblks) {
- nfsdiskless.swap_nblks = swsize / 1024;
- printf("Swap size is: %d blocks\n",nfsdiskless.swap_nblks);
- }
- nfsdiskless.swap_saddr.sin_len = sizeof(struct sockaddr_in);
- nfsdiskless.swap_saddr.sin_family = AF_INET;
- nfsdiskless.swap_saddr.sin_port = htons(swap_nfs_port);
- nfsdiskless.swap_saddr.sin_addr.s_addr =
- htonl(arptable[ARP_SWAPSERVER].ipaddr);
- nfsdiskless.swap_args.timeo = 10;
- nfsdiskless.swap_args.retrans = 100;
- }
-
- /* Lookup NFS/MOUNTD ports for ROOT using PORTMAP */
- root_nfs_port = rpclookup(ARP_ROOTSERVER, PROG_NFS, 2);
- root_mount_port = rpclookup(ARP_ROOTSERVER, PROG_MOUNT, 1);
- if ((root_nfs_port == -1) || (root_mount_port == -1)) {
- printf("Unable to get ROOT NFS/MOUNT ports\r\n");
- longjmp(jmp_bootmenu,1);
- }
- if (err = nfs_mount(ARP_ROOTSERVER, root_mount_port,
- nfsdiskless.root_hostnam, &nfsdiskless.root_fh)) {
- printf("Unable to mount ROOT filesystem: ");
- nfs_err(err);
- longjmp(jmp_bootmenu,1);
- }
- nfsdiskless.root_saddr.sin_len = sizeof(struct sockaddr_in);
- nfsdiskless.root_saddr.sin_family = AF_INET;
- nfsdiskless.root_saddr.sin_port = htons(root_nfs_port);
- nfsdiskless.root_saddr.sin_addr.s_addr =
- htonl(arptable[ARP_ROOTSERVER].ipaddr);
- nfsdiskless.root_args.timeo = 10;
- nfsdiskless.root_args.retrans = 100;
- nfsdiskless.root_time = 0;
-
- if (err = nfs_lookup(ARP_ROOTSERVER, root_nfs_port,
- &nfsdiskless.root_fh, *kernel == '/' ? kernel+1 : kernel,
- &kernel_handle, NULL)) {
- printf("Unable to open %s: ",kernel);
- nfs_err(err);
- longjmp(jmp_bootmenu,1);
- }
-
- /* Load the kernel using NFS */
- printf("Loading %s...\r\n",kernel);
- if ((err = nfs_read(ARP_ROOTSERVER, root_nfs_port, &kernel_handle, 0,
- sizeof(struct exec), &head)) < 0) {
- printf("Unable to read %s: ",kernel);
- nfs_err(err);
- longjmp(jmp_bootmenu,1);
- }
- if (N_BADMAG(head)) {
- printf("Bad executable format!\r\n");
- longjmp(jmp_bootmenu, 1);
- }
- loadpoint = (char *)(head.a_entry & 0x00FFFFFF);
- offset = N_TXTOFF(head);
- printf("text=0x%X, ",head.a_text);
- nfsload(head.a_text);
- while (((int)loadpoint) & PAGE_MASK)
- *(loadpoint++) = 0;
-
- printf("data=0x%X, ",head.a_data);
- nfsload(head.a_data);
-
- printf("bss=0x%X, ",head.a_bss);
- while(head.a_bss--) *(loadpoint++) = 0;
-
- while (((int)loadpoint) & PAGE_MASK)
- *(loadpoint++) = 0;
-
- bootinfo.bi_symtab = (u_int32_t)loadpoint;
-
- p = (char*)&head.a_syms;
- for (i=0;i<sizeof(head.a_syms);i++)
- *loadpoint++ = *p++;
-
- printf("symbols=[+0x%x+0x%x", sizeof(head.a_syms), head.a_syms);
-
- nfsload(head.a_syms);
- i = sizeof(int);
- p = loadpoint;
- nfsload(i);
- i = *(int*)p;
- printf("+0x%x]\n", i);
- i -= sizeof(int);
- nfsload(i);
- bootinfo.bi_esymtab = (u_int32_t)loadpoint;
-
- printf("entry=0x%X.\n\r",head.a_entry);
-
- /* Jump to kernel */
- bootinfo.bi_version = BOOTINFO_VERSION;
- bootinfo.bi_kernelname = (u_int32_t)kernel;
- bootinfo.bi_nfs_diskless = (u_int32_t)&nfsdiskless;
- bootinfo.bi_size = sizeof bootinfo;
- kernelentry = (void *)(head.a_entry & 0x00FFFFFF);
- (*kernelentry)(howto|RB_BOOTINFO,NODEV,0,0,0,&bootinfo,0,0,0);
- printf("*** %s execute failure ***\n",kernel);
-}
-
-/**************************************************************************
-POLLKBD - Check for Interrupt from keyboard
-**************************************************************************/
-pollkbd()
-{
-#ifndef SECURE_BOOT
- if (iskey() && (getchar() == ESC)) longjmp(jmp_bootmenu,1);
-#endif
-}
-
-/**************************************************************************
-DEFAULT_NETMASK - Set a default netmask for IP address
-**************************************************************************/
-default_netmask()
-{
- int net = arptable[ARP_CLIENT].ipaddr >> 24;
- if (net <= 127)
- netmask = htonl(0xff000000);
- else if (net < 192)
- netmask = htonl(0xffff0000);
- else
- netmask = htonl(0xffffff00);
-}
-/**************************************************************************
-UDP_TRANSMIT - Send a UDP datagram
-**************************************************************************/
-udp_transmit(destip, srcsock, destsock, len, buf)
- unsigned long destip;
- unsigned short srcsock, destsock;
- int len;
- char *buf;
-{
- struct iphdr *ip;
- struct udphdr *udp;
- struct arprequest arpreq;
- int arpentry, i;
- unsigned long time;
- int retry = MAX_ARP_RETRIES;
-
- ip = (struct iphdr *)buf;
- udp = (struct udphdr *)(buf + sizeof(struct iphdr));
- ip->verhdrlen = 0x45;
- ip->service = 0;
- ip->len = htons(len);
- ip->ident = 0;
- ip->frags = 0;
- ip->ttl = 60;
- ip->protocol = IP_UDP;
- ip->chksum = 0;
- convert_ipaddr(ip->src, &arptable[ARP_CLIENT].ipaddr);
- convert_ipaddr(ip->dest, &destip);
- ip->chksum = ipchksum(buf, sizeof(struct iphdr));
- udp->src = htons(srcsock);
- udp->dest = htons(destsock);
- udp->len = htons(len - sizeof(struct iphdr));
- udp->chksum = 0;
- if (destip == IP_BROADCAST) {
- eth_transmit(broadcast, IP, len, buf);
- } else {
- long h_netmask = ntohl(netmask);
- /* Check to see if we need gateway */
- if (((destip & h_netmask) !=
- (arptable[ARP_CLIENT].ipaddr & h_netmask)) &&
- arptable[ARP_GATEWAY].ipaddr)
- destip = arptable[ARP_GATEWAY].ipaddr;
- for(arpentry = 0; arpentry<MAX_ARP; arpentry++)
- if (arptable[arpentry].ipaddr == destip) break;
- if (arpentry == MAX_ARP) {
- printf("%I is not in my arp table!\n");
- return(0);
- }
- for (i = 0; i<ETHER_ADDR_LEN; i++)
- if (arptable[arpentry].node[i]) break;
- if (i == ETHER_ADDR_LEN) { /* Need to do arp request */
- arpreq.hwtype = htons(1);
- arpreq.protocol = htons(IP);
- arpreq.hwlen = ETHER_ADDR_LEN;
- arpreq.protolen = 4;
- arpreq.opcode = htons(ARP_REQUEST);
- bcopy(arptable[ARP_CLIENT].node, arpreq.shwaddr,
- ETHER_ADDR_LEN);
- convert_ipaddr(arpreq.sipaddr,
- &arptable[ARP_CLIENT].ipaddr);
- bzero(arpreq.thwaddr, ETHER_ADDR_LEN);
- convert_ipaddr(arpreq.tipaddr, &destip);
- while (retry--) {
- eth_transmit(broadcast, ARP, sizeof(arpreq),
- &arpreq);
- if (await_reply(AWAIT_ARP, arpentry,
- arpreq.tipaddr)) goto xmit;
- }
- return(0);
- }
-xmit: eth_transmit(arptable[arpentry].node, IP, len, buf);
- }
- return(1);
-}
-
-/**************************************************************************
-TFTP - Try to load configuation file
-**************************************************************************/
-tftp(name)
- char *name;
-{
- struct tftp_t *tr;
- int retry = MAX_TFTP_RETRIES;
- static unsigned short isocket = 2000;
- unsigned short osocket = TFTP;
- unsigned short len, block=1;
- struct tftp_t tp;
- int code;
- printf("Loading %s...\r\n",name);
- isocket++;
- tp.opcode = htons(TFTP_RRQ);
- len = (sprintf((char *)tp.u.rrq,"%s%c%s",name,0,"octet")
- - ((char *)&tp)) + 1;
- while(retry--) {
- if (!udp_transmit(arptable[ARP_SERVER].ipaddr, isocket, osocket,
- len, &tp)) return(0);
- if (await_reply(AWAIT_TFTP, isocket, NULL)) {
- tr = (struct tftp_t *)&packet[ETHER_HDR_LEN];
- if (tr->opcode == ntohs(TFTP_ERROR)) {
- printf("TFTP error %d (%s)\r\n",
- ntohs(tr->u.err.errcode),
- tr->u.err.errmsg);
- return(0);
- } /* ACK PACKET */
- if (tr->opcode != ntohs(TFTP_DATA)) return(0);
- osocket = ntohs(tr->udp.src);
- tp.opcode = htons(TFTP_ACK);
- tp.u.ack.block = tr->u.data.block;
- udp_transmit(arptable[ARP_SERVER].ipaddr, isocket,
- osocket, TFTP_MIN_PACKET_SIZE, &tp);
- len = ntohs(tr->udp.len) - sizeof(struct udphdr) - 4;
- if (len >= 512) {
- printf("Config file too large.\r\n");
- config_buffer[0] = 0;
- return(0);
- } else {
- bcopy(tr->u.data.download, config_buffer, len);
- config_buffer[len] = 0;
- }
- return(1);
- }
- }
- return(0);
-}
-
-/**************************************************************************
-BOOTP - Get my IP address and load information
-**************************************************************************/
-bootp()
-{
- int retry = MAX_BOOTP_RETRIES;
- struct bootp_t bp;
- unsigned long starttime;
- bzero(&bp, sizeof(struct bootp_t));
- bp.bp_op = BOOTP_REQUEST;
- bp.bp_htype = 1;
- bp.bp_hlen = ETHER_ADDR_LEN;
- bp.bp_xid = starttime = currticks();
- bcopy(arptable[ARP_CLIENT].node, bp.bp_hwaddr, ETHER_ADDR_LEN);
- while(retry--) {
- udp_transmit(IP_BROADCAST, 0, BOOTP_SERVER,
- sizeof(struct bootp_t), &bp);
- if (await_reply(AWAIT_BOOTP, 0, NULL))
- return(1);
- bp.bp_secs = htons((currticks()-starttime)/20);
- }
- return(0);
-}
-
-
-/**************************************************************************
-AWAIT_REPLY - Wait until we get a response for our request
-**************************************************************************/
-await_reply(type, ival, ptr)
- int type, ival;
- char *ptr;
-{
- unsigned long time;
- struct iphdr *ip;
- struct udphdr *udp;
- struct arprequest *arpreply;
- struct bootp_t *bootpreply;
- struct rpc_t *rpc;
-
- int protohdrlen = ETHER_HDR_LEN + sizeof(struct iphdr) +
- sizeof(struct udphdr);
- time = currticks() + TIMEOUT;
- while(time > currticks()) {
- pollkbd();
- if (eth_poll()) { /* We have something! */
- /* Check for ARP - No IP hdr */
- if ((type == AWAIT_ARP) &&
- (packetlen >= ETHER_HDR_LEN +
- sizeof(struct arprequest)) &&
- (((packet[12] << 8) | packet[13]) == ARP)) {
- arpreply = (struct arprequest *)
- &packet[ETHER_HDR_LEN];
- if ((arpreply->opcode == ntohs(ARP_REPLY)) &&
- bcompare(arpreply->sipaddr, ptr, 4)) {
- bcopy(arpreply->shwaddr,
- arptable[ival].node,
- ETHER_ADDR_LEN);
- return(1);
- }
- continue;
- }
-
- /* Anything else has IP header */
- if ((packetlen < protohdrlen) ||
- (((packet[12] << 8) | packet[13]) != IP)) continue;
- ip = (struct iphdr *)&packet[ETHER_HDR_LEN];
- if ((ip->verhdrlen != 0x45) ||
- ipchksum(ip, sizeof(struct iphdr)) ||
- (ip->protocol != IP_UDP)) continue;
- udp = (struct udphdr *)&packet[ETHER_HDR_LEN +
- sizeof(struct iphdr)];
-
- /* BOOTP ? */
- bootpreply = (struct bootp_t *)&packet[ETHER_HDR_LEN];
- if ((type == AWAIT_BOOTP) &&
- (packetlen >= (ETHER_HDR_LEN +
- sizeof(struct iphdr) +
- sizeof(struct udphdr) +
- BOOTP_MIN_LEN)) &&
- (ntohs(udp->dest) == BOOTP_CLIENT) &&
- (bootpreply->bp_op == BOOTP_REPLY)) {
- convert_ipaddr(&arptable[ARP_CLIENT].ipaddr,
- bootpreply->bp_yiaddr);
- default_netmask();
- convert_ipaddr(&arptable[ARP_SERVER].ipaddr,
- bootpreply->bp_siaddr);
- bzero(arptable[ARP_SERVER].node,
- ETHER_ADDR_LEN); /* Kill arp */
- convert_ipaddr(&arptable[ARP_GATEWAY].ipaddr,
- bootpreply->bp_giaddr);
- bzero(arptable[ARP_GATEWAY].node,
- ETHER_ADDR_LEN); /* Kill arp */
- if (bootpreply->bp_file[0]) {
- bcopy(bootpreply->bp_file,
- kernel_buf, 128);
- kernel = kernel_buf;
- }
- decode_rfc1048(bootpreply->bp_vend);
- return(1);
- }
-
- /* TFTP ? */
- if ((type == AWAIT_TFTP) &&
- (ntohs(udp->dest) == ival)) return(1);
-
- /* RPC */
- rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
- if ((type == AWAIT_RPC) &&
- (ntohs(udp->dest) == RPC_SOCKET) &&
- (ntohl(rpc->u.reply.id) == ival) &&
- (ntohl(rpc->u.reply.type) == MSG_REPLY)) {
- rpc_id++;
- return(1);
- }
- }
- }
- 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
-**************************************************************************/
-decode_rfc1048(p)
- unsigned char *p;
-{
- static char rfc1048_cookie[4] = RFC1048_COOKIE;
- unsigned char *end = p + BOOTP_VENDOR_LEN,*q;
- if (bcompare(p, rfc1048_cookie, 4)) { /* RFC 1048 header */
- p += 4;
- while(p < end) {
- switch (*p) {
- case RFC1048_PAD:
- p++;
- continue;
- case RFC1048_END:
- p = end;
- continue;
- case RFC1048_GATEWAY:
- convert_ipaddr(&arptable[ARP_GATEWAY].ipaddr,
- p+2);
- break;
- case RFC1048_NETMASK:
- bcopy(p+2,&netmask,4);
- break;
- case RFC1048_HOSTNAME:
- bcopy(p+2, &nfsdiskless.my_hostnam, TAG_LEN(p));
- hostnamelen = (TAG_LEN(p) + 3) & ~3;
- 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;
- case 132: /* any other options */
- case 133:
- case 134:
- case 135:
- case 136:
- case 137:
- case 138:
- case 139:
- case 140:
- case 141:
- bootp_string("", p);
- break;
- default:
- printf("Unknown RFC1048-tag ");
- for(q=p;q<p+2+TAG_LEN(p);q++)
- printf("%x ",*q);
- printf("\n\r");
- }
- p += TAG_LEN(p) + 2;
- }
- }
-}
-
-/**************************************************************************
-IPCHKSUM - Checksum IP Header
-**************************************************************************/
-ipchksum(ip, len)
- unsigned short *ip;
- int len;
-{
- unsigned long sum = 0;
- len >>= 1;
- while (len--) {
- sum += *(ip++);
- if (sum > 0xFFFF)
- sum -= 0xFFFF;
- }
- return((~sum) & 0x0000FFFF);
-}
-
-
-/**************************************************************************
-CONVERT_IPADDR - Convert IP address from net to machine order
-**************************************************************************/
-convert_ipaddr(d, s)
- char *d,*s;
-{
- *(d+3) = *s;
- *(d+2) = *(s+1);
- *(d+1) = *(s+2);
- *d = *(s+3);
-}
diff --git a/sys/i386/boot/netboot/makerom.c b/sys/i386/boot/netboot/makerom.c
deleted file mode 100644
index 51b1c28..0000000
--- a/sys/i386/boot/netboot/makerom.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/************************************************************************
-
-Program to put ROM checksum in ROM image.
-
-This program strips off the FreeBSD a.out header!
-
-************************************************************************/
-#include <stdio.h>
-#include <sys/fcntl.h>
-
-unsigned char rom[ROMSIZE];
-unsigned int sum;
-
-main(argc,argv)
- int argc; char *argv[];
-{
- int i, fd;
- if (argc < 1) {
- fprintf(stderr,"usage: %s rom-file\n",argv[0]);
- exit(2);
- }
- if ((fd = open(argv[1], O_RDWR)) < 0) {
- perror("unable to open file");
- exit(2);
- }
- bzero(rom, ROMSIZE);
- if (lseek(fd, (off_t)32, SEEK_SET) < 0) {
- perror("lseek error");
- exit(2);
- }
- if (read(fd, rom, ROMSIZE) < 0) {
- perror("read error");
- exit(2);
- }
- rom[5] = 0;
- for (i=0,sum=0; i<ROMSIZE; i++)
- sum += rom[i];
- rom[5] = -sum;
- for (i=0,sum=0; i<ROMSIZE; i++)
- sum += rom[i];
- if (sum & 0x00FF)
- printf("checksum fails.\n");
- if (lseek(fd, (off_t)0, SEEK_SET) < 0) {
- perror("unable to seek");
- exit(2);
- }
- if (write(fd, rom, ROMSIZE) < 0) {
- perror("unable to write");
- exit(2);
- }
- close(fd);
- exit(0);
-}
diff --git a/sys/i386/boot/netboot/misc.c b/sys/i386/boot/netboot/misc.c
deleted file mode 100644
index 5dc7f4e..0000000
--- a/sys/i386/boot/netboot/misc.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/**************************************************************************
-MISC Support Routines
-**************************************************************************/
-
-#include "netboot.h"
-
-#define NO_SWITCH /* saves space */
-
-/**************************************************************************
-TWIDDLE
-**************************************************************************/
-twiddle()
-{
- static int count=0;
- char tiddles[]="-\\|/";
- putchar(tiddles[(count++)&3]);
- putchar('\b');
-}
-
-/**************************************************************************
-BCOPY
-**************************************************************************/
-bcopy(s,d,n)
- char *s, *d;
- int n;
-{
- while ((n--) > 0) {
- *(d++) = *(s++);
- }
-}
-
-/**************************************************************************
-BZERO
-**************************************************************************/
-bzero(d,n)
- char *d;
- int n;
-{
- while ((n--) > 0) {
- *(d++) = 0;
- }
-}
-
-/**************************************************************************
-BCOMPARE
-**************************************************************************/
-bcompare(d,s,n)
- char *d,*s;
- int n;
-{
- while ((n--) > 0) {
- if (*(d++) != *(s++)) return(0);
- }
- return(1);
-}
-
-/**************************************************************************
-SUBSTR (slightly wacky but functional)
-**************************************************************************/
-char *substr(a,b)
-char *a,*b;
-{
-char *loc1;
-char *loc2;
-
- while (*a != '\0') {
- loc1 = a;
- loc2 = b;
- while (*loc1 == *loc2++) {
- if (*loc1 == '\0') return (0);
- loc1++;
- if (*loc2 == '\0') return (loc1);
- }
- a++;
- }
- return (0);
-}
-
-/**************************************************************************
-PRINTF and friends
-
- Formats:
- %X - 4 byte ASCII (8 hex digits)
- %x - 2 byte ASCII (4 hex digits)
- %b - 1 byte ASCII (2 hex digits)
- %d - decimal
- %c - ASCII char
- %s - ASCII string
- %I - Internet address in x.x.x.x notation
- %L - Binary long
- %S - String (multiple of 4 bytes) preceded with 4 byte
- binary length
- %M - Copy memory. Takes two args, len and ptr
-**************************************************************************/
-static char hex[]="0123456789ABCDEF";
-char *do_printf(buf, fmt, dp)
- char *buf, *fmt;
- int *dp;
-{
- register char *p;
- char tmp[16];
- while (*fmt) {
- if (*fmt == '%') { /* switch() uses more space */
- fmt++;
- if (*fmt == 'L') {
- register int h = *(dp++);
- *(buf++) = h>>24;
- *(buf++) = h>>16;
- *(buf++) = h>>8;
- *(buf++) = h;
- }
- if (*fmt == 'S') {
- register int len = 0;
- char *lenptr = buf;
- p = (char *)*dp++;
- buf += 4;
- while (*p) {
- *(buf++) = *p++;
- len ++;
- }
- *(lenptr++) = len>>24;
- *(lenptr++) = len>>16;
- *(lenptr++) = len>>8;
- *lenptr = len;
- while (len & 3) {
- *(buf++) = 0;
- len ++;
- }
- }
- if (*fmt == 'M') {
- register int len = *(dp++);
- bcopy((char *)*dp++, buf, len);
- buf += len;
- }
- if (*fmt == 'X') {
- register int h = *(dp++);
- *(buf++) = hex[(h>>28)& 0x0F];
- *(buf++) = hex[(h>>24)& 0x0F];
- *(buf++) = hex[(h>>20)& 0x0F];
- *(buf++) = hex[(h>>16)& 0x0F];
- *(buf++) = hex[(h>>12)& 0x0F];
- *(buf++) = hex[(h>>8)& 0x0F];
- *(buf++) = hex[(h>>4)& 0x0F];
- *(buf++) = hex[h& 0x0F];
- }
- if (*fmt == 'x') {
- register int h = *(dp++);
- *(buf++) = hex[(h>>12)& 0x0F];
- *(buf++) = hex[(h>>8)& 0x0F];
- *(buf++) = hex[(h>>4)& 0x0F];
- *(buf++) = hex[h& 0x0F];
- }
- if (*fmt == 'b') {
- register int h = *(dp++);
- *(buf++) = hex[(h>>4)& 0x0F];
- *(buf++) = hex[h& 0x0F];
- }
- if (*fmt == 'd') {
- register int dec = *(dp++);
- p = tmp;
- if (dec < 0) {
- *(buf++) = '-';
- dec = -dec;
- }
- do {
- *(p++) = '0' + (dec%10);
- dec = dec/10;
- } while(dec);
- while ((--p) >= tmp) *(buf++) = *p;
- }
- if (*fmt == 'I') {
- buf = sprintf(buf,"%d.%d.%d.%d",
- (*(dp)>>24) & 0x00FF,
- (*(dp)>>16) & 0x00FF,
- (*(dp)>>8) & 0x00FF,
- *dp & 0x00FF);
- dp++;
- }
- if (*fmt == 'c')
- *(buf++) = *(dp++);
- if (*fmt == 's') {
- p = (char *)*dp++;
- while (*p) *(buf++) = *p++;
- }
- } else *(buf++) = *fmt;
- fmt++;
- }
- *buf = 0;
- return(buf);
-}
-
-char *sprintf(buf, fmt, data)
- char *fmt, *buf;
- int data;
-{
- return(do_printf(buf,fmt, &data));
-}
-
-printf(fmt,data)
- char *fmt;
- int data;
-{
- char buf[1024],*p;
- p = buf;
- do_printf(buf,fmt,&data);
- while (*p) {
- if (*p=='\n') putchar('\r');
- putchar(*p++);
- }
-}
-
-/**************************************************************************
-SETIP - Convert an ascii x.x.x.x to binary form
-**************************************************************************/
-setip(p, i)
- char *p;
- unsigned *i;
-{
- unsigned ip = 0;
- int val;
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- if (*p != '.') return(0);
- p++;
- ip = val;
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- if (*p != '.') return(0);
- p++;
- ip = (ip << 8) | val;
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- if (*p != '.') return(0);
- p++;
- ip = (ip << 8) | val;
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- *i = (ip << 8) | val;
- return(1);
-}
-
-getdec(ptr)
- char **ptr;
-{
- char *p = *ptr;
- int ret=0;
- if ((*p < '0') || (*p > '9')) return(-1);
- while ((*p >= '0') && (*p <= '9')) {
- ret = ret*10 + (*p - '0');
- p++;
- }
- *ptr = p;
- return(ret);
-}
-
-
-#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
-#define K_STATUS 0x64 /* keyboard status */
-#define K_CMD 0x64 /* keybd ctlr command (write-only) */
-
-#define K_OBUF_FUL 0x01 /* output buffer full */
-#define K_IBUF_FUL 0x02 /* input buffer full */
-
-#define KC_CMD_WIN 0xd0 /* read output port */
-#define KC_CMD_WOUT 0xd1 /* write output port */
-#define KB_A20 0x9f /* enable A20,
- enable output buffer full interrupt
- enable data line
- disable clock line */
-
-/*
- * Gate A20 for high memory
- */
-unsigned char x_20 = KB_A20;
-gateA20()
-{
-#ifdef IBM_L40
- outb(0x92, 0x2);
-#else IBM_L40
- while (inb(K_STATUS) & K_IBUF_FUL);
- while (inb(K_STATUS) & K_OBUF_FUL)
- (void)inb(K_RDWR);
-
- outb(K_CMD, KC_CMD_WOUT);
- while (inb(K_STATUS) & K_IBUF_FUL);
- outb(K_RDWR, x_20);
- while (inb(K_STATUS) & K_IBUF_FUL);
-#endif IBM_L40
-}
-
diff --git a/sys/i386/boot/netboot/netboot.8 b/sys/i386/boot/netboot/netboot.8
deleted file mode 100644
index 2717ec5..0000000
--- a/sys/i386/boot/netboot/netboot.8
+++ /dev/null
@@ -1,101 +0,0 @@
-.\" $FreeBSD$
-.Dd May 15, 1997
-.Dt NETBOOT 8
-.\".Os BSD 4
-.Sh NAME
-.Nm netboot
-.Nd Allows remote booting of the operating system
-.Sh SYNOPSIS
-.Nm
-.Bl -tag -width Ds
-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:\\
- :hn:ht=ether:vm=rfc1048:\\
- :rp="rootfs.ip:/rootfs/path":\\
- :T128="swapfs.ip:/swapfs/path":\\
- :T129=swapsize:\\
- :T130="root,mount,options":\\
- :T131="swap,mount,options":\\
- :ra=255.255.255.255:
- 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.
-.Bl -tag -width indent
-.It Cm sm
-indicates the subnet mask.
-.It Cm gw
-is the ip address of the gateway.
-.It Cm hn
-instructs the bootp server to send the hostname in the reply.
-.It Cm ht= Ns Ar ether
-.\.It ht=ether
-indicates that the hardware is ethernet.
-.It Cm vm= Ns Ar rfc1048
-indicates the use of rfc1048 extensions.
-.It Cm rp
-specifies where the directory mounted as the root filesystem is located.
-The IP address of the server must be specified, followed by a : and the
-directory pathname.
-.It Cm T128
-specifies where the directory containing the swap file is located.
-The IP address of the server must be specified, followed by a : and the
-directory pathname.
-The actual swapfile is a file named swap.X.Y.Z.T where X.Y.Z.T is the
-IP address of the client. If this argument is given, the swap file must exist.
-.It Cm T129
-specifies the size of the swap file, in KB. Must be specified as
-a 8 digits long hexadecimal number. 16 MB swap thus becomes
-T129=00004000. This argument is optional; if missing, the size of the
-swap file is read from the server.
-.It Cm T130
-specifies root mount options, such as soft, intr, tcp, etc.
-This argument is optional. The default is to use UDP.
-.It Cm T131
-specifies swap mount options.
-This argument is optional.
-.It Cm bf
-is the name of the kernel. If not specified, it defaults to
-"kernel".
-.It Cm ra
-is used to override the reply address.
-
-.Sh FILES
-.Bl -tag -width /usr/mdec/nb3c509.rom -compact
-.It Pa /usr/mdec/nb8390.rom
-rom image for NE1000/NE2000 cards
-.It Pa /usr/mdec/nb8390.com
-DOS executable for NE1000/NE2000 cards
-.It Pa /usr/mdec/nb3c509.rom
-rom image for 3C509 cards
-.It Pa /usr/mdec/nb3c509.com
-DOS executable for 3C509 cards
-
-.Sh SEE ALSO
-.Xr bootptab 5 ,
-.Xr bootpd 8
-
-.Sh BUGS
-To use netboot with Western Digital/SMC cards or 3C503 cards, a recompile
-is needed after a little Makefile tweaking.
diff --git a/sys/i386/boot/netboot/netboot.h b/sys/i386/boot/netboot/netboot.h
deleted file mode 100644
index 37883b4..0000000
--- a/sys/i386/boot/netboot/netboot.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/**************************************************************************
-NETBOOT - BOOTP/TFTP Bootstrap Program
-
-Author: Martin Renters
- Date: Dec/93
-
-**************************************************************************/
-
-#include <sys/types.h>
-#include <sys/reboot.h>
-#include <a.out.h>
-#include <netdb.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/mount.h>
-#include <sys/time.h>
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <nfs/nfsv2.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsdiskless.h>
-#include <machine/bootinfo.h>
-#include <machine/cpufunc.h>
-
-#define ESC 0x1B
-
-#ifndef DEFAULT_BOOTFILE
-#define DEFAULT_BOOTFILE "/kernel"
-#endif
-
-#ifndef MAX_TFTP_RETRIES
-#define MAX_TFTP_RETRIES 20
-#endif
-
-#ifndef MAX_BOOTP_RETRIES
-#define MAX_BOOTP_RETRIES 20
-#endif
-
-#ifndef MAX_ARP_RETRIES
-#define MAX_ARP_RETRIES 20
-#endif
-
-#ifndef MAX_RPC_RETRIES
-#define MAX_RPC_RETRIES 20
-#endif
-
-#ifndef TIMEOUT /* Inter-packet retry in ticks 18/sec */
-#define TIMEOUT 20
-#endif
-
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
-#define TRUE 1
-#define FALSE 0
-
-#define VENDOR_NONE 0
-#define VENDOR_WD 1
-#define VENDOR_NOVELL 2
-#define VENDOR_3COM 3
-#define VENDOR_3C509 4
-
-#define FLAG_PIO 0x01
-#define FLAG_16BIT 0x02
-#define FLAG_790 0x04
-
-#define ARP_CLIENT 0
-#define ARP_SERVER 1
-#define ARP_GATEWAY 2
-#define ARP_NS 3
-#define ARP_ROOTSERVER 4
-#define ARP_SWAPSERVER 5
-#define MAX_ARP ARP_SWAPSERVER+1
-
-#define IP 0x0800
-#define ARP 0x0806
-
-#define BOOTP_SERVER 67
-#define BOOTP_CLIENT 68
-#define TFTP 69
-#define SUNRPC 111
-
-#define RPC_SOCKET 620 /* Arbitrary */
-
-#define IP_UDP 17
-#define IP_BROADCAST 0xFFFFFFFF
-
-#define ARP_REQUEST 1
-#define ARP_REPLY 2
-
-#define BOOTP_REQUEST 1
-#define BOOTP_REPLY 2
-
-#define TAG_LEN(p) (*((p)+1))
-#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 256 /* Extended vendor field */
-
-#define BOOTP_MIN_LEN 300 /* Minimum size of bootp udp packet */
-
-#define TFTP_RRQ 1
-#define TFTP_WRQ 2
-#define TFTP_DATA 3
-#define TFTP_ACK 4
-#define TFTP_ERROR 5
-
-#define TFTP_CODE_EOF 1
-#define TFTP_CODE_MORE 2
-#define TFTP_CODE_ERROR 3
-#define TFTP_CODE_BOOT 4
-#define TFTP_CODE_CFG 5
-
-#define PROG_PORTMAP 100000
-#define PROG_NFS 100003
-#define PROG_MOUNT 100005
-
-#define MSG_CALL 0
-#define MSG_REPLY 1
-
-#define PORTMAP_LOOKUP 3
-
-#define MOUNT_ADDENTRY 1
-#define NFS_LOOKUP 4
-#define NFS_READ 6
-
-#define NFS_READ_SIZE 1024
-
-
-#define AWAIT_ARP 0
-#define AWAIT_BOOTP 1
-#define AWAIT_TFTP 2
-#define AWAIT_RPC 3
-
-struct arptable_t {
- unsigned long ipaddr;
- unsigned char node[6];
-} arptable[MAX_ARP];
-
-struct arprequest {
- unsigned short hwtype;
- unsigned short protocol;
- char hwlen;
- char protolen;
- unsigned short opcode;
- char shwaddr[6];
- char sipaddr[4];
- char thwaddr[6];
- char tipaddr[4];
-};
-
-struct iphdr {
- char verhdrlen;
- char service;
- unsigned short len;
- unsigned short ident;
- unsigned short frags;
- char ttl;
- char protocol;
- unsigned short chksum;
- char src[4];
- char dest[4];
-};
-
-struct udphdr {
- unsigned short src;
- unsigned short dest;
- unsigned short len;
- unsigned short chksum;
-};
-
-struct bootp_t {
- struct iphdr ip;
- struct udphdr udp;
- char bp_op;
- char bp_htype;
- char bp_hlen;
- char bp_hops;
- unsigned long bp_xid;
- unsigned short bp_secs;
- unsigned short unused;
- char bp_ciaddr[4];
- char bp_yiaddr[4];
- char bp_siaddr[4];
- char bp_giaddr[4];
- char bp_hwaddr[16];
- char bp_sname[64];
- char bp_file[128];
- char bp_vend[BOOTP_VENDOR_LEN];
-};
-
-struct tftp_t {
- struct iphdr ip;
- struct udphdr udp;
- unsigned short opcode;
- union {
- char rrq[512];
- struct {
- unsigned short block;
- char download[512];
- } data;
- struct {
- unsigned short block;
- } ack;
- struct {
- unsigned short errcode;
- char errmsg[512];
- } err;
- } u;
-};
-
-struct rpc_t {
- struct iphdr ip;
- struct udphdr udp;
- union {
- char data[1400];
- struct {
- long id;
- long type;
- long rstatus;
- long verifier;
- long v2;
- long astatus;
- long data[1];
- } reply;
- } u;
-};
-
-#define TFTP_MIN_PACKET_SIZE (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)
-
-/***************************************************************************
-RPC Functions
-***************************************************************************/
-#define PUTLONG(val) {\
- register int lval = val; \
- *(rpcptr++) = ((lval) >> 24); \
- *(rpcptr++) = ((lval) >> 16); \
- *(rpcptr++) = ((lval) >> 8); \
- *(rpcptr++) = (lval); \
- rpclen+=4; }
-
-char *sprintf();
diff --git a/sys/i386/boot/netboot/ns8390.c b/sys/i386/boot/netboot/ns8390.c
deleted file mode 100644
index c495d5a..0000000
--- a/sys/i386/boot/netboot/ns8390.c
+++ /dev/null
@@ -1,668 +0,0 @@
-
-/**************************************************************************
-NETBOOT - BOOTP/TFTP Bootstrap Program
-
-Author: Martin Renters
- Date: May/94
-
- This code is based heavily on David Greenman's if_ed.c driver
-
- Copyright (C) 1993-1994, David Greenman, Martin Renters.
- This software may be used, modified, copied, distributed, and sold, in
- both source and binary form provided that the above copyright and these
- terms are retained. Under no circumstances are the authors responsible for
- the proper functioning of this software, nor do the authors assume any
- responsibility for damages incurred with its use.
-
-3c503 support added by Bill Paul (wpaul@ctr.columbia.edu) on 11/15/94
-SMC8416 support added by Bill Paul (wpaul@ctr.columbia.edu) on 12/25/94
-
-**************************************************************************/
-
-DELAY(int x)
-{ volatile long a, b, l;
- for (x; x>0; x--) b=a;
-}
-
-#include "netboot.h"
-#include "ns8390.h"
-
-#ifdef _3COM_USE_AUI
-short aui=1;
-#else
-short aui=0;
-#endif
-
-unsigned short eth_nic_base;
-unsigned short eth_asic_base;
-unsigned char eth_tx_start;
-unsigned char eth_laar;
-unsigned char eth_flags;
-unsigned char eth_vendor;
-unsigned char eth_memsize;
-unsigned char *eth_bmem;
-unsigned char *eth_rmem;
-unsigned char *eth_node_addr;
-
-/**************************************************************************
-The following two variables are used externally
-**************************************************************************/
-char eth_driver[] = "ed0";
-char packet[ETHER_MAX_LEN];
-int packetlen;
-
-#ifdef INCLUDE_NE
-static unsigned short ne_base_list[]= {
-#ifdef NE_BASE
- NE_BASE,
-#endif
- 0xff80, 0xff40, 0xff00, 0xfec0,
- 0x280, 0x300, 0
-};
-#endif
-/**************************************************************************
-ETH_PROBE - Look for an adapter
-**************************************************************************/
-eth_probe()
-{
- int i;
- struct wd_board *brd;
- char *name;
- unsigned short chksum;
- unsigned char c;
-
- eth_vendor = VENDOR_NONE;
-
-#ifdef INCLUDE_WD
- /******************************************************************
- Search for WD/SMC cards
- ******************************************************************/
- for (eth_asic_base = WD_LOW_BASE; eth_asic_base <= WD_HIGH_BASE;
- eth_asic_base += 0x20) {
- chksum = 0;
- /* Check for WD/SMC card by checking ethernet address */
- if (inb(eth_asic_base+8) != 0) continue;
- if (inb(eth_asic_base+9) != 0xE0) {
- if (inb(eth_asic_base+9) != 0) continue;
- if (inb(eth_asic_base+10) != 0xC0) continue;
- }
- for (i=8; i<16; i++)
- chksum += inb(i+eth_asic_base);
- if ((chksum & 0x00FF) == 0x00FF)
- break;
- }
- if (eth_asic_base <= WD_HIGH_BASE) { /* We've found a board */
- eth_vendor = VENDOR_WD;
- eth_nic_base = eth_asic_base + WD_NIC_ADDR;
- c = inb(eth_asic_base+WD_BID); /* Get board id */
- for (brd = wd_boards; brd->name; brd++)
- if (brd->id == c) break;
- if (!brd->name) {
- printf("\r\nUnknown Ethernet type %x\r\n", c);
- return(0); /* Unknown type */
- }
- eth_flags = brd->flags;
- eth_memsize = brd->memsize;
- eth_tx_start = 0;
- if ((c == TYPE_WD8013EP) &&
- (inb(eth_asic_base + WD_ICR) & WD_ICR_16BIT)) {
- eth_flags = FLAG_16BIT;
- eth_memsize = MEM_16384;
- }
- if ((c & WD_SOFTCONFIG) && (!(eth_flags & FLAG_790))) {
- eth_bmem = (char *)(0x80000 |
- ((inb(eth_asic_base + WD_MSR) & 0x3F) << 13));
- } else
- eth_bmem = (char *)WD_DEFAULT_MEM;
- if (brd->id == TYPE_SMC8216T || brd->id == TYPE_SMC8216C) {
- (unsigned int) *(eth_bmem + 8192) = (unsigned int)0;
- if ((unsigned int) *(eth_bmem + 8192)) {
- brd += 2;
- eth_memsize = brd->memsize;
- }
- }
- outb(eth_asic_base + WD_MSR, 0x80); /* Reset */
- printf("\r\n%s base 0x%x, memory 0x%X, addr ",
- brd->name, eth_asic_base, eth_bmem);
- for (i=0; i<6; i++) {
- printf("%b",(int)(arptable[ARP_CLIENT].node[i] =
- inb(i+eth_asic_base+WD_LAR)));
- if (i < 5) printf (":");
- }
- if (eth_flags & FLAG_790) {
- outb(eth_asic_base+WD_MSR, WD_MSR_MENB);
- outb(eth_asic_base+0x04, (inb(eth_asic_base+0x04) |
- 0x80));
- outb(eth_asic_base+0x0B,
- (((unsigned)eth_bmem >> 13) & 0x0F) |
- (((unsigned)eth_bmem >> 11) & 0x40) |
- (inb(eth_asic_base+0x0B) & 0xB0));
- outb(eth_asic_base+0x04, (inb(eth_asic_base+0x04) &
- ~0x80));
- } else {
- outb(eth_asic_base+WD_MSR,
- (((unsigned)eth_bmem >> 13) & 0x3F) | 0x40);
- }
- if (eth_flags & FLAG_16BIT) {
- if (eth_flags & FLAG_790) {
- eth_laar = inb(eth_asic_base + WD_LAAR);
- outb(eth_asic_base + WD_LAAR, WD_LAAR_M16EN);
- inb(0x84);
- } else {
- outb(eth_asic_base + WD_LAAR, (eth_laar =
- WD_LAAR_M16EN | WD_LAAR_L16EN | 1));
- }
- }
- goto found_board;
- }
-#endif
-#ifdef INCLUDE_3COM
- /******************************************************************
- Search for 3Com 3c503 if no WD/SMC cards
- ******************************************************************/
- if (eth_vendor == VENDOR_NONE) {
- eth_asic_base = _3COM_BASE + _3COM_ASIC_OFFSET;
- eth_nic_base = _3COM_BASE;
- eth_vendor = VENDOR_3COM;
- /*
- * Note that we use the same settings for both 8 and 16 bit cards:
- * both have an 8K bank of memory at page 1 while only the 16 bit
- * cards have a bank at page 0.
- */
- eth_memsize = MEM_16384;
- eth_tx_start = 32;
-
- /* Check our base address */
-
- switch(inb(eth_asic_base + _3COM_BCFR)) {
- case _3COM_BCFR_300:
- if ((int)eth_nic_base != 0x300)
- return(0);
- break;
- case _3COM_BCFR_310:
- if ((int)eth_nic_base != 0x310)
- return(0);
- break;
- case _3COM_BCFR_330:
- if ((int)eth_nic_base != 0x330)
- return(0);
- break;
- case _3COM_BCFR_350:
- if ((int)eth_nic_base != 0x350)
- return(0);
- break;
- case _3COM_BCFR_250:
- if ((int)eth_nic_base != 0x250)
- return(0);
- break;
- case _3COM_BCFR_280:
- if ((int)eth_nic_base != 0x280)
- return(0);
- break;
- case _3COM_BCFR_2A0:
- if ((int)eth_nic_base != 0x2a0)
- return(0);
- break;
- case _3COM_BCFR_2E0:
- if ((int)eth_nic_base != 0x2e0)
- return(0);
- break;
- default:
- return (0);
- }
-
- /* Now get the shared memory address */
-
- switch (inb(eth_asic_base + _3COM_PCFR)) {
- case _3COM_PCFR_DC000:
- eth_bmem = (char *)0xdc000;
- break;
- case _3COM_PCFR_D8000:
- eth_bmem = (char *)0xd8000;
- break;
- case _3COM_PCFR_CC000:
- eth_bmem = (char *)0xcc000;
- break;
- case _3COM_PCFR_C8000:
- eth_bmem = (char *)0xc8000;
- break;
- default:
- return (0);
- }
-
- /* Need this to make eth_poll() happy. */
-
- eth_rmem = eth_bmem - 0x2000;
-
- /* Reset NIC and ASIC */
-
- outb (eth_asic_base + _3COM_CR , _3COM_CR_RST | _3COM_CR_XSEL);
- outb (eth_asic_base + _3COM_CR , _3COM_CR_XSEL);
-
- /* Get our ethernet address */
-
- outb(eth_asic_base + _3COM_CR, _3COM_CR_EALO | _3COM_CR_XSEL);
- printf("\r\n3Com 3c503 base 0x%x, memory 0x%X addr ",
- eth_nic_base, eth_bmem);
- for (i=0; i<6; i++) {
- printf("%b",(int)(arptable[ARP_CLIENT].node[i] =
- inb(eth_nic_base+i)));
- if (i < 5) printf (":");
- }
- outb(eth_asic_base + _3COM_CR, _3COM_CR_XSEL);
- /*
- * Initialize GA configuration register. Set bank and enable shared
- * mem. We always use bank 1.
- */
- outb(eth_asic_base + _3COM_GACFR, _3COM_GACFR_RSEL |
- _3COM_GACFR_MBS0);
-
- outb(eth_asic_base + _3COM_VPTR2, 0xff);
- outb(eth_asic_base + _3COM_VPTR1, 0xff);
- outb(eth_asic_base + _3COM_VPTR0, 0x00);
- /*
- * Clear memory and verify that it worked (we use only 8K)
- */
- bzero(eth_bmem, 0x2000);
- for(i = 0; i < 0x2000; ++i)
- if (*((eth_bmem)+i)) {
- printf ("Failed to clear 3c503 shared mem.\r\n");
- return (0);
- }
- /*
- * Initialize GA page/start/stop registers.
- */
- outb(eth_asic_base + _3COM_PSTR, eth_tx_start);
- outb(eth_asic_base + _3COM_PSPR, eth_memsize);
-
- goto found_board;
-
- }
-#endif
-#ifdef INCLUDE_NE
- /******************************************************************
- Search for NE1000/2000 if no WD/SMC or 3com cards
- ******************************************************************/
- if (eth_vendor == VENDOR_NONE) {
- char romdata[16], testbuf[32];
- char test[] = "NE1000/2000 memory";
- unsigned short *tent_base=ne_base_list;
- eth_bmem = (char *)0; /* No shared memory */
-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);
- outb(eth_nic_base + D8390_P0_RCR, D8390_RCR_MON);
- outb(eth_nic_base + D8390_P0_DCR, D8390_DCR_FT1 | D8390_DCR_LS);
- outb(eth_nic_base + D8390_P0_PSTART, MEM_8192);
- outb(eth_nic_base + D8390_P0_PSTOP, MEM_16384);
- eth_pio_write(test, 8192, sizeof(test));
- eth_pio_read(8192, testbuf, sizeof(test));
- if (!bcompare(test, testbuf, sizeof(test))) {
- eth_flags |= FLAG_16BIT;
- eth_memsize = MEM_32768;
- eth_tx_start = 64;
- outb(eth_nic_base + D8390_P0_DCR, D8390_DCR_WTS |
- D8390_DCR_FT1 | D8390_DCR_LS);
- outb(eth_nic_base + D8390_P0_PSTART, MEM_16384);
- outb(eth_nic_base + D8390_P0_PSTOP, MEM_32768);
- eth_pio_write(test, 16384, sizeof(test));
- eth_pio_read(16384, testbuf, sizeof(test));
- if (!bcompare(testbuf, test, sizeof(test)))
- if (*++tent_base)
- goto ne_again;
- else
- return (0);
- }
- eth_pio_read(0, romdata, 16);
- 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)]));
- if (i < 5) printf (":");
- }
- goto found_board;
- }
-#endif
-found_board:
- printf("\r\n");
- if (eth_vendor == VENDOR_NONE) return(0);
-
- if (eth_vendor != VENDOR_3COM) eth_rmem = eth_bmem;
- eth_node_addr = arptable[ARP_CLIENT].node;
- eth_reset();
- return(eth_vendor);
-}
-
-/**************************************************************************
-ETH_RESET - Reset adapter
-**************************************************************************/
-eth_reset()
-{
- int i;
- if (eth_flags & FLAG_790)
- outb(eth_nic_base+D8390_P0_COMMAND,
- D8390_COMMAND_PS0 | D8390_COMMAND_STP);
- else
- outb(eth_nic_base+D8390_P0_COMMAND,
- D8390_COMMAND_PS0 | D8390_COMMAND_RD2 |
- D8390_COMMAND_STP);
- if (eth_flags & FLAG_16BIT)
- outb(eth_nic_base+D8390_P0_DCR, 0x49);
- else
- outb(eth_nic_base+D8390_P0_DCR, 0x48);
- outb(eth_nic_base+D8390_P0_RBCR0, 0);
- outb(eth_nic_base+D8390_P0_RBCR1, 0);
- outb(eth_nic_base+D8390_P0_RCR, 4); /* allow broadcast frames */
- outb(eth_nic_base+D8390_P0_TCR, 2);
- outb(eth_nic_base+D8390_P0_TPSR, eth_tx_start);
- outb(eth_nic_base+D8390_P0_PSTART, eth_tx_start + D8390_TXBUF_SIZE);
- if (eth_flags & FLAG_790) outb(eth_nic_base + 0x09, 0);
- outb(eth_nic_base+D8390_P0_PSTOP, eth_memsize);
- outb(eth_nic_base+D8390_P0_BOUND, eth_tx_start + D8390_TXBUF_SIZE);
- outb(eth_nic_base+D8390_P0_ISR, 0xFF);
- outb(eth_nic_base+D8390_P0_IMR, 0);
- if (eth_flags & FLAG_790)
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1 |
- D8390_COMMAND_STP);
- else
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1 |
- D8390_COMMAND_RD2 | D8390_COMMAND_STP);
- for (i=0; i<6; i++)
- outb(eth_nic_base+D8390_P1_PAR0+i, eth_node_addr[i]);
- for (i=0; i<6; i++)
- outb(eth_nic_base+D8390_P1_MAR0+i, 0xFF);
- outb(eth_nic_base+D8390_P1_CURR, eth_tx_start + D8390_TXBUF_SIZE+1);
- if (eth_flags & FLAG_790)
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 |
- D8390_COMMAND_STA);
- else
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 |
- D8390_COMMAND_RD2 | D8390_COMMAND_STA);
- outb(eth_nic_base+D8390_P0_ISR, 0xFF);
- outb(eth_nic_base+D8390_P0_TCR, 0);
-#ifdef INCLUDE_3COM
- if (eth_vendor == VENDOR_3COM) {
- /*
- * No way to tell whether or not we're supposed to use
- * the 3Com's transceiver unless the user tells us.
- * 'aui' should have some compile time default value
- * which can be changed from the command menu.
- */
- if (aui)
- outb(eth_asic_base + _3COM_CR, 0);
- else
- outb(eth_asic_base + _3COM_CR, _3COM_CR_XSEL);
- }
-#endif
- return(1);
-}
-
-/**************************************************************************
-ETH_TRANSMIT - Transmit a frame
-**************************************************************************/
-eth_transmit(d,t,s,p)
- char *d; /* Destination */
- unsigned short t; /* Type */
- unsigned short s; /* size */
- char *p; /* Packet */
-{
- unsigned char c;
-#ifdef INCLUDE_3COM
- if (eth_vendor == VENDOR_3COM) {
- bcopy(d, eth_bmem, 6); /* dst */
- bcopy(eth_node_addr, eth_bmem+6, ETHER_ADDR_LEN); /* src */
- *(eth_bmem+12) = t>>8; /* type */
- *(eth_bmem+13) = t;
- bcopy(p, eth_bmem+14, s);
- s += 14;
- while (s < ETHER_MIN_LEN) *(eth_bmem+(s++)) = 0;
- }
-#endif
-#ifdef INCLUDE_WD
- if (eth_vendor == VENDOR_WD) { /* Memory interface */
- if (eth_flags & FLAG_16BIT) {
- outb(eth_asic_base + WD_LAAR, eth_laar | WD_LAAR_M16EN);
- inb(0x84);
- }
- if (eth_flags & FLAG_790) {
- outb(eth_asic_base + WD_MSR, WD_MSR_MENB);
- inb(0x84);
- }
- inb(0x84);
- bcopy(d, eth_bmem, 6); /* dst */
- bcopy(eth_node_addr, eth_bmem+6, ETHER_ADDR_LEN); /* src */
- *(eth_bmem+12) = t>>8; /* type */
- *(eth_bmem+13) = t;
- bcopy(p, eth_bmem+14, s);
- s += 14;
- while (s < ETHER_MIN_LEN) *(eth_bmem+(s++)) = 0;
- if (eth_flags & FLAG_790) {
- outb(eth_asic_base + WD_MSR, 0);
- inb(0x84);
- }
- if (eth_flags & FLAG_16BIT) {
- outb(eth_asic_base + WD_LAAR, eth_laar & ~WD_LAAR_M16EN);
- inb(0x84);
- }
- }
-#endif
-#ifdef INCLUDE_NE
- if (eth_vendor == VENDOR_NOVELL) { /* Programmed I/O */
- unsigned short type;
- type = (t >> 8) | (t << 8);
- eth_pio_write(d, eth_tx_start<<8, 6);
- eth_pio_write(eth_node_addr, (eth_tx_start<<8)+6, 6);
- eth_pio_write(&type, (eth_tx_start<<8)+12, 2);
- eth_pio_write(p, (eth_tx_start<<8)+14, s);
- s += 14;
- if (s < ETHER_MIN_LEN) s = ETHER_MIN_LEN;
- }
-#endif
- twiddle();
- if (eth_flags & FLAG_790)
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 |
- D8390_COMMAND_STA);
- else
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 |
- D8390_COMMAND_RD2 | D8390_COMMAND_STA);
- outb(eth_nic_base+D8390_P0_TPSR, eth_tx_start);
- outb(eth_nic_base+D8390_P0_TBCR0, s);
- outb(eth_nic_base+D8390_P0_TBCR1, s>>8);
- if (eth_flags & FLAG_790)
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 |
- D8390_COMMAND_TXP | D8390_COMMAND_STA);
- else
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 |
- D8390_COMMAND_TXP | D8390_COMMAND_RD2 |
- D8390_COMMAND_STA);
- return(0);
-}
-
-/**************************************************************************
-ETH_POLL - Wait for a frame
-**************************************************************************/
-eth_poll()
-{
- int ret = 0;
- unsigned short type = 0;
- unsigned char bound,curr,rstat;
- unsigned short len, copylen;
- unsigned short pktoff;
- unsigned char *p;
- struct ringbuffer pkthdr;
- rstat = inb(eth_nic_base+D8390_P0_RSR);
- if (rstat & D8390_RSTAT_OVER) {
- eth_reset();
- return(0);
- }
- if (!(rstat & D8390_RSTAT_PRX)) return(0);
- bound = inb(eth_nic_base+D8390_P0_BOUND)+1;
- if (bound == eth_memsize) bound = eth_tx_start + D8390_TXBUF_SIZE;
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1);
- curr = inb(eth_nic_base+D8390_P1_CURR);
- outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0);
- if (curr == eth_memsize) curr=eth_tx_start + D8390_TXBUF_SIZE;
- if (curr == bound) return(0);
- if (eth_vendor == VENDOR_WD) {
- if (eth_flags & FLAG_16BIT) {
- outb(eth_asic_base + WD_LAAR, eth_laar | WD_LAAR_M16EN);
- inb(0x84);
- }
- if (eth_flags & FLAG_790) {
- outb(eth_asic_base + WD_MSR, WD_MSR_MENB);
- inb(0x84);
- }
- inb(0x84);
- }
- pktoff = (bound << 8);
- if (eth_flags & FLAG_PIO)
- eth_pio_read(pktoff, &pkthdr, 4);
- else
- bcopy(eth_rmem + pktoff, &pkthdr, 4);
- len = pkthdr.len - 4; /* sub CRC */
- pktoff += 4;
- if (len > 1514) len = 1514;
- bound = pkthdr.bound; /* New bound ptr */
- if ( (pkthdr.status & D8390_RSTAT_PRX) && (len > 14) && (len < 1518)) {
- p = packet;
- packetlen = copylen = len;
- len = (eth_memsize << 8) - pktoff;
- if (packetlen > len) { /* We have a wrap-around */
- if (eth_flags & FLAG_PIO)
- eth_pio_read(pktoff, p, len);
- else
- bcopy(eth_rmem + pktoff, p, len);
- pktoff = (eth_tx_start + D8390_TXBUF_SIZE) << 8;
- p += len;
- copylen -= len;
- }
- if (eth_flags & FLAG_PIO)
- eth_pio_read(pktoff, p, copylen);
- else
- bcopy(eth_rmem + pktoff, p, copylen);
-
- type = (packet[12]<<8) | packet[13];
- ret = 1;
- }
- if (eth_vendor == VENDOR_WD) {
- if (eth_flags & FLAG_790) {
- outb(eth_asic_base + WD_MSR, 0);
- inb(0x84);
- }
- if (eth_flags & FLAG_16BIT) {
- outb(eth_asic_base + WD_LAAR, eth_laar &
- ~WD_LAAR_M16EN);
- inb(0x84);
- }
- inb(0x84);
- }
- if (bound == (eth_tx_start + D8390_TXBUF_SIZE))
- bound = eth_memsize;
- outb(eth_nic_base+D8390_P0_BOUND, bound-1);
- if (ret && (type == ARP)) {
- struct arprequest *arpreq;
- unsigned long reqip;
- arpreq = (struct arprequest *)&packet[ETHER_HDR_LEN];
- convert_ipaddr(&reqip, arpreq->tipaddr);
- if ((ntohs(arpreq->opcode) == ARP_REQUEST) &&
- (reqip == arptable[ARP_CLIENT].ipaddr)) {
- arpreq->opcode = htons(ARP_REPLY);
- bcopy(arpreq->sipaddr, arpreq->tipaddr, 4);
- bcopy(arpreq->shwaddr, arpreq->thwaddr, 6);
- bcopy(arptable[ARP_CLIENT].node, arpreq->shwaddr, 6);
- convert_ipaddr(arpreq->sipaddr, &reqip);
- eth_transmit(arpreq->thwaddr, ARP, sizeof(struct arprequest),
- arpreq);
- return(0);
- }
- }
- return(ret);
-}
-
-#ifdef INCLUDE_NE
-/**************************************************************************
-ETH_PIO_READ - Read a frame via Programmed I/O
-**************************************************************************/
-eth_pio_read(src, dst, cnt)
- unsigned short src;
- unsigned char *dst;
- unsigned short cnt;
-{
- if (cnt & 1) cnt++;
- outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD2 |
- D8390_COMMAND_STA);
- outb(eth_nic_base + D8390_P0_RBCR0, cnt);
- outb(eth_nic_base + D8390_P0_RBCR1, cnt>>8);
- outb(eth_nic_base + D8390_P0_RSAR0, src);
- outb(eth_nic_base + D8390_P0_RSAR1, src>>8);
- outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD0 |
- D8390_COMMAND_STA);
- if (eth_flags & FLAG_16BIT) {
- while (cnt) {
- *((unsigned short *)dst) = inw(eth_asic_base + NE_DATA);
- dst += 2;
- cnt -= 2;
- }
- }
- else {
- while (cnt--)
- *(dst++) = inb(eth_asic_base + NE_DATA);
- }
-}
-
-/**************************************************************************
-ETH_PIO_WRITE - Write a frame via Programmed I/O
-**************************************************************************/
-eth_pio_write(src, dst, cnt)
- unsigned char *src;
- unsigned short dst;
- unsigned short cnt;
-{
- outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD2 |
- D8390_COMMAND_STA);
- outb(eth_nic_base + D8390_P0_ISR, D8390_ISR_RDC);
- outb(eth_nic_base + D8390_P0_RBCR0, cnt);
- outb(eth_nic_base + D8390_P0_RBCR1, cnt>>8);
- outb(eth_nic_base + D8390_P0_RSAR0, dst);
- outb(eth_nic_base + D8390_P0_RSAR1, dst>>8);
- outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD1 |
- D8390_COMMAND_STA);
- if (eth_flags & FLAG_16BIT) {
- if (cnt & 1) cnt++; /* Round up */
- while (cnt) {
- outw(eth_asic_base + NE_DATA, *((unsigned short *)src));
- src += 2;
- cnt -= 2;
- }
- }
- else {
- while (cnt--)
- outb(eth_asic_base + NE_DATA, *(src++));
- }
- cnt = 200;
- while((inb(eth_nic_base + D8390_P0_ISR) & D8390_ISR_RDC)
- != D8390_ISR_RDC && --cnt);
-}
-#else
-/**************************************************************************
-ETH_PIO_READ - Dummy routine when NE2000 not compiled in
-**************************************************************************/
-eth_pio_read() {}
-#endif
diff --git a/sys/i386/boot/netboot/ns8390.h b/sys/i386/boot/netboot/ns8390.h
deleted file mode 100644
index 094cbae..0000000
--- a/sys/i386/boot/netboot/ns8390.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/**************************************************************************
-NETBOOT - BOOTP/TFTP Bootstrap Program
-
-Author: Martin Renters
- Date: Jun/94
-
-**************************************************************************/
-
-#define MEM_8192 32
-#define MEM_16384 64
-#define MEM_32768 128
-
-/**************************************************************************
-Western Digital/SMC Board Definitions
-**************************************************************************/
-#define WD_LOW_BASE 0x200
-#define WD_HIGH_BASE 0x3e0
-#ifndef WD_DEFAULT_MEM
-#define WD_DEFAULT_MEM 0xD0000
-#endif
-#define WD_NIC_ADDR 0x10
-
-/**************************************************************************
-Western Digital/SMC ASIC Addresses
-**************************************************************************/
-#define WD_MSR 0x00
-#define WD_ICR 0x01
-#define WD_IAR 0x02
-#define WD_BIO 0x03
-#define WD_IRR 0x04
-#define WD_LAAR 0x05
-#define WD_IJR 0x06
-#define WD_GP2 0x07
-#define WD_LAR 0x08
-#define WD_BID 0x0E
-
-#define WD_ICR_16BIT 0x01
-
-#define WD_MSR_MENB 0x40
-
-#define WD_LAAR_L16EN 0x40
-#define WD_LAAR_M16EN 0x80
-
-#define WD_SOFTCONFIG 0x20
-
-/**************************************************************************
-Western Digital/SMC Board Types
-**************************************************************************/
-#define TYPE_WD8003S 0x02
-#define TYPE_WD8003E 0x03
-#define TYPE_WD8013EBT 0x05
-#define TYPE_WD8003W 0x24
-#define TYPE_WD8003EB 0x25
-#define TYPE_WD8013W 0x26
-#define TYPE_WD8013EP 0x27
-#define TYPE_WD8013WC 0x28
-#define TYPE_WD8013EPC 0x29
-#define TYPE_SMC8216T 0x2a
-#define TYPE_SMC8216C 0x2b
-#define TYPE_SMC8416T 0x00 /* Bogus entries: the 8416 generates the */
-#define TYPE_SMC8416C 0x00 /* the same codes as the 8216. */
-#define TYPE_SMC8013EBP 0x2c
-
-#ifdef INCLUDE_WD
-struct wd_board {
- char *name;
- char id;
- char flags;
- char memsize;
-} wd_boards[] = {
- {"WD8003S", TYPE_WD8003S, 0, MEM_8192},
- {"WD8003E", TYPE_WD8003E, 0, MEM_8192},
- {"WD8013EBT", TYPE_WD8013EBT, FLAG_16BIT, MEM_16384},
- {"WD8003W", TYPE_WD8003W, 0, MEM_8192},
- {"WD8003EB", TYPE_WD8003EB, 0, MEM_8192},
- {"WD8013W", TYPE_WD8013W, FLAG_16BIT, MEM_16384},
- {"WD8003EP/WD8013EP",
- TYPE_WD8013EP, 0, MEM_8192},
- {"WD8013WC", TYPE_WD8013WC, FLAG_16BIT, MEM_16384},
- {"WD8013EPC", TYPE_WD8013EPC, FLAG_16BIT, MEM_16384},
- {"SMC8216T", TYPE_SMC8216T, FLAG_16BIT | FLAG_790, MEM_16384},
- {"SMC8216C", TYPE_SMC8216C, FLAG_16BIT | FLAG_790, MEM_16384},
- {"SMC8416T", TYPE_SMC8416T, FLAG_16BIT | FLAG_790, MEM_8192},
- {"SMC8416C/BT", TYPE_SMC8416C, FLAG_16BIT | FLAG_790, MEM_8192},
- {"SMC8013EBP", TYPE_SMC8013EBP,FLAG_16BIT, MEM_16384},
- {NULL, 0, 0}
-};
-#endif
-/**************************************************************************
-3com 3c503 definitions
-**************************************************************************/
-
-#ifndef _3COM_BASE
-#define _3COM_BASE 0x300
-#endif
-
-#define _3COM_TX_PAGE_OFFSET_8BIT 0x20
-#define _3COM_TX_PAGE_OFFSET_16BIT 0x0
-#define _3COM_RX_PAGE_OFFSET_16BIT 0x20
-
-#define _3COM_ASIC_OFFSET 0x400
-#define _3COM_NIC_OFFSET 0x0
-
-#define _3COM_PSTR 0
-#define _3COM_PSPR 1
-
-#define _3COM_BCFR 3
-#define _3COM_BCFR_2E0 0x01
-#define _3COM_BCFR_2A0 0x02
-#define _3COM_BCFR_280 0x04
-#define _3COM_BCFR_250 0x08
-#define _3COM_BCFR_350 0x10
-#define _3COM_BCFR_330 0x20
-#define _3COM_BCFR_310 0x40
-#define _3COM_BCFR_300 0x80
-#define _3COM_PCFR 4
-#define _3COM_PCFR_C8000 0x10
-#define _3COM_PCFR_CC000 0x20
-#define _3COM_PCFR_D8000 0x40
-#define _3COM_PCFR_DC000 0x80
-#define _3COM_CR 6
-#define _3COM_CR_RST 0x01 /* Reset GA and NIC */
-#define _3COM_CR_XSEL 0x02 /* Transceiver select. BNC=1(def) AUI=0 */
-#define _3COM_CR_EALO 0x04 /* window EA PROM 0-15 to I/O base */
-#define _3COM_CR_EAHI 0x08 /* window EA PROM 16-31 to I/O base */
-#define _3COM_CR_SHARE 0x10 /* select interrupt sharing option */
-#define _3COM_CR_DBSEL 0x20 /* Double buffer select */
-#define _3COM_CR_DDIR 0x40 /* DMA direction select */
-#define _3COM_CR_START 0x80 /* Start DMA controller */
-#define _3COM_GACFR 5
-#define _3COM_GACFR_MBS0 0x01
-#define _3COM_GACFR_MBS1 0x02
-#define _3COM_GACFR_MBS2 0x04
-#define _3COM_GACFR_RSEL 0x08 /* enable shared memory */
-#define _3COM_GACFR_TEST 0x10 /* for GA testing */
-#define _3COM_GACFR_OWS 0x20 /* select 0WS access to GA */
-#define _3COM_GACFR_TCM 0x40 /* Mask DMA interrupts */
-#define _3COM_GACFR_NIM 0x80 /* Mask NIC interrupts */
-#define _3COM_STREG 7
-#define _3COM_STREG_REV 0x07 /* GA revision */
-#define _3COM_STREG_DIP 0x08 /* DMA in progress */
-#define _3COM_STREG_DTC 0x10 /* DMA terminal count */
-#define _3COM_STREG_OFLW 0x20 /* Overflow */
-#define _3COM_STREG_UFLW 0x40 /* Underflow */
-#define _3COM_STREG_DPRDY 0x80 /* Data port ready */
-#define _3COM_IDCFR 8
-#define _3COM_IDCFR_DRQ0 0x01 /* DMA request 1 select */
-#define _3COM_IDCFR_DRQ1 0x02 /* DMA request 2 select */
-#define _3COM_IDCFR_DRQ2 0x04 /* DMA request 3 select */
-#define _3COM_IDCFR_UNUSED 0x08 /* not used */
-#define _3COM_IDCFR_IRQ2 0x10 /* Interrupt request 2 select */
-#define _3COM_IDCFR_IRQ3 0x20 /* Interrupt request 3 select */
-#define _3COM_IDCFR_IRQ4 0x40 /* Interrupt request 4 select */
-#define _3COM_IDCFR_IRQ5 0x80 /* Interrupt request 5 select */
-#define _3COM_IRQ2 2
-#define _3COM_IRQ3 3
-#define _3COM_IRQ4 4
-#define _3COM_IRQ5 5
-#define _3COM_DAMSB 9
-#define _3COM_DALSB 0x0a
-#define _3COM_VPTR2 0x0b
-#define _3COM_VPTR1 0x0c
-#define _3COM_VPTR0 0x0d
-#define _3COM_RFMSB 0x0e
-#define _3COM_RFLSB 0x0f
-
-/**************************************************************************
-NE1000/2000 definitions
-**************************************************************************/
-#ifndef NE_BASE
-#define NE_BASE 0x320
-#endif
-#define NE_ASIC_OFFSET 0x10
-#define NE_RESET 0x0F /* Used to reset card */
-#define NE_DATA 0x00 /* Used to read/write NIC mem */
-
-/**************************************************************************
-8390 Register Definitions
-**************************************************************************/
-#define D8390_P0_COMMAND 0x00
-#define D8390_P0_PSTART 0x01
-#define D8390_P0_PSTOP 0x02
-#define D8390_P0_BOUND 0x03
-#define D8390_P0_TSR 0x04
-#define D8390_P0_TPSR 0x04
-#define D8390_P0_TBCR0 0x05
-#define D8390_P0_TBCR1 0x06
-#define D8390_P0_ISR 0x07
-#define D8390_P0_RSAR0 0x08
-#define D8390_P0_RSAR1 0x09
-#define D8390_P0_RBCR0 0x0A
-#define D8390_P0_RBCR1 0x0B
-#define D8390_P0_RSR 0x0C
-#define D8390_P0_RCR 0x0C
-#define D8390_P0_TCR 0x0D
-#define D8390_P0_DCR 0x0E
-#define D8390_P0_IMR 0x0F
-#define D8390_P1_COMMAND 0x00
-#define D8390_P1_PAR0 0x01
-#define D8390_P1_PAR1 0x02
-#define D8390_P1_PAR2 0x03
-#define D8390_P1_PAR3 0x04
-#define D8390_P1_PAR4 0x05
-#define D8390_P1_PAR5 0x06
-#define D8390_P1_CURR 0x07
-#define D8390_P1_MAR0 0x08
-
-#define D8390_COMMAND_PS0 0x0 /* Page 0 select */
-#define D8390_COMMAND_PS1 0x40 /* Page 1 select */
-#define D8390_COMMAND_PS2 0x80 /* Page 2 select */
-#define D8390_COMMAND_RD2 0x20 /* Remote DMA control */
-#define D8390_COMMAND_RD1 0x10
-#define D8390_COMMAND_RD0 0x08
-#define D8390_COMMAND_TXP 0x04 /* transmit packet */
-#define D8390_COMMAND_STA 0x02 /* start */
-#define D8390_COMMAND_STP 0x01 /* stop */
-
-#define D8390_RCR_MON 0x20 /* monitor mode */
-
-#define D8390_DCR_FT1 0x40
-#define D8390_DCR_LS 0x08 /* Loopback select */
-#define D8390_DCR_WTS 0x01 /* Word transfer select */
-
-#define D8390_ISR_PRX 0x01 /* successful recv */
-#define D8390_ISR_PTX 0x02 /* successful xmit */
-#define D8390_ISR_RXE 0x04 /* receive error */
-#define D8390_ISR_TXE 0x08 /* transmit error */
-#define D8390_ISR_OVW 0x10 /* Overflow */
-#define D8390_ISR_CNT 0x20 /* Counter overflow */
-#define D8390_ISR_RDC 0x40 /* Remote DMA complete */
-#define D8390_ISR_RST 0x80 /* reset */
-
-#define D8390_RSTAT_PRX 0x01 /* successful recv */
-#define D8390_RSTAT_CRC 0x02 /* CRC error */
-#define D8390_RSTAT_FAE 0x04 /* Frame alignment error */
-#define D8390_RSTAT_OVER 0x08 /* overflow */
-
-#define D8390_TXBUF_SIZE 6
-#define D8390_RXBUF_END 32
-#define D8390_PAGE_SIZE 256
-
-struct ringbuffer {
- unsigned char status;
- unsigned char bound;
- unsigned short len;
-};
diff --git a/sys/i386/boot/netboot/opt_nfs.h b/sys/i386/boot/netboot/opt_nfs.h
deleted file mode 100644
index 7cec462..0000000
--- a/sys/i386/boot/netboot/opt_nfs.h
+++ /dev/null
@@ -1 +0,0 @@
-#define NFS 1
diff --git a/sys/i386/boot/netboot/rpc.c b/sys/i386/boot/netboot/rpc.c
deleted file mode 100644
index dd3186f..0000000
--- a/sys/i386/boot/netboot/rpc.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/***********************************************************************
-
-Remote Procedure Call Support Routines
-
-Author: Martin Renters
- Date: Oct/1994
-
-***********************************************************************/
-
-#include "netboot.h"
-
-int rpc_id;
-extern char packet[];
-extern struct nfs_diskless nfsdiskless;
-extern int hostnamelen;
-/***************************************************************************
-
-RPCLOOKUP: Lookup RPC Port numbers
-
-***************************************************************************/
-rpclookup(addr, prog, ver)
- int addr, prog, ver;
-{
- struct rpc_t buf, *rpc;
- char *rpcptr;
- int retries = MAX_RPC_RETRIES;
- rpcptr = sprintf(&buf.u.data,"%L%L%L%L%L%L%L%L%L%L%L%L%L%L",
- rpc_id, MSG_CALL, 2, PROG_PORTMAP, 2, PORTMAP_LOOKUP,
- 0, 0, 0, 0, prog, ver, IP_UDP, 0);
- while(retries--) {
- udp_transmit(arptable[addr].ipaddr, RPC_SOCKET,
- SUNRPC, rpcptr - (char *)&buf, &buf);
- if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
- if (rpc->u.reply.rstatus == rpc->u.reply.verifier ==
- rpc->u.reply.astatus == 0)
- return(ntohl(rpc->u.reply.data[0]));
- else {
- rpc_err(rpc);
- return(-1);
- }
- }
- }
- return(-1);
-}
-
-/***************************************************************************
-
-NFS_MOUNT: Mount an NFS Filesystem
-
-***************************************************************************/
-nfs_mount(server, port, path, fh)
- int server;
- int port;
- char *path;
- char *fh;
-{
- struct rpc_t buf, *rpc;
- char *rpcptr;
- int retries = MAX_RPC_RETRIES;
- rpcptr = sprintf(&buf.u.data,"%L%L%L%L%L%L%L%L%L%S%L%L%L%L%L%L%L%S",
- rpc_id, MSG_CALL, 2, PROG_MOUNT, 1, MOUNT_ADDENTRY,
- 1, hostnamelen + 28,0,&nfsdiskless.my_hostnam,0,0,2,0,0,0,0,
- path);
- while(retries--) {
- udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
- port, rpcptr - (char *)&buf, &buf);
- if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
- if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
- rpc->u.reply.astatus || rpc->u.reply.data[0]) {
- rpc_err(rpc);
- return(-(ntohl(rpc->u.reply.data[0])));
- } else {
- bcopy(&rpc->u.reply.data[1],fh, 32);
- return(0);
- }
- }
- }
- return(-1);
-}
-
-
-/***************************************************************************
-
-NFS_LOOKUP: Lookup Pathname
-
-***************************************************************************/
-nfs_lookup(server, port, fh, path, file_fh, sizep)
- int server;
- int port;
- char *fh;
- char *path;
- char *file_fh;
- int *sizep;
-{
- struct rpc_t buf, *rpc;
- char *rpcptr;
- int retries = MAX_RPC_RETRIES;
- rpcptr = sprintf(&buf.u.data,"%L%L%L%L%L%L%L%L%L%S%L%L%L%L%L%L%L%M%S",
- rpc_id, MSG_CALL, 2, PROG_NFS, 2, NFS_LOOKUP,
- 1, hostnamelen + 28,0,&nfsdiskless.my_hostnam,0,0,2,0,0,0,0,
- 32, fh, path);
- while(retries--) {
- udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
- port, rpcptr - (char *)&buf, &buf);
- if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
- if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
- rpc->u.reply.astatus || rpc->u.reply.data[0]) {
- rpc_err(rpc);
- return(-(ntohl(rpc->u.reply.data[0])));
- } else {
- bcopy(&rpc->u.reply.data[1],file_fh, 32);
- if (sizep)
- *sizep = ntohl(rpc->u.reply.data[14]);
- return(0);
- }
- }
- }
- return(-1);
-}
-
-/***************************************************************************
-
-NFS_READ: Read File
-
-***************************************************************************/
-nfs_read(server, port, fh, offset, len, buffer)
- int server;
- int port;
- char *fh;
- int offset, len;
- char *buffer;
-{
- struct rpc_t buf, *rpc;
- char *rpcptr;
- int retries = MAX_RPC_RETRIES;
- int rlen;
- rpcptr = sprintf(&buf.u.data,
- "%L%L%L%L%L%L%L%L%L%S%L%L%L%L%L%L%L%M%L%L%L",
- rpc_id, MSG_CALL, 2, PROG_NFS, 2, NFS_READ,
- 1, hostnamelen + 28,0,&nfsdiskless.my_hostnam,0,0,2,0,0,0,0,
- 32, fh, offset, len, 0);
- while(retries--) {
- udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
- port, rpcptr - (char *)&buf, &buf);
- if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
- rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
- if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
- rpc->u.reply.astatus || rpc->u.reply.data[0]) {
- rpc_err(rpc);
- return(-(ntohl(rpc->u.reply.data[0])));
- } else {
- rlen = ntohl(rpc->u.reply.data[18]);
- if (len < rlen) rlen = len;
- if (len > rlen) printf("short read\r\n");
- bcopy(&rpc->u.reply.data[19], buffer, rlen);
- return(rlen);
- }
- }
- }
- return(-1);
-}
-
-/***************************************************************************
-
-RPC_ERR - Print RPC Errors
-
-***************************************************************************/
-rpc_err(rpc)
- struct rpc_t *rpc;
-{
- int err = ntohl(rpc->u.reply.data[0]);
- printf("***RPC Error: (%d,%d,%d):\r\n ",
- ntohl(rpc->u.reply.rstatus),
- ntohl(rpc->u.reply.verifier),
- ntohl(rpc->u.reply.astatus));
-}
-
-nfs_err(err)
- int err;
-{
- err = -err;
- if (err == NFSERR_PERM) printf("Not owner");
- else if (err == NFSERR_NOENT) printf("No such file or directory");
- else if (err == NFSERR_ACCES) printf("Permission denied");
- else printf("Error %d",err);
- printf("\r\n");
-}
diff --git a/sys/i386/boot/netboot/start2.S b/sys/i386/boot/netboot/start2.S
deleted file mode 100644
index f59516e..0000000
--- a/sys/i386/boot/netboot/start2.S
+++ /dev/null
@@ -1,447 +0,0 @@
-
-#define STACKADDR 0xe000 /* Needs to be end of bss + stacksize */
-#define KERN_CODE_SEG 0x08
-#define KERN_DATA_SEG 0x10
-#define REAL_MODE_CSEG 0x18
-#define REAL_MODE_DSEG 0x20
-#define CR0_PE 1
-
-#define opsize .byte 0x66
-#define addrsize .byte 0x67
-
-/* At entry, the processor is in 16 bit real mode and the code is being
- * executed from an address it was not linked to. Code must be pic and
- * 32 bit sensitive until things are fixed up.
- */
-#ifdef BOOTROM
- .word 0xaa55 /* bios extension signature */
- .byte (ROMSIZE>>9) /* no. of 512B blocks */
- jmp 1f /* enter from bios here */
- .byte 0 /* checksum */
-#ifdef PCI
- .ascii "FreeBSD boot ROM.." /* 18 bytes total */
- .word 0x1a
-/* PCI rom data structure format */
- .ascii "PCIR" /* signature */
- .word PCI_VENDOR /* vendor ID */
- .word PCI_DEVICE /* device ID */
- .word 0 /* vital product data */
- .word 0x0018 /* PCI data structure */
- .byte 0 /* PCI data struct. rev -- 0 */
- .byte PCI_CLASS /* Class code */
- .word (ROMSIZE>>9) /* no. of 512B blocks */
- .byte 0,0 /* rev. level */
- .byte 0 /* code type - 0 =x86 */
- .byte 0x80 /* indicator of last block */
- .word 0 /* reserved */
-#endif
-1: push %eax
- push %ds
- xor %eax,%eax
- mov %ax,%ds
- .byte 0xa1 /* MOV 0x304,%ax */
- .word 0x304
- .byte 0x3d /* CMP $0x4d52, %ax == 'MR' */
- .word 0x4d52
- jz 2f
- .byte 0xa1 /* MOV 0x64, %ax */
- .word 0x64
- .byte 0xa3 /* MOV %ax, 0x300 */
- .word 0x300
- .byte 0xa1 /* MOV 0x66, %ax */
- .word 0x66
- .byte 0xa3 /* MOV %ax, 0x302 */
- .word 0x302
- .byte 0xb8 /* MOV $_start-RELOCADDR, %ax */
- .word (_start-RELOC)
- .byte 0xa3 /* MOV %ax, 0x64 */
- .word 0x64
- mov %cs,%ax
- .byte 0xa3 /* MOV %ax, 0x66 */
- .word 0x66
- .byte 0xb8 /* MOV 'MR',%ax */
- .word 0x4d52
- .byte 0xa3 /* MOV %ax, 0x304 */
- .word 0x304
-2: pop %ds
- pop %eax
- lret
-#endif
-
-/**************************************************************************
-START - Where all the fun begins....
-**************************************************************************/
- .globl _start
-_start:
- cli
- cld
-#ifdef BOOTROM /* relocate ourselves */
- xor %esi, %esi /* zero for ROMs */
-#else
- .byte 0xbe /* MOV $0x100,%si -- 100h for .COM */
- .word 0x100
-#endif
- xor %edi,%edi
- .byte 0xb8 /* MOV $RELOCADDR>>4, %ax */
- .word (RELOC>>4)
- mov %ax, %es
- .byte 0xb9 /* MOV $ROMSIZE, %cx */
- .word ROMSIZE
- cs
- rep
- movsb
- opsize
- ljmp $(RELOC>>4),$1f-RELOC /* Jmp to RELOC:1f */
-1:
- nop
- mov %cs,%ax
- mov %ax,%ds
- mov %ax,%es
- mov %ax,%ss
- .byte 0xb8 /* MOV $STACKADDR, %ax */
- .word STACKADDR
- mov %eax,%esp
- opsize
- call _real_to_prot
- call _main
- .globl _exit
-_exit:
- call _prot_to_real
-#ifdef BOOTROM
- xor %eax,%eax
- mov %ax,%ds
- .byte 0xa1 /* MOV 0x302, %ax */
- .word 0x302
- push %eax
- .byte 0xa1 /* MOV 0x300, %ax */
- .word 0x300
- push %eax
- lret
-#else
- int $0x19
-#endif
-
-/**************************************************************************
-CURRTICKS - Get Time
-**************************************************************************/
- .globl _currticks
-_currticks:
- push %ebp
- mov %esp,%ebp
- push %ebx
- push %esi
- push %edi
- xor %edx,%edx
- call _prot_to_real
- xor %eax,%eax
- int $0x1a
- opsize
- call _real_to_prot
- xor %eax,%eax
- shl $16,%ecx
- mov %edx,%eax
- or %ecx,%eax
- pop %edi
- pop %esi
- pop %ebx
- pop %ebp
- ret
-
-/**************************************************************************
-PUTCHAR - Print a character
-**************************************************************************/
- .globl _putchar
-_putchar:
- push %ebp
- mov %esp,%ebp
- push %ebx
- push %esi
- push %edi
- movb 8(%ebp),%cl
- call _prot_to_real
- opsize
- mov $1,%ebx
- movb $0x0e,%ah
- movb %cl,%al
- int $0x10
- opsize
- call _real_to_prot
- pop %edi
- pop %esi
- pop %ebx
- pop %ebp
- ret
-
-/**************************************************************************
-GETCHAR - Get a character
-**************************************************************************/
- .globl _getchar
-_getchar:
- push %ebp
- mov %esp,%ebp
- push %ebx
- push %esi
- push %edi
- call _prot_to_real
- movb $0x0,%ah
- int $0x16
- movb %al,%bl
- opsize
- call _real_to_prot
- xor %eax,%eax
- movb %bl,%al
- pop %edi
- pop %esi
- pop %ebx
- pop %ebp
- ret
-
-/**************************************************************************
-ISKEY - Check for keyboard interrupt
-**************************************************************************/
- .globl _iskey
-_iskey:
- push %ebp
- mov %esp,%ebp
- push %ebx
- push %esi
- push %edi
- call _prot_to_real
- xor %ebx,%ebx
- movb $0x1,%ah
- int $0x16
- opsize
- jz 1f
- movb %al,%bl
-1:
- opsize
- call _real_to_prot
- xor %eax,%eax
- movb %bl,%al
- pop %edi
- pop %esi
- pop %ebx
- pop %ebp
- ret
-
-
-/*
- * C library -- _setjmp, _longjmp
- *
- * longjmp(a,v)
- * will generate a "return(v)" from the last call to
- * setjmp(a)
- * by restoring registers from the stack.
- * The previous signal state is restored.
- */
-
- .globl _setjmp
-_setjmp:
- movl 4(%esp),%ecx
- movl 0(%esp),%edx
- movl %edx, 0(%ecx)
- movl %ebx, 4(%ecx)
- movl %esp, 8(%ecx)
- movl %ebp,12(%ecx)
- movl %esi,16(%ecx)
- movl %edi,20(%ecx)
- movl %eax,24(%ecx)
- movl $0,%eax
- ret
-
- .globl _longjmp
-_longjmp:
- movl 4(%esp),%edx
- movl 8(%esp),%eax
- movl 0(%edx),%ecx
- movl 4(%edx),%ebx
- movl 8(%edx),%esp
- movl 12(%edx),%ebp
- movl 16(%edx),%esi
- movl 20(%edx),%edi
- cmpl $0,%eax
- jne 1f
- movl $1,%eax
-1: movl %ecx,0(%esp)
- ret
-
-/**************************************************************************
-___MAIN - Dummy to keep GCC happy
-**************************************************************************/
- .globl ___main
-___main:
- ret
-
-/**************************************************************************
-REAL_TO_PROT - Go from REAL mode to Protected Mode
-**************************************************************************/
- .globl _real_to_prot
-_real_to_prot:
- cli
- cs
- addrsize
- lgdt gdtarg-RELOC
- mov %cr0, %eax
- opsize
- or $CR0_PE, %eax
- mov %eax, %cr0 /* turn on protected mode */
-
- /* jump to relocation, flush prefetch queue, and reload %cs */
- opsize
- ljmp $KERN_CODE_SEG, $1f
-1:
- /* reload other segment registers */
- movl $KERN_DATA_SEG, %eax
- movl %ax, %ds
- movl %ax, %es
- movl %ax, %ss
- add $RELOC,%esp /* Fix up stack pointer */
- pop %eax /* Fix up return Address */
- add $RELOC,%eax
- push %eax
- ret
-
-
-/**************************************************************************
-PROT_TO_REAL - Go from Protected Mode to REAL Mode
-**************************************************************************/
- .globl _prot_to_real
-_prot_to_real:
- pop %eax
- sub $RELOC,%eax /* Adjust return address */
- push %eax
- sub $RELOC,%esp /* Adjust stack pointer */
-
- /* Prepare %ax while we're still in a mode that gas understands. */
- movw $REAL_MODE_DSEG, %ax
-
- ljmp $REAL_MODE_CSEG, $1f-RELOC /* jump to a 16 bit segment */
-1:
- mov %ax, %ds
- mov %ax, %ss
- mov %ax, %es
- mov %ax, %fs
-
- /* clear the PE bit of CR0 */
- mov %cr0, %eax
- opsize
- andl $0!CR0_PE, %eax
- mov %eax, %cr0
-
- /* make intersegment jmp to flush the processor pipeline
- * and reload CS register
- */
- opsize
- ljmp $(RELOC)>>4, $2f-RELOC
-2:
- /* we are in real mode now
- * set up the real mode segment registers : DS, SS, ES
- */
- mov %cs, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %ss
- sti
- opsize
- ret
-
-/**************************************************************************
-GET DISK GEOMETRY INFO
-**************************************************************************/
-
-/*
- *
- * get_diskinfo(): return a word that represents the
- * max number of sectors and heads and drives for this device
- *
- */
-
- .globl _get_diskinfo
-_get_diskinfo:
- push %ebp
- mov %esp, %ebp
- push %ebx
- push %esi
- push %edi
-
- movb 0x8(%ebp), %dl /* diskinfo(drive #) */
- call _prot_to_real /* enter real mode */
-
- movb $0x8, %ah /* ask for disk info */
-
- sti
- int $0x13
- cli
-
- jnc ok
- /*
- * Urk. Call failed. It is not supported for floppies by old BIOS's.
- * Guess it's a 15-sector floppy.
- */
- subb %ah, %ah /* %ax = 0 */
- movb %al, %al
- movb %ah, %bh /* %bh = 0 */
- movb $2, %bl /* %bl bits 0-3 = drive type,
- bit 2 = 1.2M */
- movb $79, %ch /* max track */
- movb $15, %cl /* max sector */
- movb $1, %dh /* max head */
- movb $1, %dl /* # floppy drives installed */
- /* es:di = parameter table */
- /* carry = 0 */
-ok:
-
- opsize
- call _real_to_prot /* back to protected mode */
-
- /*
- * form a longword representing all this gunk:
- * 6 bit zero
- * 10 bit max cylinder (0 based)
- * 8 bit max head (0 based)
- * 2 bit zero
- * 6 bit max sector (1 based) = # sectors
- */
- movb %cl, %al /* Upper two bits of cylinder count */
- andl $192,%eax
- leal 0(,%eax,4),%eax /* << 2 */
- movb %ch, %al /* Lower 8 bits */
- sall $16,%eax /* << 16 */
- movb %dh, %ah /* max head */
- andb $0x3f, %cl /* mask of cylinder gunk */
- movb %cl, %al /* max sector (and # sectors) */
-
- pop %edi
- pop %esi
- pop %ebx
- pop %ebp
- ret
-
-/**************************************************************************
-GLOBAL DESCRIPTOR TABLE
-**************************************************************************/
- .align 4
-gdt:
- .word 0, 0
- .byte 0, 0x00, 0x00, 0
-
- /* code segment */
- .word 0xffff, 0
- .byte 0, 0x9f, 0xcf, 0
-
- /* data segment */
- .word 0xffff, 0
- .byte 0, 0x93, 0xcf, 0
-
- /* 16 bit real mode code segment */
- .word 0xffff, RELOC & 0xffff
- .byte (RELOC>>16), 0x9b, 0x00, (RELOC>>24)
-
- /* 16 bit real mode data segment */
- .word 0xffff, RELOC & 0xffff
- .byte (RELOC>>16), 0x93, 0x00, (RELOC>>24)
-
- .align 4
-gdtarg:
- .word 0x27 /* limit */
- .long gdt /* addr */
OpenPOWER on IntegriCloud