亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stellarisif.c

?? lm3s下lwip的udp
?? C
?? 第 1 頁 / 共 2 頁
字號:
/**
 * @file - stellarisif.c
 * lwIP Ethernet interface for Stellaris Devices
 *
 */

/**
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels <adam@sics.se>
 *
 */

/**
 * Copyright (c) 2008 Luminary Micro, Inc.
 *
 * This file is dervied from the ``ethernetif.c'' skeleton Ethernet network
 * interface driver for lwIP.
 *
 */

#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/sys.h"
#include <lwip/stats.h>
#include <lwip/snmp.h>
#include "netif/etharp.h"
#include "netif/ppp_oe.h"
#include "stellarisif.h"

/**
 * Sanity Check:  This interface driver will NOT work if the following defines
 * are incorrect.
 *
 */
#if (PBUF_LINK_HLEN != 16)
#error "PBUF_LINK_HLEN must be 16 for this interface driver!"
#endif
#if (ETH_PAD_SIZE != 2)
#error "ETH_PAD_SIZE must be 2 for this interface driver!"
#endif
#if (!SYS_LIGHTWEIGHT_PROT)
#error "SYS_LIGHTWEIGHT_PROT must be enabled for this interface driver!"
#endif

/**
 * Number of pbufs supported in low-level tx/rx pbuf queue.
 *
 */
#ifndef STELLARIS_NUM_PBUF_QUEUE
#define STELLARIS_NUM_PBUF_QUEUE    20
#endif

/**
 * Setup processing for PTP (IEEE-1588).
 *
 */
#if LWIP_PTPD
extern void lwIPHostGetTime(u32_t *time_s, u32_t *time_ns);
#endif

/**
 * Luminary Micro DriverLib Header Files required for this interface driver.
 *
 */
#include "hw_memmap.h"
#include "hw_types.h"
#include "hw_ints.h"
#include "hw_ethernet.h"
#include "ethernet.h"
#include "interrupt.h"
#include "sysctl.h"

/* Define those to better describe your network interface. */
#define IFNAME0 'E'
#define IFNAME1 'T'

/* Helper struct to hold a queue of pbufs for transmit and receive. */
struct pbufq {
  struct pbuf *pbuf[STELLARIS_NUM_PBUF_QUEUE];
  unsigned long qwrite;
  unsigned long qread;
  unsigned long overflow;
};

/* Helper macros for accessing pbuf queues. */
#define PBUF_QUEUE_EMPTY(q) \
    (((q)->qwrite == (q)->qread) ? true : false)

#define PBUF_QUEUE_FULL(q) \
    ((((((q)->qwrite + 1) % STELLARIS_NUM_PBUF_QUEUE)) == (q)->qread) ? \
    true : false )

/**
 * Helper struct to hold private data used to operate your ethernet interface.
 * Keeping the ethernet address of the MAC in this struct is not necessary
 * as it is already kept in the struct netif.
 * But this is only an example, anyway...
 */
struct ethernetif {
  struct eth_addr *ethaddr;
  /* Add whatever per-interface state that is needed here. */
  struct pbufq txq;
  struct pbufq rxq;
};

/**
 * Global variable for this interface's private data.  Needed to allow
 * the interrupt handlers access to this information outside of the
 * context of the lwIP netif.
 *
 */
static struct ethernetif ethernetif_data;

/**
 * Pop a pbuf packet from a pbuf packet queue
 *
 * @param q is the packet queue from which to pop the pbuf.
 *
 * @return pointer to pbuf packet if available, NULL otherswise.
 */
static struct pbuf *
dequeue_packet(struct pbufq *q)
{
  struct pbuf *pBuf;
  SYS_ARCH_DECL_PROTECT(lev);

  /**
   * This entire function must run within a "critical section" to preserve
   * the integrity of the transmit pbuf queue.
   *
   */
  SYS_ARCH_PROTECT(lev);

  if(PBUF_QUEUE_EMPTY(q)) {
    /* Return a NULL pointer if the queue is empty. */
    pBuf = (struct pbuf *)NULL;
  }
  else {
    /**
     * The queue is not empty so return the next frame from it
     * and adjust the read pointer accordingly.
     *
     */
    pBuf = q->pbuf[q->qread];
    q->qread = ((q->qread + 1) % STELLARIS_NUM_PBUF_QUEUE);
  }

  /* Return to prior interrupt state and return the pbuf pointer. */
  SYS_ARCH_UNPROTECT(lev);
  return(pBuf);
}

