This is an automated email from Gerrit.

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

-- gerrit

commit 0d3274f7d010a66e1a4f2c39913dcc9c7cbd4075
Author: Dongxue Zhang <[email protected]>
Date:   Tue Oct 22 10:49:50 2013 +0800

    [PATCH 1/2]support64: Add functions into types and target common
    
    Add functions into types.h, target.c, target.h to operate 64bits data.
    Prepare for 64bits mips target.
    
    Change-Id: I668a8a5ac12ba754ae310fa6e92cfc91af850b1c
    Signed-off-by: Dongxue Zhang <[email protected]>

diff --git a/src/helper/types.h b/src/helper/types.h
index 3d27e83..b045ef6 100644
--- a/src/helper/types.h
+++ b/src/helper/types.h
@@ -5,6 +5,15 @@
  *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
  *   [email protected]                                               *
  *                                                                         *
+ *   Copyright (C) 2013 Dongxue Zhang                                      *
+ *   [email protected]                                                    *
+ *                                                                         *
+ *   Copyright (C) 2013 by FengGao                                         *
+ *   [email protected]                                                     *
+ *                                                                         *
+ *   Copyright (C) 2013 by Jia Liu                                         *
+ *   [email protected]                                                      *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -110,6 +119,17 @@ typedef bool _Bool;
  * Again, note that the "buf" pointer in memory is probably unaligned.
  */
 
+static inline uint64_t le_to_h_u64(const uint8_t *buf)
+{
+       return (uint64_t)((uint64_t)buf[0] |
+                         (uint64_t)buf[1] << 8 |
+                         (uint64_t)buf[2] << 16 |
+                         (uint64_t)buf[3] << 24 |
+                         (uint64_t)buf[4] << 32 |
+                         (uint64_t)buf[5] << 40 |
+                         (uint64_t)buf[6] << 48 |
+                         (uint64_t)buf[7] << 56);
+}
 
 static inline uint32_t le_to_h_u32(const uint8_t* buf)
 {
@@ -126,6 +146,18 @@ static inline uint16_t le_to_h_u16(const uint8_t* buf)
        return (uint16_t)(buf[0] | buf[1] << 8);
 }
 
+static inline uint64_t be_to_h_u64(const uint8_t *buf)
+{
+       return (uint64_t)((uint64_t)buf[7] |
+                         (uint64_t)buf[6] << 8 |
+                         (uint64_t)buf[5] << 16 |
+                         (uint64_t)buf[4] << 24 |
+                         (uint64_t)buf[3] << 32 |
+                         (uint64_t)buf[2] << 40 |
+                         (uint64_t)buf[1] << 48 |
+                         (uint64_t)buf[0] << 56);
+}
+
 static inline uint32_t be_to_h_u32(const uint8_t* buf)
 {
        return (uint32_t)(buf[3] | buf[2] << 8 | buf[1] << 16 | buf[0] << 24);
@@ -141,6 +173,30 @@ static inline uint16_t be_to_h_u16(const uint8_t* buf)
        return (uint16_t)(buf[1] | buf[0] << 8);
 }
 
+static inline void h_u64_to_le(uint8_t *buf, int64_t val)
+{
+       buf[7] = (uint8_t) (val >> 56);
+       buf[6] = (uint8_t) (val >> 48);
+       buf[5] = (uint8_t) (val >> 40);
+       buf[4] = (uint8_t) (val >> 32);
+       buf[3] = (uint8_t) (val >> 24);
+       buf[2] = (uint8_t) (val >> 16);
+       buf[1] = (uint8_t) (val >> 8);
+       buf[0] = (uint8_t) (val >> 0);
+}
+
+static inline void h_u64_to_be(uint8_t *buf, int64_t val)
+{
+       buf[0] = (uint8_t) (val >> 56);
+       buf[1] = (uint8_t) (val >> 48);
+       buf[2] = (uint8_t) (val >> 40);
+       buf[3] = (uint8_t) (val >> 32);
+       buf[4] = (uint8_t) (val >> 24);
+       buf[5] = (uint8_t) (val >> 16);
+       buf[6] = (uint8_t) (val >> 8);
+       buf[7] = (uint8_t) (val >> 0);
+}
+
 static inline void h_u32_to_le(uint8_t* buf, int val)
 {
        buf[3] = (uint8_t) (val >> 24);
diff --git a/src/target/target.c b/src/target/target.c
index 942dbc1..09ade4f 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -23,6 +23,15 @@
  *   Copyright (C) 2011 Andreas Fritiofson                                 *
  *   [email protected]                                          *
  *                                                                         *
+ *   Copyright (C) 2013 Dongxue Zhang                                      *
+ *   [email protected]                                                    *
+ *                                                                         *
+ *   Copyright (C) 2013 by FengGao                                         *
+ *   [email protected]                                                     *
+ *                                                                         *
+ *   Copyright (C) 2013 by Jia Liu                                         *
+ *   [email protected]                                                      *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -294,6 +303,15 @@ static int new_target_number(void)
        return x + 1;
 }
 
