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