|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* ! 26: * Copyright (c) 1992 NeXT Computer, Inc. ! 27: * ! 28: * Timer (PIT) access routines. ! 29: * ! 30: * HISTORY ! 31: * ! 32: * 24 March 1992 ? at NeXT ! 33: * Created. ! 34: */ ! 35: ! 36: #import <machdep/i386/timer.h> ! 37: #import <machdep/i386/io_inline.h> ! 38: ! 39: #define timer_get_ctl _timer_get_ctl_ ! 40: static inline timer_ctl_reg_t ! 41: _timer_get_ctl_() ! 42: { ! 43: union { ! 44: timer_ctl_reg_t reg; ! 45: unsigned char iodata; ! 46: } temp; ! 47: ! 48: temp.iodata = inb(TIMER_CTL_PORT); ! 49: ! 50: return (temp.reg); ! 51: } ! 52: ! 53: #define timer_set_ctl _timer_set_ctl_ ! 54: static inline void ! 55: _timer_set_ctl_(reg) ! 56: timer_ctl_reg_t reg; ! 57: { ! 58: union { ! 59: timer_ctl_reg_t reg; ! 60: unsigned char iodata; ! 61: } temp; ! 62: ! 63: temp.reg = reg; ! 64: ! 65: outb(TIMER_CTL_PORT, temp.iodata); ! 66: } ! 67: ! 68: #define timer_latch _timer_latch_ ! 69: static inline void ! 70: _timer_latch_(sel) ! 71: int sel; ! 72: { ! 73: timer_ctl_reg_t reg; ! 74: ! 75: reg = (timer_ctl_reg_t){ 0 }; ! 76: reg.sel = sel; ! 77: ! 78: timer_set_ctl(reg); ! 79: } ! 80: ! 81: #define TIMER_CNT_PORT(n) \ ! 82: _timer_cnt_port_[(n)] ! 83: static const int _timer_cnt_port_[] = ! 84: { TIMER_CNT0_PORT, TIMER_CNT1_PORT, TIMER_CNT2_PORT }; ! 85: ! 86: #define timer_read _timer_read_ ! 87: static inline timer_cnt_val_t ! 88: _timer_read_(sel) ! 89: int sel; ! 90: { ! 91: union { ! 92: timer_cnt_val_t val; ! 93: unsigned char iodata[2]; ! 94: } temp; ! 95: ! 96: temp.iodata[0] = inb(TIMER_CNT_PORT(sel)); ! 97: temp.iodata[1] = inb(TIMER_CNT_PORT(sel)); ! 98: ! 99: return (temp.val); ! 100: } ! 101: ! 102: #define timer_write _timer_write_ ! 103: static inline void ! 104: _timer_write_(sel, val) ! 105: int sel; ! 106: timer_cnt_val_t val; ! 107: { ! 108: union { ! 109: timer_cnt_val_t val; ! 110: unsigned char iodata[2]; ! 111: } temp; ! 112: ! 113: temp.val = val; ! 114: ! 115: outb(TIMER_CNT_PORT(sel), temp.iodata[0]); ! 116: outb(TIMER_CNT_PORT(sel), temp.iodata[1]); ! 117: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.