oemboot.c
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C语言 代码 · 共 213 行
C
213 行
/***************************************************************************
* File: oemboot.c
* Modified By: Naresh Gupta (nkgupta@hotmail.com)
* Organization: Hitachi Semiconductor America Inc.
***************************************************************************/
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1998 Hitachi,Ltd.
--*/
/***************************************************************************
* Synopsis:
* This file would contain the following:
* 1. Flash routines.
**************************************************************************/
#include "windows.h"
#include "platform.h"
#define DEBUG_SERIAL_ON 1
// include debug serial support from hal
#define BOOT_LOADER 1
#include "..\..\kernel\hal\shx\debug.c"
#include "flash.c"
void OutputFormatString(const unsigned char *, ...);
void OutputString(const unsigned char *);
volatile unsigned int *PtrCurMSec; /* current millisecond counter */
unsigned int CurMSec_dummy=0; // dummy curmsec variable
// kernel is not running, but some of the included hal functions
// rely on curmsec for timeouts.
#define REG(base,off) (*(volatile unsigned int*)(base+off))
/*
* Initialize the display HW. Assume we are in an unknown state, power the
* display down, initialize the frame buffer, and power back up. Display
* ALDER bitmap image while kernel is booting.
*/
static void
InitDisplay()
{
/* does nothing */
/* OutputString("+-InitDisplay 20th August 1998\n"); */
}
//***************************************************************************
// PowerOnSelfTest
//
//
//***************************************************************************
unsigned int PowerOnSelfTest(void)
{
OutputString("PowerOnSelfTest\n");
OutputFormatString("Hitachi Bootloader for Microsoft Windows CE %s:%s\n", __DATE__, __TIME__);
PtrCurMSec=&CurMSec_dummy; // setup pointer to curmsec so hal functions will work
InitDisplay();
return 1;
}
#ifdef JUNK
// include parallel port support from hal
typedef volatile DWORD *PVDWORD; /* pointer to a volatile dword */
#define WRITE_REGISTER_UINT32(addr,val) (*(volatile unsigned long *)(addr) = (val))
#define READ_REGISTER_UINT32(addr) (*(volatile unsigned long *)(addr))
// starting flash block and number of blocks to erase
unsigned int iStartBlock=0, iNumBlocks=0;
unsigned int ulStatusCount=0; // status output line counter
unsigned int ulWriteCount=0; // 16K write status counter
//***************************************************************************
// OEMFlashWriteBegin
//
// This function checks to see if the specified address range is contained
// in flash memory. If it is it will do any required initialization required
// to make the flash ready for writing.
//
// For flash systems which can queue erases or erase all unlocked blocks, this
// may be done in this routine. Optionally, this routine can simply return and
// perform block erases in the OEMFlashWriteStatus routine as the flash becomes
// ready.
//
// args ulPhysStart - physical starting address
// ulPhysLen - physical length
//
// returns: 0 - success flash ready to write
// FL_ADDRESS_ERROR - specified address range not in flash
//***************************************************************************
unsigned int OEMFlashWriteBegin(unsigned int ulPhysStart, unsigned int ulPhysLen) {
unsigned int ulPhysEnd;
unsigned int ulFlashStart,ulFlashEnd;
// PMemCtl=(PMEM_ASIC)0xa9000000; // power on the flash
// csr = PMemCtl->dispMr;
// csr = csr & ~FL_CSR_PWR_DOWN;
// PMemCtl->dispMr = csr;
// if image is going to flash area
// it will first be downloaded to RAM
return FL_ADDRESS_ERROR; // toriaezu subete DRAM dekaersu. FLASH niha kakanai
ulPhysEnd=ulPhysStart+ulPhysLen;
ulPhysEnd|=0x20000000;
ulPhysStart|=0x20000000;
ulPhysEnd&=0x0fffffff;
ulPhysStart&=0x0fffffff;
ulFlashStart=FLASH_START&0x0fffffff;
ulFlashEnd=FLASH_END&0x0fffffff;
OutputFormatString("\tulPhysStart=[%x],ulPhysEnd=[%x],ulFlashStart=[%x],ulFlashEnd=[%x],ulPhysLen=[%x]\r\n",ulPhysStart,ulPhysEnd,ulFlashStart,ulFlashEnd,ulPhysLen);
if (ulPhysStart >= ulFlashStart && ulPhysEnd < ulFlashEnd) {
// compute starting block number and number of blocks
iStartBlock = ((ulPhysStart|0x20000000) - (FLASH_START|0x20000000)) / FLASH_BLOCK_SIZE;
iNumBlocks = ulPhysLen / FLASH_BLOCK_SIZE;
if (ulPhysLen % FLASH_BLOCK_SIZE)
iNumBlocks++;
} else {
return FL_ADDRESS_ERROR;
}
OutputFormatString("Erasing %d blocks starting at block %d\r\n",iNumBlocks,iStartBlock);
return 0;
}
//***************************************************************************
// OEMFlashWriteEnd
//
//
//***************************************************************************
unsigned int OEMFlashWriteEnd(void)
{
return 0;
}
//***************************************************************************
// OEMFlashWriteStatus
//
//
//
// returns - 0 flash address not ready for write
// 1 flash address ready for write
//***************************************************************************
unsigned int OEMFlashWriteStatus(unsigned int ulAddress)
{
unsigned int isr;
isr=PMemCtl->dispIsr;
if (isr & FL_ISR_BUSY_STATE) {
if (iNumBlocks) {
OutputString(".");
if (++ulStatusCount > 78) {
OutputString("\r\n");
ulStatusCount=0;
}
WRITE_REGISTER_UINT32(FLASH_START+iStartBlock*FLASH_BLOCK_SIZE,FL_CMD_CLR_STATUS);
WRITE_REGISTER_UINT32(FLASH_START+iStartBlock*FLASH_BLOCK_SIZE,FL_CMD_BLOCK_ERASE);
WRITE_REGISTER_UINT32(FLASH_START+iStartBlock*FLASH_BLOCK_SIZE,FL_CMD_BLOCK_NUMBER);
WRITE_REGISTER_UINT32(FLASH_START+iStartBlock*FLASH_BLOCK_SIZE,FL_CMD_BLOCK_NUMBER);
iStartBlock++;
iNumBlocks--;
return 0;
}
return 1;
}
return 0;
}
//***************************************************************************
// OEMFlashWrite
//
// args ulAddress - address to write (must be dword aligned)
// ulValue - value to write
//
// return 0 - success
// non-zero failure
//***************************************************************************
unsigned int OEMFlashWrite(unsigned int ulAddress, unsigned int ulValue)
{
ulAddress|=0x20000000;
if (ulAddress & 3) {
OutputFormatString("ERROR: attempting to write on not word boundary at %Xh\r\n",ulAddress);
ulAddress&=0xfffffff0;
}
// Send write word Command to Flash
WRITE_REGISTER_UINT32(ulAddress,FL_CMD_WR_WORD_ALT);
// write the next word to flash
WRITE_REGISTER_UINT32(ulAddress,ulValue);
if (++ulWriteCount > 16384) {
OutputString("*");
if (++ulStatusCount > 78) {
OutputString("\r\n");
ulStatusCount=0;
}
ulWriteCount=0;
}
return 0;
}
#endif JUNK
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?