原创 S3C2450 Bootloader调试总结之三

2010-5-23 20:33 2241 4 4 分类: MCU/ 嵌入式
// (4) call OEM specific pre-download function

    switch (dwAction =OEMPreDownload ())


    {


    case BL_DOWNLOAD:


        // (5) download image


        if (!DownloadImage (&dwImageStart, &dwImageLength, &dwLaunchAddr))


        {


            // error already reported in DownloadImage


            SPIN_FOREVER;


        }


        bDownloaded = TRUE;


 


        // Check for pTOC signature ("CECE") here, after image in place


        if (*(LPDWORD) OEMMapMemAddr (dwImageStart, dwImageStart + ROM_SIGNATURE_OFFSET) == ROM_SIGNATURE)


        {


            dwpToc = *(LPDWORD) OEMMapMemAddr (dwImageStart, dwImageStart + ROM_SIGNATURE_OFFSET + sizeof(ULONG));


            // need to map the content again since the pointer is going to be in a fixup address


            dwpToc = (DWORD) OEMMapMemAddr (dwImageStart, dwpToc + g_dwROMOffset);


 


            EdbgOutputDebugString ("ROMHDR at Address %Xh\r\n", dwImageStart + ROM_SIGNATURE_OFFSET + sizeof (DWORD)); // right after signature


        }


 


        // fall through


    case BL_JUMP:


        // Before jumping to the image, optionally check the image signature.


        // NOTE: if we haven't downloaded the image by now, we assume that it'll be loaded from local storage in OEMLaunch (or it


        // already resides in RAM from an earlier download), and in this case, the image start address might be 0.  This means


        // that the image signature routine will need to find the image in storage or in RAM to validate it.  Since the OEM"s


        // OEMLaunch function will need to do this anyways, we trust that it's within their abilities to do it here.


        //


        if (g_bBINDownload && g_pOEMCheckSignature)


        {


            if (!g_pOEMCheckSignature(dwImageStart, g_dwROMOffset, dwLaunchAddr, bDownloaded))


                HALT(BLERR_CAT_SIGNATURE);


        }


        // (5) final call to launch the image. never returned


        OEMLaunch (dwImageStart, dwImageLength, dwLaunchAddr, (const ROMHDR *)dwpToc);


        // should never return


        // fall through


    default:


        // ERROR! spin forever


        HALT (BLERR_INVALIDCMD);


    }


}

文章评论0条评论)

登录后参与讨论
我要评论
0
4
关闭 站长推荐上一条 /2 下一条