#ifndef __PPBCONF_H
#define __PPBCONF_H
#define n(flags) (~(flags) & (flags))
#define STROBE 0x01
#define AUTOFEED 0x02
#define nINIT 0x04
#define SELECTIN 0x08
#define IRQENABLE 0x10
#define PCD 0x20
#define nSTROBE n(STROBE)
#define nAUTOFEED n(AUTOFEED)
#define INIT n(nINIT)
#define nSELECTIN n(SELECTIN)
#define nPCD n(PCD)
#define TIMEOUT 0x01
#define nFAULT 0x08
#define SELECT 0x10
#define PERROR 0x20
#define nACK 0x40
#define nBUSY 0x80
#ifdef _KERNEL
#include <sys/queue.h>
#define PPBPRI (PWAIT)
#define PPB_COMPATIBLE 0x0
#define PPB_NIBBLE 0x1
#define PPB_PS2 0x2
#define PPB_EPP 0x4
#define PPB_ECP 0x8
#define PPB_SPP PPB_NIBBLE|PPB_PS2
#define PPB_BYTE PPB_PS2
#define PPB_MASK 0x0f
#define PPB_OPTIONS_MASK 0xf0
#define PPB_IS_EPP(mode) (mode & PPB_EPP)
#define PPB_IN_EPP_MODE(bus) (PPB_IS_EPP (ppb_get_mode (bus)))
#define PPB_IN_NIBBLE_MODE(bus) (ppb_get_mode (bus) & PPB_NIBBLE)
#define PPB_IN_PS2_MODE(bus) (ppb_get_mode (bus) & PPB_PS2)
struct ppb_status {
unsigned char status;
unsigned int timeout:1;
unsigned int error:1;
unsigned int select:1;
unsigned int paper_end:1;
unsigned int ack:1;
unsigned int busy:1;
};
#define PPB_OUTSB_EPP 1
#define PPB_OUTSW_EPP 2
#define PPB_OUTSL_EPP 3
#define PPB_INSB_EPP 4
#define PPB_INSW_EPP 5
#define PPB_INSL_EPP 6
#define PPB_RDTR 7
#define PPB_RSTR 8
#define PPB_RCTR 9
#define PPB_REPP_A 10
#define PPB_REPP_D 11
#define PPB_RECR 12
#define PPB_RFIFO 13
#define PPB_WDTR 14
#define PPB_WSTR 15
#define PPB_WCTR 16
#define PPB_WEPP_A 17
#define PPB_WEPP_D 18
#define PPB_WECR 19
#define PPB_WFIFO 20
#define PPB_DONTWAIT 0
#define PPB_NOINTR 0
#define PPB_WAIT 0x1
#define PPB_INTR 0x2
#define PPB_POLL 0x4
#define PPB_FOREVER -1
#define PPB_MS_MAXLEN 64
#define PPB_MS_MAXARGS 3
#define PPB_MAX_XFER 6
union ppb_insarg {
int i;
void *p;
char *c;
int (* f)(void *, char *);
};
struct ppb_microseq {
int opcode;
union ppb_insarg arg[PPB_MS_MAXARGS];
};
struct ppb_xfer {
struct ppb_microseq *loop;
};
struct ppb_data;
struct ppb_context {
int valid;
int mode;
struct microseq *curpc;
struct microseq *curmsq;
};
enum {
PPBUS_IVAR_MODE = BUS_IVARS_PRIVATE
};
struct ppb_device {
const char *name;
u_int flags;
struct ppb_context ctx;
struct ppb_xfer
get_xfer[PPB_MAX_XFER];
struct ppb_xfer
put_xfer[PPB_MAX_XFER];
driver_intr_t *intr_hook;
void *intr_arg;
};
#define EPP_1_9 0x0
#define EPP_1_7 0x1
enum {
PPC_IVAR_EPP_PROTO = BUS_IVARS_PRIVATE,
PPC_IVAR_LOCK,
PPC_IVAR_INTR_HANDLER
};
#define PPB_PnP_STRING_SIZE 256
struct ppb_data {
#define PPB_PnP_PRINTER 0
#define PPB_PnP_MODEM 1
#define PPB_PnP_NET 2
#define PPB_PnP_HDC 3
#define PPB_PnP_PCMCIA 4
#define PPB_PnP_MEDIA 5
#define PPB_PnP_FDC 6
#define PPB_PnP_PORTS 7
#define PPB_PnP_SCANNER 8
#define PPB_PnP_DIGICAM 9
#define PPB_PnP_UNKNOWN 10
int class_id;
int state;
int error;
int mode;
device_t ppb_owner;
struct mtx *ppc_lock;
struct resource *ppc_irq_res;
};
struct callout;
typedef int (*ppc_intr_handler)(void *);
extern int ppb_attach_device(device_t);
extern int ppb_request_bus(device_t, device_t, int);
extern int ppb_release_bus(device_t, device_t);
extern void ppb_lock(device_t);
extern void ppb_unlock(device_t);
extern struct mtx *ppb_get_lock(device_t);
extern void _ppb_assert_locked(device_t, const char *, int);
extern void ppb_init_callout(device_t, struct callout *, int);
extern int ppb_sleep(device_t, void *, int, const char *, int);
extern int ppb_get_status(device_t, struct ppb_status *);
extern int ppb_poll_bus(device_t, int, uint8_t, uint8_t, int);
extern int ppb_reset_epp_timeout(device_t);
extern int ppb_ecp_sync(device_t);
extern int ppb_get_epp_protocol(device_t);
extern int ppb_set_mode(device_t, int);
extern int ppb_get_mode(device_t);
extern int ppb_write(device_t, char *, int, int);
#ifdef INVARIANTS
#define ppb_assert_locked(dev) _ppb_assert_locked(dev, __FILE__, __LINE__)
#else
#define ppb_assert_locked(dev)
#endif
#endif
#endif