Attachment G: UNDI API Constant and Type Definitions

Important: The code provided in this attachment is provided for informational purposes only.

/*
 *
* Copyright(c) 1997 by Intel Corporation.  All Rights Reserved.
 *
 */

#ifndef _UNDI_API_H
#define _UNDI_API_H

/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* UNDI_API.H
 *Parameter structure and type definitions for TFTP API version 2.x
 *
 *PXENV.H needs to be #included before this file.
 *
 *All of the UNDI API services are still available after the stack
 *has been unloaded.
 */


/* One of the following command op-codes needs to be loaded into the
 * op-code register (BX) before making a call a TFTP API service.
 */
 
#include "pxe_cmn.h"
 
#define PXENV_UNDI_STARTUP 0x0001
#define PXENV_UNDI_CLEANUP 0x0002
#define PXENV_UNDI_INITIALIZE 0x0003
#define PXENV_UNDI_RESET_NIC0x0004
#define PXENV_UNDI_SHUTDOWN0x0005
#define PXENV_UNDI_OPEN0x0006
#define PXENV_UNDI_CLOSE0x0007
#define PXENV_UNDI_TRANSMIT0x0008
#define PXENV_UNDI_SET_MCAST_ADDR0x0009
#define PXENV_UNDI_SET_STATION_ADDR0x000A
#define PXENV_UNDI_SET_PACKET_FILTER0x000B
#define PXENV_UNDI_GET_INFORMATION0x000C
#define PXENV_UNDI_GET_STATISTICS0x000D
#define PXENV_UNDI_CLEAR_STATISTICS0x000E
#define PXENV_UNDI_INITIATE_DIAGS0x000F
#define PXENV_UNDI_FORCE_INTERRUPT0x0010
#define PXENV_UNDI_GET_MCAST_ADDR0x0011

#define ADDR_LEN16
#define MAXNUM_MCADDR8


/* Definitions of TFTP API parameter structures.
 */

typedef struct s_PXENV_UNDI_MCAST_ADDR {
UINT16 MCastAddrCount;/* In: Number of multi-cast */
/* addresses. */
UINT8 MCastAddr[MAXNUM_MCADDR][ADDR_LEN]; /* In: */
/* list of multi-cast addresses. */
/* Each address can take up to */
/* ADDR_LEN bytes and a maximum */
/* of MAXNUM_MCADDR address can */
/* be provided*/
} t_PXENV_UNDI_MCAST_ADDR;


typedef struct s_PXENV_UNDI_STARTUP {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT8 BusType;/* In: NIC bus type. */
UINT8 AddrType;/* 0 means DataSeg contains segment */
/* addess for DS; 1 means DataSegAddr */
/* contains 32-bit physical addr for */
/* the data segment. */
UINT16 DataSeg;/* Segment address for DS */ 
UINT32 DataSegAddr;/* In: 32-bit physical address */
/* of Universal NIC Driver */
/* data segment. */
UINT16 DataSegSize;/* In: Size of data segment in bytes. */
UINT16 CodeSegSize;/* In: Size of Code segment in bytes. */
struct {
UINT16 BusDevFunc; /* In: Bus, device and function numbers */
/* of this NIC. -1 if not PCI NIC */
UINT16 PCI_ds_off;/* Far pointer to PCI data structure */
UINT16 PCI_ds_seg;
} pci;
struct {
UINT16 CardSelNum; /* In: Card select number.  */
/* -1 for non-PnP BBS device */
UINT16 PnP_eh_off;/* Far pointer to PnP expansion header */
UINT16 PnP_eh_seg;
} pnp;
} t_PXENV_UNDI_STARTUP;


typedef struct s_PXENV_UNDI_CLEANUP {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
} t_PXENV_UNDI_CLEANUP;


typedef struct s_PXENV_UNDI_INITIALIZE {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT32 ProtocolIni;/* In: See description below */
UINT16 ReceiveOffset;/* In: See description below */
UINT16 ReceiveSegment;/* In: See description below */
UINT16 GeneralIntOffset;/* In: See description below */
UINT16 GeneralIntSegment;/* In: See description below */
} t_PXENV_UNDI_INITIALIZE;


