aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Griffin <peter.griffin@linaro.org>2015-07-09 08:35:50 +0100
committerPeter Griffin <peter.griffin@linaro.org>2015-07-09 08:35:50 +0100
commit45d1f3c3ebf1a0677508bc33edad82d36e937804 (patch)
tree05c6acee54b73510b279579f68ff41455139b1f8
parentabd7ad027ff3caa3887f449492eb8ff77f2eb02a (diff)
changes to get thread-awareness working on snowballsnowball-linux-awareness
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
-rw-r--r--src/rtos/linux.c57
-rw-r--r--src/rtos/linux_header.h14
-rw-r--r--src/rtos/rtos.c6
-rw-r--r--src/target/armv4_5.c7
-rw-r--r--src/target/cortex_a.c33
5 files changed, 103 insertions, 14 deletions
diff --git a/src/rtos/linux.c b/src/rtos/linux.c
index c28236d3..bb3e4ef8 100644
--- a/src/rtos/linux.c
+++ b/src/rtos/linux.c
@@ -36,7 +36,7 @@
#define LINUX_USER_KERNEL_BORDER 0xc0000000
#include "linux_header.h"
-#define PHYS
+//#define PHYS
#define MAX_THREADS 200
/* specific task */
struct linux_os {
@@ -114,7 +114,7 @@ static int linux_compute_virt2phys(struct target *target, uint32_t address)
uint32_t pa = 0;
int retval = target->type->virt2phys(target, address, &pa);
if (retval != ERROR_OK) {
- LOG_ERROR("Cannot compute linux virt2phys translation");
+ LOG_ERROR("%s Cannot compute linux virt2phys translation addr=0x%x", __func__, address);
/* fixes default address */
linux_os->phys_base = 0;
return ERROR_FAIL;
@@ -136,7 +136,7 @@ static int linux_read_memory(struct target *target,
uint32_t pa = (address & linux_os->phys_mask) + linux_os->phys_base;
#endif
if (address < 0xc000000) {
- LOG_ERROR("linux awareness : address in user space");
+ LOG_ERROR("linux awareness : address 0x%x in user space", address);
return ERROR_FAIL;
}
#ifdef PHYS
@@ -187,6 +187,9 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
char *hex_string;
int found = 0;
int retval;
+
+ LOG_INFO("linux_os_thread_reg_list ()+\n");
+
/* check if a current thread is requested */
next = tmp;
@@ -198,6 +201,8 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
} while ((found == 0) && (next != tmp) && (next != NULL));
if (found == 1) {
+
+ LOG_INFO("found == 1\n");
/* search target to perfom the access */
struct reg **reg_list;
int reg_list_size, reg_packet_size = 0;
@@ -223,14 +228,15 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
return ERROR_FAIL;
}
- /*LOG_INFO("thread %lx current on core %x",thread_id,
- * target->coreid);*/
+ LOG_INFO("thread %lx current on core %x",thread_id, target->coreid);
retval =
target_get_gdb_reg_list(target, &reg_list, &reg_list_size,
REG_CLASS_GENERAL);
- if (retval != ERROR_OK)
+ if (retval != ERROR_OK) {
+ LOG_ERROR("failed getting thread reg list\n");
return retval;
+ }
for (i = 0; i < reg_list_size; i++)
reg_packet_size += reg_list[i]->size;
@@ -253,6 +259,7 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
free(reg_list);
} else {
+ LOG_INFO("found == 0\n");
struct threads *temp = linux_os->thread_list;
*hex_reg_list = calloc(1, 500 * sizeof(char));
hex_string = *hex_reg_list;
@@ -301,8 +308,8 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
hex_string =
reg_converter(hex_string, &temp->context->PC, 4);
- for (i = 0; i < 100; i++) /*100 */
- hex_string += sprintf(hex_string, "%02x", 0);
+// for (i = 0; i < 100; i++) /*100 */
+// hex_string += sprintf(hex_string, "%02x", 0);
uint32_t cpsr = 0x00000000;
reg_converter(hex_string, &cpsr, 4);
@@ -438,6 +445,11 @@ int get_name(struct target *target, struct threads *t)
for (i = 0; i < 17; i++)
t->name[i] = 0;
+/* LOG_INFO("full_name[0] = 0x%x\n",full_name[0]);
+ LOG_INFO("full_name[1] = 0x%x\n",full_name[1]);
+ LOG_INFO("full_name[2] = 0x%x\n",full_name[2]);
+ LOG_INFO("full_name[3] = 0x%x\n",full_name[3]);*/
+
retval = linux_read_memory(target, comm, 4, 4, (uint8_t *) full_name);
if (retval != ERROR_OK) {
@@ -445,6 +457,26 @@ int get_name(struct target *target, struct threads *t)
return ERROR_FAIL;
}
+/* LOG_INFO("full_name[0] = 0x%x\n",full_name[0]);
+ LOG_INFO("full_name[1] = 0x%x\n",full_name[1]);
+ LOG_INFO("full_name[2] = 0x%x\n",full_name[2]);
+ LOG_INFO("full_name[3] = 0x%x\n",full_name[3]);*/
+
+ retval = linux_read_memory(target, comm, 4, 1, (uint8_t *) &full_name[0]);
+
+ comm += 4;
+ retval = linux_read_memory(target, comm, 4, 1, (uint8_t *) &full_name[1]);
+ comm += 4;
+ retval = linux_read_memory(target, comm, 4, 1, (uint8_t *) &full_name[2]);
+ comm += 4;
+ retval = linux_read_memory(target, comm, 4, 1, (uint8_t *) &full_name[3]);
+
+/* LOG_INFO("pete full_name[0] = 0x%x\n",full_name[0]);
+ LOG_INFO("pete full_name[1] = 0x%x\n",full_name[1]);
+ LOG_INFO("pete full_name[2] = 0x%x\n",full_name[2]);
+ LOG_INFO("pete full_name[3] = 0x%x\n",full_name[3]);*/
+
+
uint32_t raw_name = target_buffer_get_u32(target,
(const uint8_t *)
&full_name[0]);
@@ -548,7 +580,7 @@ int get_current(struct target *target, int create)
#ifdef PID_CHECK
ct->pid = t->pid;
#endif
- /*LOG_INFO("Creation of current thread %s",t->name);*/
+ LOG_INFO("Creation of current thread %s",t->name);
}
}
}
@@ -573,6 +605,7 @@ struct cpu_context *cpu_context_read(struct target *target, uint32_t base_addr,
uint32_t thread_info_addr = 0;
uint32_t thread_info_addr_update = 0;
int retval = ERROR_FAIL;
+// int i;
context->R4 = 0xdeadbeef;
context->R5 = 0xdeadbeef;
context->R6 = 0xdeadbeef;
@@ -623,6 +656,10 @@ retry:
retval = linux_read_memory(target, thread_info_addr, 4, 10,
(uint8_t *) registers);
+// for (i=0; i<10; i++) {
+// LOG_INFO("%s registers[%d] = 0x%x\n",__func__, i, registers[i]);
+// }
+
if (retval != ERROR_OK) {
free(buffer);
LOG_ERROR("cpu_context: unable to read memory\n");
@@ -825,7 +862,7 @@ int linux_get_tasks(struct target *target, int context)
cpu_context_read(target, t->base_addr,
&t->thread_info_addr);
} else {
- /*LOG_INFO("thread %s is a current thread already created",t->name); */
+ LOG_INFO("thread %s is a current thread already created",t->name);
free(t);
}
diff --git a/src/rtos/linux_header.h b/src/rtos/linux_header.h
index faaf319b..92973aa8 100644
--- a/src/rtos/linux_header.h
+++ b/src/rtos/linux_header.h
@@ -21,6 +21,19 @@ define awareness
printf "#define MM_CTX %p\n",&((struct mm_struct *)(0))->context
end
*/
+
+/* Pete generated on v4.1-rc4 */
+#define QAT 0x4
+#define NEXT 0x164
+#define COMM 0x2e8
+#define MEM 0x18c
+#define ONCPU 0x18
+#define PID 0x208
+#define CPU_CONT 0x18
+#define PREEMPT 0x4
+#define MM_CTX 0x168
+
+/*
#define QAT 0x4
#define NEXT 0x1b0
#define COMM 0x2d4
@@ -30,3 +43,4 @@ define awareness
#define CPU_CONT 0x1c
#define PREEMPT 0x4
#define MM_CTX 0x160
+*/
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 3420d06b..984d671c 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -422,6 +422,9 @@ int rtos_get_gdb_reg_list(struct connection *connection)
{
struct target *target = get_target_from_connection(connection);
int64_t current_threadid = target->rtos->current_threadid;
+
+ LOG_DEBUG("()+");
+
if ((target->rtos != NULL) && (current_threadid != -1) &&
(current_threadid != 0) &&
((current_threadid != target->rtos->current_thread) ||
@@ -438,11 +441,14 @@ int rtos_get_gdb_reg_list(struct connection *connection)
&hex_reg_list);
if (hex_reg_list != NULL) {
+ LOG_DEBUG("gdb_put_packet strlen=%d",(int)strlen(hex_reg_list));
gdb_put_packet(connection, hex_reg_list, strlen(hex_reg_list));
free(hex_reg_list);
return ERROR_OK;
}
}
+
+ LOG_DEBUG("()+");
return ERROR_FAIL;
}
diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c
index e75fe99c..5e7a371f 100644
--- a/src/target/armv4_5.c
+++ b/src/target/armv4_5.c
@@ -1120,7 +1120,10 @@ int arm_get_gdb_reg_list(struct target *target,
switch (reg_class) {
case REG_CLASS_GENERAL:
+
*reg_list_size = 26;
+// LOG_DEBUG("REG_CLASS_GENERAL size=%d\n",*reg_list_size);
+
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
for (i = 0; i < 16; i++)
@@ -1137,7 +1140,11 @@ int arm_get_gdb_reg_list(struct target *target,
break;
case REG_CLASS_ALL:
+
*reg_list_size = (arm->core_type != ARM_MODE_MON ? 48 : 51);
+
+// LOG_DEBUG("REG_CLASS_ALL size=%d\n",*reg_list_size);
+
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
for (i = 0; i < 16; i++)
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index 207fb811..79905a8d 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -864,8 +864,12 @@ static int cortex_a_poll(struct target *target)
}
retval = mem_ap_sel_read_atomic_u32(swjdp, armv7a->debug_ap,
armv7a->debug_base + CPUDBG_DSCR, &dscr);
+
+#if 0
if (retval != ERROR_OK)
return retval;
+#endif
+
cortex_a->cpudbg_dscr = dscr;
if (DSCR_RUN_MODE(dscr) == (DSCR_CORE_HALTED | DSCR_CORE_RESTARTED)) {
@@ -2032,6 +2036,8 @@ static int cortex_a_write_apb_ab_memory_slow(struct target *target,
* - Address is in R0.
* - R0 is marked dirty.
*/
+
+ LOG_DEBUG(" ()+");
struct armv7a_common *armv7a = target_to_armv7a(target);
struct adiv5_dap *swjdp = armv7a->arm.dap;
struct arm *arm = &armv7a->arm;
@@ -2106,6 +2112,8 @@ static int cortex_a_write_apb_ab_memory_fast(struct target *target,
* - Address is in R0 and must be a multiple of 4.
* - R0 is marked dirty.
*/
+
+ LOG_DEBUG(" ()+");
struct armv7a_common *armv7a = target_to_armv7a(target);
struct adiv5_dap *swjdp = armv7a->arm.dap;
int retval;
@@ -2278,6 +2286,8 @@ static int cortex_a_read_apb_ab_memory_slow(struct target *target,
* - Address is in R0.
* - R0 is marked dirty.
*/
+
+ LOG_DEBUG(" ()+");
struct armv7a_common *armv7a = target_to_armv7a(target);
struct adiv5_dap *swjdp = armv7a->arm.dap;
struct arm *arm = &armv7a->arm;
@@ -2340,6 +2350,8 @@ static int cortex_a_read_apb_ab_memory_slow(struct target *target,
--count;
}
+ LOG_DEBUG(" ()-");
+
return ERROR_OK;
}
@@ -2358,6 +2370,8 @@ static int cortex_a_read_apb_ab_memory_fast(struct target *target,
uint32_t new_dscr, u32;
int retval;
+ LOG_DEBUG(" ()+");
+
/* Switch to non-blocking mode if not already in that mode. */
retval = cortex_a_set_dcc_mode(target, DSCR_EXT_DCC_NON_BLOCKING, dscr);
if (retval != ERROR_OK)
@@ -2428,6 +2442,8 @@ static int cortex_a_read_apb_ab_memory_fast(struct target *target,
return retval;
target_buffer_set_u32(target, buffer, u32);
+ LOG_DEBUG(" ()-");
+
return ERROR_OK;
}
@@ -2486,15 +2502,24 @@ static int cortex_a_read_apb_ab_memory(struct target *target,
if (retval != ERROR_OK)
goto out;
- if (size == 4 && (address % 4) == 0) {
- /* We are doing a word-aligned transfer, so use fast mode. */
+ if (size == 0xdeadbeef)
retval = cortex_a_read_apb_ab_memory_fast(target, count, buffer, &dscr);
- } else {
+
+// if (size == 4 && (address % 4) == 0) {
+// LOG_DEBUG("We are doing a word-aligned transfer, so use fast mode");
+// /* We are doing a word-aligned transfer, so use fast mode. */
+// retval = cortex_a_read_apb_ab_memory_fast(target, count, buffer, &dscr);
+// } else {
/* Use slow path. */
+ LOG_DEBUG("not aligned use slow mode");
retval = cortex_a_read_apb_ab_memory_slow(target, size, count, buffer, &dscr);
- }
+// }
+
+ LOG_DEBUG("Normal out");
out:
+ LOG_DEBUG("Error out");
+
final_retval = retval;
/* Switch to non-blocking mode if not already in that mode. */