Home | History | Annotate | Line # | Download | only in libsa
saio.h revision 1.1
      1 /*	$NetBSD: saio.h,v 1.1 2001/06/14 12:57:15 fredette Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Gordon W. Ross.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * This file derived from kernel/mach/sun3.md/machMon.h from the
     41  * sprite distribution.
     42  *
     43  * In particular, this file came out of the Walnut Creek cdrom collection
     44  * which contained no warnings about any possible copyright infringement.
     45  */
     46 
     47 /*
     48  * machMon.h --
     49  *
     50  *     Structures, constants and defines for access to the sun monitor.
     51  *     These were translated from the sun monitor header files:
     52  *          mon/sunromvec.h
     53  *          stand/saio.h
     54  *
     55  * Copyright (C) 1985 Regents of the University of California
     56  * All rights reserved.
     57  *
     58  * Header: /sprite/src/boot/sunprom/sun3.md/RCS/machMon.h,v \
     59  * 1.1 90/09/17 10:57:28 rab Exp Locker: rab $ SPRITE (Berkeley)
     60  */
     61 
     62 /*
     63  * The table entry that describes a device.  It exists in the PROM; a
     64  * pointer to it is passed in MachMonBootParam.  It can be used to locate
     65  * PROM subroutines for opening, reading, and writing the device.
     66  *
     67  * When using this interface, only one device can be open at once.
     68  */
     69 struct boottab {
     70 	char	b_dev[2];		/* The name of the device */
     71 	int	(*b_probe)();		/* probe() --> -1 or found controller
     72 					   number */
     73 	int	(*b_boot)();		/* boot(bp) --> -1 or start address */
     74 	int	(*b_open)();		/* open(iobp) --> -1 or 0 */
     75 	int	(*b_close)();		/* close(iobp) --> -1 or 0 */
     76 	int	(*b_strategy)();	/* strategy(iobp,rw) --> -1 or 0 */
     77 	char	*b_desc;		/* Printable string describing dev */
     78 	struct devinfo *b_devinfo;	/* Information to configure device */
     79 } __attribute__((packed));
     80 
     81 /*
     82  * This table gives information about the resources needed by a device.
     83  */
     84 struct devinfo {
     85   unsigned int      d_devbytes;   /* Bytes occupied by device in IO space.  */
     86   unsigned int      d_dmabytes;   /* Bytes needed by device in DMA memory.  */
     87   unsigned int      d_localbytes; /* Bytes needed by device for local info. */
     88   unsigned int      d_stdcount;   /* How many standard addresses.           */
     89   unsigned long     *d_stdaddrs;  /* The vector of standard addresses.      */
     90   unsigned int      d_devtype;    /* What map space device is in.           */
     91   unsigned int      d_maxiobytes; /* Size to break big I/O's into.          */
     92 };
     93 
     94 /*
     95  * These are the "page map entry types" specified in the
     96  * d_devtype field of struct devinfo.
     97  */
     98 #define MAP_MAINMEM 	0
     99 #define MAP_OBIO		1
    100 #define MAP_MBMEM		2
    101 #define MAP_MBIO		3
    102 #define MAP_VME16A16D	4
    103 #define MAP_VME16A32D	5
    104 #define MAP_VME24A16D	6
    105 #define MAP_VME24A32D	7
    106 #define MAP_VME32A16D	8
    107 #define MAP_VME32A32D	9
    108 #define MAP__NTYPES 	10
    109 
    110 /*
    111  * A "stand alone I/O request", (from SunOS saio.h)
    112  * This is passed as the main argument to the PROM I/O routines
    113  * in the MachMonBootDevice structure.
    114  */
    115 struct saioreq {
    116 	char	si_flgs;
    117 	char	si_pad1;
    118 	struct boottab *si_boottab;	/* Points to boottab entry if any */
    119 	char	*si_devdata;		/* Device-specific data pointer */
    120 	int	si_ctlr;		/* Controller number or address */
    121 	int	si_unit;		/* Unit number within controller */
    122 	long	si_boff;		/* Partition number within unit */
    123 	long	si_cyloff;
    124 	long	si_offset;
    125 	long	si_bn;			/* Block number to R/W */
    126 	char	*si_ma;			/* Memory address to R/W */
    127 	int	si_cc;			/* Character count to R/W */
    128 	struct	saif *si_sif;		/* net if. pointer (set by b_open) */
    129 	char 	*si_devaddr;		/* Points to mapped in device */
    130 	char	*si_dmaaddr;		/* Points to allocated DMA space */
    131 } __attribute__((packed));
    132 
    133 #define SAIO_F_READ	0x01
    134 #define SAIO_F_WRITE	0x02
    135 #define SAIO_F_ALLOC	0x04
    136 #define SAIO_F_FILE	0x08
    137 #define	SAIO_F_EOF	0x10	/* EOF on device */
    138 #define SAIO_F_AJAR	0x20	/* Descriptor "ajar" (stopped but not closed) */
    139 
    140 /*
    141  * Ethernet interface descriptor (from SunOS saio.h)
    142  * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc.
    143  * Then:  saiop->si_boottab->b_open()  will set:
    144  *   saiop->si_sif;
    145  *   saiop->si_devdata;
    146  * The latter is the first arg to the following functions.
    147  * Note that the buffer must be in DVMA space...
    148  */
    149 struct saif {
    150 	/* Transmit packet, returns zero on success. */
    151 	int	(*sif_xmit)(void *devdata, char *buf, int len);
    152 	/* Receive packet, return zero if none arrived. */
    153 	int	(*sif_poll)(void *devdata, char *buf);
    154 	/* Reset interface, set addresses, etc. */
    155 	int	(*sif_reset)(void *devdata, struct saioreq *sip);
    156 	/*
    157 	 * Later proms have more stuff here, but what versions?
    158 	 * It appears that all V3.X PROMs support this...
    159 	 */
    160 	/* Copy our ethernet address to the passed array. */
    161 	int	(*sif_macaddr)(char *ea);
    162 };
    163 
    164 #ifdef	_STANDALONE
    165 /* libsa:promdev.c */
    166 int  prom_iopen (struct saioreq *sip);
    167 void prom_iclose(struct saioreq *sip);
    168 #endif	/* _STANDALONE */
    169