/* ProtocolIni :  

    This is an input parameter and is a 32-bit physical address of
    a memory  copy of the  driver module in  the protocol.ini file
    obtained from the  Protocol Manager  driver(refer to  NDIS 2.0
    specifications).   This parameter  is basically  supported for
    the universal NDIS driver to pass the information contained in
    protocol.ini   file  to  the  NIC   driver  for  any  specific
    configuration of   the   NIC.      (Note   that   the   module
    identification in the  protocol.ini  file  was  done  by  NDIS
    itself.)  This value can be NULL for any other application
    interfacing to the Universal NIC Driver.

    ReceiveOffset,  ReceiveSegment:  

    This is a pointer to the receive call-back routine and must be
    a non NULL pointer.   This  routine  will  be  called  in  the
    context  of  the  receive  interrupt  after  switching  to  an
    interrupt stack.  The parameters for the routine are passed in
    the registers which  are -  pointer to  the receive  buffer in
    ES:DI and the length of data in CX.  AX contains the length of
    the media  header starting at ES:DI,  BL contains the protocol
    id (0-unknown,  1-IP,  2-ARP,  3-RARP  and  4-others)  and  BH
    contains receive flag (0-directed/promiscuous, 1-broadcast and
    2-multicast).  It is the call-back routine's responsibility to
    initialize it's own  data segment  before starting  to execute
    and to preserve the contents of all the registers except AX.

    The  call-back can either  process the packet  or postpone the
    processing  to a later time.   It must return  a SUCCESS if it
    either copied the  packet into  its own  buffer or  decided to
    reject the  packet after  examining the  packet contents.   In
    this  case the NIC driver removes  the packet from the receive
    queue and recycles the buffer.  If the call-back does not want
    to look at the packet at this time it can return DELAY and the
    NIC  driver keeps the packet in the queue and will always give
    the  first packet's pointer to the call-back in the subsequent
    interrupts.  This  delay  may  however  cause  the  subsequent
    packets  to be dropped if  the receive queue is  full.  

    If the application  decides  to  process  the  packet  it  had
    delayed  it can force the NIC driver to start the call-back by
    calling ForceInterrupt routine.

GeneralIntOffset, GeneralIntSegment:

    This is also a pointer to a call back routine and will also be
    called  in  the  context  of  an  interrupt.    However,  this
    interrupt is  not  a  receive  interrupt  and  may  be  for  a
    1)transmit  complete, 2)post processing for a previous receive
    interrupt after releasing the interrupt stack or 3)it may be a
    software  interrupt.   The AX  register contains  the function
    code 1,  2 or 3 accordingly.  If  this routine is called for a
    transmit  complete indication, CX register contains the length
    of the packet transmitted and BX register contains the type of
    transmission  0, 1 or 2 according to 0)if the transmit was for
    a directed packet  (i.e.    neither  a  broadcast  and  nor  a
    multicast),  1)if  it  was  a  broadcast  or  2)if  it  was  a
    multicast.


    Note: This call-back  pointer  must  not  be  NULL.    If  the
    application  does not want to process any of these interrupts,
    a pointer to the routine which just returns the status must be
    provided.  
*/


typedef struct s_PXENV_UNDI_SHUTDOWN {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
} t_PXENV_UNDI_SHUTDOWN;


typedef struct s_PXENV_UNDI_RESET {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
t_PXENV_UNDI_MCAST_ADDR R_Mcast_Buf; /* multicast address list */
/* see note below  */
} t_PXENV_UNDI_RESET;

  /* Note: The  NIC  driver  does  not  remember  the  multicast
    addresses provided in any  call.    So  the  application  must
    provide the multicast address  list with all  the calls that
    reset the receive unit of the adapter.  
  */


