来自
http://www.cnblogs.com/yakin/archive/2005/07/20/196572.aspx作者: yakin
multi-xip实际上很有用,但是现在有一个为难的事情:就是OS起来之后无法写flash,这个很让人苦恼。所以这也导致升级程序无法设置标志位。只能用GPIO口。
Multi-xip的实现:
1) Bib文件的修改:
MEMORY
RSVD 80000000 000FF000 RESERVED
ARGS 800FF000 00001000 RESERVED
NK 9C600000 01000000 RAMIMAGE
APP 9D600000 00500000 RAMIMAGE
CHAIN 9DB00000 00002000 RESERVED
RAM 80100000 01F00000 RAM
pdwXIPLoc 00000000 9DB00000 FIXUPVAR
CONFIG
AUTOSIZE=ON
ROM_AUTOSIZE=OFF
RAM_AUTOSIZE=OFF
DLLADDR_AUTOSIZE=ON
XIPSCHAIN=9DB00000
ROMSTART=9C600000
ROMWIDTH=32
ROMSIZE=01600000
KERNELFIXUPS=ON
2) 在OEMInit加一个连接各个bin的函数:
void InitRomChain()
{
// Added for MultiXIP stuff
static ROMChain_t s_pNextRom[MAX_ROM] = {0};
DWORD dwRomCount = 0;
DWORD dwChainCount = 0;
DWORD * pdwCurXIP;
DWORD dwNumXIPs;
PXIPCHAIN_ENTRY pChainEntry = NULL;
if(pdwXIPLoc == NOT_FIXEDUP){
return; // no chain or not fixed up properly
}
// set the top bit to mark it as a virtual address
pdwCurXIP = (DWORD*)(((DWORD)pdwXIPLoc) | 0x80000000);
// first DWORD is number of XIPs
dwNumXIPs = (*pdwCurXIP);
if(dwNumXIPs > MAX_ROM){
OALMSG(TRUE, (L"ERROR: Number of XIPs exceeds MAX\r\n"));
//lpWriteDebugStringFunc(TEXT("ERROR: Number of XIPs exceeds MAX\n"));
return;
}
pChainEntry = (PXIPCHAIN_ENTRY)(pdwCurXIP + 1);
while(dwChainCount < dwNumXIPs)
{
if ((pChainEntry->usFlags & ROMXIP_OK_TO_LOAD) && // flags indicates valid XIP
*(LPDWORD)(((DWORD)(pChainEntry->pvAddr)) + ROM_SIGNATURE_OFFSET) == ROM_SIGNATURE)
{
s_pNextRom[dwRomCount].pTOC = *(ROMHDR **)(((DWORD)(pChainEntry->pvAddr)) + ROM_SIGNATURE_OFFSET + 4);
s_pNextRom[dwRomCount].pNext = NULL;
if (dwRomCount != 0)
{
s_pNextRom[dwRomCount-1].pNext = &s_pNextRom[dwRomCount];
}
else
{
OEMRomChain = s_pNextRom;
}
dwRomCount++;
}
else
{
OALMSG(TRUE, (L"Invalid XIP found\r\n"));
//lpWriteDebugStringFunc( _T("Invalid XIP found\n") );
}
++pChainEntry;
dwChainCount++;
}
}
这是从CEPC中拷贝过来的。
通过上面的设置,romimage会生成3个bin,nk.bin,app.bin,chain.bin,还有一个xip.bin,是上面三个bin的集合体。我们download是要download xip.bin,这样就可以实现multibin。通过调试发现,InitRomChain就是利用chain.bin来连接各个bin的。
这样我们也理解了bib文件中这个语句的含义:
pdwXIPLoc 00000000 9DB00000 FIXUPVAR
也就是FIXUPVAR的含义。我们看到在代码中我们同样定义了pdwXIPLoc,这样romimage时,就将9DB00000赋给pdwXIPLoc。这就是FIXUPVAR的作用。正如pTOC也是由romimage赋值一样。