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

📄 devapi-api.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 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"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="Device Driver Interface to the Kernel"HREF="devapi-device-driver-interface-to-the-kernel.html"><LINKREL="PREVIOUS"TITLE="Synchronization Levels"HREF="devapi-synchronization-levels.html"><LINKREL="NEXT"TITLE="File System Support Infrastructure"HREF="fileio.html"></HEAD><BODYCLASS="SECTION"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="devapi-synchronization-levels.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 18. Device Driver Interface to the Kernel</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="fileio.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECTION"><H1CLASS="SECTION"><ANAME="DEVAPI-API">The API</H1><P>This section details the Driver KernelInterface. Note that most of these functions are identical to Kernel CAPI calls, and will in most configurations be wrappers for them. Innon-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<TTCLASS="FILENAME">&lt;cyg/hal/drv_api.h&gt;</TT>.</P><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11310">cyg_drv_isr_lock</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="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><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11333">cyg_drv_isr_unlock</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="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      <TTCLASS="FUNCTION">cyg_drv_isr_lock()</TT>, and only re-allows      interrupts when it goes to zero. </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11357">cyg_drv_spinlock_init</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_drv_spinlock_init(cyg_spinlock_t *lock, cyg_bool_t locked )</PRE></TD></TR></TABLE></DD><DT>Arguments:</DT><DD><P><TTCLASS="PARAMETER"><I>lock</I></TT> - pointer to spinlock to initialize</P><P><TTCLASS="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 <TTCLASS="PARAMETER"><I>locked</I></TT>      argument indicates how the spinlock should be initialized:      <TTCLASS="LITERAL">TRUE</TT> for locked or <TTCLASS="LITERAL">FALSE</TT>      for unlocked state.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11386">cyg_drv_spinlock_destroy</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_drv_spinlock_destroy(cyg_spinlock_t *lock )</PRE></TD></TR></TABLE></DD><DT>Arguments:</DT><DD><P><TTCLASS="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><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11410">cyg_drv_spinlock_spin</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_drv_spinlock_spin(cyg_spinlock_t *lock )</PRE></TD></TR></TABLE></DD><DT>Arguments:</DT><DD><P><TTCLASS="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      <TTCLASS="FUNCTION">cyg_drv_spinlock_spin_intsave()</TT>.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11435">cyg_drv_spinlock_clear</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_drv_spinlock_clear(cyg_spinlock_t *lock )</PRE></TD></TR></TABLE></DD><DT>Arguments:</DT><DD><P><TTCLASS="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      <TTCLASS="FUNCTION">cyg_drv_spinlock_spin()</TT> then just one of      them will be allowed to proceed.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11460">cyg_drv_spinlock_try</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cyg_bool_t cyg_drv_spinlock_try(cyg_spinlock_t *lock )</PRE></TD></TR></TABLE></DD><DT>Arguments:</DT><DD><P><TTCLASS="PARAMETER"><I>lock</I></TT> - pointer to spinlock to try</P></DD><DT>Result:</DT><DD><P><TTCLASS="LITERAL">TRUE</TT> if the spinlock was claimed,      <TTCLASS="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 <TTCLASS="LITERAL">TRUE</TT> is      returned. If the spinlock is already claimed then the result is      <TTCLASS="LITERAL">FALSE</TT>.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11488">cyg_drv_spinlock_test</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cyg_bool_t cyg_drv_spinlock_test(cyg_spinlock_t *lock )</PRE></TD></TR></TABLE></DD><DT>Arguments:</DT><DD><P><TTCLASS="PARAMETER"><I>lock</I></TT> - pointer to spinlock to test</P></DD><DT>Result:</DT><DD><P><TTCLASS="LITERAL">TRUE</TT> if the spinlock is available,      <TTCLASS="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 <TTCLASS="LITERAL">TRUE</TT>. If it is locked then      the result will be <TTCLASS="LITERAL">FALSE</TT>.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11516">cyg_drv_spinlock_spin_intsave</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="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><TTCLASS="PARAMETER"><I>lock</I></TT> - pointer to spinlock to claim</P><P><TTCLASS="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      <TTCLASS="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      <TTCLASS="PARAMETER"><I>*istate</I></TT>. Interrupts remain disabled once      the spinlock had been claimed and must be restored by calling      <TTCLASS="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-<TTCLASS="FUNCTION">_intsave()</TT> variants, to ensure proper      exclusion with code running on both other CPUs and this CPU.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11547">cyg_drv_spinlock_clear_intsave</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="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><TTCLASS="PARAMETER"><I>lock</I></TT> - pointer to spinlock to clear </P><P><TTCLASS="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      <TTCLASS="FUNCTION">cyg_drv_spinlock_clear()</TT> except that it      also restores an interrupt state saved by      <TTCLASS="FUNCTION">cyg_drv_spinlock_spin_intsave()</TT>. The      <TTCLASS="PARAMETER"><I>istate</I></TT> argument must have been      initialized by a previous call to      <TTCLASS="FUNCTION">cyg_drv_spinlock_spin_intsave()</TT>.      </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11577">cyg_drv_dsr_lock</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="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><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11600">cyg_drv_dsr_unlock</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="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      <TTCLASS="FUNCTION">cyg_drv_dsr_lock()</TT>.  DSRs are only allowed      to be delivered when the counter goes to zero. </P></DD></DL></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN11625">cyg_drv_mutex_init</H2><P></P><DIVCLASS="VARIABLELIST"><DL><DT>Function:</DT><DD><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_drv_mutex_init(cyg_drv_mutex *mutex)</PRE></TD></TR></TABLE></DD><DT>Arguments:</DT><DD><P><TTCLASS="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 + -