typedef struct s_PXENV_UNDI_OPEN {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT16 OpenFlag;/* In: See description below */
UINT16 PktFilter;/* In: Filter for receiving */
/* packet. It takes the following */
/* values, multiple values can be */
/* ORed together. */
#define FLTR_DIRECTED0x0001  /* directed/multicast */
#define FLTR_BRDCST0x0002  /* broadcast packets */
#define FLTR_PRMSCS0x0004  /* any packet on LAN */
#define FLTR_SRC_RTG0x0008  /* source routing packet */

t_PXENV_UNDI_MCAST_ADDR McastBuffer; /* In: */
/* See t_PXENV_UNDI_MCAST_ADDR. */
} t_PXENV_UNDI_OPEN;

/*  OpenFlag:  
    This is  an input parameter and is  adapter specific.  This is
    supported  for Universal NDIS 2.0 driver to pass down the Open
    flags  provided  by   the  protocol   driver  (See   NDIS  2.0
    specifications).  This can be zero.  
*/


typedef struct s_PXENV_UNDI_CLOSE {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
} t_PXENV_UNDI_CLOSE;


#defineMAX_DATA_BLKS8

typedefstruct s_PXENV_UNDI_TBD{
UINT16 ImmedLength;/* In: Data buffer length in */
/* bytes. */
UINT16 XmitOffset;/* 16-bit segment & offset of the */
UINT16 XmitSegment;/* immediate data buffer. */
UINT16 DataBlkCount;/* In: Number of data blocks. */
struct DataBlk {
UINT8 TDPtrType;/*  /* 0 => 32 bit Phys pointer in TDDataPtr 
/*  not supported in this version of LSA */
/*  1 => seg:offser in TDDataPtr which can 
/*  be a real mode or 16-bit protected mode 
/*  pointer */
UINT8 TDRsvdByte;/*   Reserved, must be zero. */
UINT16 TDDataLen;/*   Data block length in bytes. */
UINT32 TDDataPtr;/*   Far pointer to data buffer. */
} DataBlock[MAX_DATA_BLKS];
} t_PXENV_UNDI_TBD;

typedef struct s_PXENV_UNDI_TRANSMIT {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT8Protocol;/* See description below */
#define P_UNKNOWN0
#define P_IP 1
#define P_ARP2
#define P_RARP3

UINT8XmitFlag;/* See description below*/
#define XMT_DESTADDR0x0000/* destination address given */
#define XMT_BROADCAST0x0001/* use broadcast address */
UINT16 DestAddrOffset;/* 16-bit segment & offset of the */
UINT16 DestAddrSegment;/* destination media address */
/*  See description below */
UINT16 TBDOffset;/* 16-bit segment & offset of the */
UINT16 TBDSegment;/* transmit buffer descriptor of type */
/* XmitBufferDesc*/
UINT32 Reserved[2];/* for future use*/
} t_PXENV_UNDI_TRANSMIT;

/* 
    Protocol:

    This is the protocol  of  the  upper  layer  that  is  calling
    NICTransmit call.   If the  upper layer  has filled  the media
    header this field must be 0.

    XmitFlag:

    If  this flag is  0, the NIC  driver expects a  pointer to the
    destination media  address in the field  DestMediaAddr.  If 1,
    the   NIC  driver   fills  the   broadcast  address   for  the
    destination.

    DestAddrOffset & DestAddrSegment:

    This  is a pointer to the  hardware address of the destination
    media.  It  can be  null if  the destination  is not  known in
    which case the XmitFlag contains 1 for broadcast.  Destination
    media address  must be  obtained by  the upper  level protocol
    (with  Address Resolution Protocol) and NIC driver does not do
    any address resolution.

*/

typedef struct s_PXENV_UNDI_SET_MCAST_ADDR {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
t_PXENV_UNDI_MCAST_ADDR McastBuffer; /* In: */
/* See t_PXENV_UNDI_MCAST_ADDR. */
} t_PXENV_UNDI_SET_MCAST_ADDR;


typedef struct s_PXENV_UNDI_SET_STATION_ADDR {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT8  StationAddress[ADDR_LEN]; /* new address to be set */
} t_PXENV_UNDI_SET_STATION_ADDR;


