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

📄 lan_api.h

📁 MIPS下的boottloader yamon 的源代码
💻 H
字号:
#ifndef LAN_API_H
#define LAN_API_H

/************************************************************************
 *
 *      LAN_api.h
 *
 *      The 'LAN_api' module defines the lan device driver
 *      interface to be used via 'LAN' device driver services:
 *
 *        1) init  device:  configure and initialize LAN driver
 *        2) open  device:  register receive handler
 *        3) close device:  not used
 *        4) read  device:  read frame
 *        5) write device:  write frame
 *        6) ctrl  device:  control interfaces
 *
 *
 *
 * ######################################################################
 *
 * Copyright (c) 1999-2000 MIPS Technologies, Inc. All rights reserved. 
 * 
 * Unpublished rights reserved under the Copyright Laws of the United States of 
 * America. 
 * 
 * This document contains information that is proprietary to MIPS Technologies, 
 * Inc. ("MIPS Technologies"). Any copying, modifying or use of this information 
 * (in whole or in part) which is not expressly permitted in writing by MIPS 
 * Technologies or a contractually-authorized third party is strictly 
 * prohibited. At a minimum, this information is protected under unfair 
 * competition laws and the expression of the information contained herein is 
 * protected under federal copyright laws. Violations thereof may result in 
 * criminal penalties and fines. 
 * MIPS Technologies or any contractually-authorized third party reserves the 
 * right to change the information contained in this document to improve 
 * function, design or otherwise. MIPS Technologies does not assume any 
 * liability arising out of the application or use of this information. Any 
 * license under patent rights or any other intellectual property rights owned 
 * by MIPS Technologies or third parties shall be conveyed by MIPS Technologies 
 * or any contractually-authorized third party in a separate license agreement 
 * between the parties. 
 * The information contained in this document constitutes one or more of the 
 * following: commercial computer software, commercial computer software 
 * documentation or other commercial items. If the user of this information, or 
 * any related documentation of any kind, including related technical data or 
 * manuals, is an agency, department, or other entity of the United States 
 * government ("Government"), the use, duplication, reproduction, release, 
 * modification, disclosure, or transfer of this information, or any related 
 * documentation of any kind, is restricted in accordance with Federal 
 * Acquisition Regulation 12.212 for civilian agencies and Defense Federal 
 * Acquisition Regulation Supplement 227.7202 for military agencies. The use of 
 * this information by the Government is further restricted in accordance with 
 * the terms of the license agreement(s) and/or applicable contract terms and 
 * conditions covering this information from MIPS Technologies or any 
 * contractually-authorized third party. 
 *
 ************************************************************************/




/************************************************************************
 *    Include files
 ************************************************************************/

#include "sysdefs.h"

/************************************************************************
 *   LAN device driver, ERROR completion codes
*************************************************************************/


typedef enum LAN_error_ids
{
	                              
    ERROR_LAN_NO_FRAME                  /* No receive frame present     */
		= ERROR_LAN,  
    ERROR_LAN_COMM_ERROR,               /* Communication error detected */
    ERROR_LAN_NO_TXM_RESOURCES,         /* No buffer resources present  */
    ERROR_LAN_TXM_ERROR,                /* Transmission error detected  */
    ERROR_LAN_INIT_FAILED,              /* Initialization failed        */
    ERROR_LAN_DEVICE_BUSY,              /* Device is busy               */
    ERROR_LAN_DEVICE_NOTRDY,            /* Device not ready             */
/******* ADD NEW IO ERROR TAGS JUST BEFORE THIS LINE ONLY *******/

} t_LAN_error_ids;

typedef enum LAN_ctrl_command_ids
{
    LAN_CTRL_DISPLAY_STATISTICS = 0,    /* LAN, display statistics */
    LAN_CTRL_STOP_CONTROLLER,           /* LAN, stop any LAN controller
                                                activity, e.g. DMA */
    LAN_CTRL_START_CONTROLLER,          /* LAN, start LAN controller
                                                activity, e.g. DMA */
} t_LAN_ctrl_command_ids;


/************************************************************************
 *  Parameter definitions
*************************************************************************/

/* 
   LAN (Ethernet) frame buffer.
                                                                        */
#define LAN_MAX_FRAME_LENGTH  6+6+2+1500
typedef UINT8 t_LAN_frame_buffer[LAN_MAX_FRAME_LENGTH] ;

/* 
   IO (open) descriptor.
                                                                        */
typedef struct LAN_OPEN_desc
{
    UINT32 (*receive)( UINT32 length, UINT8 *data ) ;
} t_LAN_OPEN_desc ;


/* 
   IO (read and write) descriptor.
                                                                        */
typedef struct LAN_IO_desc
{
    UINT32 length ;
    UINT8  *data ;
} t_LAN_IO_desc ;

/* 
   CTRL  descriptor.
                                                                        */
typedef struct LAN_CTRL_desc
{
    UINT32 command ;
    void   *data ;
} t_LAN_CTRL_desc ;



/************************************************************************
 *  LAN device driver services, called by IO subsystem
*************************************************************************/



/* 
   NAME:  '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'


   RETURN VALUES:
   'OK' = 0x00

                                                                        */
typedef INT32 (*t_LAN_init_service)( 
          UINT32 major,          /* IN: major device number             */
          UINT32 minor,          /* not used                            */
          void   *p_param ) ;    /* not used                            */



/* 
   NAME: '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.

   RETURN VALUES:
   'OK' = 0x00:              receive handler registered
                                                                        */
typedef INT32 (*t_LAN_open_service)( 
          UINT32 major,          /* IN: major device number             */
          UINT32 minor,          /* IN: minor device number             */
          t_LAN_OPEN_desc *p_param ) ; /* IN: receive handler reference */



/* 
   NAME: 'close'   NOT USED

   DESCRIPTION:
     -

   RETURN VALUES:
     -
                                                                        */

/* 
   NAME: '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.

   RETURN VALUES:
   'OK' = 0x00:              frame read into user variable
   'ERROR_LAN_NO_FRAME':     no frame present on this LAN interface
   'ERROR_LAN_COMM_ERROR':   communication error detected
                                                                        */
typedef INT32 (*t_LAN_read_service)( 
          UINT32 major,          /* IN: major device number             */
          UINT32 minor,          /* IN: minor device number             */
          t_LAN_IO_desc *p_param ) ; /* INOUT: received frame      */


/* 
   NAME: 'write'

   DESCRIPTION:
   This service transmits a frame on the LAN interface

   RETURN VALUES:
   'OK' = 0x00:              frame has been transmitted successfully
   'ERROR_LAN_COMM_ERROR':   communication error detected

                                                                        */
typedef INT32 (*t_LAN_write_service)( 
          UINT32 major,          /* IN: major device number             */
          UINT32 minor,          /* IN: minor device number             */
          t_LAN_IO_desc *p_param ) ; /* OUT: frame to transmit     */


/* 
   NAME: 'ctrl' 

   DESCRIPTION:
   This service handles miscellaneous kind of services like statistics

     -

   RETURN VALUES:
   'OK' = 0x00
     -
                                                                        */
typedef INT32 (*t_LAN_ctrl_service)( 
          UINT32 major,          /* IN: major device number             */
          UINT32 minor,          /* IN: minor device number             */
          t_LAN_CTRL_desc *p_param ) ; /* IN-OUT: ctrl-service          */


/************************************************************************
 *  LAN drivers shared services, called by any LAN driver
*************************************************************************/

UINT32 LAN_init( void ) ;

#endif /* #ifndef LAN_API_H */

⌨️ 快捷键说明

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