From 6054cda4de2341b9a77ec4421411725f3684006b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 10 Jul 2020 00:23:32 +0200 Subject: Add hardware interrupt notification mechanism This allows privileged userland drivers to get notifications of hardware interrupts. Initial work by Zheng Da, reworked by Damien Zammit and myself. * Makefrag.am (libkernel_a_SOURCES): Add device/intr.c and device/intr.h. (include_device_HEADERS): Add include/device/notify.defs and include/device/notify.h. * device/dev_hdr.h (name_equal): Add declaration. * device/ds_routines.c: Include (ds_device_intr_register, ds_device_intr_ack): New functions. * device/intr.c, device/intr.h: New files. * doc/mach.texi (Device Interrupt): New section. * i386/Makefrag.am (libkernel_a_SOURCES): Add i386/i386/irq.c and i386/i386/irq.h. * i386/i386/irq.c, i386/i386/irq.h: New files. * i386/i386at/conf.c: Include . (irqname): New macro. (dev_name_list): Add irq device. * include/device/device.defs (device_intr_register, device_intr_ack): New RPCs. * include/device/notify.defs, include/device/notify.h: New files. * kern/startup.c: Include (start_kernel_threads): Start intr_thread thread. * linux/dev/arch/i386/kernel/irq.c: Include (linux_action): Add user_intr field. (linux_intr): Call user_intr action if any. (mask_irq, unmask_irq): Move functions to i386/i386/pic.c (__disable_irq, __enable_irq): Move functions to i386/i386/irq.c. (install_user_intr_handler): New function. (request_irq): Initialize user_intr field. * linux/src/include/asm-i386/irq.h (__disable_irq, __enable_irq): Remove prototypes. * i386/i386/pic.c (mask_irq, unmask_irq): New functions. * i386/i386/pic.h (mask_irq, unmask_irq): New prototypes. --- doc/mach.texi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'doc') diff --git a/doc/mach.texi b/doc/mach.texi index 91ec96ee..11b0a066 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -286,6 +286,7 @@ Device Interface * Device Map:: Mapping devices into virtual memory. * Device Status:: Querying and manipulating a device. * Device Filter:: Filtering packets arriving on a device. +* Device Interrupt:: Getting hardware interrupt notifications. Kernel Debugger @@ -6305,6 +6306,7 @@ All constants and functions in this chapter are defined in * Device Map:: Mapping devices into virtual memory. * Device Status:: Querying and manipulating a device. * Device Filter:: Filtering packets arriving on a device. +* Device Interrupt:: Getting hardware interrupt notifications. @end menu @@ -6699,6 +6701,26 @@ a device port or the device is dead or not completely open. @end deftypefun +@node Device Interrupt +@section Device Interrupt + +@deftypefun kern_return_t device_intr_register (@w{device_t @var{device}}, @w{int @var{id}}, @w{int @var{flags}}, @w{mach_port_t @var{receive_port}}) +The function @code{device_intr_register} registers for receiving hardware +interrupt events through @var{device_intr_notify} notifications. The hardware +interrupt identifier is specified by @var{id}. @var{flags} must be set to 0. The +notifications will be sent on the @var{receive_port} send right. +@code{device_intr_register} is only available on the dedicated @code{irq} device. +@end deftypefun + +@deftypefun kern_return_t device_intr_ack (@w{device_t @var{device}}, @w{mach_port_t @var{receive_port}}) +On a hardware interrupt, the kernel disables the interrupt line before sending +notifications. To prevent from interrupt losses, the interrupt is kept disabled +until @code{device_intr_ack} is called to acknowledge the interrupt. +@var{receive_port} is the send right on which the interrupt notification was +received. +@end deftypefun + + @node Kernel Debugger @chapter Kernel Debugger -- cgit v1.2.3