sysbeep_isa.c revision 1.7
11.7Sdsl/*	$NetBSD: sysbeep_isa.c,v 1.7 2009/03/14 14:45:55 dsl 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 *
191.1Schris * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Schris * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Schris * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Schris * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Schris * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Schris * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Schris * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Schris * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Schris * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Schris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Schris * POSSIBILITY OF SUCH DAMAGE.
301.1Schris */
311.5Schris
321.5Schris#include <sys/cdefs.h>
331.7Sdsl__KERNEL_RCSID(0, "$NetBSD: sysbeep_isa.c,v 1.7 2009/03/14 14:45:55 dsl Exp $");
341.1Schris
351.1Schris#include <sys/param.h>
361.1Schris#include <sys/systm.h>
371.1Schris#include <sys/device.h>
381.1Schris#include <dev/isa/isavar.h>
391.1Schris
401.1Schris#include <dev/isa/pcppivar.h>
411.1Schris
421.1Schris/* Prototypes */
431.7Sdslint sysbeep_isa_match(struct device *parent, struct cfdata *cf, void *aux);
441.7Sdslvoid sysbeep_isa_attach(struct device *parent, struct device *self, void *aux);
451.7Sdslvoid sysbeep_isa(int pitch, int period);
461.1Schris
471.1Schris/* device attach structure */
481.3SthorpejCFATTACH_DECL(sysbeep_isa, sizeof(struct device),
491.4Sthorpej    sysbeep_isa_match, sysbeep_isa_attach, NULL, NULL);
501.1Schris
511.1Schrisstatic int ppi_attached;
521.1Schrisstatic pcppi_tag_t ppicookie;
531.1Schris
541.1Schrisint
551.1Schrissysbeep_isa_match(parent, match, aux)
561.1Schris	struct device *parent;
571.1Schris	struct cfdata *match;
581.1Schris	void *aux;
591.1Schris{
601.1Schris	return (!ppi_attached);
611.1Schris}
621.1Schris
631.1Schrisvoid
641.1Schrissysbeep_isa_attach(parent, self, aux)
651.1Schris	struct device *parent, *self;
661.1Schris	void *aux;
671.1Schris{
681.1Schris	printf("\n");
691.1Schris
701.1Schris	ppicookie = ((struct pcppi_attach_args *)aux)->pa_cookie;
711.1Schris	ppi_attached = 1;
721.1Schris}
731.1Schris
741.1Schrisvoid
751.1Schrissysbeep(pitch, period)
761.1Schris	int pitch, period;
771.1Schris{
781.1Schris	if (ppi_attached)
791.1Schris		pcppi_bell(ppicookie, pitch, period, 0);
801.1Schris}
81