root/kern/dev/lamebus/lamebus.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
   3  *      The President and Fellows of Harvard College.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. Neither the name of the University nor the names of its contributors
  14  *    may be used to endorse or promote products derived from this software
  15  *    without specific prior written permission.
  16  *
  17  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27  * SUCH DAMAGE.
  28  */
  29 
  30 #ifndef _LAMEBUS_H_
  31 #define _LAMEBUS_H_
  32 
  33 #include <cpu.h>
  34 #include <spinlock.h>
  35 
  36 /*
  37  * Linear Always Mapped Extents
  38  *
  39  * Machine-independent definitions.
  40  */
  41 
  42 
  43 /* Vendors */
  44 #define LB_VENDOR_CS161      1
  45 
  46 /* CS161 devices */
  47 #define LBCS161_BUSCTL       1
  48 #define LBCS161_TIMER        2
  49 #define LBCS161_DISK         3
  50 #define LBCS161_SERIAL       4
  51 #define LBCS161_SCREEN       5
  52 #define LBCS161_NET          6
  53 #define LBCS161_EMUFS        7
  54 #define LBCS161_TRACE        8
  55 #define LBCS161_RANDOM       9
  56 
  57 /* LAMEbus controller always goes in slot 31 */
  58 #define LB_CONTROLLER_SLOT   31
  59 
  60 /* Number of slots */
  61 #define LB_NSLOTS            32
  62 
  63 /* LAMEbus controller per-slot config space */
  64 #define LB_CONFIG_SIZE       1024
  65 
  66 /* LAMEbus controller per-cpu control space */
  67 #define LB_CTLCPU_SIZE       1024
  68 
  69 /* LAMEbus controller slot offset to per-cpu control space */
  70 #define LB_CTLCPU_OFFSET     32768
  71 
  72 /* LAMEbus mapping size per slot */
  73 #define LB_SLOT_SIZE         65536
  74 
  75 /* Pointer to kind of function called on interrupt */
  76 typedef void (*lb_irqfunc)(void *devdata);
  77 
  78 /*
  79  * Driver data
  80  */
  81 struct lamebus_softc {
  82         struct spinlock ls_lock;
  83 
  84         /* Accessed from interrupts; synchronized with ls_lock */ 
  85         uint32_t     ls_slotsinuse;
  86         void        *ls_devdata[LB_NSLOTS];
  87         lb_irqfunc   ls_irqfuncs[LB_NSLOTS];
  88 };
  89 
  90 /*
  91  * Allocate and set up a lamebus_softc for the system.
  92  */
  93 struct lamebus_softc *lamebus_init(void);
  94 
  95 /*
  96  * Search for and create cpu structures for the CPUs on the mainboard.
  97  */
  98 void lamebus_find_cpus(struct lamebus_softc *lamebus);
  99 
 100 /*
 101  * Start up secondary CPUs.
 102  */
 103 void lamebus_start_cpus(struct lamebus_softc *lamebus);
 104 
 105 /*
 106  * Look for a not-in-use slot containing a device whose vendor and device 
 107  * ids match those provided, and whose version is in the range between
 108  * lowver and highver, inclusive.
 109  *
 110  * Returns a slot number (0-31) or -1 if no such device is found.
 111  */
 112 int lamebus_probe(struct lamebus_softc *, 
 113                   uint32_t vendorid, uint32_t deviceid, 
 114                   uint32_t lowver, uint32_t highver);
 115 
 116 /*
 117  * Mark a slot in-use (that is, has a device driver attached to it),
 118  * or unmark it. It is a fatal error to mark a slot that is already 
 119  * in use, or unmark a slot that is not in use.
 120  */
 121 void lamebus_mark(struct lamebus_softc *, int slot);
 122 void lamebus_unmark(struct lamebus_softc *, int slot);
 123 
 124 /*
 125  * Attach to an interrupt.
 126  */
 127 void lamebus_attach_interrupt(struct lamebus_softc *, int slot,
 128                               void *devdata, 
 129                               void (*irqfunc)(void *devdata));
 130 /*
 131  * Detach from interrupt.
 132  */
 133 void lamebus_detach_interrupt(struct lamebus_softc *, int slot);
 134 
 135 /*
 136  * Mask/unmask an interrupt.
 137  */
 138 void lamebus_mask_interrupt(struct lamebus_softc *, int slot);
 139 void lamebus_unmask_interrupt(struct lamebus_softc *, int slot);
 140 
 141 /*
 142  * Function to call to handle a LAMEbus interrupt.
 143  */
 144 void lamebus_interrupt(struct lamebus_softc *);
 145 
 146 /*
 147  * Have the LAMEbus controller power the system off.
 148  */
 149 void lamebus_poweroff(struct lamebus_softc *);
 150 
 151 /*
 152  * Ask the bus controller how much memory we have.
 153  */
 154 size_t lamebus_ramsize(void);
 155 
 156 /*
 157  * Turn on or off the inter-processor interrupt line to a CPU.
 158  */
 159 void lamebus_assert_ipi(struct lamebus_softc *, struct cpu *targetcpu);
 160 void lamebus_clear_ipi(struct lamebus_softc *, struct cpu *targetcpu);
 161 
 162 /*
 163  * Read/write 32-bit register at offset OFFSET within slot SLOT.
 164  * (Machine dependent.)
 165  */
 166 uint32_t lamebus_read_register(struct lamebus_softc *, int slot,
 167                                uint32_t offset);
 168 void lamebus_write_register(struct lamebus_softc *, int slot,
 169                             uint32_t offset, uint32_t val);
 170 
 171 /*
 172  * Map a buffer that starts at offset OFFSET within slot SLOT.
 173  */
 174 void *lamebus_map_area(struct lamebus_softc *, int slot,
 175                        uint32_t offset);
 176 
 177 
 178 #endif /* _LAMEBUS_H_ */

/* [<][>][^][v][top][bottom][index][help] */