xref: /netbsd-src/sys/arch/arm/footbridge/isa/sysbeep_isa.c (revision cbab9cadce21ae72fac13910001079fff214cc29)
1*cbab9cadSchs /*	$NetBSD: sysbeep_isa.c,v 1.11 2012/10/27 17:17:38 chs Exp $	*/
2a73dabb4Schris 
3a73dabb4Schris /*-
4a73dabb4Schris  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5a73dabb4Schris  * All rights reserved.
6a73dabb4Schris  *
7a73dabb4Schris  * This code is derived from software contributed to The NetBSD Foundation
8a73dabb4Schris  * by Mark Brinicombe of Causality Limited.
9a73dabb4Schris  *
10a73dabb4Schris  * Redistribution and use in source and binary forms, with or without
11a73dabb4Schris  * modification, are permitted provided that the following conditions
12a73dabb4Schris  * are met:
13a73dabb4Schris  * 1. Redistributions of source code must retain the above copyright
14a73dabb4Schris  *    notice, this list of conditions and the following disclaimer.
15a73dabb4Schris  * 2. Redistributions in binary form must reproduce the above copyright
16a73dabb4Schris  *    notice, this list of conditions and the following disclaimer in the
17a73dabb4Schris  *    documentation and/or other materials provided with the distribution.
18a73dabb4Schris  *
19a73dabb4Schris  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20a73dabb4Schris  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21a73dabb4Schris  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22a73dabb4Schris  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23a73dabb4Schris  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24a73dabb4Schris  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25a73dabb4Schris  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26a73dabb4Schris  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27a73dabb4Schris  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28a73dabb4Schris  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29a73dabb4Schris  * POSSIBILITY OF SUCH DAMAGE.
30a73dabb4Schris  */
31a73dabb4Schris 
329fd86b68Schris #include <sys/cdefs.h>
33*cbab9cadSchs __KERNEL_RCSID(0, "$NetBSD: sysbeep_isa.c,v 1.11 2012/10/27 17:17:38 chs Exp $");
349fd86b68Schris 
35a73dabb4Schris #include <sys/param.h>
36a73dabb4Schris #include <sys/systm.h>
37a73dabb4Schris #include <sys/device.h>
38a73dabb4Schris #include <dev/isa/isavar.h>
39a73dabb4Schris 
40a73dabb4Schris #include <dev/isa/pcppivar.h>
41a73dabb4Schris 
42a73dabb4Schris /* Prototypes */
43*cbab9cadSchs int sysbeep_isa_match(device_t, cfdata_t, void *);
44*cbab9cadSchs void sysbeep_isa_attach(device_t, device_t, void *);
45*cbab9cadSchs void sysbeep_isa(int, int);
46a73dabb4Schris 
47a73dabb4Schris /* device attach structure */
48*cbab9cadSchs CFATTACH_DECL_NEW(sysbeep_isa, 0,
49bd5bb465Sthorpej     sysbeep_isa_match, sysbeep_isa_attach, NULL, NULL);
50a73dabb4Schris 
51a73dabb4Schris static int ppi_attached;
52a73dabb4Schris static pcppi_tag_t ppicookie;
53a73dabb4Schris 
54a73dabb4Schris int
sysbeep_isa_match(device_t parent,cfdata_t match,void * aux)559cbe4c86Sskrll sysbeep_isa_match(device_t parent, cfdata_t match, void *aux)
56a73dabb4Schris {
57a73dabb4Schris 	return (!ppi_attached);
58a73dabb4Schris }
59a73dabb4Schris 
60a73dabb4Schris void
sysbeep_isa_attach(device_t parent,device_t self,void * aux)619cbe4c86Sskrll sysbeep_isa_attach(device_t parent, device_t self, void *aux)
62a73dabb4Schris {
639cbe4c86Sskrll 	aprint_normal("\n");
64a73dabb4Schris 
65a73dabb4Schris 	ppicookie = ((struct pcppi_attach_args *)aux)->pa_cookie;
66a73dabb4Schris 	ppi_attached = 1;
67a73dabb4Schris }
68a73dabb4Schris 
69a73dabb4Schris void
sysbeep(int pitch,int period)7082357f6dSdsl sysbeep(int pitch, int period)
71a73dabb4Schris {
72a73dabb4Schris 	if (ppi_attached)
73a73dabb4Schris 		pcppi_bell(ppicookie, pitch, period, 0);
74a73dabb4Schris }
75