Home | History | Annotate | Line # | Download | only in libsa
      1 /*	$NetBSD: saio.h,v 1.3 2009/01/12 07:00:59 tsutsui 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 saioreq;
     63 struct boottab {
     64 	char	b_dev[2];		/* The name of the device */
     65 	int	(*b_probe)(void);	/* probe() --> -1 or found controller
     66 					   number */
     67 	int	(*b_boot)(char *);	/* boot(bp) --> -1 or start address */
     68 	int	(*b_open)(struct saioreq *);	/* open(iobp) --> -1 or 0 */
     69 	int	(*b_close)(struct saioreq *);	/* close(iobp) --> -1 or 0 */
     70 	int	(*b_strategy)(struct saioreq *, int); /* strategy(iobp,rw)
     71 							 -->-1 or 0 */
     72 	char	*b_desc;		/* Printable string describing dev */
     73 	struct devinfo *b_devinfo;	/* Information to configure device */
     74 } __attribute__((packed));
     75 
     76 /*
     77  * This table gives information about the resources needed by a device.
     78  */
     79 struct devinfo {
     80   unsigned int      d_devbytes;   /* Bytes occupied by device in IO space.  */
     81   unsigned int      d_dmabytes;   /* Bytes needed by device in DMA memory.  */
     82   unsigned int      d_localbytes; /* Bytes needed by device for local info. */
     83   unsigned int      d_stdcount;   /* How many standard addresses.           */
     84   unsigned long     *d_stdaddrs;  /* The vector of standard addresses.      */
     85   unsigned int      d_devtype;    /* What map space device is in.           */
     86   unsigned int      d_maxiobytes; /* Size to break big I/O's into.          */
     87 };
     88 
     89 /*
     90  * These are the "page map entry types" specified in the
     91  * d_devtype field of struct devinfo.
     92  */
     93 #define MAP_MAINMEM 	0
     94 #define MAP_OBIO		1
     95 #define MAP_MBMEM		2
     96 #define MAP_MBIO		3
     97 #define MAP_VME16A16D	4
     98 #define MAP_VME16A32D	5
     99 #define MAP_VME24A16D	6
    100 #define MAP_VME24A32D	7
    101 #define MAP_VME32A16D	8
    102 #define MAP_VME32A32D	9
    103 #define MAP__NTYPES 	10
    104 
    105 /*
    106  * A "stand alone I/O request", (from SunOS saio.h)
    107  * This is passed as the main argument to the PROM I/O routines
    108  * in the MachMonBootDevice structure.
    109  */
    110 struct saioreq {
    111 	char	si_flgs;
    112 	char	si_pad1;
    113 	struct boottab *si_boottab;	/* Points to boottab entry if any */
    114 	char	*si_devdata;		/* Device-specific data pointer */
    115 	int	si_ctlr;		/* Controller number or address */
    116 	int	si_unit;		/* Unit number within controller */
    117 	long	si_boff;		/* Partition number within unit */
    118 	long	si_cyloff;
    119 	long	si_offset;
    120 	long	si_bn;			/* Block number to R/W */
    121 	char	*si_ma;			/* Memory address to R/W */
    122 	int	si_cc;			/* Character count to R/W */
    123 	struct	saif *si_sif;		/* net if. pointer (set by b_open) */
    124 	char 	*si_devaddr;		/* Points to mapped in device */
    125 	char	*si_dmaaddr;		/* Points to allocated DMA space */
    126 } __attribute__((packed));
    127 
    128 #define SAIO_F_READ	0x01
    129 #define SAIO_F_WRITE	0x02
    130 #define SAIO_F_ALLOC	0x04
    131 #define SAIO_F_FILE	0x08
    132 #define	SAIO_F_EOF	0x10	/* EOF on device */
    133 #define SAIO_F_AJAR	0x20	/* Descriptor "ajar" (stopped but not closed) */
    134 
    135 /*
    136  * Ethernet interface descriptor (from SunOS saio.h)
    137  * First, set: saiop->si_devaddr, saiop->si_dmaaddr, etc.
    138  * Then:  saiop->si_boottab->b_open()  will set:
    139  *   saiop->si_sif;
    140  *   saiop->si_devdata;
    141  * The latter is the first arg to the following functions.
    142  * Note that the buffer must be in DVMA space...
    143  */
    144 struct saif {
    145 	/* Transmit packet, returns zero on success. */
    146 	int	(*sif_xmit)(void *devdata, char *buf, int len);
    147 	/* Receive packet, return zero if none arrived. */
    148 	int	(*sif_poll)(void *devdata, char *buf);
    149 	/* Reset interface, set addresses, etc. */
    150 	int	(*sif_reset)(void *devdata, struct saioreq *sip);
    151 	/*
    152 	 * Later proms have more stuff here, but what versions?
    153 	 * It appears that all V3.X PROMs support this...
    154 	 */
    155 	/* Copy our ethernet address to the passed array. */
    156 	int	(*sif_macaddr)(u_char *ea);
    157 };
    158 
    159 #ifdef	_STANDALONE
    160 /* libsa:promdev.c */
    161 int  prom_iopen (struct saioreq *sip);
    162 void prom_iclose(struct saioreq *sip);
    163 #endif	/* _STANDALONE */
    164