1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Device Driver Interface to the Kernel</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="I/O Package (Device Drivers)"
25 TITLE="Serial testing with ser_filter"
26 HREF="io-serial-testing-with-serfilter.html"><LINK
28 TITLE="Synchronization"
29 HREF="devapi-synchronization.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="io-serial-testing-with-serfilter.html"
71 HREF="devapi-synchronization.html"
84 NAME="DEVAPI-DEVICE-DRIVER-INTERFACE-TO-THE-KERNEL">Chapter 18. Device Driver Interface to the Kernel</H1
94 HREF="devapi-device-driver-interface-to-the-kernel.html#DEVAPI-INTERRUPT-MODEL"
99 HREF="devapi-synchronization.html"
104 HREF="devapi-smp-support.html"
109 HREF="devapi-device-driver-models.html"
110 >Device Driver Models</A
114 HREF="devapi-synchronization-levels.html"
115 >Synchronization Levels</A
119 HREF="devapi-api.html"
125 >This chapter describes the API that device drivers may use
126 to interact with the kernel and HAL. It is primarily concerned with
127 the control and management of interrupts and the synchronization of
128 ISRs, DSRs and threads.</P
130 >The same API will be present in configurations where the kernel
131 is not present. In this case the functions will be supplied by code
132 acting directly on the HAL.</P
138 NAME="DEVAPI-INTERRUPT-MODEL">Interrupt Model</H1
146 > presents a three level interrupt model to
147 device drivers. This consists of Interrupt Service Routines (ISRs) that are invoked
148 in response to a hardware interrupt; Deferred
149 Service Routines (DSRs) that are invoked in response to a request by
150 an ISR; and threads that are the clients of the driver. </P
152 >Hardware interrupts are delivered with minimal intervention to an
153 ISR. The HAL decodes the hardware source of the interrupt and calls
154 the ISR of the attached interrupt object. This ISR may manipulate the
155 hardware but is only allowed to make a restricted set of calls on the
156 driver API. When it returns, an ISR may request that its DSR should be
159 >A DSR will be run when it is safe to do so without interfering with
160 the scheduler. Most of the time the DSR will run immediately after the
161 ISR, but if the current thread is in the scheduler, it will be delayed
162 until the thread is finished. A DSR is allowed to make a larger set of
163 driver API calls, including, in particular, being able to call
166 >cyg_drv_cond_signal()</TT
170 >Finally, threads are able to make all API calls and in particular are
171 allowed to wait on mutexes and condition variables. </P
173 >For a device driver to receive interrupts it must first define ISR and
174 DSR routines as shown below, and then call
177 >cyg_drv_interrupt_create()</TT
179 returned, the driver must then call
182 >cyg_drv_interrupt_attach()</TT
183 > to actually attach the
184 interrupt to the hardware vector.</P
192 SUMMARY="Footer navigation table"
203 HREF="io-serial-testing-with-serfilter.html"
221 HREF="devapi-synchronization.html"
231 >Serial testing with ser_filter</TD