typedef struct s_PXENV_UNDI_SET_PACKET_FILTER {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT8 filter;/* In: Receive filter value. */
/* see t_PXENV_UNDI_OPEN for values */
} t_PXENV_UNDI_SET_PACKET_FILTER;


typedef struct s_PXENV_UNDI_GET_INFORMATION {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT16 BaseIo;/* Out: Adapter's Base IO */
UINT16 IntNumber;/* Out: IRQ number */
UINT16 MaxTranUnit;/* Out: MTU*/
UINT16  HwType;/* Out: type of protocol at hardware level */

#define ETHER_TYPE 1
#define EXP_ETHER_TYPE 2
#define IEEE_TYPE   6
#define ARCNET_TYPE    7

    /*  other numbers can  be obtained from  rfc1010 for "Assigned
    Numbers".  This number may not be validated by the application
    and hence adding new numbers to the list should be fine at any
    time.  */

UINT16 HwAddrLen;/* Out: actual length of hardware address */
UINT8 CurrentNodeAddress[ADDR_LEN]; /* Out: Current hardware address*/
UINT8 PermNodeAddress[ADDR_LEN]; /* Out: Permanent hardware address*/
UINT16 ROMAddress;/* Out: ROM address */
UINT16 RxBufCt;/* Out: receive Queue length*/
UINT16 TxBufCt;/* Out: Transmit Queue length */
} t_PXENV_UNDI_GET_INFORMATION;


typedef struct s_PXENV_UNDI_GET_STATISTICS {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT32 XmtGoodFrames; /* Out: No. of successful transmissions*/
UINT32 RcvGoodFrames;/* Out: No. of good frames received */
UINT32 RcvCRCErrors;   /* Out: No. of frames with CRC error */
UINT32 RcvResourceErrors;  /* Out: no. of frames discarded - */ 
/* Out: receive Queue full */
} t_PXENV_UNDI_GET_STATISTICS;


typedef struct s_PXENV_UNDI_CLEAR_STATISTICS {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
} t_PXENV_UNDI_CLEAR_STATISTICS;


typedef struct s_PXENV_UNDI_INITIATE_DIAGS {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
} t_PXENV_UNDI_INITIATE_DIAGS;


typedef struct s_PXENV_UNDI_FORCE_INTERRUPT {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
} t_PXENV_UNDI_FORCE_INTERRUPT;


typedef struct s_PXENV_UNDI_GET_MCAST_ADDR {
UINT16 Status;/* Out: See PXENV_STATUS_xxx constants. */
UINT32 InetAddr;/* In: IP Multicast Address */
UINT8  MediaAddr[ADDR_LEN];/* Out: corresponding hardware */
/*      multicast address */
} t_PXENV_UNDI_GET_MCAST_ADDR;

#define PXENV_UNDI_GET_NIC_TYPE  0x12

typedef s_PXENV_UNDI_GET_NIC_TYPE{
UINT16 Status;  /* OUT: See PXENV_STATUS_xxx constants */
UINT8 NicType;  /* OUT: 2=PCI, 3=PnP */
union{
struct{
UINT16 Vendor_ID;/* OUT:  */
UINT16 Dev_ID;/* OUT:  */
UINT8 Base_Class;/* OUT: */
UINT8 Sub_Class;/* OUT: */
UINT8 Prog_Intf;/* OUT: program interface */
UINT8 Rev;/* OUT: Revision number */
UINT16 BusDevFunc;/* OUT: Bus, Device */
/* & Function numbers */
}pci;
struct{
UINT32 EISA_Dev_ID;/* Out:  */
UINT8 Base_Class;/* OUT: */
UINT8 Sub_Class;/* OUT: */
UINT8 Prog_Intf;/* OUT: program interface */
UINT16 CardSelNum;/* OUT: Card Selector Number */
}pnp;
}pci_pnp_info;
}t_PXENV_UNDI_GET_NIC_TYPE;

#endif /* _UNDI_API_H */

/* EOF - $Workfile:   undi_api.h  $ */