-static int cortex_a8_get_ttb(struct target *target, uint32_t *result)
-{
- struct cortex_a8_common *cortex_a8 = target_to_cortex_a8(target);
- struct armv7a_common *armv7a = &cortex_a8->armv7a_common;
- uint32_t ttb = 0, retval = ERROR_OK;
-
- /* current_address_mode is set inside cortex_a8_virt2phys()
- where we can determine if address belongs to user or kernel */
- if(cortex_a8->current_address_mode == ARM_MODE_SVC)
- {
- /* MRC p15,0,<Rt>,c1,c0,0 ; Read CP15 System Control Register */
- retval = armv7a->armv4_5_common.mrc(target, 15,
- 0, 1, /* op1, op2 */
- 2, 0, /* CRn, CRm */
- &ttb);
- if (retval != ERROR_OK)
- return retval;
- }
- else if(cortex_a8->current_address_mode == ARM_MODE_USR)
- {
- /* MRC p15,0,<Rt>,c1,c0,0 ; Read CP15 System Control Register */
- retval = armv7a->armv4_5_common.mrc(target, 15,
- 0, 0, /* op1, op2 */
- 2, 0, /* CRn, CRm */
- &ttb);
- if (retval != ERROR_OK)
- return retval;
- }
- /* we don't know whose address is: user or kernel
- we assume that if we are in kernel mode then
- address belongs to kernel else if in user mode
- - to user */
- else if(armv7a->armv4_5_common.core_mode == ARM_MODE_SVC)
- {
- /* MRC p15,0,<Rt>,c1,c0,0 ; Read CP15 System Control Register */
- retval = armv7a->armv4_5_common.mrc(target, 15,
- 0, 1, /* op1, op2 */
- 2, 0, /* CRn, CRm */
- &ttb);
- if (retval != ERROR_OK)
- return retval;
- }
- else if(armv7a->armv4_5_common.core_mode == ARM_MODE_USR)
- {
- /* MRC p15,0,<Rt>,c1,c0,0 ; Read CP15 System Control Register */
- retval = armv7a->armv4_5_common.mrc(target, 15,
- 0, 0, /* op1, op2 */
- 2, 0, /* CRn, CRm */
- &ttb);
- if (retval != ERROR_OK)
- return retval;
- }
- /* finally we don't know whose ttb to use: user or kernel */
- else
- LOG_ERROR("Don't know how to get ttb for current mode!!!");
-
- ttb &= 0xffffc000;
-
- *result = ttb;
-
- return ERROR_OK;
-}
-
-static int cortex_a8_disable_mmu_caches(struct target *target, int mmu,
- int d_u_cache, int i_cache)
-{
- struct cortex_a8_common *cortex_a8 = target_to_cortex_a8(target);
- struct armv7a_common *armv7a = &cortex_a8->armv7a_common;
- uint32_t cp15_control;
- int retval;
-
- /* read cp15 control register */
- retval = armv7a->armv4_5_common.mrc(target, 15,
- 0, 0, /* op1, op2 */
- 1, 0, /* CRn, CRm */
- &cp15_control);
- if (retval != ERROR_OK)
- return retval;
-
-
- if (mmu)
- cp15_control &= ~0x1U;
-
- if (d_u_cache)
- cp15_control &= ~0x4U;
-
- if (i_cache)
- cp15_control &= ~0x1000U;
-
- retval = armv7a->armv4_5_common.mcr(target, 15,
- 0, 0, /* op1, op2 */
- 1, 0, /* CRn, CRm */
- cp15_control);
- return retval;
-}
-
-static int cortex_a8_enable_mmu_caches(struct target *target, int mmu,
- int d_u_cache, int i_cache)
-{
- struct cortex_a8_common *cortex_a8 = target_to_cortex_a8(target);
- struct armv7a_common *armv7a = &cortex_a8->armv7a_common;
- uint32_t cp15_control;
- int retval;
-
- /* read cp15 control register */
- retval = armv7a->armv4_5_common.mrc(target, 15,
- 0, 0, /* op1, op2 */
- 1, 0, /* CRn, CRm */
- &cp15_control);
- if (retval != ERROR_OK)
- return retval;
-
- if (mmu)
- cp15_control |= 0x1U;
-
- if (d_u_cache)
- cp15_control |= 0x4U;
-
- if (i_cache)
- cp15_control |= 0x1000U;
-
- retval = armv7a->armv4_5_common.mcr(target, 15,
- 0, 0, /* op1, op2 */
- 1, 0, /* CRn, CRm */
- cp15_control);
- return retval;
-}