/**
 * Push a pbuf packet onto a pbuf packet queue
 *
 * @param p is the pbuf to push onto the packet queue.
 * @param q is the packet queue.
 *
 * @return 1 if successful, 0 if q is full.
 */
static int
enqueue_packet(struct pbuf *p, struct pbufq *q)
{
  SYS_ARCH_DECL_PROTECT(lev);
  int ret;

  /**
   * This entire function must run within a "critical section" to preserve
   * the integrity of the transmit pbuf queue.
   *
   */
  SYS_ARCH_PROTECT(lev);

  if(!PBUF_QUEUE_FULL(q)) {
    /**
     * The queue isn't full so we add the new frame at the current
     * write position and move the write pointer.
     *
     */
    q->pbuf[q->qwrite] = p;
    q->qwrite = ((q->qwrite + 1) % STELLARIS_NUM_PBUF_QUEUE);
    ret = 1;
  }
  else {
    /**
     * The stack is full so we are throwing away this value.  Keep track
     * of the number of times this happens.
     *
     */
    q->overflow++;
    ret = 0;
  }

  /* Return to prior interrupt state and return the pbuf pointer. */
  SYS_ARCH_UNPROTECT(lev);
  return(ret);
}

/**
 * In this function, the hardware should be initialized.
 * Called from stellarisif_init().
 *
 * @param netif the already initialized lwip network interface structure
 *        for this ethernetif
 */
static void
low_level_init(struct netif *netif)
{
  u32_t temp;
  //struct ethernetif *ethernetif = netif->state;

  /* set MAC hardware address length */
  netif->hwaddr_len = ETHARP_HWADDR_LEN;

  /* set MAC hardware address */
  EthernetMACAddrGet(ETH_BASE, &(netif->hwaddr[0]));

  /* maximum transfer unit */
  netif->mtu = 1500;

  /* device capabilities */
  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
  netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;

  /* Do whatever else is needed to initialize interface. */
  /* Disable all Ethernet Interrupts. */
  EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER |
     ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX));
  temp = EthernetIntStatus(ETH_BASE, false);
  EthernetIntClear(ETH_BASE, temp);

  /* Initialize the Ethernet Controller. */
  EthernetInitExpClk(ETH_BASE, SysCtlClockGet());

  /*
   * Configure the Ethernet Controller for normal operation.
   * - Enable TX Duplex Mode
   * - Enable TX Padding
   * - Enable TX CRC Generation
   * - Enable RX Multicast Reception
   */
  EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN |ETH_CFG_TX_CRCEN |
    ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN));

  /* Enable the Ethernet Controller transmitter and receiver. */
  EthernetEnable(ETH_BASE);
  
  IntPrioritySet(INT_ETH, 0xFF);    /*設置以太網中斷優先級*/
  /* Enable the Ethernet Interrupt handler. */
  IntEnable(INT_ETH);

  /* Enable Ethernet TX and RX Packet Interrupts. */
  EthernetIntEnable(ETH_BASE, ETH_INT_RX | ETH_INT_TX);
}

/**
 * This function should do the actual transmission of the packet. The packet is
 * contained in the pbuf that is passed to the function. This pbuf might be
 * chained.
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
 * @return ERR_OK if the packet could be sent
 *         an err_t value if the packet couldn't be sent
 * @note This function MUST be called with interrupts disabled or with the
 *       Stellaris Ethernet transmit fifo protected.
 */
