arm: add error propagation to generic get_ttb fn
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
This commit is contained in:
parent
612184176f
commit
70fee9207b
|
@ -134,16 +134,24 @@ static int arm720t_write_cp15(struct target *target, uint32_t opcode, uint32_t v
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t arm720t_get_ttb(struct target *target)
|
static int arm720t_get_ttb(struct target *target, uint32_t *result)
|
||||||
{
|
{
|
||||||
uint32_t ttb = 0x0;
|
uint32_t ttb = 0x0;
|
||||||
|
|
||||||
arm720t_read_cp15(target, 0xee120f10, &ttb);
|
int retval;
|
||||||
jtag_execute_queue();
|
|
||||||
|
retval = arm720t_read_cp15(target, 0xee120f10, &ttb);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
retval = jtag_execute_queue();
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
ttb &= 0xffffc000;
|
ttb &= 0xffffc000;
|
||||||
|
|
||||||
return ttb;
|
*result = ttb;
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arm720t_disable_mmu_caches(struct target *target,
|
static void arm720t_disable_mmu_caches(struct target *target,
|
||||||
|
|
|
@ -318,7 +318,7 @@ int arm920t_write_cp15_interpreted(struct target *target,
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPORTED to FA256
|
// EXPORTED to FA256
|
||||||
uint32_t arm920t_get_ttb(struct target *target)
|
int arm920t_get_ttb(struct target *target, uint32_t *result)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
uint32_t ttb = 0x0;
|
uint32_t ttb = 0x0;
|
||||||
|
@ -328,7 +328,8 @@ uint32_t arm920t_get_ttb(struct target *target)
|
||||||
0xeebf0f51, 0x0, &ttb)) != ERROR_OK)
|
0xeebf0f51, 0x0, &ttb)) != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
return ttb;
|
*result = ttb;
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPORTED to FA256
|
// EXPORTED to FA256
|
||||||
|
|
|
@ -66,7 +66,7 @@ int arm920t_write_memory(struct target *target,
|
||||||
uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
|
uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
|
||||||
void arm920t_post_debug_entry(struct target *target);
|
void arm920t_post_debug_entry(struct target *target);
|
||||||
void arm920t_pre_restore_context(struct target *target);
|
void arm920t_pre_restore_context(struct target *target);
|
||||||
uint32_t arm920t_get_ttb(struct target *target);
|
int arm920t_get_ttb(struct target *target, uint32_t *result);
|
||||||
void arm920t_disable_mmu_caches(struct target *target,
|
void arm920t_disable_mmu_caches(struct target *target,
|
||||||
int mmu, int d_u_cache, int i_cache);
|
int mmu, int d_u_cache, int i_cache);
|
||||||
void arm920t_enable_mmu_caches(struct target *target,
|
void arm920t_enable_mmu_caches(struct target *target,
|
||||||
|
|
|
@ -323,7 +323,7 @@ static int arm926ejs_examine_debug_reason(struct target *target)
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t arm926ejs_get_ttb(struct target *target)
|
static int arm926ejs_get_ttb(struct target *target, uint32_t *result)
|
||||||
{
|
{
|
||||||
struct arm926ejs_common *arm926ejs = target_to_arm926(target);
|
struct arm926ejs_common *arm926ejs = target_to_arm926(target);
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -332,7 +332,9 @@ static uint32_t arm926ejs_get_ttb(struct target *target)
|
||||||
if ((retval = arm926ejs->read_cp15(target, 0, 0, 2, 0, &ttb)) != ERROR_OK)
|
if ((retval = arm926ejs->read_cp15(target, 0, 0, 2, 0, &ttb)) != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
return ttb;
|
*result = ttb;
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arm926ejs_disable_mmu_caches(struct target *target, int mmu,
|
static void arm926ejs_disable_mmu_caches(struct target *target, int mmu,
|
||||||
|
|
|
@ -30,8 +30,11 @@ int armv4_5_mmu_translate_va(struct target *target, struct armv4_5_mmu_common *a
|
||||||
{
|
{
|
||||||
uint32_t first_lvl_descriptor = 0x0;
|
uint32_t first_lvl_descriptor = 0x0;
|
||||||
uint32_t second_lvl_descriptor = 0x0;
|
uint32_t second_lvl_descriptor = 0x0;
|
||||||
uint32_t ttb = armv4_5_mmu->get_ttb(target);
|
uint32_t ttb;
|
||||||
int retval;
|
int retval;
|
||||||
|
retval = armv4_5_mmu->get_ttb(target, &ttb);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
retval = armv4_5_mmu_read_physical(target, armv4_5_mmu,
|
retval = armv4_5_mmu_read_physical(target, armv4_5_mmu,
|
||||||
(ttb & 0xffffc000) | ((va & 0xfff00000) >> 18),
|
(ttb & 0xffffc000) | ((va & 0xfff00000) >> 18),
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct target;
|
||||||
|
|
||||||
struct armv4_5_mmu_common
|
struct armv4_5_mmu_common
|
||||||
{
|
{
|
||||||
uint32_t (*get_ttb)(struct target *target);
|
int (*get_ttb)(struct target *target, uint32_t *result);
|
||||||
int (*read_memory)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
|
int (*read_memory)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
|
||||||
int (*write_memory)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
|
int (*write_memory)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
|
||||||
void (*disable_mmu_caches)(struct target *target, int mmu, int d_u_cache, int i_cache);
|
void (*disable_mmu_caches)(struct target *target, int mmu, int d_u_cache, int i_cache);
|
||||||
|
|
|
@ -62,7 +62,7 @@ static void cortex_a8_disable_mmu_caches(struct target *target, int mmu,
|
||||||
int d_u_cache, int i_cache);
|
int d_u_cache, int i_cache);
|
||||||
static void cortex_a8_enable_mmu_caches(struct target *target, int mmu,
|
static void cortex_a8_enable_mmu_caches(struct target *target, int mmu,
|
||||||
int d_u_cache, int i_cache);
|
int d_u_cache, int i_cache);
|
||||||
static uint32_t cortex_a8_get_ttb(struct target *target);
|
static int cortex_a8_get_ttb(struct target *target, uint32_t *result);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1853,8 +1853,7 @@ static int cortex_a8_target_create(struct target *target, Jim_Interp *interp)
|
||||||
return cortex_a8_init_arch_info(target, cortex_a8, target->tap);
|
return cortex_a8_init_arch_info(target, cortex_a8, target->tap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIX! error propagation missing from this fn */
|
static int cortex_a8_get_ttb(struct target *target, uint32_t *result)
|
||||||
static uint32_t cortex_a8_get_ttb(struct target *target)
|
|
||||||
{
|
{
|
||||||
struct cortex_a8_common *cortex_a8 = target_to_cortex_a8(target);
|
struct cortex_a8_common *cortex_a8 = target_to_cortex_a8(target);
|
||||||
struct armv7a_common *armv7a = &cortex_a8->armv7a_common;
|
struct armv7a_common *armv7a = &cortex_a8->armv7a_common;
|
||||||
|
@ -1869,6 +1868,8 @@ static uint32_t cortex_a8_get_ttb(struct target *target)
|
||||||
0, 1, /* op1, op2 */
|
0, 1, /* op1, op2 */
|
||||||
2, 0, /* CRn, CRm */
|
2, 0, /* CRn, CRm */
|
||||||
&ttb);
|
&ttb);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
else if(cortex_a8->current_address_mode == ARM_MODE_USR)
|
else if(cortex_a8->current_address_mode == ARM_MODE_USR)
|
||||||
{
|
{
|
||||||
|
@ -1877,6 +1878,8 @@ static uint32_t cortex_a8_get_ttb(struct target *target)
|
||||||
0, 0, /* op1, op2 */
|
0, 0, /* op1, op2 */
|
||||||
2, 0, /* CRn, CRm */
|
2, 0, /* CRn, CRm */
|
||||||
&ttb);
|
&ttb);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
/* we don't know whose address is: user or kernel
|
/* we don't know whose address is: user or kernel
|
||||||
we assume that if we are in kernel mode then
|
we assume that if we are in kernel mode then
|
||||||
|
@ -1889,6 +1892,8 @@ static uint32_t cortex_a8_get_ttb(struct target *target)
|
||||||
0, 1, /* op1, op2 */
|
0, 1, /* op1, op2 */
|
||||||
2, 0, /* CRn, CRm */
|
2, 0, /* CRn, CRm */
|
||||||
&ttb);
|
&ttb);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
else if(armv7a->armv4_5_common.core_mode == ARM_MODE_USR)
|
else if(armv7a->armv4_5_common.core_mode == ARM_MODE_USR)
|
||||||
{
|
{
|
||||||
|
@ -1897,6 +1902,8 @@ static uint32_t cortex_a8_get_ttb(struct target *target)
|
||||||
0, 0, /* op1, op2 */
|
0, 0, /* op1, op2 */
|
||||||
2, 0, /* CRn, CRm */
|
2, 0, /* CRn, CRm */
|
||||||
&ttb);
|
&ttb);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
/* finally we don't know whose ttb to use: user or kernel */
|
/* finally we don't know whose ttb to use: user or kernel */
|
||||||
else
|
else
|
||||||
|
@ -1904,7 +1911,9 @@ static uint32_t cortex_a8_get_ttb(struct target *target)
|
||||||
|
|
||||||
ttb &= 0xffffc000;
|
ttb &= 0xffffc000;
|
||||||
|
|
||||||
return ttb;
|
*result = ttb;
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIX! error propagation missing from this fn */
|
/* FIX! error propagation missing from this fn */
|
||||||
|
|
|
@ -2002,15 +2002,20 @@ static int xscale_bulk_write_memory(struct target *target, uint32_t address,
|
||||||
return xscale_write_memory(target, address, 4, count, buffer);
|
return xscale_write_memory(target, address, 4, count, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t xscale_get_ttb(struct target *target)
|
static int xscale_get_ttb(struct target *target, uint32_t *result)
|
||||||
{
|
{
|
||||||
struct xscale_common *xscale = target_to_xscale(target);
|
struct xscale_common *xscale = target_to_xscale(target);
|
||||||
uint32_t ttb;
|
uint32_t ttb;
|
||||||
|
int retval;
|
||||||
|
|
||||||
xscale_get_reg(&xscale->reg_cache->reg_list[XSCALE_TTB]);
|
retval = xscale_get_reg(&xscale->reg_cache->reg_list[XSCALE_TTB]);
|
||||||
|
if (retval != ERROR_OK)
|
||||||
|
return retval;
|
||||||
ttb = buf_get_u32(xscale->reg_cache->reg_list[XSCALE_TTB].value, 0, 32);
|
ttb = buf_get_u32(xscale->reg_cache->reg_list[XSCALE_TTB].value, 0, 32);
|
||||||
|
|
||||||
return ttb;
|
*result = ttb;
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xscale_disable_mmu_caches(struct target *target, int mmu,
|
static void xscale_disable_mmu_caches(struct target *target, int mmu,
|
||||||
|
|
Loading…
Reference in New Issue