void OEMLaunchImage(UINT32 ulLaunchAddr) { UINT32 ulPhysicalJump = 0; // The IPL is running with the MMU on - before we jump to the loaded image, we need to convert // the launch address to a physical address and turn off the MMU. // // Convert jump address to a physical address. ulPhysicalJump = (DWORD)OALVAtoPA((void *)ulLaunchAddr); // Check if Current ARM speed is not matched to Target Arm speed // then To get speed up, set Voltage #if (APLL_CLK == CLK_1332MHz) LTC3714_Init(); LTC3714_VoltageSet(1,1200,100); // ARM LTC3714_VoltageSet(2,1300,100); // INT #endif #if (TARGET_ARM_CLK == CLK_800MHz) LTC3714_Init(); LTC3714_VoltageSet(1,1300,100); // ARM LTC3714_VoltageSet(2,1200,100); // INT #endif RETAILMSG(1, (L"LaunchAddr=0x%x PhysicalJump=0x%x\r\n", ulLaunchAddr, ulPhysicalJump)); // Jump... Launch(ulPhysicalJump); }
static UINT32 ReadFlashNK( ) { UINT32 rc = (UINT32)BL_ERROR; ROMHDR *pTOC; ULONG offset, size; UCHAR *pData; DWORD *pInfo; UCHAR *pBase = OALPAtoVA(g_ulFlashBase, FALSE); UCHAR *pStart = (void *)((UINT32)pBase + IMAGE_WINCE_NOR_OFFSET); OALMSG(OAL_INFO, (L"\r\nLoad NK image from flash memory\r\n")); // Set address where to place image pData = (UCHAR*)IMAGE_WINCE_CODE_CA; // First read 4kB with pointer to TOC offset = 0; size = 4096; memcpy(pData + offset, pStart, size); // Verify that we get CE image pInfo = (DWORD *)(pData + offset + ROM_SIGNATURE_OFFSET); if (*pInfo != ROM_SIGNATURE) { OALMSG(OAL_ERROR, (L"ERROR: Image signature not found\r\n")); goto cleanUp; } // Read image up through actual TOC offset = size; size = pInfo[2] - size + sizeof(ROMHDR); memcpy(pData + offset, pStart + offset, size); // Verify image if (!VerifyImage(pData, &pTOC)) { OALMSG(OAL_ERROR, (L"ERROR: NK image doesn't have ROM signature\r\n")); goto cleanUp; } // Read remainder of image offset += size; size = pTOC->physlast - pTOC->physfirst - offset; memcpy(pData + offset, pStart + offset, size); OALMSG(OAL_INFO, (L"NK Image Loaded\r\n")); // Done g_eboot.launchAddress = OALVAtoPA((UCHAR*)IMAGE_WINCE_CODE_CA); rc = BL_JUMP; cleanUp: return rc; }
void OEMLaunchImage(UINT32 ulLaunchAddr) { UINT32 ulPhysicalJump = 0; // The IPL is running with the MMU on - before we jump to the loaded image, we need to convert // the launch address to a physical address and turn off the MMU. // // Convert jump address to a physical address. ulPhysicalJump = OALVAtoPA((void *)ulLaunchAddr); RETAILMSG(1, (TEXT("Jumping to VA 0x%x PA 0x%x...\r\n"), ulLaunchAddr, ulPhysicalJump)); // Jump... Launch(ulPhysicalJump); }
//------------------------------------------------------------------------------ // // Function: OEMMultiBinNotify // VOID OEMMultiBinNotify( MultiBINInfo *pInfo ) { BOOL rc = FALSE; UINT32 base = OALVAtoPA((UCHAR*)IMAGE_WINCE_CODE_CA); UINT32 start, length; UINT32 ix; OALMSGS(OAL_FUNC, ( L"+OEMMultiBinNotify(0x%08x -> %d)\r\n", pInfo, pInfo->dwNumRegions )); OALMSG(OAL_INFO, ( L"Download file information:\r\n" )); OALMSG(OAL_INFO, ( L"-----------------------------------------------------------\r\n" )); // Copy information to EBOOT structure and set also save address g_eboot.numRegions = pInfo->dwNumRegions; for (ix = 0; ix < pInfo->dwNumRegions; ix++) { g_eboot.region[ix].start = pInfo->Region[ix].dwRegionStart; g_eboot.region[ix].length = pInfo->Region[ix].dwRegionLength; g_eboot.region[ix].base = base; base += g_eboot.region[ix].length; OALMSG(OAL_INFO, ( L"[%d]: Address=0x%08x Length=0x%08x Save=0x%08x\r\n", ix, g_eboot.region[ix].start, g_eboot.region[ix].length, g_eboot.region[ix].base )); } OALMSG(OAL_INFO, ( L"-----------------------------------------------------------\r\n" )); // Determine type of image downloaded if (g_eboot.numRegions > 1) { OALMSG(OAL_ERROR, (L"ERROR: MultiXIP image is not supported\r\n")); goto cleanUp; } base = g_eboot.region[0].base; start = g_eboot.region[0].start; length = g_eboot.region[0].length; if (start == IMAGE_XLDR_CODE_PA) { g_eboot.type = DOWNLOAD_TYPE_XLDR; memset(OALPAtoCA(base), 0xFF, length); } else if (start == IMAGE_EBOOT_CODE_CA) { g_eboot.type = DOWNLOAD_TYPE_EBOOT; memset(OALPAtoCA(base), 0xFF, length); } else if (start == (IMAGE_WINCE_CODE_CA + NAND_ROMOFFSET)) { g_eboot.type = DOWNLOAD_TYPE_FLASHNAND; memset(OALPAtoCA(base), 0xFF, length); } else if (start == (IMAGE_WINCE_CODE_CA + NOR_ROMOFFSET)) { g_eboot.type = DOWNLOAD_TYPE_FLASHNOR; memset(OALPAtoCA(base), 0xFF, length); } else if (start == 0) // Probably a NB0 file, let's fint out { // Convert the file name to lower case CHAR szFileName[MAX_PATH]; int i = 0; int fileExtPos = 0; while ((pInfo->Region[0].szFileName[i] != '\0') && (i < MAX_PATH)) { if((pInfo->Region[0].szFileName[i] >= 'A') && (pInfo->Region[0].szFileName[i] <= 'Z')) { szFileName[i] = (pInfo->Region[0].szFileName[i] - 'A' + 'a'); } else { szFileName[i] = pInfo->Region[0].szFileName[i]; } // Keep track of file extension position if (szFileName[i] == '.') { fileExtPos = i; } i++; } // Copy string terminator as well szFileName[i] = pInfo->Region[0].szFileName[i]; // Check if we support this file if (strncmp(szFileName, LOGO_NB0_FILE, LOGO_NB0_FILE_LEN) == 0) { // Remap the start address to the correct NAND location of the logo g_eboot.region[0].start = IMAGE_XLDR_BOOTSEC_NAND_SIZE + IMAGE_EBOOT_BOOTSEC_NAND_SIZE; g_eboot.type = DOWNLOAD_TYPE_LOGO; } else { OALMSG(OAL_ERROR, (L"Unsupported downloaded file\r\n")); goto cleanUp; } } else { g_eboot.type = DOWNLOAD_TYPE_RAM; } OALMSG(OAL_INFO, ( L"Download file type: %d\r\n", g_eboot.type )); rc = TRUE; cleanUp: if (!rc) { OALMSG(OAL_ERROR, (L"Spin for ever...\r\n")); for(;;); } OALMSGS(OAL_FUNC, (L"-OEMMultiBinNotify\r\n")); }
//------------------------------------------------------------------------------ // // Function: OEMLaunch // // This function is the last one called by the boot framework and it is // responsible for to launching the image. // VOID OEMLaunch( ULONG start, ULONG size, ULONG launch, const ROMHDR *pRomHeader ) { BSP_ARGS *pArgs = OALCAtoUA(IMAGE_SHARE_ARGS_CA); UNREFERENCED_PARAMETER(size); UNREFERENCED_PARAMETER(pRomHeader); OALMSG(OAL_FUNC, ( L"+OEMLaunch(0x%08x, 0x%08x, 0x%08x, 0x%08x - %d/%d)\r\n", start, size, launch, pRomHeader, g_eboot.bootDeviceType, g_eboot.type )); // Depending on protocol there can be some action required switch (g_eboot.bootDeviceType) { #if BUILDING_EBOOT_SD case BOOT_SDCARD_TYPE: switch (g_eboot.type) { #if 0 /* case DOWNLOAD_TYPE_FLASHRAM: if (BLFlashDownload(&g_bootCfg, g_kitlDevices) != BL_JUMP) { OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: " L"Image load from flash memory failed\r\n" )); goto cleanUp; } launch = g_eboot.launchAddress; break; */ #endif case DOWNLOAD_TYPE_RAM: launch = (UINT32)OEMMapMemAddr(start, launch); break; case DOWNLOAD_TYPE_FLASHNAND: if (BLFlashDownload(&g_bootCfg, g_kitlDevices) != BL_JUMP) { OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: " L"Image load from flash memory failed\r\n" )); goto cleanUp; } launch = g_eboot.launchAddress; break; #if 0 /* case DOWNLOAD_TYPE_EBOOT: case DOWNLOAD_TYPE_XLDR: OALMSG(OAL_INFO, (L"INFO: " L"XLDR/EBOOT/IPL downloaded, spin forever\r\n" )); while (TRUE); break; */ #endif default: OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: Unknown download type, spin forever\r\n")); for(;;); break; } break; #endif case OAL_KITL_TYPE_ETH: BLEthConfig(pArgs); switch (g_eboot.type) { case DOWNLOAD_TYPE_FLASHNAND: case DOWNLOAD_TYPE_FLASHNOR: if (BLFlashDownload(&g_bootCfg, g_kitlDevices) != BL_JUMP) { OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: " L"Image load from flash memory failed\r\n" )); goto cleanUp; } launch = g_eboot.launchAddress; break; case DOWNLOAD_TYPE_RAM: launch = (UINT32)OEMMapMemAddr(start, launch); break; case DOWNLOAD_TYPE_EBOOT: case DOWNLOAD_TYPE_XLDR: OALMSG(OAL_INFO, (L"INFO: " L"XLDR/EBOOT/IPL downloaded, spin forever\r\n" )); for(;;); break; case DOWNLOAD_TYPE_LOGO: OALMSG(OAL_INFO, (L"INFO: " L"Splashcreen logo downloaded, spin forever\r\n" )); for(;;); break; default: OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: Unknown download type, spin forever\r\n")); for(;;); break; } break; default: launch = g_eboot.launchAddress; break; } #ifndef BSP_NO_NAND_IN_SDBOOT if ((g_bootCfg.flashNKFlags & ENABLE_FLASH_NK) && /* if loading from NAND then do not need to flash NAND again */ (g_eboot.bootDeviceType != OAL_KITL_TYPE_FLASH) && (start != (IMAGE_WINCE_CODE_CA + NAND_ROMOFFSET)) && (start != (IMAGE_WINCE_CODE_CA + NOR_ROMOFFSET))) { if( !WriteFlashNK(start, size)) OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: " L"Flash NK.bin failed, start=%x\r\n", start )); } #endif // Check if we get launch address if (launch == (UINT32)INVALID_HANDLE_VALUE) { OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: " L"Unknown image launch address, spin forever\r\n" )); for(;;); } // Print message, flush caches and jump to image OALLog( L"Launch Windows CE image by jumping to 0x%08x...\r\n\r\n", launch ); OEMDeinitDebugSerial(); OEMPlatformDeinit(); JumpTo(OALVAtoPA((UCHAR*)launch)); cleanUp: return; }
DWORD ConvertCAtoPA(DWORD * va) { return OALVAtoPA(va); }
static UINT32 ReadFlashNK( ) { UINT32 rc = (UINT32) BL_ERROR; HANDLE hPartition; ROMHDR *pTOC; ULONG offset, size; UCHAR *pData; DWORD *pInfo; PCI_REG_INFO regInfo; memset(®Info, 0, sizeof(PCI_REG_INFO)); regInfo.MemBase.Num = 1; regInfo.MemLen.Num = 1; regInfo.MemBase.Reg[0] = g_ulFlashBase; regInfo.MemLen.Reg[0] = g_ulFlashLengthBytes; // Check if there is a valid image OALMSG(OAL_INFO, (L"\r\nLoad NK image from flash memory\r\n")); // Initialize boot partition library if (!BP_Init((LPBYTE)g_ulBPartBase, g_ulBPartLengthBytes, NULL, ®Info, NULL)) { OALLog(L"ReadFlashNK: Error initializing bootpart library!!\r\n"); goto cleanUp; } // Open OS boot partition hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)USE_REMAINING_SPACE, PART_BOOTSECTION, FALSE, PART_OPEN_EXISTING); if (hPartition == INVALID_HANDLE_VALUE) { OALMSG(OAL_ERROR, (L"ERROR: OS partition not found!\r\n")); goto cleanUp; } BP_SetDataPointer(hPartition, 0); // Set address where to place image pData = (UCHAR*)IMAGE_WINCE_CODE_CA; // First read 4kB with pointer to TOC offset = 0; size = 4096; if (!BP_ReadData(hPartition, pData + offset, size)) { OALMSG(OAL_ERROR, (L"ERROR: Error reading OS partition!\r\n")); goto cleanUp; } // Verify that we get CE image pInfo = (DWORD*)(pData + ROM_SIGNATURE_OFFSET); if (*pInfo != ROM_SIGNATURE) { OALMSG(OAL_ERROR, (L"ERROR: " L"Image signature not found\r\n" )); goto cleanUp; } // Read image up through actual TOC offset = size; size = pInfo[2] - size + sizeof(ROMHDR); if (!BP_ReadData(hPartition, pData + offset, size)) { OALMSG(OAL_ERROR, (L"ERROR: " L"BP_ReadData call failed!\r\n" )); goto cleanUp; } // Verify image if (!VerifyImage(pData, &pTOC)) { OALMSG(OAL_ERROR, (L"ERROR: " L"NK image doesn't have ROM signature\r\n" )); goto cleanUp; } // Read remainder of image offset += size; size = pTOC->physlast - pTOC->physfirst - offset; if (!BP_ReadData(hPartition, pData + offset, size)) { OALMSG(OAL_ERROR, (L"ERROR: " L"BP_ReadData call failed!\r\n" )); goto cleanUp; } OALMSG(OAL_INFO, (L"NK Image Loaded\r\n")); // Done g_eboot.launchAddress = OALVAtoPA((UCHAR*)IMAGE_WINCE_CODE_CA); rc = BL_JUMP; cleanUp: return rc; }