static err_t
low_level_transmit(struct netif *netif, struct pbuf *p)
{
  int iBuf;
  unsigned char *pucBuf;
  unsigned long *pulBuf;
  struct pbuf *q;
  int iGather;
  unsigned long ulGather;
  unsigned char *pucGather;

  /**
   * Fill in the first two bytes of the payload data (configured as padding
   * with ETH_PAD_SIZE = 2) with the total length of the payload data
   * (minus the Ethernet MAC layer header).
   *
   */
  *((unsigned short *)(p->payload)) = p->tot_len - 16;

  /* Initialize the gather register. */
  iGather = 0;
  pucGather = (unsigned char *)&ulGather;
  ulGather = 0;

  /* Copy data from the pbuf(s) into the TX Fifo. */
  for(q = p; q != NULL; q = q->next) {
    /* Intialize a char pointer and index to the pbuf payload data. */
    pucBuf = (unsigned char *)q->payload;
    iBuf = 0;

    /**
     * If the gather buffer has leftover data from a previous pbuf
     * in the chain, fill it up and write it to the Tx FIFO.
     *
     */
    while((iBuf < q->len) && (iGather != 0)) {
      /* Copy a byte from the pbuf into the gather buffer. */
      pucGather[iGather] = pucBuf[iBuf++];

      /* Increment the gather buffer index modulo 4. */
      iGather = ((iGather + 1) % 4);
    }

    /**
     * If the gather index is 0 and the pbuf index is non-zero,
     * we have a gather buffer to write into the Tx FIFO.
     *
     */
    if((iGather == 0) && (iBuf != 0)) {
      HWREG(ETH_BASE + MAC_O_DATA) = ulGather;
      ulGather = 0;
    }

    /* Initialze a long pointer into the pbuf for 32-bit access. */
    pulBuf = (unsigned long *)&pucBuf[iBuf];

    /**
     * Copy words of pbuf data into the Tx FIFO, but don't go past
     * the end of the pbuf.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精工是国产品牌吗| 成人av片在线观看| 久久成人麻豆午夜电影| 久久99精品国产麻豆不卡| 日本大胆欧美人术艺术动态| 日韩在线a电影| 国产一区二区91| 色噜噜狠狠色综合欧洲selulu| 色婷婷一区二区| 日韩一区二区精品在线观看| 欧美精品一区二区在线观看| 国产精品无人区| 视频在线观看91| 不卡在线观看av| 欧美日韩一级二级三级| 久久久精品一品道一区| 一区二区三区波多野结衣在线观看| 日韩精品电影在线| 成人免费高清在线| 欧美精品1区2区3区| 欧美韩日一区二区三区四区| 亚洲gay无套男同| 成人毛片在线观看| 欧美精品视频www在线观看| 久久久美女毛片| 亚洲观看高清完整版在线观看| 国产一区二区中文字幕| 欧美日韩在线不卡| 日本一区免费视频| 老司机精品视频导航| 欧美视频你懂的| 亚洲人成网站影音先锋播放| 激情深爱一区二区| 欧美一区永久视频免费观看| 亚洲欧美激情小说另类| 国产不卡高清在线观看视频| 欧美一级xxx| 青青草成人在线观看| 欧美无砖砖区免费| 亚洲精品久久嫩草网站秘色| 99久久婷婷国产| 中文字幕一区二区三| 国产成人精品三级| 国产日产精品1区| 国产iv一区二区三区| 欧美精品一区二区三区一线天视频| 欧美一区二区成人6969| 一区二区三区欧美亚洲| 一本色道**综合亚洲精品蜜桃冫| 久久精品水蜜桃av综合天堂| 国产精品自拍三区| 中文字幕一区二区在线播放 | 国产女同互慰高潮91漫画| 精品在线一区二区| 日本一二三不卡| 午夜久久福利影院| 国产精品一区二区91| 国产午夜亚洲精品羞羞网站| 风间由美一区二区av101| 国产欧美一区二区三区在线看蜜臀 | 国产亚洲人成网站| 99久久久无码国产精品| 亚洲精品免费在线| 日韩欧美亚洲国产精品字幕久久久| 久久99精品视频| 中文字幕在线免费不卡| 色天天综合久久久久综合片| 日韩av中文在线观看| 欧美电视剧免费观看| 国产做a爰片久久毛片| 国产精品久久久久久久久久免费看| 色婷婷综合激情| 九九精品视频在线看| 亚洲欧洲日韩综合一区二区| 欧美日韩二区三区| 国产成人在线免费| 偷拍与自拍一区| 国产精品嫩草99a| 91精品国产入口| 91亚洲精品久久久蜜桃网站| 美女视频一区二区三区| 亚洲素人一区二区| 久久久久亚洲蜜桃| 欧美一级午夜免费电影| 色婷婷久久综合| 国产69精品久久777的优势| 七七婷婷婷婷精品国产| 亚洲精品视频在线观看免费| 欧美激情中文不卡| 精品国产精品一区二区夜夜嗨| 欧美日韩在线三区| 色综合久久综合网欧美综合网| 国产精品一级二级三级| 毛片一区二区三区| 日韩中文欧美在线| 午夜电影一区二区三区| 一区二区成人在线| 亚洲综合男人的天堂| 亚洲视频图片小说| 亚洲素人一区二区| 一区二区在线观看不卡| 亚洲欧美日韩一区二区| 亚洲欧洲三级电影| 亚洲精品视频在线看| 一区二区三区久久| 一区二区三区国产豹纹内裤在线| 1000精品久久久久久久久| xf在线a精品一区二区视频网站| 在线观看91av| 精品国产sm最大网站| 久久久久国产精品厨房| 国产精品久久久久久一区二区三区| 国产精品免费观看视频| 亚洲第一会所有码转帖| 男女性色大片免费观看一区二区 | 在线观看91精品国产麻豆| 日韩欧美国产wwwww| 中文字幕国产一区| 一区二区欧美精品| 紧缚捆绑精品一区二区| 不卡在线观看av| 日韩三级伦理片妻子的秘密按摩| xfplay精品久久| 亚洲成av人片在线| 丰满亚洲少妇av| 欧美日韩国产高清一区| 中文一区在线播放| 天天色综合天天| 成人福利视频在线看| 欧美精品自拍偷拍动漫精品| 2020国产精品| 亚洲成av人片一区二区梦乃| 玖玖九九国产精品| 91久久精品午夜一区二区| 精品理论电影在线| 亚洲高清不卡在线| 国产成人在线视频播放| 欧美精品久久99| 亚洲黄色免费网站| 国产福利精品一区| 欧美xxxxx裸体时装秀| 亚洲精品国产第一综合99久久 | 欧美激情综合网| 免费成人在线影院| 欧美日韩高清不卡| 一区二区三区蜜桃| 色94色欧美sute亚洲线路一ni| 久久女同性恋中文字幕| 青青国产91久久久久久| 欧美日韩视频在线观看一区二区三区| 久久亚洲影视婷婷| 久久成人18免费观看| 欧美大片免费久久精品三p| 亚洲 欧美综合在线网络| 欧美自拍偷拍午夜视频| 亚洲综合在线免费观看| 91免费在线看| 婷婷综合在线观看| 91久久久免费一区二区| 亚洲制服丝袜一区| 欧美精选午夜久久久乱码6080| 无码av免费一区二区三区试看 | 久久久久9999亚洲精品| 国产91精品精华液一区二区三区| 国产欧美综合在线| av午夜精品一区二区三区| 亚洲欧美一区二区三区国产精品| 99国产精品视频免费观看| 亚洲欧美视频在线观看| 欧美三区免费完整视频在线观看| 五月天欧美精品| 精品国产乱码久久久久久蜜臀| 风间由美一区二区三区在线观看 | 91丝袜美女网| 亚洲sss视频在线视频| www成人在线观看| 99久久精品久久久久久清纯| 亚洲国产视频一区二区| 欧美成人video| 色琪琪一区二区三区亚洲区| 视频精品一区二区| 国产精品第四页| 日韩一区国产二区欧美三区| 成人app下载| 久国产精品韩国三级视频| 中文字幕免费不卡| 日韩一区二区在线播放| 99这里都是精品| 久久国产精品99久久人人澡| 亚洲品质自拍视频网站| 久久久久国产一区二区三区四区| 在线看日韩精品电影| 国产一区二区精品在线观看| 亚洲一级电影视频| 国产精品久线在线观看| 精品国产精品网麻豆系列| 欧美剧情电影在线观看完整版免费励志电影 | 日韩三级在线免费观看| 欧美日韩小视频| 欧美少妇一区二区|