sysbeep_isa.c revision 1.4
11.4Sthorpej/*	$NetBSD: sysbeep_isa.c,v 1.4 2002/10/02 15:45:10 thorpej Exp $	*/
21.1Schris
31.1Schris/*-
41.1Schris * Copyright (c) 1998 The NetBSD Foundation, Inc.
51.1Schris * All rights reserved.
61.1Schris *
71.1Schris * This code is derived from software contributed to The NetBSD Foundation
81.1Schris * by Mark Brinicombe of Causality Limited.
91.1Schris *
101.1Schris * Redistribution and use in source and binary forms, with or without
111.1Schris * modification, are permitted provided that the following conditions
121.1Schris * are met:
131.1Schris * 1. Redistributions of source code must retain the above copyright
141.1Schris *    notice, this list of conditions and the following disclaimer.
151.1Schris * 2. Redistributions in binary form must reproduce the above copyright
161.1Schris *    notice, this list of conditions and the following disclaimer in the
171.1Schris *    documentation and/or other materials provided with the distribution.
181.1Schris * 3. All advertising materials mentioning features or use of this software
191.1Schris *    must display the following acknowledgement:
201.1Schris *	This product includes software developed by the NetBSD
211.1Schris *	Foundation, Inc. and its contributors.
221.1Schris * 4. Neither the name of The NetBSD Foundation nor the names of its
231.1Schris *    contributors may be used to endorse or promote products derived
241.1Schris *    from this software without specific prior written permission.
251.1Schris *
261.1Schris * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.1Schris * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.1Schris * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.1Schris * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.1Schris * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.1Schris * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.1Schris * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.1Schris * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.1Schris * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.1Schris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.1Schris * POSSIBILITY OF SUCH DAMAGE.
371.1Schris */
381.1Schris
391.1Schris#include <sys/param.h>
401.1Schris#include <sys/systm.h>
411.1Schris#include <sys/device.h>
421.1Schris#include <dev/isa/isavar.h>
431.1Schris
441.1Schris#include <dev/isa/pcppivar.h>
451.1Schris
461.1Schris/* Prototypes */
471.1Schrisint sysbeep_isa_match __P((struct device *parent, struct cfdata *cf, void *aux));
481.1Schrisvoid sysbeep_isa_attach __P((struct device *parent, struct device *self, void *aux));
491.1Schrisvoid sysbeep_isa __P((int pitch, int period));
501.1Schris
511.1Schris/* device attach structure */
521.3SthorpejCFATTACH_DECL(sysbeep_isa, sizeof(struct device),
531.4Sthorpej    sysbeep_isa_match, sysbeep_isa_attach, NULL, NULL);
541.1Schris
551.1Schrisstatic int ppi_attached;
561.1Schrisstatic pcppi_tag_t ppicookie;
571.1Schris
581.1Schrisint
591.1Schrissysbeep_isa_match(parent, match, aux)
601.1Schris	struct device *parent;
611.1Schris	struct cfdata *match;
621.1Schris	void *aux;
631.1Schris{
641.1Schris	return (!ppi_attached);
651.1Schris}
661.1Schris
671.1Schrisvoid
681.1Schrissysbeep_isa_attach(parent, self, aux)
691.1Schris	struct device *parent, *self;
701.1Schris	void *aux;
711.1Schris{
721.1Schris	printf("\n");
731.1Schris
741.1Schris	ppicookie = ((struct pcppi_attach_args *)aux)->pa_cookie;
751.1Schris	ppi_attached = 1;
761.1Schris}
771.1Schris
781.1Schrisvoid
791.1Schrissysbeep(pitch, period)
801.1Schris	int pitch, period;
811.1Schris{
821.1Schris	if (ppi_attached)
831.1Schris		pcppi_bell(ppicookie, pitch, period, 0);
841.1Schris}
85