home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / bsd / dev / m68k / busvar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-30  |  5.5 KB  |  175 lines

  1. /* 
  2.  * Copyright (c) 1987 Next, Inc.
  3.  *
  4.  * HISTORY
  5.  * 22-May-91  Gregg Kellogg (gk) at NeXT
  6.  *    Split out public interface.
  7.  *
  8.  * 11-Jul-90  Gregg Kellogg (gk) at NeXT
  9.  *    Changed bc_tab from a struct buf * to a queue_head_t.
  10.  *
  11.  * 04-Mar-87  John Seamons (jks) at NeXT
  12.  *    Ported to NeXT.
  13.  */ 
  14.  
  15. #ifndef    _M68K_DEV_BUSVAR_
  16. #define _M68K_DEV_BUSVAR_
  17.  
  18. #import <kernserv/queue.h>
  19. #import <sys/callout.h>
  20.  
  21. /*
  22.  * This file contains definitions related to the kernel structures
  23.  * for dealing with the device bus.
  24.  *
  25.  * Each bus has a bus_hd structure.
  26.  * Each bus controller which is not a device has a bus_ctrl structure.
  27.  * Each bus device has a bus_device structure.
  28.  */
  29.  
  30. #ifndef ASSEMBLER
  31. /*
  32.  * Per-bus structure.
  33.  *
  34.  * At boot time we determine the devices attached to the bus.
  35.  * Additional devices may be added at a later time via the
  36.  * loadable device driver mechanism.
  37.  *
  38.  * During normal operation, resources are allocated and returned
  39.  * to the structures here.
  40.  * 
  41.  * When bus resources are needed and not available, or if a device
  42.  * which can tolerate no other bus activity gets on the bus,
  43.  * then device drivers may have to wait to get to the bus and are
  44.  * queued here.
  45.  */
  46. struct    bus_hd {
  47.     struct    bus_device *bh_actf;    /* head of queue to transfer */
  48.     struct    bus_device *bh_actl;    /* tail of queue to transfer */
  49.     short    bh_users;        /* transient use count */
  50.     short    bh_xclu;        /* exclusive use of bus */
  51. };
  52.  
  53. /*
  54.  * Per-controller structure.
  55.  * (E.g. one for each disk and tape controller)
  56.  *
  57.  * If a controller has devices attached, then there are
  58.  * cross-referenced bus_drive structures.
  59.  * This structure is the one which is queued in bus resource wait,
  60.  * and saves the information about bus resources which are used!18 The queue of devices waiting to transfer is also attached here.
  61.  */
  62. struct bus_ctrl {
  63.     /* start of fields initialized by ioconf.c */
  64.     struct    bus_driver *bc_driver;
  65.     short    bc_ctrl;    /* controller index in driver */
  66.     short    bc_ipl;        /* interrupt level */
  67.     void    *bc_addr;    /* address of device in I/O space */
  68.     /* end of fields initialized by ioconf.c */
  69.  
  70.     struct    bus_hd *bc_hd;    /* bus this controller is on */
  71.     struct    bus_device *bc_device;
  72. /* the driver saves the prototype command here for use in its go routine */
  73.     int    bc_cmd;        /* communication to go() */
  74.     queue_head_t bc_tab;    /* queue of devices for this controller */
  75.     int    bc_active;    /* Bus controller is active */
  76.     short    bc_alive;    /* controller exists */
  77. };
  78.  
  79. /*
  80.  * Per ``device'' structure.
  81.  * (A controller has devices -- everything else is a ``device''.)
  82.  *
  83.  * If a controller has many drives attached, then there will
  84.  * be several bus_device structures associated with a single bus_ctrl
  85.  * structure.
  86.  *
  87.  * This structure contains all the information necessary
  88.  * to run a bus device.  It also contains information
  89.  * for slaves of bus controllers as to which device on the slave
  90.  * this is.  A flags field here can also be given in the system specification
  91.  * and is used to tell which serial lines are hard wired or other device
  92.  * specific parameters.
  93.  */
  94. struct bus_device {
  95.     /* start of fields initialized by ioconf.c */
  96.     struct    bus_driver *bd_driver;
  97.     short    bd_unit;    /* unit number on the system */
  98.     short    bd_ctrl;    /* mass ctrl number; -1 if none */
  99.     short    bd_slave;    /* slave on controller */
  100.     char    bd_ipl;        /* interrupt level of device */
  101.     short    bd_dk;        /* if init 1 set to number for iostat */
  102.     int    bd_flags;    /* parameter from system specification */
  103.     void    *bd_addr;    /* address of device in I/O space */
  104.     char    *bd_name;    /* device name */
  105.     /* end of fields initialized by ioconf.c */
  106.  
  107.     short    bd_alive;    /* device exists */
  108.     short    bd_type;    /* driver specific type information */
  109. /* this is the forward link in a list of devices on a controller */
  110.     struct    bus_device *bd_forw;
  111. /* if the device is connected to a controller, this is the controller */
  112.     struct    bus_ctrl *bd_bc;
  113.     struct    bus_hd *bd_hd;
  114. };
  115.  
  116. /*
  117.  * Per-driver structure.
  118.  *
  119.  * Each device driver defines entries for a set of routines
  120.  * as well as an array of types which are acceptable to it.
  121.  * These are used at boot time by !19configuration program.
  122.  */
  123. struct bus_driver {
  124.     int    (*br_probe)();        /* see if a driver is really there */
  125.     int    (*br_slave)();        /* see if a slave is there */
  126.     int    (*br_attach)();        /* setup driver for a slave */
  127.     int    (*br_go)();        /* start transfer */
  128.     int    (*br_done)();        /* complete transfer */
  129.     int    (*br_intr)();        /* service interrupt */
  130.     int    (*br_init)();        /* initialize device */
  131.     int    br_size;        /* device register size */
  132.     char    *br_dname;        /* name of a device */
  133.     struct    bus_device **br_dinfo;    /* backpointers to bus_dinit structs */
  134.     char    *br_cname;        /* name of a controller */
  135.     struct    bus_ctrl **br_cinfo;    /* backpointers to bus_cinit structs */
  136.     short    br_flags;        /* driver flags */
  137. #define    BUS_XCLU    0x0001        /* want exclusive use of bus */
  138. #define    BUS_SCSI    0x0002        /* this is SCSI controller */
  139. };
  140. #endif    !ASSEMBLER
  141.  
  142. #define    BUS_CANTWAIT    0x01        /* don't block me */
  143.  
  144. #ifndef ASSEMBLER
  145. #ifdef KERNEL
  146. /*
  147.  * Bus related kernel variables
  148.  */
  149. extern struct    bus_hd bus_hd;
  150.  
  151. /*
  152.  * bus_cinit and bus_dinit initialize the mass storage controller
  153.  * and ordinary device tables specifying possible devices.
  154.  */
  155. extern    struct    bus_ctrl bus_cinit[];
  156. extern    struct    bus_device bus_dinit[];
  157.  
  158. /*
  159.  * Support for polled interrupts on the bus.
  160.  */
  161. #define    NPOLL    8            /* max number of polling routines */
  162. extern func poll_intr[];        /* polled routines to call */
  163. #define    POLLED_IPL    5        /* polling ipl */
  164. #endif KERNEL
  165.  
  166. /* pseudo device initialization routine support */
  167. struct pseudo_init {
  168.     int    ps_count;
  169.     int    (*ps_func)();
  170. };
  171. extern struct pseudo_init pseudo_inits[];
  172.  
  173. #endif !ASSEMBLER
  174. #endif _M68K_DEV_BUSVAR_
  175.