Annotation of embedaddon/ntp/kernel/sys/pcl720.h, revision 1.1
1.1 ! misho 1: /* Copyright (c) 1995 Vixie Enterprises
! 2: *
! 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.
! 9: *
! 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
! 17: * SOFTWARE.
! 18: */
! 19:
! 20: #ifndef _PCL720_DEFINED
! 21: #define _PCL720_DEFINED
! 22:
! 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)
! 33:
! 34: #ifndef DEBUG_PCL720
! 35: #define pcl720_inb(x) inb(x)
! 36: #define pcl720_outb(x,y) outb(x,y)
! 37: #else
! 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);
! 41: return (x);
! 42: }
! 43: static void pcl720_outb(int addr, unsigned char x) {
! 44: outb(addr, x);
! 45: fprintf(DEBUG_PCL720, "outb(0x%x, 0x%x)\n", addr, x);
! 46: }
! 47: #endif
! 48:
! 49: #define pcl720_load(Base,Cntr,Mode,Val) \
! 50: ({ register unsigned int b = Base, c = Cntr, v = Val; \
! 51: i8253_ctrl ctrl; \
! 52: \
! 53: ctrl.s.bcd = i8253_binary; \
! 54: ctrl.s.mode = Mode; \
! 55: ctrl.s.rl = i8253_lmb; \
! 56: ctrl.s.cntr = c; \
! 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); \
! 60: v; \
! 61: })
! 62:
! 63: #define pcl720_read(Base,Cntr) \
! 64: ({ register unsigned int b = Base, v; \
! 65: i8253_ctrl ctrl; \
! 66: \
! 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); \
! 72: v; \
! 73: })
! 74:
! 75: #define pcl720_input(Base) \
! 76: ({ register unsigned int b = Base, v; \
! 77: \
! 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); \
! 82: v; \
! 83: })
! 84:
! 85: #define pcl720_output(Base,Value) \
! 86: ({ register unsigned int b = Base, v = Value; \
! 87: \
! 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); \
! 92: v; \
! 93: })
! 94:
! 95: #endif /*_PCL720_DEFINED*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>