// Load the disk image directly into RAM
// .BUGBUG: recover from read failures
Uart_SendString("Reading Kernel Image from NAND\r\n");
i = 0;
while (dwSectorsNeeded && i < MAX_SG_SECTORS)
{
dwSector = toc.id[dwEntry].sgList.dwSector;
dwLength = toc.id[dwEntry].sgList.dwLength;
// read each sg segment
while (dwLength)
{ //这里还有一个读NAND的函数?
if ( !FMD_ReadSector(dwSector,
(LPBYTE)dwRAM,
NULL, 1) )
{
Uart_SendString("ERR_DISK_OP_FAIL2: ");
Uart_SendDWORD(dwSector, TRUE);
dwSector++;
continue;
}
dwSector++;
dwLength--;
dwRAM += SECTOR_SIZE;
drawProcessBar(totalSec,currSec); //显示启动进度条
}
dwSectorsNeeded -= toc.id[dwEntry].sgList.dwLength;
i++;
}
// We only do this if the dwRAM is not zero (The default tocblock1
// set the dwRAM to be 0)
if (toc.chainInfo.dwLoadAddress == 0)
{
return ERR_SUCCESS;
}
// Load the Chain.bin stored from NAND to the SDRAM
dwRAM = VIRTUAL_TO_PHYSICAL(toc.chainInfo.dwLoadAddress); // 0x303c0000
dwSectorsNeeded = toc.chainInfo.dwLength; // 0x20
dwSector = toc.chainInfo.dwFlashAddress; // 0x103c0
while(dwSectorsNeeded)
{ //这里还有一个?
if (!FMD_ReadSector(dwSector,
(LPBYTE) dwRAM,
NULL, 1) )
{
Uart_SendString("Failed reading Chain.bin:");
Uart_SendDWORD(dwSector, TRUE);
dwSector++;
continue;
}
dwSector++;
dwSectorsNeeded--;
dwRAM += SECTOR_SIZE;
drawProcessBar(totalSec,currSec);
}
return ERR_SUCCESS;
}
// Load the disk image directly into RAM
// .BUGBUG: recover from read failures
Uart_SendString("Reading Kernel Image from NAND\r\n");
i = 0;
while (dwSectorsNeeded && i < MAX_SG_SECTORS)
{
dwSector = toc.id[dwEntry].sgList.dwSector; //计算xipkernel需要的扇区数量
dwLength = toc.id[dwEntry].sgList.dwLength; //计算xipkernel需要的长度
// read each sg segment
while (dwLength)
{ //校验NK存放扇区是否有坏块,如果有则自动读取下一个扇区
//这里又出现了一个FMD_ReadSector,是对存储NK的扇区进行校验吗?
if ( !FMD_ReadSector(dwSector,
(LPBYTE)dwRAM,
NULL, 1) )
{
Uart_SendString("ERR_DISK_OP_FAIL2: ");
Uart_SendDWORD(dwSector, TRUE);
dwSector++;
continue;
}
dwSector++;
dwLength--;
dwRAM += SECTOR_SIZE;
drawProcessBar(totalSec,currSec); //显示启动进度条
}
dwSectorsNeeded -= toc.id[dwEntry].sgList.dwLength;
i++;
}
// We only do this if the dwRAM is not zero (The default tocblock1
// set the dwRAM to be 0)
if (toc.chainInfo.dwLoadAddress == 0)
{
return ERR_SUCCESS;
}
// Load the Chain.bin stored from NAND to the SDRAM
dwRAM = VIRTUAL_TO_PHYSICAL(toc.chainInfo.dwLoadAddress); // 0x303c0000
dwSectorsNeeded = toc.chainInfo.dwLength; // 0x20
dwSector = toc.chainInfo.dwFlashAddress; // 0x103c0
while(dwSectorsNeeded)
{
//为什么这里又出来了一个FMD_ReadSector???
if (!FMD_ReadSector(dwSector,
(LPBYTE) dwRAM,
NULL, 1) )
{
Uart_SendString("Failed reading Chain.bin:");
Uart_SendDWORD(dwSector, TRUE);
dwSector++;
continue;
}
dwSector++;
dwSectorsNeeded--;
dwRAM += SECTOR_SIZE;
drawProcessBar(totalSec,currSec);
}
return ERR_SUCCESS;
}