📄 cache.c
字号:
FALSE, the dcache was setup without error.
See Also:
stboot_InitDCache()
*****************************************************************************/
void stboot_LockCaches(CacheReg_t *CacheDevice_p)
{
#if !defined(ST_5100) && !defined(ST_5101) && !defined(ST_7710) && !defined(ST_5105) && !defined(ST_5700) && !defined(ST_5188) && !defined(ST_5107)
/* Lock access to CACHE control regs */
#if defined (ST_5514) || defined (ST_5516) || defined(ST_5517) || defined(ST_5528)
/* Separate lock control for ICACHE and DCACHE */
STSYS_WriteRegDev8(CacheDevice_p+DCACHE_CONTROL_LOCK, 1);
STSYS_WriteRegDev8(CacheDevice_p+ICACHE_CONTROL_LOCK, 1);
#else
/* single lock control */
STSYS_WriteRegDev8(CacheDevice_p+CACHE_CONTROL_LOCK, 1);
#endif
#endif
}
#endif /*#ifdef ST_OS20*/
#ifdef ST_OS21
/********************************************** OS21 **********************************************/
#ifdef ARCHITECTURE_ST200
#ifndef STBOOT_SPECIFY_HOST_MEMORY_MAP
/*****************************************************************************
Name: stboot_st200_InitDCache()
Description:
For configuration of the system data cache.
Parameters:
InitParams_p the initialization parameters.
Return Value:
ST_NO_ERROR No Errors during operation.
STBOOT_ERROR_INVALID_DCACHE Invalid dcache map.
STBOOT_ERROR_BSP_FAILURE Error from toolset BSP.
*****************************************************************************/
ST_ErrorCode_t stboot_st200_InitDCache(STBOOT_InitParams_t *InitParams_p)
{
ST_ErrorCode_t ErrorCode = ST_NO_ERROR;
U32 CachingAddressStart, CachingAddressEnd;
STBOOT_DCache_Area_t *CacheMap_p;
/*The following calls display the current memory map in a table format, can be enabled for debug*/
#ifdef STBOOT_DISPLAY_BSP_MEMORY_MAP
printf("\nDefault Caching status:\n");
printf("-----------------------------------------------------------------------\n");
bsp_mmu_dump_TLB_Settings();
bsp_scu_dump_SCU_Settings();
#endif
if((InitParams_p->DCacheMap == NULL) || (InitParams_p->DCacheEnabled == FALSE))
{
#if defined(ST_5301)
ErrorCode = bsp_mmu_memory_unmap( (void *)(0xC0000000), 0x02000000); /*unmaps for 32MB of lmi 0xC000 0000 to 0xC1FF FFFF*/
if ( ErrorCode != BSP_OK )
{
return STBOOT_ERROR_BSP_FAILURE;
}
ErrorCode = (int) bsp_mmu_memory_map((void *)(0xc0000000),
0x02000000,
PROT_USER_EXECUTE|
PROT_USER_WRITE|
PROT_USER_READ|
PROT_SUPERVISOR_EXECUTE|
PROT_SUPERVISOR_WRITE|
PROT_SUPERVISOR_READ,
MAP_SPARE_RESOURCES|
MAP_FIXED|
MAP_OVERRIDE,
(void *)(0xc0000000));
if ( ErrorCode != 0xc0000000 )
{
return STBOOT_ERROR_BSP_FAILURE;
}
#endif /*5301*/
#if defined(ST_8010)
ErrorCode = bsp_mmu_memory_unmap( (void *)(0x80000000), 0x02000000); /*unmaps for 32MB of lmi 0x8000 0000 to 0x81FF FFFF*/
if ( ErrorCode != BSP_OK )
{
return STBOOT_ERROR_BSP_FAILURE;
}
ErrorCode = (int) bsp_mmu_memory_map((void *)(0x80000000),
0x02000000,
PROT_USER_EXECUTE|
PROT_USER_WRITE|
PROT_USER_READ|
PROT_SUPERVISOR_EXECUTE|
PROT_SUPERVISOR_WRITE|
PROT_SUPERVISOR_READ,
MAP_SPARE_RESOURCES|
MAP_FIXED|
MAP_OVERRIDE,
(void *)(0x80000000));
if ( ErrorCode != 0x80000000 )
{
return STBOOT_ERROR_BSP_FAILURE;
}
#endif /*8010*/
#if defined(ST_5525)
ErrorCode = bsp_mmu_memory_unmap( (void *)(0x80000000), 0x02000000); /*unmaps for 32MB of lmi 0x8000 0000 to 0x81FF FFFF*/
if ( ErrorCode != BSP_OK )
{
return STBOOT_ERROR_BSP_FAILURE;
}
ErrorCode = (int) bsp_mmu_memory_map((void *)(0x80000000),
0x02000000,
PROT_USER_EXECUTE|
PROT_USER_WRITE|
PROT_USER_READ|
PROT_SUPERVISOR_EXECUTE|
PROT_SUPERVISOR_WRITE|
PROT_SUPERVISOR_READ,
MAP_SPARE_RESOURCES|
MAP_FIXED|
MAP_OVERRIDE,
(void *)(0x80000000));
if ( ErrorCode != 0x80000000 )
{
return STBOOT_ERROR_BSP_FAILURE;
}
#endif /*5525*/
/*The following calls display the current memory map in a table format, can be enabled for debug*/
#ifdef STBOOT_DISPLAY_BSP_MEMORY_MAP
printf("\n\nDisabled all data caching:\n");
printf("-----------------------------------------------------------------------\n");
bsp_mmu_dump_TLB_Settings();
bsp_scu_dump_SCU_Settings();
#endif
return ST_NO_ERROR;
} /*corresponds to-> if((InitParams_p->DCacheMap == NULL) || (InitParams_p->DCacheEnabled == FALSE))*/
else /*if not disabling the dcache completely*/
{
if((InitParams_p->DCacheMap->StartAddress == NULL) && (InitParams_p->DCacheMap->EndAddress == NULL))
{
return ST_NO_ERROR; /*do no cache config in this case, the default remains*/
}
#ifdef ST_5301
if((((int) InitParams_p->DCacheMap->StartAddress) > 0xC1C00000) || (((int) InitParams_p->DCacheMap->StartAddress) < 0xC0000000) || (((int) InitParams_p->DCacheMap->EndAddress) > 0xC1FFFFFF) || (((int) InitParams_p->DCacheMap->EndAddress) < 0xC03FFFFF))
{
return STBOOT_ERROR_INVALID_DCACHE;
}
#endif
#ifdef ST_8010
if((((int) InitParams_p->DCacheMap->StartAddress) > 0x81C00000) || (((int) InitParams_p->DCacheMap->StartAddress) < 0x80000000) || (((int) InitParams_p->DCacheMap->EndAddress) > 0x81FFFFFF) || (((int) InitParams_p->DCacheMap->EndAddress) < 0x803FFFFF))
{
return STBOOT_ERROR_INVALID_DCACHE;
}
#endif
#ifdef ST_5525
if((((int) InitParams_p->DCacheMap->StartAddress) > 0x81C00000) || (((int) InitParams_p->DCacheMap->StartAddress) < 0x80000000) || (((int) InitParams_p->DCacheMap->EndAddress) > 0x81FFFFFF) || (((int) InitParams_p->DCacheMap->EndAddress) < 0x803FFFFF))
{
return STBOOT_ERROR_INVALID_DCACHE;
}
#endif
CachingAddressStart = (U32) InitParams_p->DCacheMap->StartAddress;
CachingAddressEnd = (U32) InitParams_p->DCacheMap->EndAddress;
if(((CachingAddressEnd - CachingAddressStart + 1) % 4194304) != 0) /*check that it is multiple of 4MB (4194304 bytes) page size or not*/
{
return STBOOT_ERROR_INVALID_DCACHE;
}
#if defined(ST_5301) /*disable whole dcache(chip specific), then enable required region*/
ErrorCode = bsp_mmu_memory_unmap( (void *)(0xC0000000), 0x02000000); /*unmaps for 32MB of lmi 0xC000 0000 to 0xC1FF FFFF*/
if ( ErrorCode != BSP_OK )
{
return STBOOT_ERROR_BSP_FAILURE;
}
ErrorCode = (int) bsp_mmu_memory_map((void *)(0xc0000000),
0x02000000,
PROT_USER_EXECUTE|
PROT_USER_WRITE|
PROT_USER_READ|
PROT_SUPERVISOR_EXECUTE|
PROT_SUPERVISOR_WRITE|
PROT_SUPERVISOR_READ,
MAP_SPARE_RESOURCES|
MAP_FIXED|
MAP_OVERRIDE,
(void *)(0xc0000000));
if ( ErrorCode != 0xc0000000 )
{
return STBOOT_ERROR_BSP_FAILURE;
}
#endif /*5301*/
#if defined(ST_8010)
ErrorCode = bsp_mmu_memory_unmap( (void *)(0x80000000), 0x02000000); /*unmaps for 32MB of lmi 0x8000 0000 to 0x81FF FFFF*/
if ( ErrorCode != BSP_OK )
{
return STBOOT_ERROR_BSP_FAILURE;
}
ErrorCode = (int) bsp_mmu_memory_map((void *)(0x80000000),
0x02000000,
PROT_USER_EXECUTE|
PROT_USER_WRITE|
PROT_USER_READ|
PROT_SUPERVISOR_EXECUTE|
PROT_SUPERVISOR_WRITE|
PROT_SUPERVISOR_READ,
MAP_SPARE_RESOURCES|
MAP_FIXED|
MAP_OVERRIDE,
(void *)(0x80000000));
if ( ErrorCode != 0x80000000 )
{
return STBOOT_ERROR_BSP_FAILURE;
}
#endif /*8010*/
#if defined(ST_5525)
ErrorCode = bsp_mmu_memory_unmap( (void *)(0x80000000), 0x02000000); /*unmaps for 32MB of lmi 0x8000 0000 to 0x81FF FFFF*/
if ( ErrorCode != BSP_OK )
{
return STBOOT_ERROR_BSP_FAILURE;
}
ErrorCode = (int) bsp_mmu_memory_map((void *)(0x80000000),
0x02000000,
PROT_USER_EXECUTE|
PROT_USER_WRITE|
PROT_USER_READ|
PROT_SUPERVISOR_EXECUTE|
PROT_SUPERVISOR_WRITE|
PROT_SUPERVISOR_READ,
MAP_SPARE_RESOURCES|
MAP_FIXED|
MAP_OVERRIDE,
(void *)(0x80000000));
if ( ErrorCode != 0x80000000 )
{
return STBOOT_ERROR_BSP_FAILURE;
}
#endif /*5525*/
/*The following calls display the current memory map in a table format, can be enabled for debug*/
#ifdef STBOOT_DISPLAY_BSP_MEMORY_MAP
printf("\n\nDisabled all data caching:\n");
printf("-----------------------------------------------------------------------\n");
bsp_mmu_dump_TLB_Settings();
bsp_scu_dump_SCU_Settings();
#endif
CacheMap_p = InitParams_p->DCacheMap;
do
{
/*Enable dcache for specific region now*/
ErrorCode = bsp_mmu_memory_unmap( (void *)(CachingAddressStart), CachingAddressEnd - CachingAddressStart + 1);
if ( ErrorCode != BSP_OK )
{
return STBOOT_ERROR_BSP_FAILURE;
}
ErrorCode = (int) bsp_mmu_memory_map((void *)(CachingAddressStart),
(CachingAddressEnd - CachingAddressStart + 1),
PROT_USER_EXECUTE|
PROT_USER_WRITE|
PROT_USER_READ|
PROT_SUPERVISOR_EXECUTE|
PROT_SUPERVISOR_WRITE|
PROT_SUPERVISOR_READ|
PROT_CACHEABLE,
MAP_SPARE_RESOURCES|
MAP_FIXED|
MAP_OVERRIDE,
(void *)(CachingAddressStart));
if ( ErrorCode != CachingAddressStart )
{
return STBOOT_ERROR_BSP_FAILURE;
}
CacheMap_p++;
if ((CacheMap_p->StartAddress != NULL) && (CacheMap_p->EndAddress != NULL))
{
CachingAddressStart = (U32) CacheMap_p->StartAddress;
CachingAddressEnd = (U32) CacheMap_p->EndAddress;
}
}
while((CacheMap_p->StartAddress != NULL) || (CacheMap_p->EndAddress != NULL));
/*The following calls display the current memory map in a table format, can be enabled for debug*/
#ifdef STBOOT_DISPLAY_BSP_MEMORY_MAP
printf("\n\nUser requested dcache configuration done (pre OS21 initialise):\n");
printf("-----------------------------------------------------------------------\n");
bsp_mmu_dump_TLB_Settings();
bsp_scu_dump_SCU_Settings();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -