timerreg.h revision 146211
1146211Snyan/*- 2146211Snyan * Copyright (C) 2005 TAKAHASHI Yoshihiro. All rights reserved. 3146211Snyan * 4146211Snyan * Redistribution and use in source and binary forms, with or without 5146211Snyan * modification, are permitted provided that the following conditions 6146211Snyan * are met: 7146211Snyan * 1. Redistributions of source code must retain the above copyright 8146211Snyan * notice, this list of conditions and the following disclaimer. 9146211Snyan * 2. Redistributions in binary form must reproduce the above copyright 10146211Snyan * notice, this list of conditions and the following disclaimer in the 11146211Snyan * documentation and/or other materials provided with the distribution. 12146211Snyan * 13146211Snyan * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14146211Snyan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15146211Snyan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16146211Snyan * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 17146211Snyan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18146211Snyan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19146211Snyan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20146211Snyan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21146211Snyan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22146211Snyan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23146211Snyan * SUCH DAMAGE. 24146211Snyan * 25146211Snyan * $FreeBSD: head/sys/i386/include/timerreg.h 146211 2005-05-14 09:10:02Z nyan $ 26146211Snyan */ 27146211Snyan 28146211Snyan/* 29146211Snyan * The outputs of the three timers are connected as follows: 30146211Snyan * 31146211Snyan * timer 0 -> irq 0 32146211Snyan * timer 1 -> dma chan 0 (for dram refresh) 33146211Snyan * timer 2 -> speaker (via keyboard controller) 34146211Snyan * 35146211Snyan * Timer 0 is used to call hardclock. 36146211Snyan * Timer 2 is used to generate console beeps. 37146211Snyan */ 38146211Snyan 39146211Snyan#ifndef _MACHINE_TIMERREG_H_ 40146211Snyan#define _MACHINE_TIMERREG_H_ 41146211Snyan 42146211Snyan#ifdef _KERNEL 43146211Snyan 44146211Snyan#include <dev/ic/i8253reg.h> 45146211Snyan 46146211Snyan#define IO_TIMER1 0x40 /* 8253 Timer #1 */ 47146211Snyan#define TIMER_CNTR0 (IO_TIMER1 + TIMER_REG_CNTR0) 48146211Snyan#define TIMER_CNTR1 (IO_TIMER1 + TIMER_REG_CNTR1) 49146211Snyan#define TIMER_CNTR2 (IO_TIMER1 + TIMER_REG_CNTR2) 50146211Snyan#define TIMER_MODE (IO_TIMER1 + TIMER_REG_MODE) 51146211Snyan 52146211Snyan#define timer_spkr_acquire() \ 53146211Snyan acquire_timer2(TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT) 54146211Snyan#define timer_spkr_release() \ 55146211Snyan release_timer2() 56146211Snyan 57146211Snyanstatic __inline void 58146211Snyanspkr_set_pitch(u_int16_t pitch) 59146211Snyan{ 60146211Snyan 61146211Snyan outb(TIMER_CNTR2, pitch & 0xff); 62146211Snyan outb(TIMER_CNTR2, pitch >> 8); 63146211Snyan} 64146211Snyan 65146211Snyan#endif /* _KERNEL */ 66146211Snyan 67146211Snyan#endif /* _MACHINE_TIMERREG_H_ */ 68