From owner-freebsd-drivers@FreeBSD.ORG Wed Sep 29 16:36:38 2010 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 972811065672 for ; Wed, 29 Sep 2010 16:36:38 +0000 (UTC) (envelope-from dsriniv@ncsu.edu) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 39DD68FC14 for ; Wed, 29 Sep 2010 16:36:37 +0000 (UTC) Received: by wyb33 with SMTP id 33so42706wyb.13 for ; Wed, 29 Sep 2010 09:36:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.166.203 with SMTP id g53mr2702864wel.54.1285776447623; Wed, 29 Sep 2010 09:07:27 -0700 (PDT) Received: by 10.216.133.89 with HTTP; Wed, 29 Sep 2010 09:07:27 -0700 (PDT) Date: Wed, 29 Sep 2010 12:07:27 -0400 Message-ID: From: Deepa Srinivasan To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Requesting an IRQ X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Sep 2010 16:36:38 -0000 I'm writing a "pseudo" device driver for FreeBSD 5.0 - i.e. there is no physical device backing it. But I need to be able to send an interrupt to it from an underlying hypervisor (KVM). FreeBSD runs as a guest OS. I have done the same in Linux - wrote a kernel module and used the "request_irq" function to allocate an unused interrupt number. When the underlying KVM injects an interrupt into the guest OS, the registered interrupt handler gets called as expected. However, in FreeBSD, I cannot find an equivalent function to "request_irq". Going with the available documentation and sample code, I tried modifying a PCI driver (this may be overkill for what I'm doing, but still...) and used the bus_alloc_resource() and bus_setup_intr() functions. In my OS configuration, this results in the "irq9" being allocated to my driver. But the same IRQ is also allocated to "acpi0". Now, when I inject an interrupt from the hypervisor, it immediately causes an "interrupt storm" and I see this message continuously printed: "interrupt storm detected on irq9; throttling interrupt source". This happens even without my driver being loaded. In the KVM hypervisor code, I set the interrupt to "1" and immediately to "0" and I know for sure that this code path is being executed. My question is: - Is it possible to write a pseudo device driver and use something like the "request_irq" in Linux to just be able to invoke a callback function in the driver? - Is it possible to specify the interrupt number that needs to be allocated to my device driver so I can ensure that it is not shared with anything else? Thanks for any help. - Deepa