summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src
diff options
context:
space:
mode:
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2015-08-04 17:36:55 +0000
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2015-08-04 17:36:55 +0000
commitb5765a2a97bc50a3ec8564d34a51c9874abd2221 (patch)
tree9b8d6da1a3b9e4b26e753633a83f68c25f642711 /FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src
parenta5ddfe03149df3ebee68aa52b13e10f9ba823cfb (diff)
downloadfreertos-b5765a2a97bc50a3ec8564d34a51c9874abd2221.tar.gz
Common scheduler code:
- Back out changes that allow mutexes to be given from a semaphore after tests showed issues that would not be fast to fix. Demo projects: - Update the Microblaze Kintex 7 project and BSP to use version 2015.2 of the Xilinx SDK. git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@2363 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src')
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/Makefile27
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.c967
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.h404
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_g.c59
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_i.h136
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_intr.c359
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.c503
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.h371
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_selftest.c208
-rw-r--r--FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_sinit.c153
10 files changed, 3187 insertions, 0 deletions
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/Makefile b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/Makefile
new file mode 100644
index 000000000..69f2191df
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/Makefile
@@ -0,0 +1,27 @@
+COMPILER=
+ARCHIVER=
+CP=cp
+COMPILER_FLAGS=
+EXTRA_COMPILER_FLAGS=
+LIB=libxil.a
+
+RELEASEDIR=../../../lib
+INCLUDEDIR=../../../include
+INCLUDES=-I./. -I${INCLUDEDIR}
+
+INCLUDEFILES=*.h
+LIBSOURCES=*.c
+OUTS = *.o
+
+libs:
+ echo "Compiling emaclite"
+ $(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
+ $(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
+ make clean
+
+include:
+ ${CP} $(INCLUDEFILES) $(INCLUDEDIR)
+
+clean:
+ rm -rf ${OUTS}
+
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.c b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.c
new file mode 100644
index 000000000..5b5381159
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.c
@@ -0,0 +1,967 @@
+/******************************************************************************
+*
+* Copyright (C) 2004 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xemaclite.c
+*
+* Functions in this file are the minimum required functions for the EmacLite
+* driver. See xemaclite.h for a detailed description of the driver.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- --------------------------------------------------------
+* 1.01a ecm 01/31/04 First release
+* 1.11a mta 03/21/07 Updated to new coding style
+* 1.11a ecm 05/18/07 Updated the TxBufferAvailable routine to look at both
+* the active and busy bits
+* 1.13a sv 02/1/08 Updated the TxBufferAvailable routine to return
+* busy status properly
+* 2.00a ktn 02/16/09 Added support for MDIO
+* 2.01a ktn 07/20/09 Modified XEmacLite_Send function to use Ping buffers
+* Interrupt enable bit since this alone is used to enable
+* the interrupts for both Ping and Pong Buffers.
+* 3.00a ktn 10/22/09 Updated driver to use the HAL APIs/macros.
+* The macros have been renamed to remove _m from the name.
+* 3.01a ktn 07/08/10 The macro XEmacLite_GetReceiveDataLength is changed to
+* a static function.
+* Updated the XEmacLite_GetReceiveDataLength and
+* XEmacLite_Recv functions to support little endian
+* MicroBlaze.
+* 3.02a sdm 07/22/11 Removed redundant code in XEmacLite_Recv functions for
+* CR617290
+* 3.04a srt 04/13/13 Removed warnings (CR 705000).
+*
+* </pre>
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xil_io.h"
+#include "xenv.h"
+#include "xemaclite.h"
+#include "xemaclite_i.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+
+/************************** Function Prototypes ******************************/
+
+static u16 XEmacLite_GetReceiveDataLength(u32 BaseAddress);
+
+/************************** Variable Definitions *****************************/
+
+/*****************************************************************************/
+/**
+*
+* Initialize a specific XEmacLite instance/driver. The initialization entails:
+* - Initialize fields of the XEmacLite instance structure.
+*
+* The driver defaults to polled mode operation.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance.
+* @param EmacLiteConfigPtr points to the XEmacLite device configuration
+* structure.
+* @param EffectiveAddr is the device base address in the virtual memory
+* address space. If the address translation is not used then the
+* physical address is passed.
+* Unexpected errors may occur if the address mapping is changed
+* after this function is invoked.
+*
+* @return
+* - XST_SUCCESS if initialization was successful.
+*
+* @note The initialization of the PHY device is not done in this
+* function. The user needs to use XEmacLite_PhyRead and
+* XEmacLite_PhyWrite functions to access the PHY device.
+*
+******************************************************************************/
+int XEmacLite_CfgInitialize(XEmacLite *InstancePtr,
+ XEmacLite_Config *EmacLiteConfigPtr,
+ u32 EffectiveAddr)
+{
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+ Xil_AssertNonvoid(EmacLiteConfigPtr != NULL);
+
+ /*
+ * Zero the provided instance memory.
+ */
+ memset(InstancePtr, 0, sizeof(XEmacLite));
+
+ /*
+ * Set some default values for instance data, don't indicate the device
+ * is ready to use until everything has been initialized successfully.
+ */
+ InstancePtr->EmacLiteConfig.BaseAddress = EffectiveAddr;
+ InstancePtr->EmacLiteConfig.DeviceId = EmacLiteConfigPtr->DeviceId;
+ InstancePtr->EmacLiteConfig.TxPingPong = EmacLiteConfigPtr->TxPingPong;
+ InstancePtr->EmacLiteConfig.RxPingPong = EmacLiteConfigPtr->RxPingPong;
+ InstancePtr->EmacLiteConfig.MdioInclude = EmacLiteConfigPtr->MdioInclude;
+ InstancePtr->EmacLiteConfig.Loopback = EmacLiteConfigPtr->Loopback;
+
+ InstancePtr->NextTxBufferToUse = 0x0;
+ InstancePtr->NextRxBufferToUse = 0x0;
+ InstancePtr->RecvHandler = (XEmacLite_Handler) StubHandler;
+ InstancePtr->SendHandler = (XEmacLite_Handler) StubHandler;
+
+ /*
+ * Clear the TX CSR's in case this is a restart.
+ */
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_TSR_OFFSET, 0);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_BUFFER_OFFSET + XEL_TSR_OFFSET, 0);
+
+ /*
+ * Since there were no failures, indicate the device is ready to use.
+ */
+ InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
+
+ return XST_SUCCESS;
+}
+
+/*****************************************************************************/
+/**
+*
+* Send an Ethernet frame. The ByteCount is the total frame size, including
+* header.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance.
+* @param FramePtr is a pointer to frame. For optimal performance, a
+* 32-bit aligned buffer should be used but it is not required, the
+* function will align the data if necessary.
+* @param ByteCount is the size, in bytes, of the frame
+*
+* @return
+* - XST_SUCCESS if data was transmitted.
+* - XST_FAILURE if buffer(s) was (were) full and no valid data was
+* transmitted.
+*
+* @note
+*
+* This function call is not blocking in nature, i.e. it will not wait until the
+* frame is transmitted.
+*
+******************************************************************************/
+int XEmacLite_Send(XEmacLite *InstancePtr, u8 *FramePtr, unsigned ByteCount)
+{
+ u32 Register;
+ u32 BaseAddress;
+ u32 EmacBaseAddress;
+ u32 IntrEnableStatus;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+
+ /*
+ * Determine the expected TX buffer address.
+ */
+ BaseAddress = XEmacLite_NextTransmitAddr(InstancePtr);
+ EmacBaseAddress = InstancePtr->EmacLiteConfig.BaseAddress;
+
+ /*
+ * Check the Length if it is too large, truncate it.
+ * The maximum Tx packet size is
+ * Ethernet header (14 Bytes) + Maximum MTU (1500 bytes).
+ */
+ if (ByteCount > XEL_MAX_TX_FRAME_SIZE) {
+
+ ByteCount = XEL_MAX_TX_FRAME_SIZE;
+ }
+
+ /*
+ * Determine if the expected buffer address is empty.
+ */
+ Register = XEmacLite_GetTxStatus(BaseAddress);
+
+ /*
+ * If the expected buffer is available, fill it with the provided data
+ * Align if necessary.
+ */
+ if ((Register & (XEL_TSR_XMIT_BUSY_MASK |
+ XEL_TSR_XMIT_ACTIVE_MASK)) == 0) {
+
+ /*
+ * Switch to next buffer if configured.
+ */
+ if (InstancePtr->EmacLiteConfig.TxPingPong != 0) {
+ InstancePtr->NextTxBufferToUse ^= XEL_BUFFER_OFFSET;
+ }
+
+ /*
+ * Write the frame to the buffer.
+ */
+ XEmacLite_AlignedWrite(FramePtr, (u32 *) BaseAddress,
+ ByteCount);
+
+
+ /*
+ * The frame is in the buffer, now send it.
+ */
+ XEmacLite_WriteReg(BaseAddress, XEL_TPLR_OFFSET,
+ (ByteCount & (XEL_TPLR_LENGTH_MASK_HI |
+ XEL_TPLR_LENGTH_MASK_LO)));
+
+ /*
+ * Update the Tx Status Register to indicate that there is a
+ * frame to send.
+ * If the interrupt enable bit of Ping buffer(since this
+ * controls both the buffers) is enabled then set the
+ * XEL_TSR_XMIT_ACTIVE_MASK flag which is used by the interrupt
+ * handler to call the callback function provided by the user
+ * to indicate that the frame has been transmitted.
+ */
+ Register = XEmacLite_GetTxStatus(BaseAddress);
+ Register |= XEL_TSR_XMIT_BUSY_MASK;
+ IntrEnableStatus = XEmacLite_GetTxStatus(EmacBaseAddress);
+ if ((IntrEnableStatus & XEL_TSR_XMIT_IE_MASK) != 0) {
+ Register |= XEL_TSR_XMIT_ACTIVE_MASK;
+ }
+ XEmacLite_SetTxStatus(BaseAddress, Register);
+
+ return XST_SUCCESS;
+ }
+
+ /*
+ * If the expected buffer was full, try the other buffer if configured.
+ */
+ if (InstancePtr->EmacLiteConfig.TxPingPong != 0) {
+
+ BaseAddress ^= XEL_BUFFER_OFFSET;
+
+ /*
+ * Determine if the expected buffer address is empty.
+ */
+ Register = XEmacLite_GetTxStatus(BaseAddress);
+
+ /*
+ * If the next buffer is available, fill it with the provided
+ * data.
+ */
+ if ((Register & (XEL_TSR_XMIT_BUSY_MASK |
+ XEL_TSR_XMIT_ACTIVE_MASK)) == 0) {
+
+ /*
+ * Write the frame to the buffer.
+ */
+ XEmacLite_AlignedWrite(FramePtr, (u32 *) BaseAddress,
+ ByteCount);
+
+ /*
+ * The frame is in the buffer, now send it.
+ */
+ XEmacLite_WriteReg(BaseAddress, XEL_TPLR_OFFSET,
+ (ByteCount & (XEL_TPLR_LENGTH_MASK_HI |
+ XEL_TPLR_LENGTH_MASK_LO)));
+
+ /*
+ * Update the Tx Status Register to indicate that there
+ * is a frame to send.
+ * If the interrupt enable bit of Ping buffer(since this
+ * controls both the buffers) is enabled then set the
+ * XEL_TSR_XMIT_ACTIVE_MASK flag which is used by the
+ * interrupt handler to call the callback function
+ * provided by the user to indicate that the frame has
+ * been transmitted.
+ */
+ Register = XEmacLite_GetTxStatus(BaseAddress);
+ Register |= XEL_TSR_XMIT_BUSY_MASK;
+ IntrEnableStatus =
+ XEmacLite_GetTxStatus(EmacBaseAddress);
+ if ((IntrEnableStatus & XEL_TSR_XMIT_IE_MASK) != 0) {
+ Register |= XEL_TSR_XMIT_ACTIVE_MASK;
+ }
+ XEmacLite_SetTxStatus(BaseAddress, Register);
+
+ /*
+ * Do not switch to next buffer, there is a sync problem
+ * and the expected buffer should not change.
+ */
+ return XST_SUCCESS;
+ }
+ }
+
+
+ /*
+ * Buffer(s) was(were) full, return failure to allow for polling usage.
+ */
+ return XST_FAILURE;
+}
+
+/*****************************************************************************/
+/**
+*
+* Receive a frame. Intended to be called from the interrupt context or
+* with a wrapper which waits for the receive frame to be available.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance.
+* @param FramePtr is a pointer to a buffer where the frame will
+* be stored. The buffer must be at least XEL_MAX_FRAME_SIZE bytes.
+* For optimal performance, a 32-bit aligned buffer should be used
+* but it is not required, the function will align the data if
+* necessary.
+*
+* @return
+*
+* The type/length field of the frame received. When the type/length field
+* contains the type, XEL_MAX_FRAME_SIZE bytes will be copied out of the
+* buffer and it is up to the higher layers to sort out the frame.
+* Function returns 0 if there is no data waiting in the receive buffer or
+* the pong buffer if configured.
+*
+* @note
+*
+* This function call is not blocking in nature, i.e. it will not wait until
+* a frame arrives.
+*
+******************************************************************************/
+u16 XEmacLite_Recv(XEmacLite *InstancePtr, u8 *FramePtr)
+{
+ u16 LengthType;
+ u16 Length;
+ u32 Register;
+ u32 BaseAddress;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+
+ Xil_AssertNonvoid(InstancePtr != NULL);
+
+ /*
+ * Determine the expected buffer address.
+ */
+ BaseAddress = XEmacLite_NextReceiveAddr(InstancePtr);
+
+ /*
+ * Verify which buffer has valid data.
+ */
+ Register = XEmacLite_GetRxStatus(BaseAddress);
+
+ if ((Register & XEL_RSR_RECV_DONE_MASK) == XEL_RSR_RECV_DONE_MASK) {
+
+ /*
+ * The driver is in sync, update the next expected buffer if
+ * configured.
+ */
+
+ if (InstancePtr->EmacLiteConfig.RxPingPong != 0) {
+ InstancePtr->NextRxBufferToUse ^= XEL_BUFFER_OFFSET;
+ }
+ }
+ else {
+ /*
+ * The instance is out of sync, try other buffer if other
+ * buffer is configured, return 0 otherwise. If the instance is
+ * out of sync, do not update the 'NextRxBufferToUse' since it
+ * will correct on subsequent calls.
+ */
+ if (InstancePtr->EmacLiteConfig.RxPingPong != 0) {
+ BaseAddress ^= XEL_BUFFER_OFFSET;
+ }
+ else {
+ return 0; /* No data was available */
+ }
+
+ /*
+ * Verify that buffer has valid data.
+ */
+ Register = XEmacLite_GetRxStatus(BaseAddress);
+ if ((Register & XEL_RSR_RECV_DONE_MASK) !=
+ XEL_RSR_RECV_DONE_MASK) {
+ return 0; /* No data was available */
+ }
+ }
+
+ /*
+ * Get the length of the frame that arrived.
+ */
+ LengthType = XEmacLite_GetReceiveDataLength(BaseAddress);
+
+ /*
+ * Check if length is valid.
+ */
+ if (LengthType > XEL_MAX_FRAME_SIZE) {
+
+
+ if (LengthType == XEL_ETHER_PROTO_TYPE_IP) {
+
+ /*
+ * The packet is a an IP Packet.
+ */
+#ifdef __LITTLE_ENDIAN__
+ Length = (XEmacLite_ReadReg((BaseAddress),
+ XEL_HEADER_IP_LENGTH_OFFSET +
+ XEL_RXBUFF_OFFSET) &
+ (XEL_RPLR_LENGTH_MASK_HI |
+ XEL_RPLR_LENGTH_MASK_LO));
+ Length = (u16) (((Length & 0xFF00) >> 8) | ((Length & 0x00FF) << 8));
+#else
+ Length = ((XEmacLite_ReadReg((BaseAddress),
+ XEL_HEADER_IP_LENGTH_OFFSET +
+ XEL_RXBUFF_OFFSET) >>
+ XEL_HEADER_SHIFT) &
+ (XEL_RPLR_LENGTH_MASK_HI |
+ XEL_RPLR_LENGTH_MASK_LO));
+#endif
+
+ Length += XEL_HEADER_SIZE + XEL_FCS_SIZE;
+
+ } else if (LengthType == XEL_ETHER_PROTO_TYPE_ARP) {
+
+ /*
+ * The packet is an ARP Packet.
+ */
+ Length = XEL_ARP_PACKET_SIZE + XEL_HEADER_SIZE +
+ XEL_FCS_SIZE;
+
+ } else {
+ /*
+ * Field contains type other than IP or ARP, use max
+ * frame size and let user parse it.
+ */
+ Length = XEL_MAX_FRAME_SIZE;
+
+ }
+ } else {
+
+ /*
+ * Use the length in the frame, plus the header and trailer.
+ */
+ Length = LengthType + XEL_HEADER_SIZE + XEL_FCS_SIZE;
+ }
+
+ /*
+ * Read from the EmacLite.
+ */
+ XEmacLite_AlignedRead(((u32 *) (BaseAddress + XEL_RXBUFF_OFFSET)),
+ FramePtr, Length);
+
+ /*
+ * Acknowledge the frame.
+ */
+ Register = XEmacLite_GetRxStatus(BaseAddress);
+ Register &= ~XEL_RSR_RECV_DONE_MASK;
+ XEmacLite_SetRxStatus(BaseAddress, Register);
+
+ return Length;
+}
+
+/*****************************************************************************/
+/**
+*
+* Set the MAC address for this device. The address is a 48-bit value.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance.
+* @param AddressPtr is a pointer to a 6-byte MAC address.
+* the format of the MAC address is major octet to minor octet
+*
+* @return None.
+*
+* @note
+*
+* - TX must be idle and RX should be idle for deterministic results.
+* It is recommended that this function should be called after the
+* initialization and before transmission of any packets from the device.
+* - Function will not return if hardware is absent or not functioning
+* properly.
+* - The MAC address can be programmed using any of the two transmit
+* buffers (if configured).
+*
+******************************************************************************/
+void XEmacLite_SetMacAddress(XEmacLite *InstancePtr, u8 *AddressPtr)
+{
+ u32 BaseAddress;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+
+ /*
+ * Determine the expected TX buffer address.
+ */
+ BaseAddress = XEmacLite_NextTransmitAddr(InstancePtr);
+
+ /*
+ * Copy the MAC address to the Transmit buffer.
+ */
+ XEmacLite_AlignedWrite(AddressPtr,
+ (u32 *) BaseAddress,
+ XEL_MAC_ADDR_SIZE);
+
+ /*
+ * Set the length.
+ */
+ XEmacLite_WriteReg(BaseAddress,
+ XEL_TPLR_OFFSET,
+ XEL_MAC_ADDR_SIZE);
+
+ /*
+ * Update the MAC address in the EmacLite.
+ */
+ XEmacLite_SetTxStatus(BaseAddress, XEL_TSR_PROG_MAC_ADDR);
+
+
+ /*
+ * Wait for EmacLite to finish with the MAC address update.
+ */
+ while ((XEmacLite_GetTxStatus(BaseAddress) &
+ XEL_TSR_PROG_MAC_ADDR) != 0);
+
+}
+
+/******************************************************************************/
+/**
+*
+* This is a stub for the send and receive callbacks. The stub
+* is here in case the upper layers forget to set the handlers.
+*
+* @param CallBackRef is a pointer to the upper layer callback reference.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void StubHandler(void *CallBackRef)
+{
+ (void)(CallBackRef);
+ Xil_AssertVoidAlways();
+}
+
+
+/****************************************************************************/
+/**
+*
+* Determine if there is a transmit buffer available.
+*
+* @param InstancePtr is the pointer to the instance of the driver to
+* be worked on.
+*
+* @return
+* - TRUE if there is a TX buffer available for data to be written
+* - FALSE if Tx Buffer is not available.
+*
+* @note None.
+*
+*****************************************************************************/
+int XEmacLite_TxBufferAvailable(XEmacLite *InstancePtr)
+{
+
+ u32 Register;
+ int TxPingBusy;
+ int TxPongBusy;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+
+ /*
+ * Read the Tx Status and determine if the buffer is available.
+ */
+ Register = XEmacLite_GetTxStatus(InstancePtr->EmacLiteConfig.
+ BaseAddress);
+
+ TxPingBusy = (Register & (XEL_TSR_XMIT_BUSY_MASK |
+ XEL_TSR_XMIT_ACTIVE_MASK));
+
+
+ /*
+ * Read the Tx Status of the second buffer register and determine if the
+ * buffer is available.
+ */
+ if (InstancePtr->EmacLiteConfig.TxPingPong != 0) {
+ Register = XEmacLite_GetTxStatus(InstancePtr->EmacLiteConfig.
+ BaseAddress +
+ XEL_BUFFER_OFFSET);
+
+ TxPongBusy = (Register & (XEL_TSR_XMIT_BUSY_MASK |
+ XEL_TSR_XMIT_ACTIVE_MASK));
+
+ return (!(TxPingBusy && TxPongBusy));
+ }
+
+ return (!TxPingBusy);
+
+
+}
+
+/****************************************************************************/
+/**
+*
+* Flush the Receive buffers. All data will be lost.
+*
+* @param InstancePtr is the pointer to the instance of the driver to
+* be worked on.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void XEmacLite_FlushReceive(XEmacLite *InstancePtr)
+{
+
+ u32 Register;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+
+ /*
+ * Read the current buffer register and determine if the buffer is
+ * available.
+ */
+ Register = XEmacLite_GetRxStatus(InstancePtr->EmacLiteConfig.
+ BaseAddress);
+
+ /*
+ * Preserve the IE bit.
+ */
+ Register &= XEL_RSR_RECV_IE_MASK;
+
+ /*
+ * Write out the value to flush the RX buffer.
+ */
+ XEmacLite_SetRxStatus(InstancePtr->EmacLiteConfig.BaseAddress,
+ Register);
+
+ /*
+ * If the pong buffer is available, flush it also.
+ */
+ if (InstancePtr->EmacLiteConfig.RxPingPong != 0) {
+ /*
+ * Read the current buffer register and determine if the buffer
+ * is available.
+ */
+ Register = XEmacLite_GetRxStatus(InstancePtr->EmacLiteConfig.
+ BaseAddress +
+ XEL_BUFFER_OFFSET);
+
+ /*
+ * Preserve the IE bit.
+ */
+ Register &= XEL_RSR_RECV_IE_MASK;
+
+ /*
+ * Write out the value to flush the RX buffer.
+ */
+ XEmacLite_SetRxStatus(InstancePtr->EmacLiteConfig.BaseAddress +
+ XEL_BUFFER_OFFSET, Register);
+
+ }
+
+}
+
+/******************************************************************************/
+/**
+*
+* Read the specified PHY register.
+*
+* @param InstancePtr is the pointer to the instance of the driver.
+* @param PhyAddress is the address of the PHY device. The valid range is
+* is from 0 to 31.
+* @param RegNum is the register number in the PHY device which
+* is to be read. The valid range is is from 0 to 31.
+* @param PhyDataPtr is a pointer to the data in which the data read
+* from the PHY device is returned.
+*
+* @return
+* - XST_SUCCESS if the data is read from the PHY.
+* - XST_DEVICE_BUSY if MDIO is busy.
+*
+* @note This function waits for the completion of MDIO data transfer.
+*
+*****************************************************************************/
+int XEmacLite_PhyRead(XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum,
+ u16 *PhyDataPtr)
+{
+ u32 PhyAddrReg;
+ u32 MdioCtrlReg;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+ Xil_AssertNonvoid(InstancePtr->EmacLiteConfig.MdioInclude == TRUE);
+ Xil_AssertNonvoid(PhyAddress <= 31);
+ Xil_AssertNonvoid(RegNum <= 31);
+ Xil_AssertNonvoid(PhyDataPtr != NULL);
+
+ /*
+ * Verify MDIO master status.
+ */
+ if (XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET) &
+ XEL_MDIOCNTR_STATUS_MASK) {
+ return XST_DEVICE_BUSY;
+ }
+
+ PhyAddrReg = ((((PhyAddress << XEL_MDIO_ADDRESS_SHIFT) &
+ XEL_MDIO_ADDRESS_MASK) | RegNum) | XEL_MDIO_OP_MASK);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOADDR_OFFSET, PhyAddrReg);
+
+ /*
+ * Enable MDIO and start the transfer.
+ */
+ MdioCtrlReg =
+ XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET,
+ MdioCtrlReg |
+ XEL_MDIOCNTR_STATUS_MASK |
+ XEL_MDIOCNTR_ENABLE_MASK);
+
+ /*
+ * Wait till the completion of transfer.
+ */
+ while ((XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET) &
+ XEL_MDIOCNTR_STATUS_MASK));
+
+ /*
+ * Read data from MDIO read data register.
+ */
+ *PhyDataPtr = (u16)XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIORD_OFFSET);
+
+ /*
+ * Disable the MDIO.
+ */
+ MdioCtrlReg =
+ XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET);
+
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET,
+ MdioCtrlReg & ~XEL_MDIOCNTR_ENABLE_MASK);
+
+
+ return XST_SUCCESS;
+}
+
+/******************************************************************************/
+/**
+*
+* Write the given data to the specified register in the PHY device.
+*
+* @param InstancePtr is the pointer to the instance of the driver.
+* @param PhyAddress is the address of the PHY device. The valid range is
+* is from 0 to 31.
+* @param RegNum is the register number in the PHY device which
+* is to be written. The valid range is is from 0 to 31.
+* @param PhyData is the data to be written to the specified register in
+* the PHY device.
+*
+* @return
+* - XST_SUCCESS if the data is written to the PHY.
+* - XST_DEVICE_BUSY if MDIO is busy.
+*
+* @note This function waits for the completion of MDIO data transfer.
+*
+*******************************************************************************/
+int XEmacLite_PhyWrite(XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum,
+ u16 PhyData)
+{
+ u32 PhyAddrReg;
+ u32 MdioCtrlReg;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+ Xil_AssertNonvoid(InstancePtr->EmacLiteConfig.MdioInclude == TRUE);
+ Xil_AssertNonvoid(PhyAddress <= 31);
+ Xil_AssertNonvoid(RegNum <= 31);
+
+ /*
+ * Verify MDIO master status.
+ */
+ if (XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET) &
+ XEL_MDIOCNTR_STATUS_MASK) {
+ return XST_DEVICE_BUSY;
+ }
+
+
+
+ PhyAddrReg = ((((PhyAddress << XEL_MDIO_ADDRESS_SHIFT) &
+ XEL_MDIO_ADDRESS_MASK) | RegNum) & ~XEL_MDIO_OP_MASK);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOADDR_OFFSET, PhyAddrReg);
+
+ /*
+ * Write data to MDIO write data register.
+ */
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOWR_OFFSET, (u32)PhyData);
+
+ /*
+ * Enable MDIO and start the transfer.
+ */
+ MdioCtrlReg =
+ XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET,
+ MdioCtrlReg | XEL_MDIOCNTR_STATUS_MASK |
+ XEL_MDIOCNTR_ENABLE_MASK);
+
+ /*
+ * Wait till the completion of transfer.
+ */
+ while ((XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET) & XEL_MDIOCNTR_STATUS_MASK));
+
+
+ /*
+ * Disable the MDIO.
+ */
+ MdioCtrlReg =
+ XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_MDIOCNTR_OFFSET,
+ MdioCtrlReg & ~XEL_MDIOCNTR_ENABLE_MASK);
+
+
+
+ return XST_SUCCESS;
+}
+
+
+
+/****************************************************************************/
+/**
+*
+* Enable Internal loop back functionality.
+*
+* @param InstancePtr is the pointer to the instance of the driver.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void XEmacLite_EnableLoopBack(XEmacLite *InstancePtr)
+{
+ u32 TsrReg;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(InstancePtr->EmacLiteConfig.Loopback == TRUE);
+
+ TsrReg = XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_TSR_OFFSET);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_TSR_OFFSET, TsrReg | XEL_TSR_LOOPBACK_MASK);
+}
+
+/****************************************************************************/
+/**
+*
+* Disable Internal loop back functionality.
+*
+* @param InstancePtr is the pointer to the instance of the driver.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void XEmacLite_DisableLoopBack(XEmacLite *InstancePtr)
+{
+ u32 TsrReg;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(InstancePtr->EmacLiteConfig.Loopback == TRUE);
+
+ TsrReg = XEmacLite_ReadReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_TSR_OFFSET);
+ XEmacLite_WriteReg(InstancePtr->EmacLiteConfig.BaseAddress,
+ XEL_TSR_OFFSET, TsrReg & (~XEL_TSR_LOOPBACK_MASK));
+}
+
+
+/*****************************************************************************/
+/**
+*
+* Return the length of the data in the Receive Buffer.
+*
+* @param BaseAddress contains the base address of the device.
+*
+* @return The type/length field of the frame received.
+*
+* @note None.
+*
+******************************************************************************/
+static u16 XEmacLite_GetReceiveDataLength(u32 BaseAddress)
+{
+ u16 Length;
+
+#ifdef __LITTLE_ENDIAN__
+ Length = (XEmacLite_ReadReg((BaseAddress),
+ XEL_HEADER_OFFSET + XEL_RXBUFF_OFFSET) &
+ (XEL_RPLR_LENGTH_MASK_HI | XEL_RPLR_LENGTH_MASK_LO));
+ Length = (u16) (((Length & 0xFF00) >> 8) | ((Length & 0x00FF) << 8));
+#else
+ Length = ((XEmacLite_ReadReg((BaseAddress),
+ XEL_HEADER_OFFSET + XEL_RXBUFF_OFFSET) >>
+ XEL_HEADER_SHIFT) &
+ (XEL_RPLR_LENGTH_MASK_HI | XEL_RPLR_LENGTH_MASK_LO));
+#endif
+
+ return Length;
+}
+
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.h b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.h
new file mode 100644
index 000000000..4de21a59b
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite.h
@@ -0,0 +1,404 @@
+/******************************************************************************
+*
+* Copyright (C) 2004 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xemaclite.h
+*
+* The Xilinx Ethernet Lite (EmacLite) driver. This driver supports the Xilinx
+* Ethernet Lite 10/100 MAC (EmacLite).
+*
+* The Xilinx Ethernet Lite 10/100 MAC supports the following features:
+* - Media Independent Interface (MII) for connection to external
+* 10/100 Mbps PHY transceivers
+* - Independent internal transmit and receive buffers
+* - CSMA/CD compliant operations for half-duplex modes
+* - Unicast and broadcast
+* - Automatic FCS insertion
+* - Automatic pad insertion on transmit
+* - Configurable ping/pong buffers for either/both transmit and receive
+* buffer areas
+* - Interrupt driven mode
+* - Internal loop back
+* - MDIO Support to access PHY Registers
+*
+* The Xilinx Ethernet Lite 10/100 MAC does not support the following features:
+* - multi-frame buffering
+* only 1 transmit frame is allowed into each transmit buffer,
+* only 1 receive frame is allowed into each receive buffer.
+* the hardware blocks reception until buffer is emptied
+* - Pause frame (flow control) detection in full-duplex mode
+* - Programmable inter frame gap
+* - Multicast and promiscuous address filtering
+* - Automatic source address insertion or overwrite
+*
+* <b>Driver Description</b>
+*
+* The device driver enables higher layer software (e.g., an application) to
+* communicate to the EmacLite. The driver handles transmission and reception
+* of Ethernet frames, as well as configuration of the controller. It does not
+* handle protocol stack functionality such as Link Layer Control (LLC) or the
+* Address Resolution Protocol (ARP). The protocol stack that makes use of the
+* driver handles this functionality. This implies that the driver is simply a
+* pass-through mechanism between a protocol stack and the EmacLite.
+*
+* Since the driver is a simple pass-through mechanism between a protocol stack
+* and the EmacLite, no assembly or disassembly of Ethernet frames is done at
+* the driver-level. This assumes that the protocol stack passes a correctly
+* formatted Ethernet frame to the driver for transmission, and that the driver
+* does not validate the contents of an incoming frame. A single device driver
+* can support multiple EmacLite devices.
+*
+* The driver supports interrupt driven mode and the default mode of operation
+* is polled mode. If interrupts are desired, XEmacLite_InterruptEnable() must
+* be called.
+*
+* <b>Device Configuration</b>
+*
+* The device can be configured in various ways during the FPGA implementation
+* process. Configuration parameters are stored in the xemaclite_g.c file.
+* A table is defined where each entry contains configuration information for an
+* EmacLite device. This information includes such things as the base address
+* of the memory-mapped device and the number of buffers.
+*
+* <b>Interrupt Processing</b>
+*
+* After _Initialize is called, _InterruptEnable can be called to enable the
+* interrupt driven functionality. If polled operation is desired, just call
+* _Send and check the return code. If XST_FAILURE is returned, call _Send with
+* the same data until XST_SUCCESS is returned. The same idea applies to _Recv.
+* Call _Recv until the returned length is non-zero at which point the received
+* data is in the buffer provided in the function call.
+*
+* The Transmit and Receive interrupts are enabled within the _InterruptEnable
+* function and disabled in the _InterruptDisable function. The _Send and _Recv
+* functions acknowledge the EmacLite generated interrupts associated with each
+* function.
+* It is the application's responsibility to acknowledge any associated Interrupt
+* Controller interrupts if it is used in the system.
+*
+* <b>Memory Buffer Alignment</b>
+*
+* The alignment of the input/output buffers for the _Send and _Recv routine is
+* not required to be 32 bits. If the buffer is not aligned on a 32-bit boundary
+* there will be a performance impact while the driver aligns the data for
+* transmission or upon reception.
+*
+* For optimum performance, the user should provide a 32-bit aligned buffer
+* to the _Send and _Recv routines.
+*
+* <b>Asserts</b>
+*
+* Asserts are used within all Xilinx drivers to enforce constraints on argument
+* values. Asserts can be turned off on a system-wide basis by defining, at
+* compile time, the NDEBUG identifier. By default, asserts are turned on and it
+* is recommended that application developers leave asserts on during
+* development.
+*
+* @note
+*
+* This driver requires EmacLite hardware version 1.01a and higher. It is not
+* compatible with earlier versions of the EmacLite hardware. Use version 1.00a
+* software driver for hardware version 1.00a/b.
+*
+* The RX hardware is enabled from powerup and there is no disable. It is
+* possible that frames have been received prior to the initialization
+* of the driver. If this situation is possible, call XEmacLite_FlushReceive()
+* to empty the receive buffers after initialization.
+*
+* This driver is intended to be RTOS and processor independent. It works
+* with physical addresses only. Any needs for dynamic memory management,
+* threads or thread mutual exclusion, virtual memory, or cache control must
+* be satisfied by the layer above this driver.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.01a ecm 01/30/04 First release
+* 1.11a mta 03/21/07 Updated to new coding style
+* 1.12a mta 11/28/07 Added the function XEmacLite_CfgInitialize,
+* moved the functions XEmacLite_LookupConfig and
+* XEmacLite_Initialize to xemaclite_sinit.c for removing
+* the dependency on the static config table and
+* xparameters.h from the driver initialization
+* 1.13a sv 02/1/08 Updated the TxBufferAvailable routine to return
+* busy status properly and added macros for Tx/Rx status
+* 1.14a sdm 08/22/08 Removed support for static interrupt handlers from the MDD
+* file
+* 2.00a ktn 02/16/09 Added support for MDIO and internal loop back
+* 2.01a ktn 07/20/09 Updated the XEmacLite_AlignedWrite and
+* XEmacLite_AlignedRead functions to use volatile
+* variables so that they are not optimized.
+* Modified the XEmacLite_EnableInterrupts and
+* XEmacLite_DisableInterrupts functions to enable/disable
+* the interrupt in the Ping buffer as this is used to enable
+* the interrupts for both Ping and Pong Buffers.
+* The interrupt enable bit in the Pong buffer is not used by
+* the HW.
+* Modified XEmacLite_Send function to use Ping buffers
+* Interrupt enable bit since this alone is used to enable
+* the interrupts for both Ping and Pong Buffers.
+* 3.00a ktn 10/22/09 Updated driver to use the HAL Processor APIs/macros.
+* The macros have been renamed to remove _m from the name in
+* all the driver files.
+* The macros changed in this file are
+* XEmacLite_mNextTransmitAddr is XEmacLite_NextTransmitAddr,
+* XEmacLite_mNextReceiveAddr is XEmacLite_NextReceiveAddr,
+* XEmacLite_mIsMdioConfigured is XEmacLite_IsMdioConfigured,
+* XEmacLite_mIsLoopbackConfigured is
+* XEmacLite_IsLoopbackConfigured.
+* See xemaclite_i.h for the macros which have changed.
+* 3.01a ktn 07/08/10 The macro XEmacLite_GetReceiveDataLength in the
+* xemaclite.c file is changed to a static function.
+* XEmacLite_GetReceiveDataLength and XEmacLite_Recv
+* functions are updated to support little endian
+* MicroBlaze.
+* 3.02a sdm 07/22/11 Removed redundant code in XEmacLite_Recv functions for
+* CR617290
+* 3.03a asa 04/05/12 Defined the flag __LITTLE_ENDIAN__ for cases where the
+* driver is compiled with ARM toolchain.
+* 3.04a srt 04/13/13 Removed warnings (CR 705000).
+* 4.0 adk 19/12/13 Updated as per the New Tcl API's
+*
+* </pre>
+*
+*
+******************************************************************************/
+#ifndef XEMACLITE_H /* prevent circular inclusions */
+#define XEMACLITE_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************** Include Files *********************************/
+
+#include "xenv.h"
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xstatus.h"
+#include "xemaclite_l.h"
+
+#ifdef __ARMEL__
+#ifndef __LITTLE_ENDIAN__
+#define __LITTLE_ENDIAN__
+#endif
+#endif
+/************************** Constant Definitions *****************************/
+/*
+ * Device information
+ */
+#define XEL_DEVICE_NAME "xemaclite"
+#define XEL_DEVICE_DESC "Xilinx Ethernet Lite 10/100 MAC"
+
+/**************************** Type Definitions *******************************/
+
+/**
+ * This typedef contains configuration information for a device.
+ */
+typedef struct {
+ u16 DeviceId; /**< Unique ID of device */
+ u32 BaseAddress; /**< Device base address */
+ u8 TxPingPong; /**< 1 if TX Pong buffer configured, 0 otherwise */
+ u8 RxPingPong; /**< 1 if RX Pong buffer configured, 0 otherwise */
+ u8 MdioInclude; /**< 1 if MDIO is enabled, 0 otherwise */
+ u8 Loopback; /**< 1 if internal loopback is enabled, 0 otherwise */
+} XEmacLite_Config;
+
+
+/*
+ * Callback when data is sent or received .
+ * @param CallBackRef is a callback reference passed in by the upper layer
+ * when setting the callback functions, and passed back to the
+ * upper layer when the callback is invoked.
+ */
+typedef void (*XEmacLite_Handler) (void *CallBackRef);
+
+/**
+ * The XEmacLite driver instance data. The user is required to allocate a
+ * variable of this type for every EmacLite device in the system. A pointer
+ * to a variable of this type is then passed to the driver API functions.
+ */
+typedef struct {
+ XEmacLite_Config EmacLiteConfig; /* Device configuration */
+ u32 IsReady; /* Device is initialized and ready */
+
+ u32 NextTxBufferToUse; /* Next TX buffer to write to */
+ u32 NextRxBufferToUse; /* Next RX buffer to read from */
+
+ /*
+ * Callbacks
+ */
+ XEmacLite_Handler RecvHandler;
+ void *RecvRef;
+ XEmacLite_Handler SendHandler;
+ void *SendRef;
+
+} XEmacLite;
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/****************************************************************************/
+/**
+*
+* Return the next expected Transmit Buffer's address.
+*
+* @param InstancePtr is the pointer to the instance of the driver to
+* be worked on
+*
+* @note C-Style signature:
+* u32 XEmacLite_NextTransmitAddr(XEmacLite *InstancePtr);
+*
+* This macro returns the address of the next transmit buffer to put data into.
+* This is used to determine the destination of the next transmit data frame.
+*
+*****************************************************************************/
+#define XEmacLite_NextTransmitAddr(InstancePtr) \
+ ((InstancePtr)->EmacLiteConfig.BaseAddress + \
+ (InstancePtr)->NextTxBufferToUse) + XEL_TXBUFF_OFFSET
+
+/****************************************************************************/
+/**
+*
+* Return the next expected Receive Buffer's address.
+*
+* @param InstancePtr is the pointer to the instance of the driver to
+* be worked on
+*
+* @note C-Style signature:
+* u32 XEmacLite_NextReceiveAddr(XEmacLite *InstancePtr);
+*
+* This macro returns the address of the next receive buffer to read data from.
+* This is the expected receive buffer address if the driver is in sync.
+*
+*****************************************************************************/
+#define XEmacLite_NextReceiveAddr(InstancePtr) \
+ ((InstancePtr)->EmacLiteConfig.BaseAddress + \
+ (InstancePtr)->NextRxBufferToUse)
+
+/*****************************************************************************/
+/**
+*
+* This macro determines if the device is currently configured for MDIO.
+*
+* @param InstancePtr is the pointer to the instance of the
+* EmacLite driver.
+*
+* @return
+* - TRUE if the device is configured for MDIO.
+* - FALSE if the device is NOT configured for MDIO.
+*
+* @note C-Style signature:
+* int XEmacLite_IsMdioConfigured(XEmacLite *InstancePtr)
+*
+******************************************************************************/
+#define XEmacLite_IsMdioConfigured(InstancePtr) \
+ ((InstancePtr)->EmacLiteConfig.MdioInclude == 1)
+
+/*****************************************************************************/
+/**
+*
+* This macro determines if the device is currently configured for internal
+* loopback.
+*
+* @param InstancePtr is the pointer to the instance of the
+* EmacLite driver.
+*
+* @return
+* - TRUE if the device is configured for internal loopback.
+* - FALSE if the device is NOT configured for internal loopback.
+*
+* @note C-Style signature:
+* int XEmacLite_IsLoopbackConfigured(XEmacLite *InstancePtr)
+*
+******************************************************************************/
+#define XEmacLite_IsLoopbackConfigured(InstancePtr) \
+ ((InstancePtr)->EmacLiteConfig.Loopback == 1)
+
+/************************** Variable Definitions *****************************/
+
+/************************** Function Prototypes ******************************/
+
+/*
+ * Functions in xemaclite.c
+ */
+int XEmacLite_CfgInitialize(XEmacLite *InstancePtr,
+ XEmacLite_Config *EmacLiteConfigPtr,
+ u32 EffectiveAddr);
+void XEmacLite_SetMacAddress(XEmacLite *InstancePtr, u8 *AddressPtr);
+int XEmacLite_TxBufferAvailable(XEmacLite *InstancePtr);
+void XEmacLite_FlushReceive(XEmacLite *InstancePtr);
+
+int XEmacLite_Send(XEmacLite *InstancePtr, u8 *FramePtr, unsigned ByteCount);
+u16 XEmacLite_Recv(XEmacLite *InstancePtr, u8 *FramePtr);
+
+int XEmacLite_PhyRead(XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum,
+ u16 *PhyDataPtr);
+int XEmacLite_PhyWrite(XEmacLite *InstancePtr, u32 PhyAddress, u32 RegNum,
+ u16 PhyData);
+
+void XEmacLite_EnableLoopBack(XEmacLite *InstancePtr);
+void XEmacLite_DisableLoopBack(XEmacLite *InstancePtr);
+
+/*
+ * Initialization functions in xemaclite_sinit.c
+ */
+XEmacLite_Config *XEmacLite_LookupConfig(u16 DeviceId);
+int XEmacLite_Initialize(XEmacLite *InstancePtr, u16 DeviceId);
+
+/*
+ * Interrupt driven functions in xemaclite_intr.c
+ */
+int XEmacLite_EnableInterrupts(XEmacLite *InstancePtr);
+void XEmacLite_DisableInterrupts(XEmacLite *InstancePtr);
+
+void XEmacLite_InterruptHandler(void *InstancePtr);
+
+void XEmacLite_SetRecvHandler(XEmacLite *InstancePtr, void *CallBackRef,
+ XEmacLite_Handler FuncPtr);
+void XEmacLite_SetSendHandler(XEmacLite *InstancePtr, void *CallBackRef,
+ XEmacLite_Handler FuncPtr);
+
+/*
+ * Selftest function in xemaclite_selftest.c
+ */
+int XEmacLite_SelfTest(XEmacLite *InstancePtr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
+
+
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_g.c b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_g.c
new file mode 100644
index 000000000..9e9c1ea08
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_g.c
@@ -0,0 +1,59 @@
+
+/*******************************************************************
+*
+* CAUTION: This file is automatically generated by HSI.
+* Version:
+* DO NOT EDIT.
+*
+* Copyright (C) 2010-2015 Xilinx, Inc. All Rights Reserved.*
+*Permission is hereby granted, free of charge, to any person obtaining a copy
+*of this software and associated documentation files (the Software), to deal
+*in the Software without restriction, including without limitation the rights
+*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*copies of the Software, and to permit persons to whom the Software is
+*furnished to do so, subject to the following conditions:
+*
+*The above copyright notice and this permission notice shall be included in
+*all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+*(a) running on a Xilinx device, or
+*(b) that interact with a Xilinx device through a bus or interconnect.
+*
+*THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+*WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+*OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*
+*Except as contained in this notice, the name of the Xilinx shall not be used
+*in advertising or otherwise to promote the sale, use or other dealings in
+*this Software without prior written authorization from Xilinx.
+*
+
+*
+* Description: Driver configuration
+*
+*******************************************************************/
+
+#include "xparameters.h"
+#include "xemaclite.h"
+
+/*
+* The configuration table for devices
+*/
+
+XEmacLite_Config XEmacLite_ConfigTable[] =
+{
+ {
+ XPAR_AXI_ETHERNETLITE_0_DEVICE_ID,
+ XPAR_AXI_ETHERNETLITE_0_BASEADDR,
+ XPAR_AXI_ETHERNETLITE_0_TX_PING_PONG,
+ XPAR_AXI_ETHERNETLITE_0_RX_PING_PONG,
+ XPAR_AXI_ETHERNETLITE_0_INCLUDE_MDIO,
+ XPAR_AXI_ETHERNETLITE_0_INCLUDE_INTERNAL_LOOPBACK
+ }
+};
+
+
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_i.h b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_i.h
new file mode 100644
index 000000000..6bfa1714d
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_i.h
@@ -0,0 +1,136 @@
+/******************************************************************************
+*
+* Copyright (C) 2004 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/******************************************************************************/
+/**
+* @file xemaclite_i.h
+*
+* This header file contains internal identifiers, which are those shared
+* between the files of the driver. It is intended for internal use only.
+*
+* NOTES:
+*
+* None.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.01a ecm 05/21/04 First release
+* 1.11a mta 03/21/07 Updated to new coding style
+* 1.13a sv 02/1/08 Added macros to Get/Set Tx/Rx status
+* 3.00a ktn 10/22/09 The macros have been renamed to remove _m from the name.
+* The macros changed in this file are
+* XEmacLite_mGetTxActive changed to XEmacLite_GetTxActive,
+* XEmacLite_mSetTxActive changed to XEmacLite_SetTxActive.
+*
+* </pre>
+******************************************************************************/
+
+#ifndef XEMACLITE_I_H /* prevent circular inclusions */
+#define XEMACLITE_I_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***************************** Include Files *********************************/
+
+#include "xemaclite.h"
+
+/************************** Constant Definitions ****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/****************************************************************************/
+/**
+*
+* Get the TX active location to check status. This is used to check if
+* the TX buffer is currently active. There isn't any way in the hardware
+* to implement this but the register is fully populated so the driver can
+* set the bit in the send routine and the ISR can clear the bit when
+* the handler is complete. This mimics the correct operation of the hardware
+* if it was possible to do this in hardware.
+*
+* @param BaseAddress is the base address of the device
+*
+* @return Contents of active bit in register.
+*
+* @note C-Style signature:
+* u32 XEmacLite_GetTxActive(u32 BaseAddress)
+*
+*****************************************************************************/
+#define XEmacLite_GetTxActive(BaseAddress) \
+ (XEmacLite_ReadReg((BaseAddress), XEL_TSR_OFFSET))
+
+/****************************************************************************/
+/**
+*
+* Set the TX active location to update status. This is used to set the bit
+* indicating which TX buffer is currently active. There isn't any way in the
+* hardware to implement this but the register is fully populated so the driver
+* can set the bit in the send routine and the ISR can clear the bit when
+* the handler is complete. This mimics the correct operation of the hardware
+* if it was possible to do this in hardware.
+*
+* @param BaseAddress is the base address of the device
+* @param Mask is the data to be written
+*
+* @return None
+*
+* @note C-Style signature:
+* void XEmacLite_SetTxActive(u32 BaseAddress, u32 Mask)
+*
+*****************************************************************************/
+#define XEmacLite_SetTxActive(BaseAddress, Mask) \
+ (XEmacLite_WriteReg((BaseAddress), XEL_TSR_OFFSET, (Mask)))
+
+/************************** Variable Definitions ****************************/
+
+extern XEmacLite_Config XEmacLite_ConfigTable[];
+
+/************************** Function Prototypes ******************************/
+
+void XEmacLite_AlignedWrite(void *SrcPtr, u32 *DestPtr, unsigned ByteCount);
+void XEmacLite_AlignedRead(u32 *SrcPtr, void *DestPtr, unsigned ByteCount);
+
+void StubHandler(void *CallBackRef);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_intr.c b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_intr.c
new file mode 100644
index 000000000..5f979e7e8
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_intr.c
@@ -0,0 +1,359 @@
+/******************************************************************************
+*
+* Copyright (C) 2004 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xemaclite_intr.c
+*
+* Functions in this file are for the interrupt driven processing functionality.
+* See xemaclite.h for a detailed description of the driver.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- --------------------------------------------------------
+* 1.01a ecm 03/31/04 First release
+* 1.11a mta 03/21/07 Updated to new coding style
+* 2.01a ktn 07/20/09 Modified the XEmacLite_EnableInterrupts and
+* XEmacLite_DisableInterrupts functions to enable/disable
+* the interrupt in the Ping buffer as this is used to enable
+* the interrupts for both Ping and Pong Buffers.
+* The interrupt enable bit in the Pong buffer is not used by
+* the HW.
+* 3.00a ktn 10/22/09 Updated file to use the HAL Processor APIs/macros.
+* The macros have been renamed to remove _m from the name.
+*
+* </pre>
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xemaclite_i.h"
+#include "xil_io.h"
+#include "xemaclite.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Definitions *****************************/
+/*****************************************************************************/
+/**
+*
+* Enable the EmacLite Interrupts.
+*
+* This function must be called before other functions to send or receive data
+* in interrupt driven mode. The user should have connected the
+* interrupt handler of the driver to an interrupt source such as an interrupt
+* controller or the processor interrupt prior to this function being called.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance.
+*
+* @return
+* - XST_SUCCESS if the device interrupts were enabled
+* successfully.
+* - XST_NO_CALLBACK if the callbacks were not set.
+*
+* @note None.
+*
+******************************************************************************/
+int XEmacLite_EnableInterrupts(XEmacLite *InstancePtr)
+{
+ u32 Register;
+ u32 BaseAddress;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+ Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+ BaseAddress = InstancePtr->EmacLiteConfig.BaseAddress;
+
+ /*
+ * Verify that the handlers are in place.
+ */
+ if ((InstancePtr->RecvHandler == (XEmacLite_Handler) StubHandler) ||
+ (InstancePtr->SendHandler == (XEmacLite_Handler) StubHandler)) {
+ return XST_NO_CALLBACK;
+ }
+
+ /*
+ * Enable the TX interrupts for both the buffers, the Interrupt Enable
+ * is common for the both the buffers and is defined in the
+ * Ping buffer.
+ */
+ Register = XEmacLite_GetTxStatus(BaseAddress);
+ Register |= XEL_TSR_XMIT_IE_MASK;
+ XEmacLite_SetTxStatus(BaseAddress, Register);
+
+ /*
+ * Enable the RX interrupts for both the buffers, the Interrupt Enable
+ * is common for the both the buffers and is defined in the
+ * Ping buffer.
+ */
+ Register = XEmacLite_GetRxStatus(BaseAddress);
+ Register |= XEL_RSR_RECV_IE_MASK;
+ XEmacLite_SetRxStatus(BaseAddress, Register);
+
+ /*
+ * Enable the global interrupt output.
+ */
+ XEmacLite_WriteReg(BaseAddress, XEL_GIER_OFFSET, XEL_GIER_GIE_MASK);
+
+ return XST_SUCCESS;
+}
+
+/*****************************************************************************/
+/**
+*
+* Disables the interrupts from the device (the higher layer software is
+* responsible for disabling interrupts at the interrupt controller).
+*
+* To start using the device again, _EnableInterrupts must be called.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance .
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void XEmacLite_DisableInterrupts(XEmacLite *InstancePtr)
+{
+ u32 Register;
+ u32 BaseAddress;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+
+ BaseAddress = InstancePtr->EmacLiteConfig.BaseAddress;
+
+ /*
+ * Disable the global interrupt output.
+ */
+ XEmacLite_WriteReg(BaseAddress, XEL_GIER_OFFSET, 0);
+
+ /*
+ * Disable the TX interrupts for both the buffers, the Interrupt Enable
+ * is common for the both the buffers and is defined in the
+ * Ping buffer.
+ */
+ Register = XEmacLite_GetTxStatus(BaseAddress);
+ Register &= ~XEL_TSR_XMIT_IE_MASK;
+ XEmacLite_SetTxStatus(BaseAddress, Register);
+
+ /*
+ * Disable the RX interrupts for both the buffers, the Interrupt Enable
+ * is common for the both the buffers and is defined in the
+ * Ping buffer.
+ */
+ Register = XEmacLite_GetRxStatus(BaseAddress);
+ Register &= ~XEL_RSR_RECV_IE_MASK;
+ XEmacLite_SetRxStatus(BaseAddress, Register);
+
+}
+
+/*****************************************************************************/
+/**
+*
+* Interrupt handler for the EmacLite driver. It performs the following
+* processing:
+*
+* - Get the interrupt status from the registers to determine the source
+* of the interrupt.
+* - Call the appropriate handler based on the source of the interrupt.
+*
+* @param InstancePtr contains a pointer to the EmacLite device instance
+* for the interrupt.
+*
+* @return None.
+*
+* @note None.
+*
+*
+******************************************************************************/
+void XEmacLite_InterruptHandler(void *InstancePtr)
+{
+
+ XEmacLite *EmacLitePtr;
+ int TxCompleteIntr = FALSE;
+ u32 BaseAddress;
+ u32 TxStatus;
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+
+ /*
+ * Convert the non-typed pointer to an EmacLite instance pointer
+ * such that there is access to the device.
+ */
+ EmacLitePtr = (XEmacLite *) InstancePtr;
+ BaseAddress = EmacLitePtr->EmacLiteConfig.BaseAddress;
+
+ if ((XEmacLite_IsRxEmpty(BaseAddress) != TRUE) ||
+ (XEmacLite_IsRxEmpty(BaseAddress +
+ XEL_BUFFER_OFFSET) != TRUE)) {
+ /*
+ * Call the RX callback.
+ */
+ EmacLitePtr->RecvHandler(EmacLitePtr->RecvRef);
+
+ }
+
+ TxStatus = XEmacLite_GetTxStatus(BaseAddress);
+ if (((TxStatus & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
+ (TxStatus & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
+
+ /*
+ * Clear the Tx Active bit in the Tx Status Register.
+ */
+ TxStatus &= ~XEL_TSR_XMIT_ACTIVE_MASK;
+ XEmacLite_SetTxStatus(BaseAddress, TxStatus);
+
+ /*
+ * Update the flag indicating that there was a Tx Interrupt.
+ */
+ TxCompleteIntr = TRUE;
+
+ }
+
+ TxStatus = XEmacLite_GetTxStatus(BaseAddress + XEL_BUFFER_OFFSET);
+ if (((TxStatus & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
+ (TxStatus & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
+
+ /*
+ * Clear the Tx Active bit in the Tx Status Register.
+ */
+ TxStatus &= ~XEL_TSR_XMIT_ACTIVE_MASK;
+ XEmacLite_SetTxStatus(BaseAddress + XEL_BUFFER_OFFSET,
+ TxStatus);
+ /*
+ * Update the flag indicating that there was a Tx Interrupt.
+ */
+ TxCompleteIntr = TRUE;
+ }
+
+ /*
+ * If there was a TX interrupt, call the callback.
+ */
+ if (TxCompleteIntr == TRUE) {
+
+ /*
+ * Call the TX callback.
+ */
+ EmacLitePtr->SendHandler(EmacLitePtr->SendRef);
+
+ }
+}
+
+/*****************************************************************************/
+/**
+*
+* Sets the callback function for handling received frames in interrupt mode.
+* The upper layer software should call this function during initialization.
+* The callback is called when a frame is received. The callback function
+* should communicate the data to a thread such that the processing is not
+* performed in an interrupt context.
+*
+* The callback is invoked by the driver within interrupt context, so it needs
+* to do its job quickly. If there are other potentially slow operations
+* within the callback, these should be done at task-level.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance..
+* @param CallBackRef is a reference pointer to be passed back to the
+* application in the callback. This helps the application
+* correlate the callback to a particular driver.
+* @param FuncPtr is the pointer to the callback function.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void XEmacLite_SetRecvHandler(XEmacLite *InstancePtr, void *CallBackRef,
+ XEmacLite_Handler FuncPtr)
+{
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(FuncPtr != NULL);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+ InstancePtr->RecvHandler = FuncPtr;
+ InstancePtr->RecvRef = CallBackRef;
+}
+
+
+/*****************************************************************************/
+/**
+*
+* Sets the callback function for handling transmitted frames in interrupt mode.
+* The upper layer software should call this function during initialization.
+* The callback is called when a frame is transmitted. The callback function
+* should communicate the data to a thread such that the processing is not
+* performed in an interrupt context.
+*
+* The callback is invoked by the driver within interrupt context, so it needs
+* to do its job quickly. If there are other potentially slow operations
+* within the callback, these should be done at task-level.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance.
+* @param CallBackRef is a reference pointer to be passed back to the
+* application in the callback. This helps the application
+* correlate the callback to a particular driver.
+* @param FuncPtr is the pointer to the callback function.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void XEmacLite_SetSendHandler(XEmacLite *InstancePtr, void *CallBackRef,
+ XEmacLite_Handler FuncPtr)
+{
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(FuncPtr != NULL);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+ InstancePtr->SendHandler = FuncPtr;
+ InstancePtr->SendRef = CallBackRef;
+}
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.c b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.c
new file mode 100644
index 000000000..689c39675
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.c
@@ -0,0 +1,503 @@
+/******************************************************************************
+*
+* Copyright (C) 2004 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xemaclite_l.c
+*
+* This file contains the minimal, polled functions to send and receive Ethernet
+* frames.
+*
+* Refer to xemaclite.h for more details.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.00a ecm 06/01/02 First release
+* 1.01a ecm 03/31/04 Additional functionality and the _AlignedRead and
+* _AlignedWrite functions.
+* 1.11a mta 03/21/07 Updated to new coding style
+* 2.01a ktn 07/20/09 Updated the XEmacLite_AlignedWrite and
+* XEmacLite_AlignedRead functions to use volatile
+* variables so that they are not optimized.
+* 3.00a ktn 10/22/09 The macros have been renamed to remove _m from the name.
+*
+* </pre>
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xemaclite_l.h"
+#include "xemaclite_i.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+void XEmacLite_AlignedWrite(void *SrcPtr, u32 *DestPtr, unsigned ByteCount);
+void XEmacLite_AlignedRead(u32 *SrcPtr, void *DestPtr, unsigned ByteCount);
+
+/************************** Variable Definitions *****************************/
+
+/*****************************************************************************/
+/**
+*
+* Send an Ethernet frame. The size is the total frame size, including header.
+* This function blocks waiting for the frame to be transmitted.
+*
+* @param BaseAddress is the base address of the device
+* @param FramePtr is a pointer to frame
+* @param ByteCount is the size, in bytes, of the frame
+*
+* @return None.
+*
+* @note
+*
+* This function call is blocking in nature, i.e. it will wait until the
+* frame is transmitted. This function can hang and not exit if the
+* hardware is not configured properly.
+*
+* If the ping buffer is the destination of the data, the argument should be
+* DeviceAddress + XEL_TXBUFF_OFFSET.
+* If the pong buffer is the destination of the data, the argument should be
+* DeviceAddress + XEL_TXBUFF_OFFSET + XEL_BUFFER_OFFSET.
+* The function does not take the different buffers into consideration.
+*
+******************************************************************************/
+void XEmacLite_SendFrame(u32 BaseAddress, u8 *FramePtr, unsigned ByteCount)
+{
+ u32 Register;
+
+ /*
+ * Write data to the EmacLite
+ */
+ XEmacLite_AlignedWrite(FramePtr, (u32 *) (BaseAddress), ByteCount);
+
+ /*
+ * The frame is in the buffer, now send it
+ */
+ XEmacLite_WriteReg(BaseAddress, XEL_TPLR_OFFSET,
+ (ByteCount & (XEL_TPLR_LENGTH_MASK_HI |
+ XEL_TPLR_LENGTH_MASK_LO)));
+
+
+ Register = XEmacLite_GetTxStatus(BaseAddress);
+ XEmacLite_SetTxStatus(BaseAddress, Register | XEL_TSR_XMIT_BUSY_MASK);
+
+ /*
+ * Loop on the status waiting for the transmit to be complete.
+ */
+ while (!XEmacLite_IsTxDone(BaseAddress));
+
+}
+
+
+/*****************************************************************************/
+/**
+*
+* Receive a frame. Wait for a frame to arrive.
+*
+* @param BaseAddress is the base address of the device
+* @param FramePtr is a pointer to a buffer where the frame will
+* be stored.
+*
+* @return
+*
+* The type/length field of the frame received. When the type/length field
+* contains the type , XEL_MAX_FRAME_SIZE bytes will be copied out of the
+* buffer and it is up to the higher layers to sort out the frame.
+*
+* @note
+*
+* This function call is blocking in nature, i.e. it will wait until a
+* frame arrives.
+*
+* If the ping buffer is the source of the data, the argument should be
+* DeviceAddress + XEL_RXBUFF_OFFSET.
+* If the pong buffer is the source of the data, the argument should be
+* DeviceAddress + XEL_RXBUFF_OFFSET + XEL_BUFFER_OFFSET.
+* The function does not take the different buffers into consideration.
+*
+******************************************************************************/
+u16 XEmacLite_RecvFrame(u32 BaseAddress, u8 *FramePtr)
+{
+ u16 LengthType;
+ u16 Length;
+ u32 Register;
+
+ /*
+ * Wait for a frame to arrive - this is a blocking call
+ */
+ while (XEmacLite_IsRxEmpty(BaseAddress));
+
+ /*
+ * Get the length of the frame that arrived, only 32-bit reads are
+ * allowed LengthType is in the upper half of the 32-bit word.
+ */
+ Register = XEmacLite_ReadReg(BaseAddress, XEL_RPLR_OFFSET);
+ LengthType = (u16) ((Register >> 16) &
+ (XEL_RPLR_LENGTH_MASK_HI |
+ XEL_RPLR_LENGTH_MASK_LO));
+
+ /*
+ * Check if length is valid
+ */
+ if (LengthType > XEL_MAX_FRAME_SIZE) {
+ /*
+ * Field contain type, use max frame size and
+ * let user parse it
+ */
+ Length = XEL_MAX_FRAME_SIZE;
+ }
+ else {
+ /*
+ * Use the length in the frame, plus the header and trailer
+ */
+ Length = LengthType + XEL_HEADER_SIZE + XEL_FCS_SIZE;
+ }
+
+ /*
+ * Read each byte from the EmacLite
+ */
+ XEmacLite_AlignedRead((u32 *) (BaseAddress + XEL_RXBUFF_OFFSET),
+ FramePtr, Length);
+
+ /*
+ * Acknowledge the frame
+ */
+ Register = XEmacLite_GetRxStatus(BaseAddress);
+ Register &= ~XEL_RSR_RECV_DONE_MASK;
+ XEmacLite_SetRxStatus(BaseAddress, Register);
+
+ return LengthType;
+}
+
+/******************************************************************************/
+/**
+*
+* This function aligns the incoming data and writes it out to a 32-bit
+* aligned destination address range.
+*
+* @param SrcPtr is a pointer to incoming data of any alignment.
+* @param DestPtr is a pointer to outgoing data of 32-bit alignment.
+* @param ByteCount is the number of bytes to write.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void XEmacLite_AlignedWrite(void *SrcPtr, u32 *DestPtr, unsigned ByteCount)
+{
+ unsigned Index;
+ unsigned Length = ByteCount;
+ volatile u32 AlignBuffer;
+ volatile u32 *To32Ptr;
+ u32 *From32Ptr;
+ volatile u16 *To16Ptr;
+ u16 *From16Ptr;
+ volatile u8 *To8Ptr;
+ u8 *From8Ptr;
+
+ To32Ptr = DestPtr;
+
+ if ((((u32) SrcPtr) & 0x00000003) == 0) {
+
+ /*
+ * Word aligned buffer, no correction needed.
+ */
+ From32Ptr = (u32 *) SrcPtr;
+
+ while (Length > 3) {
+ /*
+ * Output each word destination.
+ */
+ *To32Ptr++ = *From32Ptr++;
+
+ /*
+ * Adjust length accordingly
+ */
+ Length -= 4;
+ }
+
+ /*
+ * Set up to output the remaining data, zero the temp buffer
+ first.
+ */
+ AlignBuffer = 0;
+ To8Ptr = (u8 *) &AlignBuffer;
+ From8Ptr = (u8 *) From32Ptr;
+
+ }
+ else if ((((u32) SrcPtr) & 0x00000001) != 0) {
+ /*
+ * Byte aligned buffer, correct.
+ */
+ AlignBuffer = 0;
+ To8Ptr = (u8 *) &AlignBuffer;
+ From8Ptr = (u8 *) SrcPtr;
+
+ while (Length > 3) {
+ /*
+ * Copy each byte into the temporary buffer.
+ */
+ for (Index = 0; Index < 4; Index++) {
+ *To8Ptr++ = *From8Ptr++;
+ }
+
+ /*
+ * Output the buffer
+ */
+ *To32Ptr++ = AlignBuffer;
+
+ /*.
+ * Reset the temporary buffer pointer and adjust length.
+ */
+ To8Ptr = (u8 *) &AlignBuffer;
+ Length -= 4;
+ }
+
+ /*
+ * Set up to output the remaining data, zero the temp buffer
+ * first.
+ */
+ AlignBuffer = 0;
+ To8Ptr = (u8 *) &AlignBuffer;
+
+ }
+ else {
+ /*
+ * Half-Word aligned buffer, correct.
+ */
+ AlignBuffer = 0;
+
+ /*
+ * This is a funny looking cast. The new gcc, version 3.3.x has
+ * a strict cast check for 16 bit pointers, aka short pointers.
+ * The following warning is issued if the initial 'void *' cast
+ * is not used:
+ * 'dereferencing type-punned pointer will break strict-aliasing
+ * rules'
+ */
+
+ To16Ptr = (u16 *) ((void *) &AlignBuffer);
+ From16Ptr = (u16 *) SrcPtr;
+
+ while (Length > 3) {
+ /*
+ * Copy each half word into the temporary buffer.
+ */
+ for (Index = 0; Index < 2; Index++) {
+ *To16Ptr++ = *From16Ptr++;
+ }
+
+ /*
+ * Output the buffer.
+ */
+ *To32Ptr++ = AlignBuffer;
+
+ /*
+ * Reset the temporary buffer pointer and adjust length.
+ */
+
+ /*
+ * This is a funny looking cast. The new gcc, version
+ * 3.3.x has a strict cast check for 16 bit pointers,
+ * aka short pointers. The following warning is issued
+ * if the initial 'void *' cast is not used:
+ * 'dereferencing type-punned pointer will break
+ * strict-aliasing rules'
+ */
+ To16Ptr = (u16 *) ((void *) &AlignBuffer);
+ Length -= 4;
+ }
+
+ /*
+ * Set up to output the remaining data, zero the temp buffer
+ * first.
+ */
+ AlignBuffer = 0;
+ To8Ptr = (u8 *) &AlignBuffer;
+ From8Ptr = (u8 *) From16Ptr;
+ }
+
+ /*
+ * Output the remaining data, zero the temp buffer first.
+ */
+ for (Index = 0; Index < Length; Index++) {
+ *To8Ptr++ = *From8Ptr++;
+ }
+
+ *To32Ptr++ = AlignBuffer;
+
+}
+
+/******************************************************************************/
+/**
+*
+* This function reads from a 32-bit aligned source address range and aligns
+* the writes to the provided destination pointer alignment.
+*
+* @param SrcPtr is a pointer to incoming data of 32-bit alignment.
+* @param DestPtr is a pointer to outgoing data of any alignment.
+* @param ByteCount is the number of bytes to read.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void XEmacLite_AlignedRead(u32 *SrcPtr, void *DestPtr, unsigned ByteCount)
+{
+ unsigned Index;
+ unsigned Length = ByteCount;
+ volatile u32 AlignBuffer;
+ u32 *To32Ptr;
+ volatile u32 *From32Ptr;
+ u16 *To16Ptr;
+ volatile u16 *From16Ptr;
+ u8 *To8Ptr;
+ volatile u8 *From8Ptr;
+
+ From32Ptr = (u32 *) SrcPtr;
+
+ if ((((u32) DestPtr) & 0x00000003) == 0) {
+
+ /*
+ * Word aligned buffer, no correction needed.
+ */
+ To32Ptr = (u32 *) DestPtr;
+
+ while (Length > 3) {
+ /*
+ * Output each word.
+ */
+ *To32Ptr++ = *From32Ptr++;
+
+ /*
+ * Adjust length accordingly.
+ */
+ Length -= 4;
+ }
+
+ /*
+ * Set up to read the remaining data.
+ */
+ To8Ptr = (u8 *) To32Ptr;
+
+ }
+ else if ((((u32) DestPtr) & 0x00000001) != 0) {
+ /*
+ * Byte aligned buffer, correct.
+ */
+ To8Ptr = (u8 *) DestPtr;
+
+ while (Length > 3) {
+ /*
+ * Copy each word into the temporary buffer.
+ */
+ AlignBuffer = *From32Ptr++;
+ From8Ptr = (u8 *) &AlignBuffer;
+
+ /*
+ * Write data to destination.
+ */
+ for (Index = 0; Index < 4; Index++) {
+ *To8Ptr++ = *From8Ptr++;
+ }
+
+ /*
+ * Adjust length
+ */
+ Length -= 4;
+ }
+
+ }
+ else {
+ /*
+ * Half-Word aligned buffer, correct.
+ */
+ To16Ptr = (u16 *) DestPtr;
+
+ while (Length > 3) {
+ /*
+ * Copy each word into the temporary buffer.
+ */
+ AlignBuffer = *From32Ptr++;
+
+ /*
+ * This is a funny looking cast. The new gcc, version
+ * 3.3.x has a strict cast check for 16 bit pointers,
+ * aka short pointers. The following warning is issued
+ * if the initial 'void *' cast is not used:
+ * 'dereferencing type-punned pointer will break
+ * strict-aliasing rules'
+ */
+ From16Ptr = (u16 *) ((void *) &AlignBuffer);
+
+ /*
+ * Write data to destination.
+ */
+ for (Index = 0; Index < 2; Index++) {
+ *To16Ptr++ = *From16Ptr++;
+ }
+
+ /*
+ * Adjust length.
+ */
+ Length -= 4;
+ }
+
+ /*
+ * Set up to read the remaining data.
+ */
+ To8Ptr = (u8 *) To16Ptr;
+ }
+
+ /*
+ * Read the remaining data.
+ */
+ AlignBuffer = *From32Ptr++;
+ From8Ptr = (u8 *) &AlignBuffer;
+
+ for (Index = 0; Index < Length; Index++) {
+ *To8Ptr++ = *From8Ptr++;
+ }
+}
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.h b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.h
new file mode 100644
index 000000000..a0b812105
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_l.h
@@ -0,0 +1,371 @@
+/******************************************************************************
+*
+* Copyright (C) 2004 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xemaclite_l.h
+*
+* This header file contains identifiers and basic driver functions and macros
+* that can be used to access the Xilinx Ethernet Lite 10/100 MAC (EmacLite).
+*
+* Refer to xemaclite.h for more details.
+*
+* @note
+*
+* The functions and macros in this file assume that the proper device address is
+* provided in the argument. If the ping buffer is the source or destination,
+* the argument should be DeviceAddress + XEL_(T/R)XBUFF_OFFSET. If the pong
+* buffer is the source or destination, the argument should be
+* DeviceAddress + XEL_(T/R)XBUFF_OFFSET + XEL_BUFFER_OFFSET. The driver does
+* not take the different buffers into consideration.
+* For more details on the ping/pong buffer configuration please refer to the
+* Ethernet Lite 10/100 Media Access Controller hardware specification.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.00a ecm 06/01/02 First release
+* 1.01a ecm 03/31/04 Additional functionality and the _AlignedRead and
+* AlignedWrite functions.
+* Moved the bulk of description to xemaclite.h
+* 1.11a mta 03/21/07 Updated to new coding style
+* 2.00a ktn 02/16/09 Added support for MDIO and internal loop back
+* 3.00a ktn 10/22/09 The macros have been renamed to remove _m from the name.
+* The macros changed in this file are
+* XEmacLite_mReadReg changed to XEmacLite_mReadReg,
+* XEmacLite_mWriteReg changed to XEmacLite_mWriteReg,
+* XEmacLite_mGetTxStatus changed to XEmacLite_GetTxStatus,
+* XEmacLite_mSetTxStatus changed to XEmacLite_SetTxStatus,
+* XEmacLite_mGetRxStatus changed to XEmacLite_GetRxStatus,
+* XEmacLite_mSetRxStatus changed to XEmacLite_SetRxStatus,
+* XEmacLite_mIsTxDone changed to XEmacLite_IsTxDone and
+* XEmacLite_mIsRxEmpty changed to XEmacLite_IsRxEmpty.
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XEMAC_LITE_L_H /* prevent circular inclusions */
+#define XEMAC_LITE_L_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xil_io.h"
+
+/************************** Constant Definitions *****************************/
+/**
+ * Register offsets for the Ethernet MAC.
+ */
+#define XEL_TXBUFF_OFFSET (0x00000000) /**< Transmit Buffer */
+#define XEL_MDIOADDR_OFFSET (XEL_TXBUFF_OFFSET + 0x07E4)/**< MDIO Address offset
+ register */
+#define XEL_MDIOWR_OFFSET (XEL_TXBUFF_OFFSET + 0x07E8) /**< MDIO write data
+ register offset */
+#define XEL_MDIORD_OFFSET (XEL_TXBUFF_OFFSET + 0x07EC) /**< MDIO read data
+ register offset*/
+#define XEL_MDIOCNTR_OFFSET (XEL_TXBUFF_OFFSET + 0x07F0)/**< MDIO Control
+ Register offset */
+#define XEL_GIER_OFFSET (XEL_TXBUFF_OFFSET + 0x07F8) /**< Offset for the GIE
+ Register */
+#define XEL_TSR_OFFSET (XEL_TXBUFF_OFFSET + 0x07FC) /**< Tx status */
+#define XEL_TPLR_OFFSET (XEL_TXBUFF_OFFSET + 0x07F4) /**< Tx packet length */
+
+#define XEL_RXBUFF_OFFSET (0x00001000) /**< Receive Buffer */
+#define XEL_RSR_OFFSET (XEL_RXBUFF_OFFSET + 0x07FC) /**< Rx status */
+#define XEL_RPLR_OFFSET (XEL_RXBUFF_OFFSET + 0x0C) /**< Rx packet length */
+
+#define XEL_MAC_HI_OFFSET (XEL_TXBUFF_OFFSET + 0x14) /**< MAC address hi
+ offset */
+#define XEL_MAC_LO_OFFSET (XEL_TXBUFF_OFFSET) /**< MAC address lo
+ offset */
+
+#define XEL_BUFFER_OFFSET (0x00000800) /**< Next buffer's
+ offset same for
+ both TX and RX */
+/**
+ * MDIO Address/Write Data/Read Data Register Bit Masks
+ */
+#define XEL_MDIO_ADDRESS_MASK 0x00003E0 /**< PHY Address mask */
+#define XEL_MDIO_ADDRESS_SHIFT 0x5 /**< PHY Address shift*/
+#define XEL_MDIO_OP_MASK 0x00000400 /**< PHY read access */
+
+/**
+ * MDIO Control Register Bit Masks
+ */
+#define XEL_MDIOCNTR_STATUS_MASK 0x00000001 /**< MDIO transfer in
+ Progress */
+#define XEL_MDIOCNTR_ENABLE_MASK 0x00000008 /**< MDIO Enable */
+
+/**
+ * Global Interrupt Enable Register (GIER) Bit Masks
+ */
+#define XEL_GIER_GIE_MASK 0x80000000 /**< Global Enable */
+
+/**
+ * Transmit Status Register (TSR) Bit Masks
+ */
+#define XEL_TSR_XMIT_BUSY_MASK 0x00000001 /**< Xmit complete */
+#define XEL_TSR_PROGRAM_MASK 0x00000002 /**< Program the MAC
+ address */
+#define XEL_TSR_XMIT_IE_MASK 0x00000008 /**< Xmit interrupt
+ enable bit */
+#define XEL_TSR_LOOPBACK_MASK 0x00000010 /**< Loop back enable
+ bit */
+#define XEL_TSR_XMIT_ACTIVE_MASK 0x80000000 /**< Buffer is active,
+ SW bit only. This
+ is not documented
+ in the HW spec */
+
+/**
+ * define for programming the MAC address into the EmacLite
+ */
+#define XEL_TSR_PROG_MAC_ADDR (XEL_TSR_XMIT_BUSY_MASK | XEL_TSR_PROGRAM_MASK)
+
+/**
+ * Receive Status Register (RSR)
+ */
+#define XEL_RSR_RECV_DONE_MASK 0x00000001 /**< Recv complete */
+#define XEL_RSR_RECV_IE_MASK 0x00000008 /**< Recv interrupt
+ enable bit */
+
+/**
+ * Transmit Packet Length Register (TPLR)
+ */
+#define XEL_TPLR_LENGTH_MASK_HI 0x0000FF00 /**< Transmit packet length
+ upper byte */
+#define XEL_TPLR_LENGTH_MASK_LO 0x000000FF /**< Transmit packet length
+ lower byte */
+
+/**
+ * Receive Packet Length Register (RPLR)
+ */
+#define XEL_RPLR_LENGTH_MASK_HI 0x0000FF00 /**< Receive packet length
+ upper byte */
+#define XEL_RPLR_LENGTH_MASK_LO 0x000000FF /**< Receive packet length
+ lower byte */
+
+#define XEL_HEADER_SIZE 14 /**< Size of header in bytes */
+#define XEL_MTU_SIZE 1500 /**< Max size of data in frame */
+#define XEL_FCS_SIZE 4 /**< Size of CRC */
+
+#define XEL_HEADER_OFFSET 12 /**< Offset to length field */
+#define XEL_HEADER_SHIFT 16 /**< Right shift value to align
+ length */
+
+
+#define XEL_MAX_FRAME_SIZE (XEL_HEADER_SIZE+XEL_MTU_SIZE+ XEL_FCS_SIZE) /**< Max
+ length of Rx frame used if
+ length/type field
+ contains the type (> 1500) */
+
+#define XEL_MAX_TX_FRAME_SIZE (XEL_HEADER_SIZE + XEL_MTU_SIZE) /**< Max
+ length of Tx frame */
+
+
+#define XEL_MAC_ADDR_SIZE 6 /**< length of MAC address */
+
+
+/*
+ * General Ethernet Definitions
+ */
+#define XEL_ETHER_PROTO_TYPE_IP 0x0800 /**< IP Protocol */
+#define XEL_ETHER_PROTO_TYPE_ARP 0x0806 /**< ARP Protocol */
+#define XEL_ETHER_PROTO_TYPE_VLAN 0x8100 /**< VLAN Tagged */
+#define XEL_ARP_PACKET_SIZE 28 /**< Max ARP packet size */
+#define XEL_HEADER_IP_LENGTH_OFFSET 16 /**< IP Length Offset */
+#define XEL_VLAN_TAG_SIZE 4 /**< VLAN Tag Size */
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+#define XEmacLite_In32 Xil_In32
+#define XEmacLite_Out32 Xil_Out32
+
+/****************************************************************************/
+/**
+*
+* Read from the specified EmacLite device register.
+*
+* @param BaseAddress contains the base address of the device.
+* @param RegOffset contains the offset from the 1st register of the
+* device to select the specific register.
+*
+* @return The value read from the register.
+*
+* @note C-Style signature:
+* u32 XEmacLite_ReadReg(u32 BaseAddress, u32 RegOffset);
+*
+******************************************************************************/
+#define XEmacLite_ReadReg(BaseAddress, RegOffset) \
+ XEmacLite_In32((BaseAddress) + (RegOffset))
+
+/***************************************************************************/
+/**
+*
+* Write to the specified EmacLite device register.
+*
+* @param BaseAddress contains the base address of the device.
+* @param RegOffset contains the offset from the 1st register of the
+* device to select the specific register.
+* @param RegisterValue is the value to be written to the register.
+*
+* @return None.
+*
+* @note C-Style signature:
+* void XEmacLite_WriteReg(u32 BaseAddress, u32 RegOffset,
+* u32 RegisterValue);
+******************************************************************************/
+#define XEmacLite_WriteReg(BaseAddress, RegOffset, RegisterValue) \
+ XEmacLite_Out32((BaseAddress) + (RegOffset), (RegisterValue))
+
+
+/****************************************************************************/
+/**
+*
+* Get the Tx Status Register Contents.
+*
+* @param BaseAddress is the base address of the device
+*
+* @return The contents of the Tx Status Register.
+*
+* @note C-Style signature:
+* u32 XEmacLite_GetTxStatus(u32 BaseAddress)
+*
+*****************************************************************************/
+#define XEmacLite_GetTxStatus(BaseAddress) \
+ (XEmacLite_ReadReg((BaseAddress), XEL_TSR_OFFSET))
+
+
+/****************************************************************************/
+/**
+*
+* Set the Tx Status Register Contents.
+*
+* @param BaseAddress is the base address of the device
+* @param Data is the value to be written to the Register.
+*
+* @return None.
+*
+* @note C-Style signature:
+* u32 XEmacLite_SetTxStatus(u32 BaseAddress, u32 Data)
+*
+*****************************************************************************/
+#define XEmacLite_SetTxStatus(BaseAddress, Data) \
+ (XEmacLite_WriteReg((BaseAddress), XEL_TSR_OFFSET, (Data)))
+
+
+/****************************************************************************/
+/**
+*
+* Get the Rx Status Register Contents.
+*
+* @param BaseAddress is the base address of the device
+*
+* @return The contents of the Rx Status Register.
+*
+* @note C-Style signature:
+* u32 XEmacLite_GetRxStatus(u32 BaseAddress)
+*
+*****************************************************************************/
+#define XEmacLite_GetRxStatus(BaseAddress) \
+ (XEmacLite_ReadReg((BaseAddress), XEL_RSR_OFFSET))
+
+
+/****************************************************************************/
+/**
+*
+* Set the Rx Status Register Contents.
+*
+* @param BaseAddress is the base address of the device
+* @param Data is the value to be written to the Register.
+*
+* @return None.
+*
+* @note C-Style signature:
+* u32 XEmacLite_SetRxStatus(u32 BaseAddress, u32 Data)
+*
+*****************************************************************************/
+#define XEmacLite_SetRxStatus(BaseAddress, Data) \
+ (XEmacLite_WriteReg((BaseAddress), XEL_RSR_OFFSET, (Data)))
+
+
+/****************************************************************************/
+/**
+*
+* Check to see if the transmission is complete.
+*
+* @param BaseAddress is the base address of the device
+*
+* @return TRUE if it is done, or FALSE if it is not.
+*
+* @note C-Style signature:
+* int XEmacLite_IsTxDone(u32 BaseAddress)
+*
+*****************************************************************************/
+#define XEmacLite_IsTxDone(BaseAddress) \
+ ((XEmacLite_ReadReg((BaseAddress), XEL_TSR_OFFSET) & \
+ XEL_TSR_XMIT_BUSY_MASK) != XEL_TSR_XMIT_BUSY_MASK)
+
+
+/****************************************************************************/
+/**
+*
+* Check to see if the receive is empty.
+*
+* @param BaseAddress is the base address of the device
+*
+* @return TRUE if it is empty, or FALSE if it is not.
+*
+* @note C-Style signature:
+* int XEmacLite_IsRxEmpty(u32 BaseAddress)
+*
+*****************************************************************************/
+#define XEmacLite_IsRxEmpty(BaseAddress) \
+ ((XEmacLite_ReadReg((BaseAddress), XEL_RSR_OFFSET) & \
+ XEL_RSR_RECV_DONE_MASK) != XEL_RSR_RECV_DONE_MASK)
+
+/************************** Function Prototypes ******************************/
+
+void XEmacLite_SendFrame(u32 BaseAddress, u8 *FramePtr, unsigned ByteCount);
+u16 XEmacLite_RecvFrame(u32 BaseAddress, u8 *FramePtr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_selftest.c b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_selftest.c
new file mode 100644
index 000000000..b8891b814
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_selftest.c
@@ -0,0 +1,208 @@
+/******************************************************************************
+*
+* Copyright (C) 2004 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xemaclite_selftest.c
+*
+* Function(s) in this file are the required functions for the EMAC Lite
+* driver sefftest for the hardware.
+* See xemaclite.h for a detailed description of the driver.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- --------------------------------------------------------
+* 1.01a ecm 01/31/04 First release
+* 1.11a mta 03/21/07 Updated to new coding style
+* 3.00a ktn 10/22/09 Updated driver to use the HAL Processor APIs/macros.
+* </pre>
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xil_io.h"
+#include "xemaclite.h"
+#include "xemaclite_i.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Definitions *****************************/
+
+/*****************************************************************************/
+/**
+*
+* Performs a SelfTest on the EmacLite device as follows:
+* - Writes to the mandatory TX buffer and reads back to verify.
+* - If configured, writes to the secondary TX buffer and reads back to verify.
+* - Writes to the mandatory RX buffer and reads back to verify.
+* - If configured, writes to the secondary RX buffer and reads back to verify.
+*
+*
+* @param InstancePtr is a pointer to the XEmacLite instance .
+*
+* @return
+* - XST_SUCCESS if the device Passed the Self Test.
+* - XST_FAILURE if any of the data read backs fail.
+*
+* @note None.
+*
+******************************************************************************/
+int XEmacLite_SelfTest(XEmacLite * InstancePtr)
+{
+ u32 BaseAddress;
+ u8 Index;
+ u8 TestString[4] = { 0xDE, 0xAD, 0xBE, 0xEF };
+ u8 ReturnString[4] = { 0x0, 0x0, 0x0, 0x0 };
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+
+ /*
+ * Determine the TX buffer address
+ */
+ BaseAddress = InstancePtr->EmacLiteConfig.BaseAddress +
+ XEL_TXBUFF_OFFSET;
+
+ /*
+ * Write the TestString to the TX buffer in EMAC Lite then
+ * back from the EMAC Lite and verify
+ */
+ XEmacLite_AlignedWrite(TestString, (u32 *) BaseAddress,
+ sizeof(TestString));
+ XEmacLite_AlignedRead((u32 *) BaseAddress, ReturnString,
+ sizeof(ReturnString));
+
+ for (Index = 0; Index < 4; Index++) {
+
+ if (ReturnString[Index] != TestString[Index]) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Zero the return string for the next test
+ */
+ ReturnString[Index] = 0;
+ }
+
+ /*
+ * If the second buffer is configured, test it also
+ */
+ if (InstancePtr->EmacLiteConfig.TxPingPong != 0) {
+ BaseAddress += XEL_BUFFER_OFFSET;
+ /*
+ * Write the TestString to the optional TX buffer in EMAC Lite
+ * then back from the EMAC Lite and verify
+ */
+ XEmacLite_AlignedWrite(TestString, (u32 *) BaseAddress,
+ sizeof(TestString));
+ XEmacLite_AlignedRead((u32 *) BaseAddress, ReturnString,
+ sizeof(ReturnString));
+
+ for (Index = 0; Index < 4; Index++) {
+
+ if (ReturnString[Index] != TestString[Index]) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Zero the return string for the next test
+ */
+ ReturnString[Index] = 0;
+ }
+ }
+
+ /*
+ * Determine the RX buffer address
+ */
+ BaseAddress = InstancePtr->EmacLiteConfig.BaseAddress +
+ XEL_RXBUFF_OFFSET;
+
+ /*
+ * Write the TestString to the RX buffer in EMAC Lite then
+ * back from the EMAC Lite and verify
+ */
+ XEmacLite_AlignedWrite(TestString, (u32 *) (BaseAddress),
+ sizeof(TestString));
+ XEmacLite_AlignedRead((u32 *) (BaseAddress), ReturnString,
+ sizeof(ReturnString));
+
+ for (Index = 0; Index < 4; Index++) {
+
+ if (ReturnString[Index] != TestString[Index]) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Zero the return string for the next test
+ */
+ ReturnString[Index] = 0;
+ }
+
+ /*
+ * If the second buffer is configured, test it also
+ */
+ if (InstancePtr->EmacLiteConfig.RxPingPong != 0) {
+ BaseAddress += XEL_BUFFER_OFFSET;
+ /*
+ * Write the TestString to the optional RX buffer in EMAC Lite
+ * then back from the EMAC Lite and verify
+ */
+ XEmacLite_AlignedWrite(TestString, (u32 *) BaseAddress,
+ sizeof(TestString));
+ XEmacLite_AlignedRead((u32 *) BaseAddress, ReturnString,
+ sizeof(ReturnString));
+
+ for (Index = 0; Index < 4; Index++) {
+
+ if (ReturnString[Index] != TestString[Index]) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Zero the return string for the next test
+ */
+ ReturnString[Index] = 0;
+ }
+ }
+
+ return XST_SUCCESS;
+}
diff --git a/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_sinit.c b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_sinit.c
new file mode 100644
index 000000000..4c3df772e
--- /dev/null
+++ b/FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/emaclite_v4_0/src/xemaclite_sinit.c
@@ -0,0 +1,153 @@
+/******************************************************************************
+*
+* Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xemaclite_sinit.c
+*
+* This file contains the implementation of the XEmacLite driver's static
+* initialization functionality.
+*
+* @note None.
+*
+* <pre>
+*
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.12a sv 11/28/07 First release
+*
+* </pre>
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xparameters.h"
+#include "xemaclite.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Definitions *****************************/
+extern XEmacLite_Config XEmacLite_ConfigTable[];
+
+/*****************************************************************************/
+/**
+*
+* Lookup the device configuration based on the unique device ID. The table
+* XEmacLite_ConfigTable contains the configuration info for each device in the
+* system.
+*
+* @param DeviceId is the unique device ID of the device being looked up.
+*
+* @return A pointer to the configuration table entry corresponding to the
+* given device ID, or NULL if no match is found.
+*
+* @note None.
+*
+******************************************************************************/
+XEmacLite_Config *XEmacLite_LookupConfig(u16 DeviceId)
+{
+ XEmacLite_Config *CfgPtr = NULL;
+ u32 Index;
+
+ for (Index = 0; Index < XPAR_XEMACLITE_NUM_INSTANCES; Index++) {
+ if (XEmacLite_ConfigTable[Index].DeviceId == DeviceId) {
+ CfgPtr = &XEmacLite_ConfigTable[Index];
+ break;
+ }
+ }
+
+ return CfgPtr;
+}
+
+
+/*****************************************************************************/
+/**
+*
+* Initialize a specific XEmacLite instance/driver. The initialization entails:
+* - Initialize fields of the XEmacLite instance structure.
+*
+* The driver defaults to polled mode operation.
+*
+* @param InstancePtr is a pointer to the XEmacLite instance.
+* @param DeviceId is the unique id of the device controlled by this
+* XEmacLite instance. Passing in a device id associates the
+* generic XEmacLite instance to a specific device, as chosen by
+* the caller or application developer.
+*
+* @return
+* - XST_SUCCESS if initialization was successful.
+* - XST_DEVICE_NOT_FOUND/XST_FAILURE if device configuration
+* information was not found for a device with the supplied
+* device ID.
+*
+* @note None
+*
+******************************************************************************/
+int XEmacLite_Initialize(XEmacLite *InstancePtr, u16 DeviceId)
+{
+ int Status;
+ XEmacLite_Config *EmacLiteConfigPtr;/* Pointer to Configuration data. */
+
+ /*
+ * Verify that each of the inputs are valid.
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+
+ /*
+ * Lookup the device configuration in the configuration table. Use this
+ * configuration info down below when initializing this driver.
+ */
+ EmacLiteConfigPtr = XEmacLite_LookupConfig(DeviceId);
+ if (EmacLiteConfigPtr == NULL) {
+ return XST_DEVICE_NOT_FOUND;
+ }
+
+ Status = XEmacLite_CfgInitialize(InstancePtr,
+ EmacLiteConfigPtr,
+ EmacLiteConfigPtr->BaseAddress);
+ if (Status != XST_SUCCESS) {
+ return XST_FAILURE;
+ }
+
+ return XST_SUCCESS;
+}
+
+