📄 sed.c
字号:
/*-----------------------------------------------------------------------------*//* *//* Copyright (C) 1996-2003 by Texas Instruments, Inc. All rights reserved. *//* Copyright (C) 2001-2003 Telogy Networks, Inc. *//* *//* NOTE: THIS VERSION OF CODE IS MAINTAINED BY TELOGY NETWORKS AND NOT TI! *//* *//* IMPORTANT - READ CAREFULLY BEFORE PROCEEDING TO USE SOFTWARE. *//* *//* This document is displayed for you to read prior to using the software *//* and documentation. By using the software and documentation, or opening *//* the sealed packet containing the software, or proceeding to download the *//* software from a Bulletin Board System(BBS) or a WEB Server, you agree to *//* abide by the following Texas Instruments License Agreement. If you choose *//* not to agree with these provisions, promptly discontinue use of the *//* software and documentation and return the material to the place you *//* obtained it. *//* *//* *** NOTE *** *//* *//* The licensed materials contain MIPS Technologies, Inc. confidential *//* information which is protected by the appropriate MIPS Technologies, Inc. *//* license agreement. It is your responsibility to comply with these *//* licenses. *//* *//* Texas Instruments License Agreement *//* *//* 1. License - Texas Instruments (hereinafter "TI"), grants you a license *//* to use the software program and documentation in this package ("Licensed *//* Materials") for Texas Instruments broadband products. *//* *//* 2. Restrictions - You may not reverse-assemble or reverse-compile the *//* Licensed Materials provided in object code or executable format. You may *//* not sublicense, transfer, assign, rent, or lease the Licensed Materials *//* or this Agreement without written permission from TI. *//* *//* 3. Copyright - The Licensed Materials are copyrighted. Accordingly, you *//* may either make one copy of the Licensed Materials for backup and/or *//* archival purposes or copy the Licensed Materials to another medium and *//* keep the original Licensed Materials for backup and/or archival purposes. *//* *//* 4. Runtime and Applications Software - You may create modified or *//* derivative programs of software identified as Runtime Libraries or *//* Applications Software, which, in source code form, remain subject to this *//* Agreement, but object code versions of such derivative programs are not *//* subject to this Agreement. *//* *//* 5. Warranty - TI warrants the media to be free from defects in material *//* and workmanship and that the software will substantially conform to the *//* related documentation for a period of ninety (90) days after the date of *//* your purchase. TI does not warrant that the Licensed Materials will be *//* free from error or will meet your specific requirements. *//* *//* 6. Remedies - If you find defects in the media or that the software does *//* not conform to the enclosed documentation, you may return the Licensed *//* Materials along with the purchase receipt, postage prepaid, to the *//* following address within the warranty period and receive a refund. *//* *//* TEXAS INSTRUMENTS *//* Application Specific Products, MS 8650 *//* c/o ADAM2 Application Manager *//* 12500 TI Boulevard *//* Dallas, TX 75243 - U.S.A. *//* *//* 7. Limitations - TI makes no warranty or condition, either expressed or *//* implied, including, but not limited to, any implied warranties of *//* merchantability and fitness for a particular purpose, regarding the *//* licensed materials. *//* *//* Neither TI nor any applicable licensor will be liable for any indirect, *//* incidental or consequential damages, including but not limited to loss of *//* profits. *//* *//* 8. Term - The license is effective until terminated. You may terminate *//* it at any other time by destroying the program together with all copies, *//* modifications and merged portions in any form. It also will terminate if *//* you fail to comply with any term or condition of this Agreement. *//* *//* 9. Export Control - The re-export of United States origin software and *//* documentation is subject to the U.S. Export Administration Regulations or *//* your equivalent local regulations. Compliance with such regulations is *//* your responsibility. *//* *//* *** IMPORTANT NOTICE *** *//* *//* Texas Instruments (TI) reserves the right to make changes to or to *//* discontinue any semiconductor product or service identified in this *//* publication without notice. TI advises its customers to obtain the latest *//* version of the relevant information to verify, before placing orders, *//* that the information being relied upon is current. *//* *//* TI warrants performance of its semiconductor products and related *//* software to current specifications in accordance with TI's standard *//* warranty. Testing and other quality control techniques are utilized to *//* the extent TI deems necessary to support this warranty. Unless mandated *//* by government requirements, specific testing of all parameters of each *//* device is not necessarily performed. *//* *//* Please be aware that Texas Instruments products are not intended for use *//* in life-support appliances, devices, or systems. Use of a TI product in *//* such applications without the written approval of the appropriate TI *//* officer is prohibited. Certain applications using semiconductor devices *//* may involve potential risks of injury, property damage, or loss of life. *//* In order to minimize these risks, adequate design and operating *//* safeguards should be provided by the customer to minimize inherent or *//* procedural hazards. Inclusion of TI products in such applications is *//* understood to be fully at the risk of the customer using TI devices or *//* systems. *//* *//* TI assumes no liability for TI applications assistance, customer product *//* design, software performance, or infringement of patents or services *//* described herein. Nor does TI warrant or represent that license, either *//* expressed or implied, is granted under any patent right, copyright, mask *//* work right, or other intellectual property right of TI covering or *//* relating to any combination, machine, or process in which such *//* semiconductor products or services might be or are used. *//* *//* All company and/or product names are trademarks and/or registered *//* trademarks of their respective manaufacturers. *//* *//*-----------------------------------------------------------------------------*//* *//* Ethernet Driver. *//* A Very Simple set of ethernet driver primitives. The ethernet (3com Mbus) *//* interface is controlled by busy-waiting, the application is handed the *//* location of on-board packet buffers, and allowed to fill in the *//* transmit buffer directly. The interface is entirely blocking. *//* *//* Written March, 1986 by Geoffrey Cooper *//* *//* Copyright (C) 1986, IMAGEN Corporation *//* "This code may be duplicated in whole or in part provided that [1] there *//* is no commercial gain involved in the duplication, and [2] that this *//* copyright notice is preserved on all copies. Any other duplication *//* requires written notice of the author." *//* *//* Primitives: *//* sed_Init() -- Initialize the package *//* sed_FormatPacket( destEAddr ) => location of transmit buffer *//* sed_Send( pkLength ) -- send the packet that is in the transmit buffer */ /* sed_Receive( recBufLocation ) -- enable receiving packets. *//* sed_IsPacket() => location of packet in receive buffer *//* sed_CheckPacket( recBufLocation, expectedType ) *//* sed_shutdown(); *//* *//* Global Variables: *//* sed_lclEthAddr -- Ethernet address of this host. *//* sed_ethBcastAddr -- Ethernet broadcast address. */ /*-----------------------------------------------------------------------------*/#include "_stdio.h"#include "tinyip.h"#include "emacphy.h"#include "hw.h"#include "env.h"#include "support.h"#define E10P_MIN 60 /* Minimum Ethernet packet size */#define TCB_ENTRIES 16#define RCB_ENTRIES 32#define BUFFER_SIZE 1518#define TX_COMP_ENTRIES 16#define RX_COMP_ENTRIES 32#define DISABLE 0x80000000#define CLRP 0x20000000#define TXPACE 0x00000100#define NO_LOOP 0x08000000#define FULL_DUPLEX 0x00000001#define SPEED_100 0x00000002#define CAF 0x00000400#define CMF 0x00002000#define PEFCE 0x00080000#define DMACONFIG (*(volatile unsigned *)(emacbase+0x000))#define INTSTS (*(volatile unsigned *)(emacbase+0x004))#define INTMASK (*(volatile unsigned *)(emacbase+0x008))#define WRAPCLK (*(volatile unsigned *)(emacbase+0x340))#define STATSBASE (*(volatile unsigned *)(emacbase+0x400)) #define TCRPTR (*(volatile unsigned *)(emacbase+0x100))#define TCRSIZE (*(volatile unsigned *)(emacbase+0x104))#define TCRINTTHRESH (*(volatile unsigned *)(emacbase+0x108))#define TCRTOTENT (*(volatile unsigned *)(emacbase+0x10C))#define TCRFREEENT (*(volatile unsigned *)(emacbase+0x110))#define TCRPENDENT (*(volatile unsigned *)(emacbase+0x114))#define TCRENTINC (*(volatile unsigned *)(emacbase+0x118))#define TXISRPACE (*(volatile unsigned *)(emacbase+0x11c))#define TDMASTATE0 (*(volatile unsigned *)(emacbase+0x120))#define TDMASTATE1 (*(volatile unsigned *)(emacbase+0x124))#define TDMASTATE2 (*(volatile unsigned *)(emacbase+0x128))#define TDMASTATE3 (*(volatile unsigned *)(emacbase+0x12C))#define TDMASTATE4 (*(volatile unsigned *)(emacbase+0x130))#define TDMASTATE5 (*(volatile unsigned *)(emacbase+0x134))#define TDMASTATE6 (*(volatile unsigned *)(emacbase+0x138))#define TDMASTATE7 (*(volatile unsigned *)(emacbase+0x13C))#define TXPADDCNT (*(volatile unsigned *)(emacbase+0x140))#define TXPADDSTART (*(volatile unsigned *)(emacbase+0x144))#define TXPADDEND (*(volatile unsigned *)(emacbase+0x148))#define TXQFLUSH (*(volatile unsigned *)(emacbase+0x14C)) #define RCRPTR (*(volatile unsigned *)(emacbase+0x200))#define RCRSIZE (*(volatile unsigned *)(emacbase+0x204))#define RCRINTTHRESH (*(volatile unsigned *)(emacbase+0x208))#define RCRTOTENT (*(volatile unsigned *)(emacbase+0x20C))#define RCRFREEENT (*(volatile unsigned *)(emacbase+0x210))#define RCRPENDENT (*(volatile unsigned *)(emacbase+0x214))#define RCRENTINC (*(volatile unsigned *)(emacbase+0x218))#define RXISRPACE (*(volatile unsigned *)(emacbase+0x21c)) #define RDMASTATE0 (*(volatile unsigned *)(emacbase+0x220))#define RDMASTATE1 (*(volatile unsigned *)(emacbase+0x224))#define RDMASTATE2 (*(volatile unsigned *)(emacbase+0x228))#define RDMASTATE3 (*(volatile unsigned *)(emacbase+0x22C))#define RDMASTATE4 (*(volatile unsigned *)(emacbase+0x230))#define RDMASTATE5 (*(volatile unsigned *)(emacbase+0x234))#define RDMASTATE6 (*(volatile unsigned *)(emacbase+0x238))#define RDMASTATE7 (*(volatile unsigned *)(emacbase+0x23C))#define FBLADDCNT (*(volatile unsigned *)(emacbase+0x240))#define FBLADDSTART (*(volatile unsigned *)(emacbase+0x244))#define FBLADDEND (*(volatile unsigned *)(emacbase+0x248))#define RXONOFF (*(volatile unsigned *)(emacbase+0x24C)) #define FBL0NEXTD (*(volatile unsigned *)(emacbase+0x280))#define FBL0LASTD (*(volatile unsigned *)(emacbase+0x284))#define FBL0COUNTD (*(volatile unsigned *)(emacbase+0x288))#define FBL0BUFSIZE (*(volatile unsigned *)(emacbase+0x28C)) #define MACCONTROL (*(volatile unsigned *)(emacbase+0x300))#define MACSTATUS (*(volatile unsigned *)(emacbase+0x304))#define MACADDRHI (*(volatile unsigned *)(emacbase+0x308))#define MACADDRLO (*(volatile unsigned *)(emacbase+0x30C))#define MACHASH1 (*(volatile unsigned *)(emacbase+0x310))#define MACHASH2 (*(volatile unsigned *)(emacbase+0x314)) #define WRAPCLK (*(volatile unsigned *)(emacbase+0x340))#define BOFTEST (*(volatile unsigned *)(emacbase+0x344))#define PACTEST (*(volatile unsigned *)(emacbase+0x348))#define PAUSEOP (*(volatile unsigned *)(emacbase+0x34C)) #define MDIOCONTROL (*(volatile unsigned *)(emacbase+0x380))#define MDIOUSERACCESS (*(volatile unsigned *)(emacbase+0x384))#define MDIOACK (*(volatile unsigned *)(emacbase+0x388))#define MDIOLINK (*(volatile unsigned *)(emacbase+0x38C))#define MDIOMACPHY (*(volatile unsigned *)(emacbase+0x390))#define SAVE1 (*(volatile unsigned *)(0x9401f000))#define SAVE2 (*(volatile unsigned *)(0x9401f004))#define SAVE3 (*(volatile unsigned *)(0x9401f008))#define SAVE4 (*(volatile unsigned *)(0x9401f00c))#define SAVE5 (*(volatile unsigned *)(0x9401f010))#define SAVE6 (*(volatile unsigned *)(0x9401f014))#define SAVE7 (*(volatile unsigned *)(0x9401f018))#define SAVE8 (*(volatile unsigned *)(0x9401f01c))#ifdef ACPEP #define ACPEP_EPLD_RESET_CTRL_REG (*(volatile short *)(0x9C800004))#define ACPEP_EPLD_RESET_MIIA 0x0080#define ACPEP_EPLD_RESET_MIIB 0x0040#endif #define en10pages ((en10size) >> pageshift)#define LINK_TIMEOUT 5#define TEST_TIMEOUT 120000#define NORMAL 0#define INTERNAL_LOOP 1#define EXTERNAL_LOOP 2#define WIRE_LOOP 3#define TX_BUF_COUNT 25#define FLIP_TBUF_INDEX 0 /*16 at which point it flips to SDRAM*/#define MIN_FRAME_SIZE 64#define MAX_FRAME_SIZE 1518#define TX_BURST_COUNT 11#define SEQ 16bit32u emacbase;bit32u PhyState;int loops, steps;int tx_frame_seq, rx_fram_seq, tx_buf_index;volatile unsigned *tx_buf[TX_BUF_COUNT]; void *GetRxPacket(void);struct txcompring_s { int status; int fblid_noofbufs; int sof_list; int eof_list; };struct txcompring_s *TxCompPtr;int TxCompRingMask;int TxCompRingBase;int txcompring_size;int txcompring_index;struct rxcompring_s { int status; int sof_list; int eof_list; int flen_errs; };struct rxcompring_s *RxCompPtr;int RxCompRingMask;int RxCompRingBase;int rxcompring_size;int rxcompring_index;struct rcb_s { int size; int BufPtr; int Res1; int Res2; int *DatPtr; int Res3; int Res4; int Res5; }rcb_array_i[RCB_ENTRIES];struct rcb_s *rcb_array,*CurrentRcb;volatile struct tcb_s { int mode; int BufPtr; int Res1; int DO_FBLID; void *RcbPtr; int Res3; int Res4; int Res5; }tcb_array_i[TCB_ENTRIES];struct tcb_s *tcb_array;int rcb_index, rcb_pending;int tcb_index, tcb_pending;octet *sed_va; /* virtual address of ethernet card */BOOL sed_respondARPreq; /* controls responses to ARP req's */char bufAinUse, bufBinUse; /* tell whether bufs are in use *//* * Initialize the Ethernet Interface, and this package. Enable input on * both buffers. */void InitRcb(int size) { int i; int *pTmp; rcb_index=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -