]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - doc/html/ref/devapi-device-driver-interface-to-the-kernel.html
RedBoot TX53 Release 2012-02-15
[karo-tx-redboot.git] / doc / html / ref / devapi-device-driver-interface-to-the-kernel.html
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.               -->
9 <HTML
10 ><HEAD
11 ><TITLE
12 >Device Driver Interface to the Kernel</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
14 <META
15 NAME="GENERATOR"
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17 "><LINK
18 REL="HOME"
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
21 REL="UP"
22 TITLE="I/O Package (Device Drivers)"
23 HREF="io.html"><LINK
24 REL="PREVIOUS"
25 TITLE="Serial testing with ser_filter"
26 HREF="io-serial-testing-with-serfilter.html"><LINK
27 REL="NEXT"
28 TITLE="Synchronization"
29 HREF="devapi-synchronization.html"></HEAD
30 ><BODY
31 CLASS="CHAPTER"
32 BGCOLOR="#FFFFFF"
33 TEXT="#000000"
34 LINK="#0000FF"
35 VLINK="#840084"
36 ALINK="#0000FF"
37 ><DIV
38 CLASS="NAVHEADER"
39 ><TABLE
40 SUMMARY="Header navigation table"
41 WIDTH="100%"
42 BORDER="0"
43 CELLPADDING="0"
44 CELLSPACING="0"
45 ><TR
46 ><TH
47 COLSPAN="3"
48 ALIGN="center"
49 >eCos Reference Manual</TH
50 ></TR
51 ><TR
52 ><TD
53 WIDTH="10%"
54 ALIGN="left"
55 VALIGN="bottom"
56 ><A
57 HREF="io-serial-testing-with-serfilter.html"
58 ACCESSKEY="P"
59 >Prev</A
60 ></TD
61 ><TD
62 WIDTH="80%"
63 ALIGN="center"
64 VALIGN="bottom"
65 ></TD
66 ><TD
67 WIDTH="10%"
68 ALIGN="right"
69 VALIGN="bottom"
70 ><A
71 HREF="devapi-synchronization.html"
72 ACCESSKEY="N"
73 >Next</A
74 ></TD
75 ></TR
76 ></TABLE
77 ><HR
78 ALIGN="LEFT"
79 WIDTH="100%"></DIV
80 ><DIV
81 CLASS="CHAPTER"
82 ><H1
83 ><A
84 NAME="DEVAPI-DEVICE-DRIVER-INTERFACE-TO-THE-KERNEL">Chapter 18. Device Driver Interface to the Kernel</H1
85 ><DIV
86 CLASS="TOC"
87 ><DL
88 ><DT
89 ><B
90 >Table of Contents</B
91 ></DT
92 ><DT
93 ><A
94 HREF="devapi-device-driver-interface-to-the-kernel.html#DEVAPI-INTERRUPT-MODEL"
95 >Interrupt Model</A
96 ></DT
97 ><DT
98 ><A
99 HREF="devapi-synchronization.html"
100 >Synchronization</A
101 ></DT
102 ><DT
103 ><A
104 HREF="devapi-smp-support.html"
105 >SMP Support</A
106 ></DT
107 ><DT
108 ><A
109 HREF="devapi-device-driver-models.html"
110 >Device Driver Models</A
111 ></DT
112 ><DT
113 ><A
114 HREF="devapi-synchronization-levels.html"
115 >Synchronization Levels</A
116 ></DT
117 ><DT
118 ><A
119 HREF="devapi-api.html"
120 >The API</A
121 ></DT
122 ></DL
123 ></DIV
124 ><P
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
129 ><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
133 ><DIV
134 CLASS="SECTION"
135 ><H1
136 CLASS="SECTION"
137 ><A
138 NAME="DEVAPI-INTERRUPT-MODEL">Interrupt Model</H1
139 ><P
140 ><SPAN
141 CLASS="emphasis"
142 ><I
143 CLASS="EMPHASIS"
144 >eCos</I
145 ></SPAN
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
151 ><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
157 scheduled to run.</P
158 ><P
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
164 <TT
165 CLASS="FUNCTION"
166 >cyg_drv_cond_signal()</TT
167 > to wake up waiting
168 threads.</P
169 ><P
170 >Finally, threads are able to make all API calls and in particular are
171 allowed to wait on mutexes and condition variables. </P
172 ><P
173 >For a device driver to receive interrupts it must first define ISR and
174 DSR routines as shown below, and then call
175 <TT
176 CLASS="FUNCTION"
177 >cyg_drv_interrupt_create()</TT
178 >.  Using the handle
179 returned, the driver must then call
180 <TT
181 CLASS="FUNCTION"
182 >cyg_drv_interrupt_attach()</TT
183 > to actually attach the
184 interrupt to the hardware vector.</P
185 ></DIV
186 ></DIV
187 ><DIV
188 CLASS="NAVFOOTER"
189 ><HR
190 ALIGN="LEFT"
191 WIDTH="100%"><TABLE
192 SUMMARY="Footer navigation table"
193 WIDTH="100%"
194 BORDER="0"
195 CELLPADDING="0"
196 CELLSPACING="0"
197 ><TR
198 ><TD
199 WIDTH="33%"
200 ALIGN="left"
201 VALIGN="top"
202 ><A
203 HREF="io-serial-testing-with-serfilter.html"
204 ACCESSKEY="P"
205 >Prev</A
206 ></TD
207 ><TD
208 WIDTH="34%"
209 ALIGN="center"
210 VALIGN="top"
211 ><A
212 HREF="ecos-ref.html"
213 ACCESSKEY="H"
214 >Home</A
215 ></TD
216 ><TD
217 WIDTH="33%"
218 ALIGN="right"
219 VALIGN="top"
220 ><A
221 HREF="devapi-synchronization.html"
222 ACCESSKEY="N"
223 >Next</A
224 ></TD
225 ></TR
226 ><TR
227 ><TD
228 WIDTH="33%"
229 ALIGN="left"
230 VALIGN="top"
231 >Serial testing with ser_filter</TD
232 ><TD
233 WIDTH="34%"
234 ALIGN="center"
235 VALIGN="top"
236 ><A
237 HREF="io.html"
238 ACCESSKEY="U"
239 >Up</A
240 ></TD
241 ><TD
242 WIDTH="33%"
243 ALIGN="right"
244 VALIGN="top"
245 >Synchronization</TD
246 ></TR
247 ></TABLE
248 ></DIV
249 ></BODY
250 ></HTML
251 >