FreeBSD/Linux Kernel Cross Reference
sys/dev/ppbus/lptvar.h
1 /* $NetBSD: lptvar.h,v 1.10 2008/04/28 20:23:56 martin Exp $ */
2
3 /*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gary Thorpe.
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 #ifndef __DEV_PPBUS_LPTVAR_H
33 #define __DEV_PPBUS_LPTVAR_H
34
35 #include <machine/vmparam.h>
36 #include <dev/ppbus/ppbus_device.h>
37
38 /* #define LPINITRDY 4 wait up to 4 seconds for a ready
39 #define BUFSTATSIZE 32
40 #define LPTOUTINITIAL 10 initial timeout to wait for ready 1/10 s
41 #define LPTOUTMAX 1 maximal timeout 1 s */
42 #define LPPRI (PZERO+8)
43 #define BUFSIZE PAGE_SIZE
44
45 #define LPTUNIT(s) (minor(s) & 0xff)
46 #define LPTCTL(s) (minor(s) & 0x100)
47
48 /* Wait up to 16 seconds for a ready */
49 #define LPT_TIMEOUT ((hz)*16)
50 #define LPT_STEP ((hz)/4)
51
52 struct lpt_softc {
53 struct ppbus_device_softc ppbus_dev;
54
55 int sc_state;
56 /* bits for state */
57 #define OPEN (unsigned)(1<<0) /* device is open */
58 #define ASLP (unsigned)(1<<1) /* awaiting draining of printer */
59 #define EERROR (unsigned)(1<<2) /* error was received from printer */
60 #define OBUSY (unsigned)(1<<3) /* printer is busy doing output */
61 #define LPTOUT (unsigned)(1<<4) /* timeout while not selected */
62 #define TOUT (unsigned)(1<<5) /* timeout while not selected */
63 #define LPTINIT (unsigned)(1<<6) /* waiting to initialize for open */
64 #define INTERRUPTED (unsigned)(1<<7) /* write call was interrupted */
65 #define HAVEBUS (unsigned)(1<<8) /* the driver owns the bus */
66
67 int sc_flags; /* flags from lptio.h */
68
69 void *sc_inbuf;
70 void *sc_outbuf;
71 bus_addr_t sc_in_baddr;
72 bus_addr_t sc_out_baddr;
73 };
74
75 #define MAX_SLEEP (hz*5) /* Timeout while waiting for device ready */
76 #define MAX_SPIN 20 /* Max delay for device ready in usecs */
77
78 #ifdef LPT_DEBUG
79 static volatile int lptdebug = 1;
80 #ifndef LPT_DPRINTF
81 #define LPT_DPRINTF(arg) if(lptdebug) printf arg
82 #else
83 #define LPT_DPRINTF(arg) if(lptdebug) printf("WARNING: LPT_DPRINTF " \
84 "REDEFINED!!!")
85 #endif /* LPT_DPRINTF */
86 #else
87 #define LPT_DPRINTF(arg)
88 #endif /* LPT_DEBUG */
89
90 #ifdef LPT_VERBOSE
91 static volatile int lptverbose = 1;
92 #ifndef LPT_VPRINTF
93 #define LPT_VPRINTF(arg) if(lptverbose) printf arg
94 #else
95 #define LPT_VPRINTF(arg) if(lptverbose) printf("WARNING: LPT_VPRINTF " \
96 "REDEFINED!!!")
97 #endif /* LPT_VPRINTF */
98 #else
99 #define LPT_VPRINTF(arg)
100 #endif /* LPT_VERBOSE */
101
102 #endif /* __DEV_PPBUS_LPTVAR_H */
Cache object: 422e88c2d76291b9aedf7d41af1fa910
|