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

📄 io-eth-drv-api-funcs.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!-- 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>Review of the functions</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="Generic Ethernet Device Driver"HREF="io-eth-drv-generic1.html"><LINKREL="PREVIOUS"TITLE="Generic Ethernet Device Driver"HREF="io-eth-drv-generic1.html"><LINKREL="NEXT"TITLE="Upper Layer Functions"HREF="io-eth-drv-upper-api.html"></HEAD><BODYCLASS="SECT1"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="io-eth-drv-generic1.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 46. Generic Ethernet Device Driver</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="io-eth-drv-upper-api.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="IO-ETH-DRV-API-FUNCS">Review of the functions</H1><P>Now a brief review of the functions.  This discussion will use genericnames for the functions &#8212; your driver should use hardware-specificnames to maintain uniqueness against any other drivers.</P><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="IO-ETH-DRV-API-INIT">Init function</H2><P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">static bool <TTCLASS="REPLACEABLE"><I>DRV_HDWR</I></TT>_init(struct cyg_netdevtab_entry *tab)</PRE></TD></TR></TABLE>This function is called as part of system initialization.  Its primaryfunction is to decide if the hardware (as indicated via<SPANCLASS="TYPE">tab-&gt;device_instance</SPAN>)is working and if the interface needs to be madeavailable in the system.  If this is the case, this function needs tofinish with a call to the ethernet driver function:<TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    struct eth_drv_sc *sc = (struct eth_drv_sc *)tab-&#62;device_instance;    <TTCLASS="REPLACEABLE"><I>....initialization code....</I></TT>    // Initialize upper level driver    (sc-&gt;funs-&gt;eth_drv-&gt;init)( sc, unsigned char *enaddr );</PRE></TD></TR></TABLE>where <TTCLASS="PARAMETER"><I>enaddr</I></TT>is a pointer to the ethernet station address for this unit, to informthe stack of this device's readiness and availability.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>The ethernet station address(<SPANCLASS="ACRONYM">ESA</SPAN>)is supposed to be aworld-unique, 48 bit address for this particular ethernet interface.Typically it is provided by the board/hardware manufacturer in ROM.</P><P>In many packages it is possible for the<SPANCLASS="ACRONYM">ESA</SPAN>to be set from RedBoot,(perhaps from 'fconfig' data), hard-coded from<SPANCLASS="ACRONYM">CDL</SPAN>, or from an <SPANCLASS="ACRONYM">EPROM</SPAN>.A driver should choose a run-time specified<SPANCLASS="ACRONYM">ESA</SPAN>(e.g. from RedBoot)preferentially, otherwise (in order) it should use a <SPANCLASS="ACRONYM">CDL</SPAN> specified<SPANCLASS="ACRONYM">ESA</SPAN>if one has been set, otherwise an <SPANCLASS="ACRONYM">EPROM</SPAN> set<SPANCLASS="ACRONYM">ESA</SPAN>, or otherwisefail. See the <TTCLASS="FILENAME">cl/cs8900a</TT>ethernet driver for an example.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="IO-ETH-DRV-API-START">Start function</H2><P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">static void<TTCLASS="REPLACEABLE"><I>HRDWR</I></TT>_start(struct eth_drv_sc *sc, unsigned char *enaddr, int flags)</PRE></TD></TR></TABLE>This function is called, perhaps much later than system initializationtime, when the system (an application) is ready for the interface tobecome active.  The purpose of this function is to set up the hardwareinterface to start accepting packets from the network and be able tosend packets out.  The receiver hardware should not be enabled prior tothis call.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>This function will be called whenever theup/down state of the logical interface changes, e.g. when the IP addresschanges, or when promiscuous mode is selected by means of an<TTCLASS="FUNCTION">ioctl()</TT> call in the application.This may occur more than once, so this function needs tobe prepared for that case.</P></BLOCKQUOTE></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>In future, the <TTCLASS="PARAMETER"><I>flags</I></TT>field (currently unused) may be used to tell thefunction how to start up, e.g. whether interrupts will be used,alternate means of selecting promiscuous mode etc.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="IO-ETH-DRV-API-STOP">Stop function</H2><P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">static void <TTCLASS="REPLACEABLE"><I>HRDWR</I></TT>_stop(struct eth_drv_sc *sc)</PRE></TD></TR></TABLE>This function is the inverse of &#8220;start.&#8221;It should shut down the hardware, disable the receiver, and keep it frominteracting with the physical network.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="IO-ETH-DRV-API-CONTROL">Control function</H2><P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">static int<TTCLASS="REPLACEABLE"><I>HRDWR</I></TT>_control(	struct eth_drv_sc *sc, unsigned long key,	void *data, int len)</PRE></TD></TR></TABLE>This function is used to perform low-level &#8220;control&#8221;operations on theinterface.  These operations would typically be initiated via<TTCLASS="FUNCTION">ioctl()</TT> calls in the BSDstack, and would be anything that might require the hardware setup tochange (i.e. cannot be performed totally by theplatform-independent layers).</P><P>The <TTCLASS="PARAMETER"><I>key</I></TT> parameter selects the operation, and the<TTCLASS="PARAMETER"><I>data</I></TT> and <TTCLASS="PARAMETER"><I>len</I></TT> params point describe,as required, some data for the operation in question.</P><P></P><DIVCLASS="VARIABLELIST"><P><B>Available Operations:</B></P><DL><DT>ETH_DRV_SET_MAC_ADDRESS</DT><DD><P>This operation sets the ethernet station address (ESA or MAC) for thedevice.  Normally this address is kept in non-volatile memory and isunique in the world.  This function must at least set the interface touse the new address.  It may also update the NVM as appropriate.</P></DD><DT>ETH_DRV_GET_IF_STATS_UD, ETH_DRV_GET_IF_STATS</DT><DD><P>These acquire a set of statistical counters from the interface, and writethe information into the memory pointed to by <TTCLASS="PARAMETER"><I>data</I></TT>.The &#8220;UD&#8221; variant explicitly instructs the driver to acquireup-to-date values.  This is a separate option because doing so may takesome time, depending on the hardware.</P><P>The definition of the data structure is in<TTCLASS="FILENAME">cyg/io/eth/eth_drv_stats.h</TT>.</P><P>This call is typically made by SNMP, see <AHREF="net-snmp-ecos-port.html">Chapter 47</A>.</P></DD><DT>ETH_DRV_SET_MC_LIST</DT><DD><P>This entry instructs the device to set up multicast packet filteringto receive only packets addressed to the multicast ESAs in the list pointedto by <TTCLASS="PARAMETER"><I>data</I></TT>.</P><P>The format of the data is a 32-bit count of the ESAs in the list, followedby packed bytes which are the ESAs themselves, thus:<TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#define ETH_DRV_MAX_MC 8struct eth_drv_mc_list {    int len;    unsigned char addrs[ETH_DRV_MAX_MC][ETHER_ADDR_LEN];};</PRE></TD></TR></TABLE></P></DD><DT>ETH_DRV_SET_MC_ALL</DT><DD><P>This entry instructs the device to receive all multicast packets, anddelete any explicit filtering which had been set up.</P></DD></DL></DIV><P>This function should return zero if the specified operation wascompleted successfully.  It should return non-zero if the operationcould not be performed, for any reason.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="IO-ETH-DRV-API-CAN-SEND">Can-send function</H2><P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD

⌨️ 快捷键说明

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