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