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

📄 lan_am79c973.c

📁 MIPS YAMON, a famous monitor inc. source, make file and PDF manuals.
💻 C
📖 第 1 页 / 共 5 页
字号:
 *  ------------ * *  'pdevice',     IN,    reference for this device  context * * *  Return values : *  --------------- * *  'OK'(=0) * * * ************************************************************************/staticvoid LAN_AM79C973_dump_status( t_LAN_AM79C973_device *pdevice ) ;/************************************************************************ * *                         LAN_AM79C973_dump_descriptors  *  Description : *  ------------- *    Dump all AM79C973 LAN controller TX and RX ring descriptors *  * *  Parameters : *  ------------ * *  'pdevice',     IN,    reference for this device  context * * *  Return values : *  --------------- * *  'OK'(=0) * * * ************************************************************************/#ifdef ETH_DEBUGstaticINT32 LAN_AM79C973_dump_descriptors( t_LAN_AM79C973_device *pdevice ) ;#endif/************************************************************************ * *                         LAN_AM79C973_receive *  Description : *  ------------- *    Receive a packet  *  * *  Parameters : *  ------------ * *  'pdevice',     IN,    reference for this device  context * * *  Return values : *  --------------- * *  'OK'(=0) * * * ************************************************************************/staticINT32 LAN_AM79C973_receive( t_LAN_AM79C973_device *pdevice ) ;/************************************************************************ * *                          LAN_AM79C973_dump_device *  Description : *  ------------- *    Dump all AM79C973 LAN controller TX and RX ring descriptors * * *  Parameters : *  ------------ * *  'pdevice',     IN,    reference for this device  context * * *  Return values : *  --------------- * *  'OK'(=0) * * * ************************************************************************/#ifdef ETH_DEBUGstaticINT32 LAN_AM79C973_dump_device( t_LAN_AM79C973_device *pdevice ) ;#endif/************************************************************************ *      Static function prototypes, device driver IO functions ************************************************************************//************************************************************************ * *                          LAN_AM79C973_init *  Description : *  ------------- *  This service initializes the lan driver and configures *  the MAC-address for the 'EN0' LAN interface. *  The MAC-address is read during 'init' via the 'syscon' parameter: *    -'SYSCON_COM_EN0_MAC_ADDR_ID'. *   * *  Parameters : *  ------------ * *  'major',     IN,    major device number *  'minor',     IN,    not used *  'p_param',   INOUT, not used * * *  Return values : *  --------------- * *  'OK'(=0) * * * ************************************************************************/staticINT32 LAN_AM79C973_init(          UINT32 major,          /* IN: major device number             */          UINT32 minor,          /* IN: minor device number             */          void   *p_param ) ;    /* INOUT: device parameter block       *//************************************************************************ * *                          LAN_AM79C973_open *  Description : *  ------------- *  This service registers a mac-layer defined receive-handler in the *  LAN-drivers ISR-context to allow for interrupt controlled receive *  frame processing in the network stack. No external buffer *  administration is required as the protocol-layers are responsible for *  handling buffer-allocation and data copy-ing to the allocated buffer *  payload area. At return from 'receive' handler, the LAN-drivers *  local RX-buffer (packet) is released for re-use. After 'open' *  has been called, the LAN-driver's 'read' service will call the *  registered receive-handler by any frame reception with direct *  reference to the LAN-drivers packet space and no read data will be *  delivered in the IO-descriptor. * * * *  Parameters : *  ------------ * *  'major',     IN,    major device number *  'minor',     IN,    not used *  'p_param',   IN,    LAN variable of type, t_LAN_IO_desc. * * *  Return values : *  --------------- * *  'OK'(=0) * * * ************************************************************************/staticINT32 LAN_AM79C973_open(          UINT32 major,          /* IN: major device number             */          UINT32 minor,          /* IN: minor device number             */          t_LAN_OPEN_desc *p_param ) ; /* IN: receive handler reference *//************************************************************************ * *                          LAN_AM79C973_read *  Description : *  ------------- *  This service polls the specified LAN interface for any received frame. *  If any frame has been received, it will be read into the user allocated *  variable, *p_param; if none present, completion = 'ERROR_LAN_NO_FRAME' *  will be returned. *   * *  Parameters : *  ------------ * *  'major',     IN,    major device number *  'minor',     IN,    minor device number for multi device drivers *  'p_param',   INOUT, LAN variable of type, t_LAN_IO_desc. * * *  Return values : *  --------------- * *  'OK'(=0) *  'ERROR_LAN_NO_FRAME':     no frame present on this LAN interface *  'ERROR_LAN_COMM_ERROR':   communication error detected * * ************************************************************************/staticINT32 LAN_AM79C973_read(          UINT32 major,          /* IN: major device number             */          UINT32 minor,          /* IN: minor device number             */          t_LAN_IO_desc *p_param ) ; /* INOUT: LAN frame           *//************************************************************************ * *                          LAN_AM79C973_write *  Description : *  ------------- *  This service requests transmission of a frame on the LAN interface. *   * *  Parameters : *  ------------ * *  'major',     IN,    major device number *  'minor',     IN,    minor device number for multi device drivers *  'p_param',   INOUT, LAN variable of type, t_LAN_IO_desc. * * *  Return values : *  --------------- * *  'OK'(=0) *  'ERROR_LAN_COMM_ERROR':   communication error detected * * ************************************************************************/staticINT32 LAN_AM79C973_write(          UINT32 major,          /* IN: major device number             */          UINT32 minor,          /* IN: minor device number             */          t_LAN_IO_desc *p_param ) ; /* OUT: frame to transmit     *//************************************************************************ * *                          LAN_AM79C973_ctrl *  Description : *  ------------- *  This service requests special service via 'ctrl' *   * *  Parameters : *  ------------ * *  'major',     IN,    major device number *  'minor',     IN,    minor device number for multi device drivers *  'p_param',   INOUT, LAN variable of type, t_LAN_IO_desc. * * *  Return values : *  --------------- * *  'OK'(=0) * * ************************************************************************/staticINT32 LAN_AM79C973_ctrl(          UINT32 major,          /* IN: major device number             */          UINT32 minor,          /* IN: minor device number             */          t_LAN_CTRL_desc *p_param ) ; /* IN-OUT:                       *//************************************************************************ *      Implementation : Public functions ************************************************************************//************************************************************************ * *                          LAN_AM79C973_install *  Description : *  ------------- * *  Installs the AM79C973 LAN device drivers services in  *  the IO system at the reserved device slot, found in the *  'sysdev.h' file, which defines all major device numbers. * *  Note: *  This service is the only public declared interface function; all *  provided device driver services are static declared, but this *  function installs the function pointers in the io-system to *  enable the provided public driver services. * *  Parameters : *  ------------ * *  - * * *  Return values : *  --------------- * *  'OK'(=0) *  'ERROR_IO_ILLEGAL_MAJOR':  Illegal major device number *  'ERROR_IO_NO_SPACE':       Device slot already allocated * ************************************************************************/INT32 LAN_AM79C973_install( void ){    /* pre-initialize local variables and install device services */    memset( minor_device, sizeof(minor_device), 0) ;    IO_install(   SYS_MAJOR_LAN_AM79C973,         /* major device number */           (t_io_service) LAN_AM79C973_init,      /* 'init'  service     */           (t_io_service) LAN_AM79C973_open,      /* 'open'  service     */                          NULL,                   /* 'close' service  na */           (t_io_service) LAN_AM79C973_read,      /* 'read'  service     */           (t_io_service) LAN_AM79C973_write,     /* 'write' service     */           (t_io_service) LAN_AM79C973_ctrl ) ;   /* 'ctrl'  service     */    /* initialize AM79C973 LAN device driver */    if( IO_init( SYS_MAJOR_LAN_AM79C973, 0, NULL ) != OK )    {	/* Should not happen unless board is defect */	IO_deinstall( SYS_MAJOR_LAN_AM79C973 );    }    return OK;}/************************************************************************ *      Implementation : Static functions ************************************************************************//************************************************************************ *      Implementation : Local helper functions ************************************************************************//************************************************************************ * *                          LAN_AM79C973_allocate_memory *  Description : *  ------------- *     This routine allocates memory for: * *     - Init Block *     - TX and RX descriptor ring elements *     - Tx data buffers *     - Rx data buffers  *   * *  Parameters : *  ------------ * *  'pdevice',     IN,    reference for this device  context * * *  Return values : *  --------------- * *  'OK'(=0) * * * ************************************************************************/staticINT32 LAN_AM79C973_allocate_memory( t_LAN_AM79C973_device *pdevice )  {    INT32         rcode ;    t_sys_malloc  mem ;    UINT32        ptmp ;    int           i ;    if (first_time_init == 0)    {        /* first time initialization */        /* 1: allocate initialization block */        mem.size     = LAN_AM79C973_INITBLOCK_SIZE ;        mem.boundary = sizeof(UINT32) ;        mem.memory   = (void*)&ptmp ;        rcode = SYSCON_read( SYSCON_BOARD_MALLOC_ID,                             &mem,                             sizeof(t_sys_malloc) ) ;        if (rcode != OK)        {            return( rcode ) ;        }        pdevice->pInitBlock = (void*) KSEG1( ptmp ) ;        /* 2: allocate TX Descriptor Ring */        mem.size     = LAN_AM79C973_TDRE_COUNT * LAN_AM79C973_TDRE_SIZE ;        mem.boundary = LAN_AM79C973_TDRE_SIZE ;        mem.memory   = (void*)&ptmp ;        rcode = SYSCON_read( SYSCON_BOARD_MALLOC_ID,                             &mem,                             sizeof(t_sys_malloc) ) ;        if (rcode != OK)        {            return( rcode ) ;        }        ptmp = KSEG1( ptmp ) ;        for (i=0; i<LAN_AM79C973_TDRE_COUNT; i++)        {            pdevice->TXDRE[i] = ptmp ;            ptmp             += LAN_AM79C973_TDRE_SIZE ;        }        /* 3: allocate RX Descriptor Ring */        mem.size     = LAN_AM79C973_RDRE_COUNT * LAN_AM79C973_RDRE_SIZE ;        mem.boundary = LAN_AM79C973_RDRE_SIZE ;        mem.memory   = (void*)&ptmp ;        rcode = SYSCON_read( SYSCON_BOARD_MALLOC_ID,                             &mem,                             sizeof(t_sys_malloc) ) ;

⌨️ 快捷键说明

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