📄 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.
//
#include <bsp.h>
#include "loader.h"
#include "pmc_loader.h"
#include <kitl_cfg.h>
// current KITL ethernet driver
OAL_KITL_ETH_DRIVER *gp_kitlEthDriver = NULL;
/*
@func UINT32 | InitEthDevice | Initializes the Ethernet device to be used for download.
@rdesc Index of the initialized Ethernet device. ETH_DEVICE_NONE indicates failure.
@comm
@xref
*/
UINT32 InitEthDevice(OAL_KITL_ARGS *pKITLArgs)
{
// TODO: Update based on eboot\ether.c
PBYTE pBaseIOAddress = NULL;
UINT32 MemoryBase = 0;
UINT32 Result = ETH_DEVICE_NONE;
OAL_KITL_DEVICE *pDevice = NULL;
BOOL bResult;
OALMSG(OAL_FUNC, (TEXT("+InitEthDevice.\r\n")));
// search
pDevice = OALKitlFindDevice(&pKITLArgs->devLoc,g_kitlDevices);
if(pDevice == NULL)
{
gp_kitlEthDriver = NULL;
EdbgOutputDebugString ( "InitEthDevice: OALKitlFindDevice failed\r\n");
return Result;
}
else
{
// init the function pointers for the driver
gp_kitlEthDriver = (OAL_KITL_ETH_DRIVER*)pDevice->pDriver;
}
// intialize board-specific settings
bResult = InitEthernetHardware(pKITLArgs);
if(!bResult)
{
OALMSG(OAL_ERROR, (TEXT("ERROR: InitEthernetHardware: Failed to initialize device hardware.\r\n")));
goto CleanUp;
}
pBaseIOAddress = (PBYTE)OALPAtoVA(pKITLArgs->devLoc.LogicalLoc, FALSE);
// Initialize the Ethernet controller
RETAILMSG(1, (L"Initializing Ethernet controller at 0x%x...\r\n", pBaseIOAddress));
if (!gp_kitlEthDriver->pfnInit((PBYTE)pBaseIOAddress, 1, pKITLArgs->mac))
{
OALMSG(OAL_ERROR, (TEXT("ERROR: InitEthDevice: Failed to initialize Ethernet controller.\r\n")));
goto CleanUp;
}
EdbgOutputDebugString ( "InitEthDevice: Base addr = %x, %x\r\n",pBaseIOAddress,pKITLArgs->devLoc.LogicalLoc);
EdbgOutputDebugString("InitEthDevice: MAC address: %x-%x-%x-%x-%x-%x\r\n",
pKITLArgs->mac[0] & 0x00FF, pKITLArgs->mac[0] >> 8,
pKITLArgs->mac[1] & 0x00FF, pKITLArgs->mac[1] >> 8,
pKITLArgs->mac[2] & 0x00FF, pKITLArgs->mac[2] >> 8);
// Make sure MAC address has been programmed.
//
if (!pKITLArgs->mac[0] && !pKITLArgs->mac[1] && !pKITLArgs->mac[2])
{
OALMSG(OAL_ERROR, (TEXT("ERROR: InitEthDevice: Invalid MAC address.\r\n")));
goto CleanUp;
}
Result = ETH_DEVICE_CS8900A;
CleanUp:
OALMSG(OAL_FUNC, (TEXT("-InitEthDevice.\r\n")));
return(Result);
}
//
// Platform-specific hardware intialization (set up memory timings, etc)
// use the LogicalLoc address as the distinguishing factor during setup
//
BOOL InitEthernetHardware(OAL_KITL_ARGS *pKITLArgs)
{
// TODO: Any platform specifics? I don't think so, but I'm not sure
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -