xref: /netbsd-src/sys/dev/ppbus/lptvar.h (revision aaf4ece63a859a04e37cf3a7229b5fab0157cc06)
1 /* $NetBSD: lptvar.h,v 1.8 2005/12/11 12:23:28 christos 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  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef __DEV_PPBUS_LPTVAR_H
40 #define __DEV_PPBUS_LPTVAR_H
41 
42 #include <machine/vmparam.h>
43 #include <dev/ppbus/ppbus_device.h>
44 
45 /* #define LPINITRDY       4       wait up to 4 seconds for a ready
46 #define BUFSTATSIZE     32
47 #define LPTOUTINITIAL   10       initial timeout to wait for ready 1/10 s
48 #define LPTOUTMAX       1        maximal timeout 1 s */
49 #define LPPRI           (PZERO+8)
50 #define BUFSIZE		PAGE_SIZE
51 
52 #define	LPTUNIT(s)	(minor(s) & 0xff)
53 #define	LPTCTL(s)	(minor(s) & 0x100)
54 
55 /* Wait up to 16 seconds for a ready */
56 #define	LPT_TIMEOUT		((hz)*16)
57 #define LPT_STEP		((hz)/4)
58 
59 struct lpt_softc {
60 	struct ppbus_device_softc ppbus_dev;
61 
62 	int sc_state;
63 /* bits for state */
64 #define OPEN            (unsigned)(1<<0)  /* device is open */
65 #define ASLP            (unsigned)(1<<1)  /* awaiting draining of printer */
66 #define EERROR          (unsigned)(1<<2)  /* error was received from printer */
67 #define OBUSY           (unsigned)(1<<3)  /* printer is busy doing output */
68 #define LPTOUT          (unsigned)(1<<4)  /* timeout while not selected */
69 #define TOUT            (unsigned)(1<<5)  /* timeout while not selected */
70 #define LPTINIT         (unsigned)(1<<6)  /* waiting to initialize for open */
71 #define INTERRUPTED     (unsigned)(1<<7)  /* write call was interrupted */
72 #define HAVEBUS         (unsigned)(1<<8)  /* the driver owns the bus */
73 
74 	int sc_flags;		/* flags from lptio.h */
75 
76 	char *sc_inbuf;
77 	char *sc_outbuf;
78 	bus_addr_t sc_in_baddr;
79 	bus_addr_t sc_out_baddr;
80 };
81 
82 #define MAX_SLEEP       (hz*5)  /* Timeout while waiting for device ready */
83 #define MAX_SPIN        20      /* Max delay for device ready in usecs */
84 
85 #ifdef LPT_DEBUG
86 static volatile int lptdebug = 1;
87 #ifndef LPT_DPRINTF
88 #define LPT_DPRINTF(arg) if(lptdebug) printf arg
89 #else
90 #define LPT_DPRINTF(arg) if(lptdebug) printf("WARNING: LPT_DPRINTF " \
91 	"REDEFINED!!!")
92 #endif /* LPT_DPRINTF */
93 #else
94 #define LPT_DPRINTF(arg)
95 #endif /* LPT_DEBUG */
96 
97 #ifdef LPT_VERBOSE
98 static volatile int lptverbose = 1;
99 #ifndef LPT_VPRINTF
100 #define LPT_VPRINTF(arg) if(lptverbose) printf arg
101 #else
102 #define LPT_VPRINTF(arg) if(lptverbose) printf("WARNING: LPT_VPRINTF " \
103 	"REDEFINED!!!")
104 #endif /* LPT_VPRINTF */
105 #else
106 #define LPT_VPRINTF(arg)
107 #endif /* LPT_VERBOSE */
108 
109 #endif /* __DEV_PPBUS_LPTVAR_H */
110