xref: /netbsd-src/sys/arch/prep/isa/isabeep.c (revision ec1797c173fd96659f1e3e648addcd7e3408b345)
1*ec1797c1Smatt /*	$NetBSD: isabeep.c,v 1.10 2011/06/06 16:42:18 matt Exp $	*/
237eb9eebSnonaka 
337eb9eebSnonaka /*
437eb9eebSnonaka  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
537eb9eebSnonaka  * All rights reserved.
637eb9eebSnonaka  *
737eb9eebSnonaka  * Author: Chris G. Demetriou
837eb9eebSnonaka  *
937eb9eebSnonaka  * Permission to use, copy, modify and distribute this software and
1037eb9eebSnonaka  * its documentation is hereby granted, provided that both the copyright
1137eb9eebSnonaka  * notice and this permission notice appear in all copies of the
1237eb9eebSnonaka  * software, derivative works or modified versions, and any portions
1337eb9eebSnonaka  * thereof, and that both notices appear in supporting documentation.
1437eb9eebSnonaka  *
1537eb9eebSnonaka  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
1637eb9eebSnonaka  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
1737eb9eebSnonaka  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
1837eb9eebSnonaka  *
1937eb9eebSnonaka  * Carnegie Mellon requests users of this software to return to
2037eb9eebSnonaka  *
2137eb9eebSnonaka  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
2237eb9eebSnonaka  *  School of Computer Science
2337eb9eebSnonaka  *  Carnegie Mellon University
2437eb9eebSnonaka  *  Pittsburgh PA 15213-3890
2537eb9eebSnonaka  *
2637eb9eebSnonaka  * any improvements or extensions that they make and grant Carnegie the
2737eb9eebSnonaka  * rights to redistribute these changes.
2837eb9eebSnonaka  */
2937eb9eebSnonaka 
30ed517291Slukem #include <sys/cdefs.h>
31*ec1797c1Smatt __KERNEL_RCSID(0, "$NetBSD: isabeep.c,v 1.10 2011/06/06 16:42:18 matt Exp $");
32ed517291Slukem 
3337eb9eebSnonaka #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
3437eb9eebSnonaka 
3537eb9eebSnonaka #include <sys/types.h>
3637eb9eebSnonaka #include <sys/param.h>
3737eb9eebSnonaka #include <sys/time.h>
3837eb9eebSnonaka #include <sys/systm.h>
3937eb9eebSnonaka #include <sys/errno.h>
4037eb9eebSnonaka #include <sys/device.h>
41fa00dc59Smrg #include <uvm/uvm_extern.h>
4237eb9eebSnonaka 
4337eb9eebSnonaka #include <dev/isa/isavar.h>
4437eb9eebSnonaka 
4537eb9eebSnonaka #include "pcppi.h"
4637eb9eebSnonaka #if NPCPPI > 0
4737eb9eebSnonaka #include <dev/isa/pcppivar.h>
4837eb9eebSnonaka 
49*ec1797c1Smatt int isabeepmatch(device_t, cfdata_t, void *);
50*ec1797c1Smatt void isabeepattach(device_t, device_t, void *);
5137eb9eebSnonaka 
52*ec1797c1Smatt CFATTACH_DECL_NEW(isabeep, 0,
5389bf5a8fSthorpej     isabeepmatch, isabeepattach, NULL, NULL);
5437eb9eebSnonaka 
5537eb9eebSnonaka static int ppi_attached;
5637eb9eebSnonaka static pcppi_tag_t ppicookie;
5737eb9eebSnonaka 
5837eb9eebSnonaka int
isabeepmatch(device_t parent,cfdata_t match,void * aux)59*ec1797c1Smatt isabeepmatch(device_t parent, cfdata_t match, void *aux)
6037eb9eebSnonaka {
6137eb9eebSnonaka 	return (!ppi_attached);
6237eb9eebSnonaka }
6337eb9eebSnonaka 
6437eb9eebSnonaka void
isabeepattach(device_t parent,device_t self,void * aux)65*ec1797c1Smatt isabeepattach(device_t parent, device_t self, void *aux)
6637eb9eebSnonaka {
67d974db0aSgarbled 	aprint_normal("\n");
6837eb9eebSnonaka 
6937eb9eebSnonaka 	ppicookie = ((struct pcppi_attach_args *)aux)->pa_cookie;
7037eb9eebSnonaka 	ppi_attached = 1;
7137eb9eebSnonaka }
7237eb9eebSnonaka #endif
7337eb9eebSnonaka 
7437eb9eebSnonaka void
isabeep(int pitch,int period)756434af65Sgarbled isabeep(int pitch, int period)
7637eb9eebSnonaka {
7737eb9eebSnonaka #if NPCPPI > 0
7837eb9eebSnonaka 	if (ppi_attached)
7937eb9eebSnonaka 		pcppi_bell(ppicookie, pitch, period, 0);
8037eb9eebSnonaka #endif
8137eb9eebSnonaka }
82