⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 devapi-api.html

📁 ecos 文档
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
<!-- This material may be distributed only subject to the terms      -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- or later (the latest version is presently available at          -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- permission is obtained from the copyright holder.               -->
<HTML
><HEAD
><TITLE
>The API</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"><LINK
REL="UP"
TITLE="Device Driver Interface to the Kernel"
HREF="devapi-device-driver-interface-to-the-kernel.html"><LINK
REL="PREVIOUS"
TITLE="Synchronization Levels"
HREF="devapi-synchronization-levels.html"><LINK
REL="NEXT"
TITLE="File System Support Infrastructure"
HREF="fileio.html"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>eCos Reference Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="devapi-synchronization-levels.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 18. Device Driver Interface to the Kernel</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="fileio.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="DEVAPI-API">The API</H1
><P
>This section details the Driver Kernel
Interface. Note that most of these functions are identical to Kernel C
API calls, and will in most configurations be wrappers for them. In
non-kernel configurations they will be supported directly by the HAL,
or by code to emulate the required behavior.</P
><P
>This API is defined in the header file
<TT
CLASS="FILENAME"
>&lt;cyg/hal/drv_api.h&gt;</TT
>.</P
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11309">cyg_drv_isr_lock</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_isr_lock()</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
>None</P
></DD
><DT
>Result:</DT
><DD
><P
>None </P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>      Disables delivery of interrupts, preventing all ISRs running.  This
      function maintains a counter of the number of times it is
      called.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11332">cyg_drv_isr_unlock</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_isr_unlock()</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
>None</P
></DD
><DT
>Result:</DT
><DD
><P
>None </P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>Re-enables delivery of interrupts, allowing ISRs to
      run. This function decrements the counter maintained by
      <TT
CLASS="FUNCTION"
>cyg_drv_isr_lock()</TT
>, and only re-allows
      interrupts when it goes to zero. </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11356">cyg_drv_spinlock_init</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_spinlock_init(cyg_spinlock_t *lock, cyg_bool_t locked )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock to initialize</P
><P
><TT
CLASS="PARAMETER"
><I
>locked</I
></TT
> - initial state of lock</P
></DD
><DT
>Result:</DT
><DD
><P
>None</P
></DD
><DT
>Level:</DT
><DD
><P
>Thread</P
></DD
><DT
>Description:</DT
><DD
><P
>      Initialize a spinlock. The <TT
CLASS="PARAMETER"
><I
>locked</I
></TT
>
      argument indicates how the spinlock should be initialized:
      <TT
CLASS="LITERAL"
>TRUE</TT
> for locked or <TT
CLASS="LITERAL"
>FALSE</TT
>
      for unlocked state.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11385">cyg_drv_spinlock_destroy</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_spinlock_destroy(cyg_spinlock_t *lock )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock destroy</P
></DD
><DT
>Result:</DT
><DD
><P
>None</P
></DD
><DT
>Level:</DT
><DD
><P
>Thread</P
></DD
><DT
>Description:</DT
><DD
><P
>      Destroy a spinlock that is no longer of use. There should be no
      CPUs attempting to claim the lock at the time this function is
      called, otherwise the behavior is undefined.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11409">cyg_drv_spinlock_spin</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_spinlock_spin(cyg_spinlock_t *lock )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock to claim</P
></DD
><DT
>Result:</DT
><DD
><P
>None</P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>      Claim a spinlock, waiting in a busy loop until it is
      available. Wherever this is called from, this operation
      effectively pauses the CPU until it succeeds. This operations
      should therefore be used sparingly, and in situations where
      deadlocks/livelocks cannot occur. Also see
      <TT
CLASS="FUNCTION"
>cyg_drv_spinlock_spin_intsave()</TT
>.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11434">cyg_drv_spinlock_clear</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_spinlock_clear(cyg_spinlock_t *lock )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock to clear </P
></DD
><DT
>Result:</DT
><DD
><P
>None</P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>      Clear a spinlock. This clears the spinlock and allows another
      CPU to claim it. If there is more than one CPU waiting in
      <TT
CLASS="FUNCTION"
>cyg_drv_spinlock_spin()</TT
> then just one of
      them will be allowed to proceed.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11459">cyg_drv_spinlock_try</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>cyg_bool_t cyg_drv_spinlock_try(cyg_spinlock_t *lock )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock to try</P
></DD
><DT
>Result:</DT
><DD
><P
><TT
CLASS="LITERAL"
>TRUE</TT
> if the spinlock was claimed,
      <TT
CLASS="LITERAL"
>FALSE</TT
> otherwise.</P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>      Try to claim the spinlock without waiting. If the spinlock could
      be claimed immediately then <TT
CLASS="LITERAL"
>TRUE</TT
> is
      returned. If the spinlock is already claimed then the result is
      <TT
CLASS="LITERAL"
>FALSE</TT
>.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11487">cyg_drv_spinlock_test</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>cyg_bool_t cyg_drv_spinlock_test(cyg_spinlock_t *lock )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock to test</P
></DD
><DT
>Result:</DT
><DD
><P
><TT
CLASS="LITERAL"
>TRUE</TT
> if the spinlock is available,
      <TT
CLASS="LITERAL"
>FALSE</TT
> otherwise.</P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>      Inspect the state of the spinlock. If the spinlock is not locked
      then the result is <TT
CLASS="LITERAL"
>TRUE</TT
>. If it is locked then
      the result will be <TT
CLASS="LITERAL"
>FALSE</TT
>.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11515">cyg_drv_spinlock_spin_intsave</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_spinlock_spin_intsave(cyg_spinlock_t *lock,
                                   cyg_addrword_t *istate )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock to claim</P
