3 /* Copyright (c) 1995 Vixie Enterprises
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies, and that
8 * the name of Vixie Enterprises not be used in advertising or publicity
9 * pertaining to distribution of the document or software without specific,
10 * written prior permission.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND VIXIE ENTERPRISES DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
14 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VIXIE ENTERPRISES
15 * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
16 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
18 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22 #ifndef _PCL720_DEFINED
23 #define _PCL720_DEFINED
25 #define pcl720_data(base,bit) (base+(bit>>3))
26 #define pcl720_data_0_7(base) (base+0)
27 #define pcl720_data_8_15(base) (base+1)
28 #define pcl720_data_16_23(base) (base+2)
29 #define pcl720_data_24_31(base) (base+3)
30 #define pcl720_cntr(base,cntr) (base+4+cntr) /* cntr: 0..2 */
31 #define pcl720_cntr_0(base) (base+4)
32 #define pcl720_cntr_1(base) (base+5)
33 #define pcl720_cntr_2(base) (base+6)
34 #define pcl720_ctrl(base) (base+7)
37 #define pcl720_inb(x) inb(x)
38 #define pcl720_outb(x,y) outb(x,y)
40 static unsigned char pcl720_inb(int addr
) {
41 unsigned char x
= inb(addr
);
42 fprintf(DEBUG_PCL720
, "inb(0x%x) -> 0x%x\n", addr
, x
);
45 static void pcl720_outb(int addr
, unsigned char x
) {
47 fprintf(DEBUG_PCL720
, "outb(0x%x, 0x%x)\n", addr
, x
);
51 #define pcl720_load(Base,Cntr,Mode,Val) \
52 ({ register unsigned int b = Base, c = Cntr, v = Val; \
55 ctrl.s.bcd = i8253_binary; \
57 ctrl.s.rl = i8253_lmb; \
59 pcl720_outb(pcl720_ctrl(b), ctrl.i); \
60 pcl720_outb(pcl720_cntr(b,c), v); \
61 pcl720_outb(pcl720_cntr(b,c), v >> 8); \
65 #define pcl720_read(Base,Cntr) \
66 ({ register unsigned int b = Base, v; \
69 ctrl.s.rl = i8253_latch; \
70 ctrl.s.cntr = i8253_cntr_0; \
71 pcl720_outb(pcl720_ctrl(b), ctrl.i); \
72 v = pcl720_inb(pcl720_cntr_0(b)); \
73 v |= (pcl720_inb(pcl720_cntr_0(b)) << 8); \
77 #define pcl720_input(Base) \
78 ({ register unsigned int b = Base, v; \
80 v = pcl720_inb(pcl720_data_0_7(b)); \
81 v |= (pcl720_inb(pcl720_data_8_15(b)) << 8); \
82 v |= (pcl720_inb(pcl720_data_16_23(b)) << 16); \
83 v |= (pcl720_inb(pcl720_data_24_31(b)) << 24); \
87 #define pcl720_output(Base,Value) \
88 ({ register unsigned int b = Base, v = Value; \
90 pcl720_outb(pcl720_data_0_7(b), v); \
91 pcl720_outb(pcl720_data_8_15(b), v << 8); \
92 pcl720_outb(pcl720_data_16_23(b), v << 16); \
93 pcl720_outb(pcl720_data_24_31(b), v << 24); \
97 #endif /*_PCL720_DEFINED*/