gerrit
2017-05-18 09:08:37 UTC
This is an automated email from Gerrit.
Salvador Arroyo (***@yahoo.es) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4138
-- gerrit
commit e7af83e7c067c8d3243a38a67860d64196face22
Author: Salvador Arroyo <***@yahoo.es>
Date: Thu May 18 11:00:29 2017 +0200
mips32: some fixes
mips32_run_algorithm(), restore target context, propagate
return value.
Fix code to prevent fasdata handler overwrite.
Fix KSEGX() macro, addresses from 0x20000000 to 0x7fffffff
are in KUSEG.
Change-Id: Ia767a6b1851aefe9ac458b91b132ebb1257a7748
Signed-off-by: Salvador Arroyo <***@yahoo.es>
diff --git a/src/target/mips32.c b/src/target/mips32.c
index 7881275..06b892a 100644
--- a/src/target/mips32.c
+++ b/src/target/mips32.c
@@ -271,21 +271,17 @@ int mips32_save_context(struct target *target)
int mips32_restore_context(struct target *target)
{
- unsigned int i;
-
/* get pointers to arch-specific information */
struct mips32_common *mips32 = target_to_mips32(target);
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
- for (i = 0; i < MIPS32_NUM_REGS; i++) {
+ for (unsigned i = 0; i < MIPS32_NUM_REGS; i++) {
if (mips32->core_cache->reg_list[i].dirty)
mips32->write_core_reg(target, i);
}
/* write core regs */
- mips32_pracc_write_regs(ejtag_info, mips32->core_regs);
-
- return ERROR_OK;
+ return mips32_pracc_write_regs(ejtag_info, mips32->core_regs);
}
int mips32_arch_state(struct target *target)
@@ -534,7 +530,7 @@ int mips32_run_algorithm(struct target *target, int num_mem_params,
mips32->isa_mode = isa_mode;
- return ERROR_OK;
+ return mips32_restore_context(target);
}
int mips32_examine(struct target *target)
diff --git a/src/target/mips32.h b/src/target/mips32.h
index 8454980..9f2bb95 100644
--- a/src/target/mips32.h
+++ b/src/target/mips32.h
@@ -40,7 +40,7 @@
#define KSEG3 0xe0000000
/** Returns the kernel segment base of a given address */
-#define KSEGX(a) ((a) & 0xe0000000)
+#define KSEGX(a) ((a) & 1 << 31 ? (a) & 0xe0000000 : KUSEG)
/** CP0 CONFIG register fields */
#define MIPS32_CONFIG0_KU_SHIFT 25
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index 2798fdc..dd351d7 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -1207,7 +1207,6 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
struct working_area *fast_data_area;
int retval;
- int write_t = 1;
LOG_DEBUG("address: " TARGET_ADDR_FMT ", count: 0x%8.8" PRIx32 "",
address, count);
@@ -1235,13 +1234,14 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
fast_data_area = mips32->fast_data_area;
- if (address <= fast_data_area->address + fast_data_area->size &&
- fast_data_area->address <= address + count) {
+ /* prevent handler overwrite, but only if in the same kernel segment */
+ if (address < fast_data_area->address + fast_data_area->size &&
+ fast_data_area->address < address + count * 4) {
LOG_ERROR("fast_data (" TARGET_ADDR_FMT ") is within write area "
"(" TARGET_ADDR_FMT "-" TARGET_ADDR_FMT ").",
- fast_data_area->address, address, address + count);
+ fast_data_area->address, address, address + count * 4);
LOG_ERROR("Change work-area-phys or load_image address!");
- return ERROR_FAIL;
+ return ERROR_OK; /* if not, will be overwritten by default write function */
}
/* mips32_pracc_fastdata_xfer requires uint32_t in host endianness, */
@@ -1255,6 +1255,7 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
target_buffer_get_u32_array(target, buffer, count, t);
+ int write_t = 1;
retval = mips32_pracc_fastdata_xfer(ejtag_info, mips32->fast_data_area, write_t, address,
count, t);
--
Salvador Arroyo (***@yahoo.es) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4138
-- gerrit
commit e7af83e7c067c8d3243a38a67860d64196face22
Author: Salvador Arroyo <***@yahoo.es>
Date: Thu May 18 11:00:29 2017 +0200
mips32: some fixes
mips32_run_algorithm(), restore target context, propagate
return value.
Fix code to prevent fasdata handler overwrite.
Fix KSEGX() macro, addresses from 0x20000000 to 0x7fffffff
are in KUSEG.
Change-Id: Ia767a6b1851aefe9ac458b91b132ebb1257a7748
Signed-off-by: Salvador Arroyo <***@yahoo.es>
diff --git a/src/target/mips32.c b/src/target/mips32.c
index 7881275..06b892a 100644
--- a/src/target/mips32.c
+++ b/src/target/mips32.c
@@ -271,21 +271,17 @@ int mips32_save_context(struct target *target)
int mips32_restore_context(struct target *target)
{
- unsigned int i;
-
/* get pointers to arch-specific information */
struct mips32_common *mips32 = target_to_mips32(target);
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
- for (i = 0; i < MIPS32_NUM_REGS; i++) {
+ for (unsigned i = 0; i < MIPS32_NUM_REGS; i++) {
if (mips32->core_cache->reg_list[i].dirty)
mips32->write_core_reg(target, i);
}
/* write core regs */
- mips32_pracc_write_regs(ejtag_info, mips32->core_regs);
-
- return ERROR_OK;
+ return mips32_pracc_write_regs(ejtag_info, mips32->core_regs);
}
int mips32_arch_state(struct target *target)
@@ -534,7 +530,7 @@ int mips32_run_algorithm(struct target *target, int num_mem_params,
mips32->isa_mode = isa_mode;
- return ERROR_OK;
+ return mips32_restore_context(target);
}
int mips32_examine(struct target *target)
diff --git a/src/target/mips32.h b/src/target/mips32.h
index 8454980..9f2bb95 100644
--- a/src/target/mips32.h
+++ b/src/target/mips32.h
@@ -40,7 +40,7 @@
#define KSEG3 0xe0000000
/** Returns the kernel segment base of a given address */
-#define KSEGX(a) ((a) & 0xe0000000)
+#define KSEGX(a) ((a) & 1 << 31 ? (a) & 0xe0000000 : KUSEG)
/** CP0 CONFIG register fields */
#define MIPS32_CONFIG0_KU_SHIFT 25
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index 2798fdc..dd351d7 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -1207,7 +1207,6 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
struct working_area *fast_data_area;
int retval;
- int write_t = 1;
LOG_DEBUG("address: " TARGET_ADDR_FMT ", count: 0x%8.8" PRIx32 "",
address, count);
@@ -1235,13 +1234,14 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
fast_data_area = mips32->fast_data_area;
- if (address <= fast_data_area->address + fast_data_area->size &&
- fast_data_area->address <= address + count) {
+ /* prevent handler overwrite, but only if in the same kernel segment */
+ if (address < fast_data_area->address + fast_data_area->size &&
+ fast_data_area->address < address + count * 4) {
LOG_ERROR("fast_data (" TARGET_ADDR_FMT ") is within write area "
"(" TARGET_ADDR_FMT "-" TARGET_ADDR_FMT ").",
- fast_data_area->address, address, address + count);
+ fast_data_area->address, address, address + count * 4);
LOG_ERROR("Change work-area-phys or load_image address!");
- return ERROR_FAIL;
+ return ERROR_OK; /* if not, will be overwritten by default write function */
}
/* mips32_pracc_fastdata_xfer requires uint32_t in host endianness, */
@@ -1255,6 +1255,7 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
target_buffer_get_u32_array(target, buffer, count, t);
+ int write_t = 1;
retval = mips32_pracc_fastdata_xfer(ejtag_info, mips32->fast_data_area, write_t, address,
count, t);
--