+/* read a uint64_t from a buffer in target memory endianness */
+uint64_t target_buffer_get_u64(struct target *target, const uint8_t *buffer)
+{
+       if (target->endianness == TARGET_LITTLE_ENDIAN)
+               return le_to_h_u64(buffer);
+       else
+               return be_to_h_u64(buffer);
+}
+
 /* read a uint32_t from a buffer in target memory endianness */
 uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
 {
@@ -327,6 +345,15 @@ static uint8_t target_buffer_get_u8(struct target *target, 
const uint8_t *buffer
        return *buffer & 0x0ff;
 }
 
+/* write a uint64_t to a buffer in target memory endianness */
+void target_buffer_set_u64(struct target *target, uint8_t *buffer, uint64_t 
value)
+{
+       if (target->endianness == TARGET_LITTLE_ENDIAN)
+               h_u64_to_le(buffer, value);
+       else
+               h_u64_to_be(buffer, value);
+}
+
 /* write a uint32_t to a buffer in target memory endianness */
 void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t 
value)
 {
@@ -360,6 +387,14 @@ static void target_buffer_set_u8(struct target *target, 
uint8_t *buffer, uint8_t
        *buffer = value;
 }
 
+/* write a uint64_t array to a buffer in target memory endianness */
+void target_buffer_get_u64_array(struct target *target, const uint8_t *buffer, 
uint32_t count, uint64_t *dstbuf)
+{
+       uint32_t i;
+       for (i = 0; i < count; i++)
+               dstbuf[i] = target_buffer_get_u64(target, &buffer[i * 8]);
+}
+
 /* write a uint32_t array to a buffer in target memory endianness */
 void target_buffer_get_u32_array(struct target *target, const uint8_t *buffer, 
uint32_t count, uint32_t *dstbuf)
 {
@@ -376,6 +411,14 @@ void target_buffer_get_u16_array(struct target *target, 
const uint8_t *buffer, u
                dstbuf[i] = target_buffer_get_u16(target, &buffer[i * 2]);
 }
 
+/* write a uint64_t array to a buffer in target memory endianness */
+void target_buffer_set_u64_array(struct target *target, uint8_t *buffer, 
uint32_t count, uint64_t *srcbuf)
+{
+       uint32_t i;
+       for (i = 0; i < count; i++)
+               target_buffer_set_u64(target, &buffer[i * 8], srcbuf[i]);
+}
+
 /* write a uint32_t array to a buffer in target memory endianness */
 void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, 
uint32_t count, uint32_t *srcbuf)
 {
@@ -1983,6 +2026,30 @@ int target_blank_check_memory(struct target *target, 
uint32_t address, uint32_t
        return retval;
 }
 
+int target_read_u64(struct target *target, uint64_t address, uint64_t *value)
+{
+       uint8_t value_buf[8];
+       if (!target_was_examined(target)) {
+               LOG_ERROR("Target not examined yet");
+               return ERROR_FAIL;
+       }
+
+       int retval = target_read_memory(target, address, 8, 1, value_buf);
+
+       if (retval == ERROR_OK) {
+               *value = target_buffer_get_u64(target, value_buf);
+               LOG_DEBUG("address: 0x%" PRIx64 ", value: 0x%16.16" PRIx64 "",
+                                 address,
+                                 *value);
+       } else {
+               *value = 0x0;
+               LOG_DEBUG("address: 0x%" PRIx64 " failed",
+                                 address);
+       }
+
+       return retval;
+}
+
 int target_read_u32(struct target *target, uint32_t address, uint32_t *value)
 {
        uint8_t value_buf[4];
@@ -2053,6 +2120,27 @@ int target_read_u8(struct target *target, uint32_t 
address, uint8_t *value)
        return retval;
 }
 
+int target_write_u64(struct target *target, uint64_t address, uint64_t value)
+{
+       int retval;
+       uint8_t value_buf[8];
+       if (!target_was_examined(target)) {
+               LOG_ERROR("Target not examined yet");
+               return ERROR_FAIL;
+       }
+
+       LOG_DEBUG("address: 0x%" PRIx64 ", value: 0x%16.16" PRIx64 "",
+                         address,
+                         value);
+
+       target_buffer_set_u64(target, value_buf, value);
+       retval = target_write_memory(target, address, 8, 1, value_buf);
+       if (retval != ERROR_OK)
+               LOG_DEBUG("failed: %i", retval);
+
+       return retval;
+}
+
 int target_write_u32(struct target *target, uint32_t address, uint32_t value)
 {
        int retval;
diff --git a/src/target/target.h b/src/target/target.h
index 44f382a..c14b430 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -14,6 +14,15 @@
  *   Copyright (C) ST-Ericsson SA 2011                                     *
  *   [email protected] : smp minimum support                    *
  *                                                                         *
+ *   Copyright (C) 2013 Dongxue Zhang                                      *
+ *   [email protected]                                                    *
+ *                                                                         *
+ *   Copyright (C) 2013 by FengGao                                         *
+ *   [email protected]                                                     *
+ *                                                                         *
+ *   Copyright (C) 2013 by Jia Liu                                         *
+ *   [email protected]                                                      *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -593,21 +602,27 @@ uint32_t target_get_working_area_avail(struct target 
*target);
 
 extern struct target *all_targets;
 
+uint64_t target_buffer_get_u64(struct target *target, const uint8_t *buffer);
 uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer);
 uint32_t target_buffer_get_u24(struct target *target, const uint8_t *buffer);
 uint16_t target_buffer_get_u16(struct target *target, const uint8_t *buffer);
+void target_buffer_set_u64(struct target *target, uint8_t *buffer, uint64_t 
value);
 void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t 
value);
 void target_buffer_set_u24(struct target *target, uint8_t *buffer, uint32_t 
value);
 void target_buffer_set_u16(struct target *target, uint8_t *buffer, uint16_t 
value);
 
+void target_buffer_get_u64_array(struct target *target, const uint8_t *buffer, 
uint32_t count, uint64_t *dstbuf);
 void target_buffer_get_u32_array(struct target *target, const uint8_t *buffer, 
uint32_t count, uint32_t *dstbuf);
 void target_buffer_get_u16_array(struct target *target, const uint8_t *buffer, 
uint32_t count, uint16_t *dstbuf);
+void target_buffer_set_u64_array(struct target *target, uint8_t *buffer, 
uint32_t count, uint64_t *srcbuf);
 void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, 
uint32_t count, uint32_t *srcbuf);
 void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, 
uint32_t count, uint16_t *srcbuf);
 
+int target_read_u64(struct target *target, uint64_t address, uint64_t *value);
 int target_read_u32(struct target *target, uint32_t address, uint32_t *value);
 int target_read_u16(struct target *target, uint32_t address, uint16_t *value);
 int target_read_u8(struct target *target, uint32_t address, uint8_t *value);
+int target_write_u64(struct target *target, uint64_t address, uint64_t value);
 int target_write_u32(struct target *target, uint32_t address, uint32_t value);
 int target_write_u16(struct target *target, uint32_t address, uint16_t value);
 int target_write_u8(struct target *target, uint32_t address, uint8_t value);

-- 

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to