Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/sommerfeld_i386mp_1]: src/sys/arch/i386/stand/pxeboot Add a PXE boot loa...



details:   https://anonhg.NetBSD.org/src/rev/d6d9c467c462
branches:  sommerfeld_i386mp_1
changeset: 482488:d6d9c467c462
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Feb 16 03:37:41 2002 +0000

description:
Add a PXE boot loader.  PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.

diffstat:

 sys/arch/i386/stand/pxeboot/conf.c    |   89 +++++
 sys/arch/i386/stand/pxeboot/pxe.h     |  527 ++++++++++++++++++++++++++++++++++
 sys/arch/i386/stand/pxeboot/pxeboot.h |   55 +++
 sys/arch/i386/stand/pxeboot/version   |    7 +
 4 files changed, 678 insertions(+), 0 deletions(-)

diffs (truncated from 694 to 300 lines):

diff -r fd22a4e8652a -r d6d9c467c462 sys/arch/i386/stand/pxeboot/conf.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/pxeboot/conf.c        Sat Feb 16 03:37:41 2002 +0000
@@ -0,0 +1,89 @@
+/*     $NetBSD: conf.c,v 1.1.2.2 2002/02/16 03:37:41 thorpej Exp $     */
+
+/*
+ * Copyright 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed for the NetBSD Project by
+ *     Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <stand.h>
+#ifdef SUPPORT_NFS
+#include <nfs.h>
+#endif
+#ifdef SUPPORT_TFTP
+#include <tftp.h>
+#endif
+#include <dev_net.h>
+
+#include "pxeboot.h"
+
+#ifdef SUPPORT_NFS
+struct fs_ops file_system_nfs = {
+       nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat
+};
+#endif
+
+#ifdef SUPPORT_TFTP
+struct fs_ops file_system_tftp = {
+       tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat
+};
+#endif
+
+struct pxeboot_fstab pxeboot_fstab[] = {
+#ifdef SUPPORT_NFS
+       { "nfs", &file_system_nfs },
+#endif
+#ifdef SUPPORT_TFTP
+       { "tftp", &file_system_tftp },
+#endif
+};
+int npxeboot_fstab = sizeof(pxeboot_fstab) / sizeof(pxeboot_fstab[0]);
+
+/* Filled in in devopen(). */
+struct fs_ops file_system[1];
+int nfsys = 1;
+
+struct devsw devsw[] = {
+       { "net", net_strategy, net_open, net_close, net_ioctl },
+};
+int ndevs = sizeof(devsw) / sizeof(devsw[0]);
+
+extern struct netif_driver pxe_netif_driver;
+
+struct netif_driver *netif_drivers[] = {
+       &pxe_netif_driver,
+};
+int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]);
diff -r fd22a4e8652a -r d6d9c467c462 sys/arch/i386/stand/pxeboot/pxe.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/pxeboot/pxe.h Sat Feb 16 03:37:41 2002 +0000
@@ -0,0 +1,527 @@
+/*     $NetBSD: pxe.h,v 1.1.2.2 2002/02/16 03:37:41 thorpej Exp $      */
+
+/*
+ * Copyright (c) 2000 Alfred Perlstein <alfred%freebsd.org@localhost>
+ * All rights reserved.
+ * Copyright (c) 2000 Paul Saab <ps%freebsd.org@localhost>
+ * All rights reserved.
+ * Copyright (c) 2000 John Baldwin <jhb%freebsd.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Note that these structures and types are named according to
+ * the Intel PXE documentation.
+ */
+
+#define        S_SIZE(s)       s, sizeof(s) - 1
+
+#define        IP_STR          "%d.%d.%d.%d"
+#define        IP_ARGS(ip)                                     \
+       (int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
+       (int)(ip >> 8) & 0xff, (int)ip & 0xff
+
+#define        MAC_STR         "%02x:%02x:%02x:%02x:%02x:%02x"
+#define        MAC_ARGS(mac)                                   \
+       mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] 
+
+typedef struct {
+       uint16_t                offset;
+       uint16_t                segment;
+} SEGOFF16_t __attribute__((__packed__));
+
+typedef struct {
+       uint16_t                Seg_Addr;
+       uint32_t                Phy_Addr;
+       uint16_t                Seg_Size;
+} SEGDESC_t __attribute__((__packed__));
+
+typedef        uint16_t                SEGSEL_t;
+typedef        uint16_t                PXENV_STATUS_t;
+typedef        uint32_t                IP4_t;
+typedef        uint32_t                ADDR32_t;
+typedef        uint16_t                UDP_PORT_t;
+
+#define        MAC_ADDR_LEN            16
+typedef        uint8_t                 MAC_ADDR[MAC_ADDR_LEN];
+
+/* PXENV+ */
+typedef struct {
+       uint8_t         Signature[6];   /* 'PXENV+' */
+       uint16_t        Version;        /* MSB = major, LSB = minor */
+       uint8_t         Length;         /* structure length */
+       uint8_t         Checksum;       /* checksum pad */
+       SEGOFF16_t      RMEntry;        /* SEG:OFF to PXE entry point */
+       /* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
+       uint32_t        PMOffset;       /* Protected mode entry */
+       SEGSEL_t        PMSelector;     /* Protected mode selector */
+       SEGSEL_t        StackSeg;       /* Stack segment address */
+       uint16_t        StackSize;      /* Stack segment size (bytes) */
+       SEGSEL_t        BC_CodeSeg;     /* BC Code segment address */
+       uint16_t        BC_CodeSize;    /* BC Code segment size (bytes) */
+       SEGSEL_t        BC_DataSeg;     /* BC Data segment address */
+       uint16_t        BC_DataSize;    /* BC Data segment size (bytes) */
+       SEGSEL_t        UNDIDataSeg;    /* UNDI Data segment address */
+       uint16_t        UNDIDataSize;   /* UNDI Data segment size (bytes) */
+       SEGSEL_t        UNDICodeSeg;    /* UNDI Code segment address */
+       uint16_t        UNDICodeSize;   /* UNDI Code segment size (bytes) */
+       SEGOFF16_t      PXEPtr;         /* SEG:OFF to !PXE struct, 
+                                          only present when Version > 2.1 */
+} __attribute__((__packed__)) pxenv_t;
+
+/* !PXE */
+typedef struct {
+       uint8_t         Signature[4];
+       uint8_t         StructLength;
+       uint8_t         StructCksum;
+       uint8_t         StructRev;
+       uint8_t         reserved_1;
+       SEGOFF16_t      UNDIROMID;
+       SEGOFF16_t      BaseROMID;
+       SEGOFF16_t      EntryPointSP;
+       SEGOFF16_t      EntryPointESP;
+       SEGOFF16_t      StatusCallout;
+       uint8_t         reserved_2;
+       uint8_t         SegDescCn;
+       SEGSEL_t        FirstSelector;
+       SEGDESC_t       Stack;
+       SEGDESC_t       UNDIData;
+       SEGDESC_t       UNDICode;
+       SEGDESC_t       UNDICodeWrite;
+       SEGDESC_t       BC_Data;
+       SEGDESC_t       BC_Code;
+       SEGDESC_t       BC_CodeWrite;
+} __attribute__((__packed__)) pxe_t;
+
+#define        PXENV_START_UNDI                0x0000
+typedef struct {
+       PXENV_STATUS_t  Status;
+       uint16_t        ax;
+       uint16_t        bx;
+       uint16_t        dx;
+       uint16_t        di;
+       uint16_t        es;
+} __attribute__((__packed__)) t_PXENV_START_UNDI;
+
+#define        PXENV_UNDI_STARTUP              0x0001
+typedef struct {
+       PXENV_STATUS_t  Status;
+} __attribute__((__packed__)) t_PXENV_UNDI_STARTUP;
+
+#define        PXENV_UNDI_CLEANUP              0x0002
+typedef struct {
+       PXENV_STATUS_t  Status;
+} __attribute__((__packed__)) t_PXENV_UNDI_CLEANUP;
+
+#define        PXENV_UNDI_INITIALIZE           0x0003
+typedef struct {
+       PXENV_STATUS_t  Status;
+       ADDR32_t        ProtocolIni;    /* Phys addr of a copy of the
+                                          driver module */
+       uint8_t         reserved[8];
+} __attribute__((__packed__)) t_PXENV_UNDI_INITALIZE;
+
+
+#define        MAXNUM_MCADDR           8
+typedef struct {
+       PXENV_STATUS_t  Status;
+       uint16_t        MCastAddrCount;
+       MAC_ADDR        McastAddr[MAXNUM_MCADDR];
+} __attribute__((__packed__)) t_PXENV_UNDI_MCAST_ADDRESS;
+
+#define        PXENV_UNDI_RESET_ADAPTER        0x0004          
+typedef struct {
+       PXENV_STATUS_t  Status;
+       t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
+} __attribute__((__packed__)) t_PXENV_UNDI_RESET;
+
+#define        PXENV_UNDI_SHUTDOWN             0x0005
+typedef struct {
+       PXENV_STATUS_t  Status;
+} __attribute__((__packed__)) t_PXENV_UNDI_SHUTDOWN;
+
+#define        PXENV_UNDI_OPEN                 0x0006
+typedef struct {
+       PXENV_STATUS_t  Status;
+       uint16_t        OpenFlag;
+       uint16_t        PktFilter;
+#      define FLTR_DIRECTED    0x0001
+#      define FLTR_BRDCST      0x0002
+#      define FLTR_PRMSCS      0x0003
+#      define FLTR_SRC_RTG     0x0004
+
+       t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
+} __attribute__((__packed__)) t_PXENV_UNDI_OPEN;
+
+#define        PXENV_UNDI_CLOSE                0x0007
+typedef struct {
+       PXENV_STATUS_t  Status;
+} __attribute__((__packed__)) t_PXENV_UNDI_CLOSE;
+
+#define        PXENV_UNDI_TRANSMIT             0x0008
+typedef struct {
+       PXENV_STATUS_t  Status;
+       uint8_t         Protocol;
+#      define P_UNKNOWN        0
+#      define P_IP             1
+#      define P_ARP            2
+#      define P_RARP           3
+
+       uint8_t         XmitFlag;
+#      define XMT_DESTADDR     0x0000
+#      define XMT_BROADCAST    0x0001
+
+       SEGOFF16_t      DestAddr;
+       SEGOFF16_t      TBD;
+       uint32_t        Reserved[2];
+} __attribute__((__packed__)) t_PXENV_UNDI_TRANSMIT;
+
+#define        MAX_DATA_BLKS           8
+typedef struct {
+       uint16_t        ImmedLength;
+       SEGOFF16_t      Xmit;



Home | Main Index | Thread Index | Old Index