Software Drivers

xemacps.c File Reference

#include "xemacps.h"

Functions

void XEmacPs_StubHandler (void)
int XEmacPs_CfgInitialize (XEmacPs *InstancePtr, XEmacPs_Config *CfgPtr, u32 EffectiveAddress)
void XEmacPs_Start (XEmacPs *InstancePtr)
void XEmacPs_Stop (XEmacPs *InstancePtr)
void XEmacPs_Reset (XEmacPs *InstancePtr)

Detailed Description

The XEmacPs driver. Functions in this file are the minimum required functions for this driver. See xemacps.h for a detailed description of the driver.

 MODIFICATION HISTORY:
 Ver   Who  Date     Changes
 ----- ---- -------- -------------------------------------------------------
 1.00a wsy  01/10/10 First release
 

Function Documentation

int XEmacPs_CfgInitialize ( XEmacPs InstancePtr,
XEmacPs_Config CfgPtr,
u32  EffectiveAddress 
)

Initialize a specific XEmacPs instance/driver. The initialization entails:

  • Initialize fields of the XEmacPs instance structure
  • Reset hardware and apply default options
  • Configure the DMA channels

The PHY is setup independently from the device. Use the MII or whatever other interface may be present for setup.

Parameters:
InstancePtr is a pointer to the instance to be worked on.
CfgPtr is the device configuration structure containing required hardware build data.
EffectiveAddress is the base address of the device. If address translation is not utilized, this parameter can be passed in using CfgPtr->Config.BaseAddress to specify the physical base address.
Returns:
  • XST_SUCCESS if initialization was successful
void XEmacPs_Reset ( XEmacPs InstancePtr  ) 

Perform a graceful reset of the Ethernet MAC. Resets the DMA channels, the transmitter, and the receiver.

Steps to reset

  • Stops transmit and receive channels
  • Stops DMA
  • Configure transmit and receive buffer size to default
  • Clear transmit and receive status register and counters
  • Clear all interrupt sources
  • Clear phy (if there is any previously detected) address
  • Clear MAC addresses (1-4) as well as Type IDs and hash value

All options are placed in their default state. Any frames in the descriptor lists will remain in the lists. The side effect of doing this is that after a reset and following a restart of the device, frames were in the list before the reset may be transmitted or received.

The upper layer software is responsible for re-configuring (if necessary) and restarting the MAC after the reset. Note also that driver statistics are not cleared on reset. It is up to the upper layer software to clear the statistics if needed.

When a reset is required, the driver notifies the upper layer software of this need through the ErrorHandler callback and specific status codes. The upper layer software is responsible for calling this Reset function and then re-configuring the device.

Parameters:
InstancePtr is a pointer to the instance to be worked on.
void XEmacPs_Start ( XEmacPs InstancePtr  ) 

Start the Ethernet controller as follows:

  • Enable transmitter if XTE_TRANSMIT_ENABLE_OPTION is set
  • Enable receiver if XTE_RECEIVER_ENABLE_OPTION is set
  • Start the SG DMA send and receive channels and enable the device interrupt
Parameters:
InstancePtr is a pointer to the instance to be worked on.
Returns:
N/A
Note:
Hardware is configured with scatter-gather DMA, the driver expects to start the scatter-gather channels and expects that the user has previously set up the buffer descriptor lists.

This function makes use of internal resources that are shared between the Start, Stop, and Set/ClearOptions functions. So if one task might be setting device options while another is trying to start the device, the user is required to provide protection of this shared data (typically using a semaphore).

This function must not be preempted by an interrupt that may service the device.

void XEmacPs_Stop ( XEmacPs InstancePtr  ) 

Gracefully stop the Ethernet MAC as follows:

  • Disable all interrupts from this device
  • Stop DMA channels
  • Disable the tansmitter and receiver

Device options currently in effect are not changed.

This function will disable all interrupts. Default interrupts settings that had been enabled will be restored when XEmacPs_Start() is called.

Parameters:
InstancePtr is a pointer to the instance to be worked on.
Note:
This function makes use of internal resources that are shared between the Start, Stop, SetOptions, and ClearOptions functions. So if one task might be setting device options while another is trying to start the device, the user is required to provide protection of this shared data (typically using a semaphore).

Stopping the DMA channels causes this function to block until the DMA operation is complete.

void XEmacPs_StubHandler ( void   ) 

This is a stub for the asynchronous callbacks. The stub is here in case the upper layer forgot to set the handler(s). On initialization, all handlers are set to this callback. It is considered an error for this handler to be invoked.