<!-- 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
|
>SMP Support</TITLE
|
>SMP Support</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="Synchronization"
|
TITLE="Synchronization"
|
HREF="devapi-synchronization.html"><LINK
|
HREF="devapi-synchronization.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="Device Driver Models"
|
TITLE="Device Driver Models"
|
HREF="devapi-device-driver-models.html"></HEAD
|
HREF="devapi-device-driver-models.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-synchronization.html"
|
HREF="devapi-synchronization.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-device-driver-models.html"
|
HREF="devapi-device-driver-models.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-SMP-SUPPORT">SMP Support</H1
|
NAME="DEVAPI-SMP-SUPPORT">SMP Support</H1
|
><P
|
><P
|
>Some eCos targets contain support for Symmetric Multi-Processing (SMP)
|
>Some eCos targets contain support for Symmetric Multi-Processing (SMP)
|
configurations, where more than one CPU may be present. This option
|
configurations, where more than one CPU may be present. This option
|
has a number of ramifications for the way in which device drivers must
|
has a number of ramifications for the way in which device drivers must
|
be written if they are to be SMP-compatible. </P
|
be written if they are to be SMP-compatible. </P
|
><P
|
><P
|
>Since it is possible for the ISR, DSR and thread components of a
|
>Since it is possible for the ISR, DSR and thread components of a
|
device driver to execute on different CPUs, it is important that
|
device driver to execute on different CPUs, it is important that
|
SMP-compatible device drivers use the driver API routines correctly.</P
|
SMP-compatible device drivers use the driver API routines correctly.</P
|
><P
|
><P
|
>Synchronization between threads and DSRs continues to require that the
|
>Synchronization between threads and DSRs continues to require that the
|
thread-side code use <TT
|
thread-side code use <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_drv_dsr_lock()</TT
|
>cyg_drv_dsr_lock()</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_drv_dsr_unlock()</TT
|
>cyg_drv_dsr_unlock()</TT
|
> to protect access to shared
|
> to protect access to shared
|
data. While it is not strictly necessary for DSR code to claim the DSR
|
data. While it is not strictly necessary for DSR code to claim the DSR
|
lock, since DSRs are run with it claimed already, it is good practice
|
lock, since DSRs are run with it claimed already, it is good practice
|
to do so.</P
|
to do so.</P
|
><P
|
><P
|
>Synchronization between ISRs and DSRs or threads requires that access
|
>Synchronization between ISRs and DSRs or threads requires that access
|
to sensitive data be protected, in all places, by calls to
|
to sensitive data be protected, in all places, by calls to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_drv_isr_lock()</TT
|
>cyg_drv_isr_lock()</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_drv_isr_unlock()</TT
|
>cyg_drv_isr_unlock()</TT
|
>. Disabling or masking
|
>. Disabling or masking
|
interrupts is not adequate, since the thread or DSR may be running on
|
interrupts is not adequate, since the thread or DSR may be running on
|
a different CPU and interrupt enable/disable only work on the current
|
a different CPU and interrupt enable/disable only work on the current
|
CPU.</P
|
CPU.</P
|
><P
|
><P
|
>The ISR lock, for SMP systems, not only disables local interrupts, but
|
>The ISR lock, for SMP systems, not only disables local interrupts, but
|
also acquires a spinlock to protect against concurrent access from
|
also acquires a spinlock to protect against concurrent access from
|
other CPUs. This is necessary because ISRs are not run with the
|
other CPUs. This is necessary because ISRs are not run with the
|
scheduler lock claimed. Hence they can run in parallel with the other
|
scheduler lock claimed. Hence they can run in parallel with the other
|
components of the device driver.</P
|
components of the device driver.</P
|
><P
|
><P
|
>The ISR lock provided by the driver API is just a shared spinlock that
|
>The ISR lock provided by the driver API is just a shared spinlock that
|
is available for use by all drivers. If a driver needs to implement a
|
is available for use by all drivers. If a driver needs to implement a
|
finer grain of locking, it can use private spinlocks, accessed via the
|
finer grain of locking, it can use private spinlocks, accessed via the
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>cyg_drv_spinlock_*()</TT
|
>cyg_drv_spinlock_*()</TT
|
> functions.</P
|
> functions.</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-synchronization.html"
|
HREF="devapi-synchronization.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-device-driver-models.html"
|
HREF="devapi-device-driver-models.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"
|
>Synchronization</TD
|
>Synchronization</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"
|
>Device Driver Models</TD
|
>Device Driver Models</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|