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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [devapi-device-driver-models.html] - Diff between revs 28 and 174

Only display areas with differences | Details | Blame | View Log

Rev 28 Rev 174
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
<!-- This material may be distributed only subject to the terms      -->
<!-- This material may be distributed only subject to the terms      -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- or later (the latest version is presently available at          -->
<!-- or later (the latest version is presently available at          -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- permission is obtained from the copyright holder.               -->
<!-- permission is obtained from the copyright holder.               -->
<HTML
<HTML
><HEAD
><HEAD
><TITLE
><TITLE
>Device Driver Models</TITLE
>Device Driver Models</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
<META
NAME="GENERATOR"
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
"><LINK
REL="HOME"
REL="HOME"
TITLE="eCos Reference Manual"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"><LINK
HREF="ecos-ref.html"><LINK
REL="UP"
REL="UP"
TITLE="Device Driver Interface to the Kernel"
TITLE="Device Driver Interface to the Kernel"
HREF="devapi-device-driver-interface-to-the-kernel.html"><LINK
HREF="devapi-device-driver-interface-to-the-kernel.html"><LINK
REL="PREVIOUS"
REL="PREVIOUS"
TITLE="SMP Support"
TITLE="SMP Support"
HREF="devapi-smp-support.html"><LINK
HREF="devapi-smp-support.html"><LINK
REL="NEXT"
REL="NEXT"
TITLE="Synchronization Levels"
TITLE="Synchronization Levels"
HREF="devapi-synchronization-levels.html"></HEAD
HREF="devapi-synchronization-levels.html"></HEAD
><BODY
><BODY
CLASS="SECTION"
CLASS="SECTION"
BGCOLOR="#FFFFFF"
BGCOLOR="#FFFFFF"
TEXT="#000000"
TEXT="#000000"
LINK="#0000FF"
LINK="#0000FF"
VLINK="#840084"
VLINK="#840084"
ALINK="#0000FF"
ALINK="#0000FF"
><DIV
><DIV
CLASS="NAVHEADER"
CLASS="NAVHEADER"
><TABLE
><TABLE
SUMMARY="Header navigation table"
SUMMARY="Header navigation table"
WIDTH="100%"
WIDTH="100%"
BORDER="0"
BORDER="0"
CELLPADDING="0"
CELLPADDING="0"
CELLSPACING="0"
CELLSPACING="0"
><TR
><TR
><TH
><TH
COLSPAN="3"
COLSPAN="3"
ALIGN="center"
ALIGN="center"
>eCos Reference Manual</TH
>eCos Reference Manual</TH
></TR
></TR
><TR
><TR
><TD
><TD
WIDTH="10%"
WIDTH="10%"
ALIGN="left"
ALIGN="left"
VALIGN="bottom"
VALIGN="bottom"
><A
><A
HREF="devapi-smp-support.html"
HREF="devapi-smp-support.html"
ACCESSKEY="P"
ACCESSKEY="P"
>Prev</A
>Prev</A
></TD
></TD
><TD
><TD
WIDTH="80%"
WIDTH="80%"
ALIGN="center"
ALIGN="center"
VALIGN="bottom"
VALIGN="bottom"
>Chapter 18. Device Driver Interface to the Kernel</TD
>Chapter 18. Device Driver Interface to the Kernel</TD
><TD
><TD
WIDTH="10%"
WIDTH="10%"
ALIGN="right"
ALIGN="right"
VALIGN="bottom"
VALIGN="bottom"
><A
><A
HREF="devapi-synchronization-levels.html"
HREF="devapi-synchronization-levels.html"
ACCESSKEY="N"
ACCESSKEY="N"
>Next</A
>Next</A
></TD
></TD
></TR
></TR
></TABLE
></TABLE
><HR
><HR
ALIGN="LEFT"
ALIGN="LEFT"
WIDTH="100%"></DIV
WIDTH="100%"></DIV
><DIV
><DIV
CLASS="SECTION"
CLASS="SECTION"
><H1
><H1
CLASS="SECTION"
CLASS="SECTION"
><A
><A
NAME="DEVAPI-DEVICE-DRIVER-MODELS">Device Driver Models</H1
NAME="DEVAPI-DEVICE-DRIVER-MODELS">Device Driver Models</H1
><P
><P
>There are several ways in which device drivers
>There are several ways in which device drivers
may be built. The exact model chosen will depend on the properties of
may be built. The exact model chosen will depend on the properties of
the device and the behavior desired. There are three basic models that
the device and the behavior desired. There are three basic models that
may be adopted.</P
may be adopted.</P
><P
><P
>The first model is to do all device processing in the ISR.  When it is
>The first model is to do all device processing in the ISR.  When it is
invoked the ISR programs the device hardware directly and accesses
invoked the ISR programs the device hardware directly and accesses
data to be transferred directly in memory. The ISR should also call
data to be transferred directly in memory. The ISR should also call
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_interrupt_acknowledge()</TT
>cyg_drv_interrupt_acknowledge()</TT
>.  When it is
>.  When it is
finished it may optionally request that its DSR be invoked.  The DSR
finished it may optionally request that its DSR be invoked.  The DSR
does nothing but call <TT
does nothing but call <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_cond_signal()</TT
>cyg_drv_cond_signal()</TT
> to
> to
cause a thread to be woken up. Thread level code must call
cause a thread to be woken up. Thread level code must call
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_isr_lock()</TT
>cyg_drv_isr_lock()</TT
>, or
>, or
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_interrupt_mask()</TT
>cyg_drv_interrupt_mask()</TT
> to prevent ISRs running
> to prevent ISRs running
while it manipulates shared memory.</P
while it manipulates shared memory.</P
><P
><P
>The second model is to defer device processing to the DSR.  The ISR
>The second model is to defer device processing to the DSR.  The ISR
simply prevents further delivery of interrupts by either programming
simply prevents further delivery of interrupts by either programming
the device, or by calling
the device, or by calling
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_interrupt_mask()</TT
>cyg_drv_interrupt_mask()</TT
>.  It must then call
>.  It must then call
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_interrupt_acknowledge()</TT
>cyg_drv_interrupt_acknowledge()</TT
> to allow other
> to allow other
interrupts to be delivered and then request that its DSR be
interrupts to be delivered and then request that its DSR be
called. When the DSR runs it does the majority of the device handling,
called. When the DSR runs it does the majority of the device handling,
optionally signals a condition variable to wake a thread, and finishes
optionally signals a condition variable to wake a thread, and finishes
by calling <TT
by calling <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_interrupt_unmask()</TT
>cyg_drv_interrupt_unmask()</TT
> to re-allow
> to re-allow
device interrupts. Thread level code uses
device interrupts. Thread level code uses
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_dsr_lock()</TT
>cyg_drv_dsr_lock()</TT
> to prevent DSRs running while
> to prevent DSRs running while
it manipulates shared memory.  The eCos serial device drivers use this
it manipulates shared memory.  The eCos serial device drivers use this
approach.</P
approach.</P
><P
><P
>The third model is to defer device processing even further to a
>The third model is to defer device processing even further to a
thread. The ISR behaves exactly as in the previous model and simply
thread. The ISR behaves exactly as in the previous model and simply
blocks and acknowledges the interrupt before request that the DSR
blocks and acknowledges the interrupt before request that the DSR
run. The DSR itself only calls
run. The DSR itself only calls
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_cond_signal()</TT
>cyg_drv_cond_signal()</TT
> to wake the thread. When
> to wake the thread. When
the thread awakens it performs all device processing, and has full
the thread awakens it performs all device processing, and has full
access to all kernel facilities while it does so. It should finish by
access to all kernel facilities while it does so. It should finish by
calling <TT
calling <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>cyg_drv_interrupt_unmask()</TT
>cyg_drv_interrupt_unmask()</TT
> to re-allow
> to re-allow
device interrupts.  The eCos ethernet device drivers are written to
device interrupts.  The eCos ethernet device drivers are written to
this model.</P
this model.</P
><P
><P
>The first model is good for devices that need immediate processing and
>The first model is good for devices that need immediate processing and
interact infrequently with thread level. The second model trades a
interact infrequently with thread level. The second model trades a
little latency in dealing with the device for a less intrusive
little latency in dealing with the device for a less intrusive
synchronization mechanism. The last model allows device processing to
synchronization mechanism. The last model allows device processing to
be scheduled with other threads and permits more complex device
be scheduled with other threads and permits more complex device
handling.</P
handling.</P
></DIV
></DIV
><DIV
><DIV
CLASS="NAVFOOTER"
CLASS="NAVFOOTER"
><HR
><HR
ALIGN="LEFT"
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
SUMMARY="Footer navigation table"
WIDTH="100%"
WIDTH="100%"
BORDER="0"
BORDER="0"
CELLPADDING="0"
CELLPADDING="0"
CELLSPACING="0"
CELLSPACING="0"
><TR
><TR
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="left"
ALIGN="left"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="devapi-smp-support.html"
HREF="devapi-smp-support.html"
ACCESSKEY="P"
ACCESSKEY="P"
>Prev</A
>Prev</A
></TD
></TD
><TD
><TD
WIDTH="34%"
WIDTH="34%"
ALIGN="center"
ALIGN="center"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="ecos-ref.html"
HREF="ecos-ref.html"
ACCESSKEY="H"
ACCESSKEY="H"
>Home</A
>Home</A
></TD
></TD
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="right"
ALIGN="right"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="devapi-synchronization-levels.html"
HREF="devapi-synchronization-levels.html"
ACCESSKEY="N"
ACCESSKEY="N"
>Next</A
>Next</A
></TD
></TD
></TR
></TR
><TR
><TR
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="left"
ALIGN="left"
VALIGN="top"
VALIGN="top"
>SMP Support</TD
>SMP Support</TD
><TD
><TD
WIDTH="34%"
WIDTH="34%"
ALIGN="center"
ALIGN="center"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="devapi-device-driver-interface-to-the-kernel.html"
HREF="devapi-device-driver-interface-to-the-kernel.html"
ACCESSKEY="U"
ACCESSKEY="U"
>Up</A
>Up</A
></TD
></TD
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="right"
ALIGN="right"
VALIGN="top"
VALIGN="top"
>Synchronization Levels</TD
>Synchronization Levels</TD
></TR
></TR
></TABLE
></TABLE
></DIV
></DIV
></BODY
></BODY
></HTML
></HTML
 
 

powered by: WebSVN 2.1.0

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