xref: /netbsd-src/sys/arch/prep/isa/isabeep.c (revision ec1797c173fd96659f1e3e648addcd7e3408b345)
1 /*	$NetBSD: isabeep.c,v 1.10 2011/06/06 16:42:18 matt Exp $	*/
2 
3 /*
4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: isabeep.c,v 1.10 2011/06/06 16:42:18 matt Exp $");
32 
33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
34 
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/time.h>
38 #include <sys/systm.h>
39 #include <sys/errno.h>
40 #include <sys/device.h>
41 #include <uvm/uvm_extern.h>
42 
43 #include <dev/isa/isavar.h>
44 
45 #include "pcppi.h"
46 #if NPCPPI > 0
47 #include <dev/isa/pcppivar.h>
48 
49 int isabeepmatch(device_t, cfdata_t, void *);
50 void isabeepattach(device_t, device_t, void *);
51 
52 CFATTACH_DECL_NEW(isabeep, 0,
53     isabeepmatch, isabeepattach, NULL, NULL);
54 
55 static int ppi_attached;
56 static pcppi_tag_t ppicookie;
57 
58 int
isabeepmatch(device_t parent,cfdata_t match,void * aux)59 isabeepmatch(device_t parent, cfdata_t match, void *aux)
60 {
61 	return (!ppi_attached);
62 }
63 
64 void
isabeepattach(device_t parent,device_t self,void * aux)65 isabeepattach(device_t parent, device_t self, void *aux)
66 {
67 	aprint_normal("\n");
68 
69 	ppicookie = ((struct pcppi_attach_args *)aux)->pa_cookie;
70 	ppi_attached = 1;
71 }
72 #endif
73 
74 void
isabeep(int pitch,int period)75 isabeep(int pitch, int period)
76 {
77 #if NPCPPI > 0
78 	if (ppi_attached)
79 		pcppi_bell(ppicookie, pitch, period, 0);
80 #endif
81 }
82