><P
><TT
CLASS="PARAMETER"
><I
>istate</I
></TT
> - pointer to interrupt state save location</P
></DD
><DT
>Result:</DT
><DD
><P
>None</P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>      This function behaves exactly like
      <TT
CLASS="FUNCTION"
>cyg_drv_spinlock_spin()</TT
> except that it also
      disables interrupts before attempting to claim the lock. The
      current interrupt enable state is saved in
      <TT
CLASS="PARAMETER"
><I
>*istate</I
></TT
>. Interrupts remain disabled once
      the spinlock had been claimed and must be restored by calling
      <TT
CLASS="FUNCTION"
>cyg_drv_spinlock_clear_intsave()</TT
>.
      </P
><P
>      In general, device drivers should use this function to claim and
      release spinlocks rather than the
      non-<TT
CLASS="FUNCTION"
>_intsave()</TT
> variants, to ensure proper
      exclusion with code running on both other CPUs and this CPU.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11546">cyg_drv_spinlock_clear_intsave</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_spinlock_clear_intsave( cyg_spinlock_t *lock,
                                     cyg_addrword_t istate )</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>lock</I
></TT
> - pointer to spinlock to clear </P
><P
><TT
CLASS="PARAMETER"
><I
>istate</I
></TT
> - interrupt state to restore </P
></DD
><DT
>Result:</DT
><DD
><P
>None</P
></DD
><DT
>Level:</DT
><DD
><P
>ISR</P
></DD
><DT
>Description:</DT
><DD
><P
>      This function behaves exactly like
      <TT
CLASS="FUNCTION"
>cyg_drv_spinlock_clear()</TT
> except that it
      also restores an interrupt state saved by
      <TT
CLASS="FUNCTION"
>cyg_drv_spinlock_spin_intsave()</TT
>. The
      <TT
CLASS="PARAMETER"
><I
>istate</I
></TT
> argument must have been
      initialized by a previous call to
      <TT
CLASS="FUNCTION"
>cyg_drv_spinlock_spin_intsave()</TT
>.
      </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11576">cyg_drv_dsr_lock</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_dsr_lock()</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
>None</P
></DD
><DT
>Result:</DT
><DD
><P
>None </P
></DD
><DT
>Level:</DT
><DD
><P
>DSR</P
></DD
><DT
>Description:</DT
><DD
><P
>Disables scheduling of DSRs. This function maintains a
      counter of the number of times it has been called. </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11599">cyg_drv_dsr_unlock</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_dsr_unlock()</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
>None</P
></DD
><DT
>Result:</DT
><DD
><P
>		</P
><P
>None </P
></DD
><DT
>Level:</DT
><DD
><P
>DSR</P
></DD
><DT
>Description:</DT
><DD
><P
>Re-enables scheduling of DSRs. This function decrements
      the counter incremented by
      <TT
CLASS="FUNCTION"
>cyg_drv_dsr_lock()</TT
>.  DSRs are only allowed
      to be delivered when the counter goes to zero. </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN11624">cyg_drv_mutex_init</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Function:</DT
><DD
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void cyg_drv_mutex_init(cyg_drv_mutex *mutex)</PRE
></TD
></TR
></TABLE
></DD
><DT
>Arguments:</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>mutex</I
></TT
> - pointer to mutex to initialize</P
></DD
><DT
>Result:</DT
><DD
><P
>None </P
></DD
><DT
>Level:</DT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -