Home | History | Annotate | Line # | Download | only in ppbus
ppbus_conf.h revision 1.1
      1 /*-
      2  * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
      3  * All rights reserved.
      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  *
     14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24  * SUCH DAMAGE.
     25  *
     26  * $FreeBSD: src/sys/dev/ppbus/ppbconf.h,v 1.17.2.1 2000/05/24 00:20:57 n_hibma Exp $
     27  *
     28  */
     29 #ifndef __PPBUS_CONF_H
     30 #define __PPBUS_CONF_H
     31 
     32 #include <sys/device.h>
     33 #include <sys/lock.h>
     34 #include <sys/queue.h>
     35 
     36 #include <machine/bus.h>
     37 
     38 #include <dev/ppbus/ppbus_msq.h>
     39 #include <dev/ppbus/ppbus_device.h>
     40 
     41 
     42 /* Function pointer types used for interface */
     43 typedef u_char (*PARPORT_IO_T)(struct device *, int, u_char *, int, u_char);
     44 typedef int (*PARPORT_EXEC_MICROSEQ_T)(struct device *,
     45 	struct ppbus_microseq **);
     46 typedef void (*PARPORT_RESET_EPP_TIMEOUT_T)(struct device *);
     47 typedef int (*PARPORT_SETMODE_T)(struct device *, int);
     48 typedef int (*PARPORT_GETMODE_T)(struct device *);
     49 typedef void (*PARPORT_ECP_SYNC_T)(struct device *);
     50 typedef int (*PARPORT_READ_T)(struct device *, char *, int, int, size_t *);
     51 typedef int (*PARPORT_WRITE_T)(struct device *, char *, int, int, size_t *);
     52 typedef int (*PARPORT_READ_IVAR_T)(struct device *, int, unsigned int *);
     53 typedef int (*PARPORT_WRITE_IVAR_T)(struct device *, int, unsigned int *);
     54 typedef int (*PARPORT_DMA_MALLOC_T)(struct device *, caddr_t *, bus_addr_t *,
     55 	bus_size_t);
     56 typedef void (*PARPORT_DMA_FREE_T)(struct device *, caddr_t *, bus_addr_t *,
     57 	bus_size_t);
     58 typedef int (*PARPORT_ADD_HANDLER_T)(struct device *, void (*)(void *),
     59 	void *);
     60 typedef int (*PARPORT_REMOVE_HANDLER_T)(struct device *, void (*)(void *));
     61 
     62 /* Adapter structure that each parport device needs to implement ppbus */
     63 struct parport_adapter {
     64 	u_int16_t capabilities;
     65 
     66 	/* Functions which make up interface */
     67 	PARPORT_IO_T parport_io;
     68 	PARPORT_EXEC_MICROSEQ_T parport_exec_microseq;
     69 	PARPORT_RESET_EPP_TIMEOUT_T parport_reset_epp_timeout;
     70 	PARPORT_SETMODE_T parport_setmode;
     71 	PARPORT_GETMODE_T parport_getmode;
     72 	PARPORT_ECP_SYNC_T parport_ecp_sync;
     73 	PARPORT_READ_T parport_read;
     74 	PARPORT_WRITE_T parport_write;
     75 	PARPORT_READ_IVAR_T parport_read_ivar;
     76 	PARPORT_WRITE_IVAR_T parport_write_ivar;
     77 	PARPORT_DMA_MALLOC_T parport_dma_malloc;
     78 	PARPORT_DMA_FREE_T parport_dma_free;
     79 	PARPORT_ADD_HANDLER_T parport_add_handler;
     80 	PARPORT_REMOVE_HANDLER_T parport_remove_handler;
     81 };
     82 
     83 /* Parallel Port Bus configuration structure. */
     84 struct ppbus_softc {
     85 	struct device sc_dev;
     86 
     87 	/* Lock for critical section when requesting/releasing the bus */
     88 	struct lock sc_lock;
     89 
     90 #define PPBUS_OK 1
     91 #define PPBUS_NOK 0
     92 	u_int8_t sc_dev_ok;
     93 
     94 	/* ppbus capabilities (see ppbus_var.h) */
     95 	u_int16_t sc_capabilities;
     96 
     97 /* PnP device type defined in ppbus_var.h */
     98 	int sc_class_id;		/* not a PnP device if class_id < 0 */
     99 
    100 	/* Defined in pbus_1284.h: error and host side state. */
    101 	u_int32_t sc_1284_state;	/* current IEEE1284 state */
    102 	u_int32_t sc_1284_error;	/* last IEEE1284 error */
    103 
    104 	/* Use IEEE 1284 negociations in mode changes and direction changes */
    105 	u_int32_t sc_use_ieee;
    106 
    107 /* PPBUS mode masks defined in ppbus_var.h. */
    108 	u_int32_t sc_mode;		/* IEEE 1284-1994 mode */
    109 
    110 	/* ppbus_device which owns the bus */
    111 	struct device * ppbus_owner;
    112 
    113 	/* Head of list of child devices */
    114 	SLIST_HEAD(childlist, ppbus_device_softc) sc_childlist_head;
    115 
    116 	/* Functions which make up interface */
    117 	PARPORT_IO_T ppbus_io;
    118 	PARPORT_EXEC_MICROSEQ_T ppbus_exec_microseq;
    119 	PARPORT_RESET_EPP_TIMEOUT_T ppbus_reset_epp_timeout;
    120 	PARPORT_SETMODE_T ppbus_setmode;
    121 	PARPORT_GETMODE_T ppbus_getmode;
    122 	PARPORT_ECP_SYNC_T ppbus_ecp_sync;
    123 	PARPORT_READ_T ppbus_read;
    124 	PARPORT_WRITE_T ppbus_write;
    125         PARPORT_READ_IVAR_T ppbus_read_ivar;
    126         PARPORT_WRITE_IVAR_T ppbus_write_ivar;
    127 	PARPORT_DMA_MALLOC_T ppbus_dma_malloc;
    128 	PARPORT_DMA_FREE_T ppbus_dma_free;
    129 	PARPORT_ADD_HANDLER_T ppbus_add_handler;
    130 	PARPORT_REMOVE_HANDLER_T ppbus_remove_handler;
    131 };
    132 
    133 #endif
    134