This is an automated email from Gerrit.

Peter Mamonov ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/4028

-- gerrit

commit 72c3569d81093704c29e548cc31df74a08b326f5
Author: Peter Mamonov <[email protected]>
Date:   Wed Jun 1 13:31:03 2016 +0300

    mips64: sign extend addresses if mips64mode32 is enabled
    
    Change-Id: Ibae7fdc2bac0b0aa4ad4a5651be3e29f762b2f91
    Signed-off-by: Peter Mamonov <[email protected]>

diff --git a/src/target/mips_mips64.c b/src/target/mips_mips64.c
index 381e6c5..57619e7 100644
--- a/src/target/mips_mips64.c
+++ b/src/target/mips_mips64.c
@@ -44,6 +44,15 @@ static int mips_mips64_set_breakpoint(struct target *target,
 static int mips_mips64_unset_breakpoint(struct target *target,
                struct breakpoint *breakpoint);
 
+static uint64_t mips64_extend_sign(uint64_t addr)
+{
+       if (addr >> 32)
+               return addr;
+       if (addr >> 31)
+               return addr | (ULLONG_MAX << 32);
+       return addr;
+}
+
 static int mips_mips64_examine_debug_reason(struct target *target)
 {
        if ((target->debug_reason != DBG_REASON_DBGRQ)
@@ -243,6 +252,9 @@ static int mips_mips64_resume(struct target *target, int 
current, uint64_t addre
        struct breakpoint *breakpoint = NULL;
        uint64_t resume_pc;
 
+       if (mips64mode32)
+               address = mips64_extend_sign(address);
+
        if (target->state != TARGET_HALTED) {
                LOG_WARNING("target not halted %d", target->state);
                return ERROR_TARGET_NOT_HALTED;
@@ -307,6 +319,9 @@ static int mips_mips64_step(struct target *target, int 
current, uint64_t address
        struct mips_ejtag *ejtag_info = &mips64->ejtag_info;
        struct breakpoint *breakpoint = NULL;
 
+       if (mips64mode32)
+               address = mips64_extend_sign(address);
+
        if (target->state != TARGET_HALTED) {
                LOG_WARNING("target not halted");
                return ERROR_TARGET_NOT_HALTED;
@@ -510,6 +525,9 @@ static int mips_mips64_add_breakpoint(struct target 
*target, struct breakpoint *
 {
        mips64_common_t *mips64 = target->arch_info;
 
+       if (mips64mode32)
+               breakpoint->address = mips64_extend_sign(breakpoint->address);
+
        if (breakpoint->type == BKPT_HARD) {
                if (mips64->num_inst_bpoints_avail < 1) {
                        LOG_INFO("no hardware breakpoint available");
@@ -686,6 +704,9 @@ static int mips_mips64_read_memory(struct target *target, 
uint64_t address,
        mips64_common_t *mips64 = target->arch_info;
        struct mips_ejtag *ejtag_info = &mips64->ejtag_info;
 
+       if (mips64mode32)
+               address = mips64_extend_sign(address);
+
        LOG_DEBUG("address: 0x%16.16" PRIx64 ", size: 0x%8.8" PRIx32 ", count: 
0x%8.8" PRIx32 "", address, size, count);
 
        if (target->state != TARGET_HALTED) {
@@ -817,6 +838,9 @@ static int mips_mips64_write_memory(struct target *target, 
uint64_t address,
        struct mips_ejtag *ejtag_info = &mips64->ejtag_info;
        int retval;
 
+       if (mips64mode32)
+               address = mips64_extend_sign(address);
+
        LOG_DEBUG("address: 0x%16.16" PRIx64 ", size: 0x%8.8" PRIx32 ", count: 
0x%8.8" PRIx32 "", address, size, count);
 
        if (target->state != TARGET_HALTED) {

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to