OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [devapi-device-driver-models.html] - Blame information for rev 28

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
<!-- 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 Models</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="Device Driver Interface to the Kernel"
23
HREF="devapi-device-driver-interface-to-the-kernel.html"><LINK
24
REL="PREVIOUS"
25
TITLE="SMP Support"
26
HREF="devapi-smp-support.html"><LINK
27
REL="NEXT"
28
TITLE="Synchronization Levels"
29
HREF="devapi-synchronization-levels.html"></HEAD
30
><BODY
31
CLASS="SECTION"
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="devapi-smp-support.html"
58
ACCESSKEY="P"
59
>Prev</A
60
></TD
61
><TD
62
WIDTH="80%"
63
ALIGN="center"
64
VALIGN="bottom"
65
>Chapter 18. Device Driver Interface to the Kernel</TD
66
><TD
67
WIDTH="10%"
68
ALIGN="right"
69
VALIGN="bottom"
70
><A
71
HREF="devapi-synchronization-levels.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="SECTION"
82
><H1
83
CLASS="SECTION"
84
><A
85
NAME="DEVAPI-DEVICE-DRIVER-MODELS">Device Driver Models</H1
86
><P
87
>There are several ways in which device drivers
88
may be built. The exact model chosen will depend on the properties of
89
the device and the behavior desired. There are three basic models that
90
may be adopted.</P
91
><P
92
>The first model is to do all device processing in the ISR.  When it is
93
invoked the ISR programs the device hardware directly and accesses
94
data to be transferred directly in memory. The ISR should also call
95
<TT
96
CLASS="FUNCTION"
97
>cyg_drv_interrupt_acknowledge()</TT
98
>.  When it is
99
finished it may optionally request that its DSR be invoked.  The DSR
100
does nothing but call <TT
101
CLASS="FUNCTION"
102
>cyg_drv_cond_signal()</TT
103
> to
104
cause a thread to be woken up. Thread level code must call
105
<TT
106
CLASS="FUNCTION"
107
>cyg_drv_isr_lock()</TT
108
>, or
109
<TT
110
CLASS="FUNCTION"
111
>cyg_drv_interrupt_mask()</TT
112
> to prevent ISRs running
113
while it manipulates shared memory.</P
114
><P
115
>The second model is to defer device processing to the DSR.  The ISR
116
simply prevents further delivery of interrupts by either programming
117
the device, or by calling
118
<TT
119
CLASS="FUNCTION"
120
>cyg_drv_interrupt_mask()</TT
121
>.  It must then call
122
<TT
123
CLASS="FUNCTION"
124
>cyg_drv_interrupt_acknowledge()</TT
125
> to allow other
126
interrupts to be delivered and then request that its DSR be
127
called. When the DSR runs it does the majority of the device handling,
128
optionally signals a condition variable to wake a thread, and finishes
129
by calling <TT
130
CLASS="FUNCTION"
131
>cyg_drv_interrupt_unmask()</TT
132
> to re-allow
133
device interrupts. Thread level code uses
134
<TT
135
CLASS="FUNCTION"
136
>cyg_drv_dsr_lock()</TT
137
> to prevent DSRs running while
138
it manipulates shared memory.  The eCos serial device drivers use this
139
approach.</P
140
><P
141
>The third model is to defer device processing even further to a
142
thread. The ISR behaves exactly as in the previous model and simply
143
blocks and acknowledges the interrupt before request that the DSR
144
run. The DSR itself only calls
145
<TT
146
CLASS="FUNCTION"
147
>cyg_drv_cond_signal()</TT
148
> to wake the thread. When
149
the thread awakens it performs all device processing, and has full
150
access to all kernel facilities while it does so. It should finish by
151
calling <TT
152
CLASS="FUNCTION"
153
>cyg_drv_interrupt_unmask()</TT
154
> to re-allow
155
device interrupts.  The eCos ethernet device drivers are written to
156
this model.</P
157
><P
158
>The first model is good for devices that need immediate processing and
159
interact infrequently with thread level. The second model trades a
160
little latency in dealing with the device for a less intrusive
161
synchronization mechanism. The last model allows device processing to
162
be scheduled with other threads and permits more complex device
163
handling.</P
164
></DIV
165
><DIV
166
CLASS="NAVFOOTER"
167
><HR
168
ALIGN="LEFT"
169
WIDTH="100%"><TABLE
170
SUMMARY="Footer navigation table"
171
WIDTH="100%"
172
BORDER="0"
173
CELLPADDING="0"
174
CELLSPACING="0"
175
><TR
176
><TD
177
WIDTH="33%"
178
ALIGN="left"
179
VALIGN="top"
180
><A
181
HREF="devapi-smp-support.html"
182
ACCESSKEY="P"
183
>Prev</A
184
></TD
185
><TD
186
WIDTH="34%"
187
ALIGN="center"
188
VALIGN="top"
189
><A
190
HREF="ecos-ref.html"
191
ACCESSKEY="H"
192
>Home</A
193
></TD
194
><TD
195
WIDTH="33%"
196
ALIGN="right"
197
VALIGN="top"
198
><A
199
HREF="devapi-synchronization-levels.html"
200
ACCESSKEY="N"
201
>Next</A
202
></TD
203
></TR
204
><TR
205
><TD
206
WIDTH="33%"
207
ALIGN="left"
208
VALIGN="top"
209
>SMP Support</TD
210
><TD
211
WIDTH="34%"
212
ALIGN="center"
213
VALIGN="top"
214
><A
215
HREF="devapi-device-driver-interface-to-the-kernel.html"
216
ACCESSKEY="U"
217
>Up</A
218
></TD
219
><TD
220
WIDTH="33%"
221
ALIGN="right"
222
VALIGN="top"
223
>Synchronization Levels</TD
224
></TR
225
></TABLE
226
></DIV
227
></BODY
228
></HTML
229
>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.