引用 10 楼 shuiii 的回复:
以后启动时调用了ReadOSImageFromBootMedia()函数,该函数调用了如下函数:
? ? hPart = BP_OpenPartition( NEXT_FREE_LOC,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? USE_REMAINING_SPACE,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PART_BINFS,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TRUE,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PART_OPEN_EXISTING);
根据启动时串口输出信息,再次打开时binfs分区是存在的。
ReadOSImageFromBootMedia()函数为什么还要调BP_OpenPartition?????
EBoot原来里面的代码内部就调用了BP_OpenPartiton函数,我看了几个BSP都是这样的,下面是
ReadOSImageFromBootMedia函数的代码:
/*
@func BOOL | ReadKernelRegionFromBootMedia |
BinFS support. Reads the kernel region from Boot Media into RAM. The kernel region is fixed up
to run from RAM and this is done just before jumping to the kernel entry point.
@rdesc TRUE = Success, FALSE = Failure.
@comm
@xref
*/
BOOL ReadOSImageFromBootMedia()
{
HANDLE hPart;
SectorInfo si;
DWORD chainaddr, flashaddr;
DWORD i;
OALMSG(OAL_FUNC, (TEXT("+ReadOSImageFromBootMedia\r\n")));
if (!g_bBootMediaExist)
{
OALMSG(OAL_ERROR, (TEXT("ERROR: ReadOSImageFromBootMedia: device doesn't exist.\r\n")));
return(FALSE);
}
if ( !VALID_TOC(g_pTOC) )
{
OALMSG(OAL_ERROR, (TEXT("ERROR: ReadOSImageFromBootMedia: INVALID_TOC\r\n")));
return(FALSE);
}
if ( !VALID_IMAGE_DESCRIPTOR(&g_pTOC->id[g_dwTocEntry]) )
{
OALMSG(OAL_ERROR, (TEXT("ReadOSImageFromBootMedia: ERROR_INVALID_IMAGE_DESCRIPTOR: 0x%x\r\n"),
g_pTOC->id[g_dwTocEntry].dwSignature));
return FALSE;
}
if ( !OEMVerifyMemory(g_pTOC->id[g_dwTocEntry].dwLoadAddress, sizeof(DWORD)) ||
!OEMVerifyMemory(g_pTOC->id[g_dwTocEntry].dwJumpAddress, sizeof(DWORD)) ||
!g_pTOC->id[g_dwTocEntry].dwTtlSectors )
{
OALMSG(OAL_ERROR, (TEXT("ReadOSImageFromBootMedia: ERROR_INVALID_ADDRESS: (address=0x%x, sectors=0x%x, launch address=0x%x)...\r\n"),
g_pTOC->id[g_dwTocEntry].dwLoadAddress, g_pTOC->id[g_dwTocEntry].dwTtlSectors, g_pTOC->id[g_dwTocEntry].dwJumpAddress));
return FALSE;
}
[color=#FF0000] // Open the BINFS partition (it must exist).
//
hPart = BP_OpenPartition( NEXT_FREE_LOC,
USE_REMAINING_SPACE,
PART_BINFS,
TRUE,
PART_OPEN_EXISTING);[/color]
if (hPart == INVALID_HANDLE_VALUE )
{
OALMSG(OAL_ERROR, (TEXT("ERROR: ReadOSImageFromBootMedia: Failed to open existing partition.\r\n")));
return(FALSE);
}
// Set the partition file pointer to the correct offset for the kernel region.
//
if ( !BP_SetDataPointer(hPart, g_pTOC->id[g_dwTocEntry].dwStoreOffset) )
{
OALMSG(OAL_ERROR, (TEXT("ERROR: ReadOSImageFromBootMedia: Failed to set data pointer in partition (offset=0x%x).\r\n"),
g_pTOC->id[g_dwTocEntry].dwStoreOffset));
return(FALSE);
}
// Read the kernel region from the Boot Media into RAM.
//
if ( !BP_ReadData( hPart,
(LPBYTE)(g_pTOC->id[g_dwTocEntry].dwLoadAddress),
SECTOR_TO_FILE_SIZE(g_pTOC->id[g_dwTocEntry].dwTtlSectors)) )
{
OALMSG(OAL_ERROR, (TEXT("ERROR: ReadOSImageFromBootMedia: Failed to read kernel region from partition.\r\n")));
return(FALSE);
}
if (!g_pTOC->chainInfo.dwLoadAddress)
{
OALMSG(TRUE, (TEXT("start read from nand\r\n")));
chainaddr = g_pTOC->chainInfo.dwLoadAddress;
flashaddr = g_pTOC->chainInfo.dwFlashAddress;
for ( i = 0; i < (g_pTOC->chainInfo.dwLength); i++ )
{
OALMSG(TRUE, (TEXT("chainaddr=0x%x, flashaddr=0x%x\r\n"), chainaddr, flashaddr+i));
if ( !FMD_ReadSector(flashaddr+i, (PUCHAR)(chainaddr), &si, 1) ) {
OALMSG(OAL_ERROR, (TEXT("TOC ERROR: Unable to read/verify TOC\r\n")));
return FALSE;
}
chainaddr += 512;
}
}
OALMSG(OAL_FUNC, (TEXT("_ReadOSImageFromBootMedia\r\n")));
return(TRUE);
}
复制代码