📄 utils.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-2007, 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: utils.c
//
// Generic "utility" routines for the bootloader.
//
//-----------------------------------------------------------------------------
#include <windows.h>
#include "bsp.h"
#include "loader.h"
//-----------------------------------------------------------------------------
// External Variables
extern EBOOT_BINDIO_CONTEXT g_BinDIO;
//-----------------------------------------------------------------------------
//
// Function: SpinForever
//
// Halts the bootloader.
//
// Parameters:
// None.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void SpinForever(void)
{
KITLOutputDebugString("SpinForever...\r\n");
while (1)
{
;
}
}
//-----------------------------------------------------------------------------
//
// Function: OEMReadData
//
// This function reads data from the transport during the download process.
// It is called by the BLCOMMON framework.
//
// Parameters:
// cbData
// [in] Amount of data, in bytes, to read.
//
// pbData
// [out] Pointer to read buffer.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
BOOL OEMReadData(DWORD cbData, LPBYTE pbData)
{
// TODO: increment bytes read to track download progress.
// Save read data size and location. It is used in workaround
// for download BIN DIO images larger than RAM.
g_BinDIO.readSize = cbData;
g_BinDIO.pReadBuffer = pbData;
return(EbootEtherReadData(cbData, pbData));
}
//-----------------------------------------------------------------------------
//
// Function: OEMShowProgress
//
// This function shows visual information, on an LED, for example,
// to let users know that the download is in progress. It is called as the
// download progresses.
//
// Parameters:
// dwPacketNum
// [in] Equal to the packet number currently downloading. Knowing
// the total number of packets, a download percentage can be computed.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void OEMShowProgress(DWORD dwPacketNum)
{
}
//-----------------------------------------------------------------------------
//
// Function: OEMEthGetSecs
//
// This function returns the number of seconds that have passed since a
// certain fixed time. This function handles time-outs while in polling
// mode. The origin of the count is unimportant as long as the count is
// incremental.
//
// Parameters:
// None.
//
// Returns:
// Count of seconds that have passed since a certain fixed time.
//
//-----------------------------------------------------------------------------
DWORD OEMEthGetSecs(void)
{
DWORD sec, hourmin;
pRTCRegisters_t pRTC = (pRTCRegisters_t) OALPAtoUA(CSP_BASE_REG_PA_RTC);
sec = INREG32(&pRTC->RTCSecCnt);
hourmin = INREG32(&pRTC->RTCHMCnt);
sec += (((((hourmin >> 8) & 0xFF) * 60) + (hourmin & 0xFF)) * 60);
return sec;
}
//-----------------------------------------------------------------------------
//
// Function: OALGetTickCount
//
// This function is called by some KITL libraries to obtain relative time
// since device boot. It is mostly used to implement timeout in network
// protocol.
//
// Parameters:
// None.
//
// Returns:
// Returns the number of 1-millisecond ticks that have elapsed since
// the last system boot or reset.
//
//-----------------------------------------------------------------------------
UINT32 OALGetTickCount()
{
return OEMEthGetSecs () * 1000;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -