📄 ether.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//-----------------------------------------------------------------------------
//
// File: ether.c
//
// EBOOT ethernet routines
//
//-----------------------------------------------------------------------------
#include <windows.h>
#include "bsp.h"
#include "loader.h"
//-----------------------------------------------------------------------------
// External Functions
//-----------------------------------------------------------------------------
// External Variables
extern BSP_ARGS *g_pBSPArgs;
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Global Variables
// Function pointers to the support library functions of the currently installed debug ethernet controller.
//
PFN_EDBG_INIT pfnEDbgInit;
PFN_EDBG_GET_FRAME pfnEDbgGetFrame;
PFN_EDBG_SEND_FRAME pfnEDbgSendFrame;
PFN_EDBG_ENABLE_INTS pfnEDbgEnableInts;
PFN_EDBG_DISABLE_INTS pfnEDbgDisableInts;
PFN_EDBG_GET_PENDING_INTS pfnEDbgGetPendingInts;
PFN_EDBG_READ_EEPROM pfnEDbgReadEEPROM;
PFN_EDBG_WRITE_EEPROM pfnEDbgWriteEEPROM;
PFN_EDBG_SET_OPTIONS pfnEDbgSetOptions;
//-----------------------------------------------------------------------------
// Local Variables
//-----------------------------------------------------------------------------
//
// Function: InitSpecifiedEthDevice
//
// Initializes the specified Ethernet device to be used for download and
// KITL services.
//
// Parameters:
// pKITLArgs
// [in/out] Points to the KITL argument structure.
//
// EthDevice
// [in] Ethernet device to be initialized.
//
// Returns:
// Returns Ethernet adapter type intialized on success, otherwise
// returns -1.
//
//-----------------------------------------------------------------------------
UINT32 InitSpecifiedEthDevice(OAL_KITL_ARGS *pKITLArgs, UINT32 EthDevice)
{
UINT32 rc = -1;
switch(EthDevice)
{
case ETH_DEVICE_CS8900A:
if (CS8900AInit((PBYTE) OALPAtoUA(BSP_BASE_REG_PA_CS8900A_IOBASE), 0, pKITLArgs->mac))
{
pfnEDbgInit = (PFN_EDBG_INIT) CS8900AInit;
pfnEDbgGetFrame = (PFN_EDBG_GET_FRAME) CS8900AGetFrame;
pfnEDbgSendFrame = (PFN_EDBG_SEND_FRAME) CS8900ASendFrame;
pfnEDbgEnableInts = (PFN_EDBG_ENABLE_INTS) CS8900AEnableInts;
pfnEDbgDisableInts = (PFN_EDBG_DISABLE_INTS)CS8900ADisableInts;
// Save the device location information for later use.
//
pKITLArgs->devLoc.IfcType = Internal;
pKITLArgs->devLoc.BusNumber = 0;
pKITLArgs->devLoc.PhysicalLoc = (PVOID)(BSP_BASE_REG_PA_CS8900A_IOBASE);
pKITLArgs->devLoc.LogicalLoc = (DWORD)pKITLArgs->devLoc.PhysicalLoc;
KITLOutputDebugString("INFO: CS8900A Ethernet controller initialized.\r\n");
rc = EDBG_ADAPTER_OEM;
}
else
{
KITLOutputDebugString("ERROR: Failed to initialize CS8900A Ethernet controller.\n");
}
break;
}
return rc;
}
//-----------------------------------------------------------------------------
//
// Function: OEMEthGetFrame
//
// Reads data from the Ethernet device.
//
// Parameters:
// pData
// [out] Ptr to the receive buffer.
//
// pwLength
// [in] Length of data in the receiving buffer.
//
// Returns:
// FALSE if no frame has been received
//
//-----------------------------------------------------------------------------
BOOL OEMEthGetFrame(PUCHAR pData, PUSHORT pwLength)
{
return(pfnEDbgGetFrame(pData, pwLength));
}
//-----------------------------------------------------------------------------
//
// Function: OEMEthGetFrame
//
// Function checks if a frame has been received, and if so copy it to buffer.
//
// Parameters:
// pData
// [in] Ptr to the send buffer.
//
// pwLength
// [in] Length of data to be sent.
//
// Returns:
// FALSE on failure
//
//-----------------------------------------------------------------------------
BOOL OEMEthSendFrame(PUCHAR pData, DWORD dwLength)
{
BYTE Retries = 0;
while (Retries++ < 4)
{
if (!pfnEDbgSendFrame(pData, dwLength))
return(TRUE);
KITLOutputDebugString("INFO: OEMEthSendFrame: retrying send (%u)\r\n", Retries);
}
return(FALSE);
}
//------------------------------------------------------------------------------
//
// Function: OALKitlInitEthIrq
//
// This function is called by OAL_KITLETH_INIT function to configure
// the IRQ line for the Ethernet controller.
//
// Parameters:
// None.
//
// Returns:
// TRUE if successful, otherwise returns FALSE.
//
//------------------------------------------------------------------------------
BOOL OALKitlInitEthIrq(void)
{
return TRUE;
}
//------------------------------------------------------------------------------
//
// Function: OALKitlClearEthIrq
//
// This function is called by OAL_KITLETH_GET_FRAME function to clear
// the IRQ from the Ethernet controller.
//
// Parameters:
// None.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void OALKitlClearEthIrq(void)
{
}
//------------------------------------------------------------------------------
//
// Function: OALKitlSendEthSelfReset
//
// This function is called by OAL_KITLETH_INIT function to determine if
// the Ethernet self reset should be issued to the controller.
//
// Parameters:
// None.
//
// Returns:
// TRUE if self reset should be issued, otherwise returns FALSE.
//
//------------------------------------------------------------------------------
BOOL OALKitlSendEthSelfReset(void)
{
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -