在lib_blackfin/board.c中有一个函数:
void
init_cplbtables(void)
{
volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
uint32_t extern_memory;
size_t i;
void icplb_add(uint32_t addr, uint32_t data)
{
*(ICPLB_ADDR + i) = addr;
*(ICPLB_DATA + i) = data;
}
void dcplb_add(uint32_t addr, uint32_t data)
{
*(DCPLB_ADDR + i) = addr;
*(DCPLB_DATA + i) = data;
}
…
}
在这里它将icplb_add和dcpld_add这两个函数放到了init_cplbtables函数里面,而这在VDSP中是不允许的,因此将其提取到外面来。
static
volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
static
volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
static
size_t g_iIndex;
static
void icplb_add(uint32_t addr, uint32_t data)
{
*(ICPLB_ADDR + g_iIndex) = addr;
*(ICPLB_DATA + g_iIndex) = data;
}
static
void dcplb_add(uint32_t addr, uint32_t data)
{
*(DCPLB_ADDR + g_iIndex) = addr;
*(DCPLB_DATA + g_iIndex) = data;
}
void
init_cplbtables(void)
{
uint32_t extern_memory;
/* populate a few common entries ... we'll let
* the memory map and cplb exception handler do
* the rest of the work.
*/
g_iIndex = 0;
ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0;
ICPLB_DATA = (uint32_t *)ICPLB_DATA0;
DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0;
DCPLB_DATA = (uint32_t *)DCPLB_DATA0;
icplb_add(0xFFA00000, L1_IMEMORY);
dcplb_add(0xFF800000, L1_DMEMORY);
++g_iIndex;
icplb_add(CFG_MONITOR_BASE & CPLB_PAGE_MASK, SDRAM_IKERNEL);
dcplb_add(CFG_MONITOR_BASE & CPLB_PAGE_MASK, SDRAM_DKERNEL);
++g_iIndex;
/* If the monitor crosses a 4 meg boundary, we'll need
* to lock two entries for it.
*/
if ((CFG_MONITOR_BASE & CPLB_PAGE_MASK) != ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & CPLB_PAGE_MASK)) {
icplb_add((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & CPLB_PAGE_MASK, SDRAM_IKERNEL);
dcplb_add((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & CPLB_PAGE_MASK, SDRAM_DKERNEL);
++g_iIndex;
}
icplb_add(0x20000000, SDRAM_INON_CHBL);
dcplb_add(0x20000000, SDRAM_EBIU);
++g_iIndex;
/* Add entries for the rest of external RAM up to the bootrom */
extern_memory = 0;
#ifdef
CONFIG_DEBUG_NULL_PTR
icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
++g_iIndex;
icplb_add(extern_memory, SDRAM_IKERNEL);
dcplb_add(extern_memory, SDRAM_DKERNEL);
extern_memory += CPLB_PAGE_SIZE;
++g_iIndex;
#endif
while (g_iIndex < 16 && extern_memory < (CFG_MONITOR_BASE & CPLB_PAGE_MASK)) {
icplb_add(extern_memory, SDRAM_IGENERIC);
dcplb_add(extern_memory, SDRAM_DGENERIC);
extern_memory += CPLB_PAGE_SIZE;
++g_iIndex;
}
while (g_iIndex < 16) {
icplb_add(0, 0);
dcplb_add(0, 0);
++g_iIndex;
}
}