debuggers: import openocd-0.7.0

Initial check-in of openocd-0.7.0 as it can be downloaded from
http://sourceforge.net/projects/openocd/files/openocd/0.7.0/

Any modifications will follow.

Change-Id: I6949beaefd589e046395ea0cb80f4e1ab1654d55
This commit is contained in:
Lars Rademacher
2013-10-21 00:50:02 +02:00
parent 85fffe007e
commit 83d72a091e
1148 changed files with 571445 additions and 0 deletions

View File

@ -0,0 +1,557 @@
/***************************************************************************
* Copyright (C) 2012 by Matthias Blaicher *
* Matthias Blaicher - matthias@blaicher.com *
* *
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "target/armv7m.h"
#include "target/cortex_m.h"
#include "rtos.h"
#include "helper/log.h"
#include "helper/types.h"
#include "rtos_chibios_stackings.h"
/**
* @brief ChibiOS/RT memory signature record.
*
* @details Definition copied from os/kernel/include/chregistry.h of ChibiOS/RT.
*/
struct ChibiOS_chdebug {
char ch_identifier[4]; /**< @brief Always set to "main". */
uint8_t ch_zero; /**< @brief Must be zero. */
uint8_t ch_size; /**< @brief Size of this structure. */
uint16_t ch_version; /**< @brief Encoded ChibiOS/RT version. */
uint8_t ch_ptrsize; /**< @brief Size of a pointer. */
uint8_t ch_timesize; /**< @brief Size of a @p systime_t. */
uint8_t ch_threadsize; /**< @brief Size of a @p Thread struct. */
uint8_t cf_off_prio; /**< @brief Offset of @p p_prio field. */
uint8_t cf_off_ctx; /**< @brief Offset of @p p_ctx field. */
uint8_t cf_off_newer; /**< @brief Offset of @p p_newer field. */
uint8_t cf_off_older; /**< @brief Offset of @p p_older field. */
uint8_t cf_off_name; /**< @brief Offset of @p p_name field. */
uint8_t cf_off_stklimit; /**< @brief Offset of @p p_stklimit
field. */
uint8_t cf_off_state; /**< @brief Offset of @p p_state field. */
uint8_t cf_off_flags; /**< @brief Offset of @p p_flags field. */
uint8_t cf_off_refs; /**< @brief Offset of @p p_refs field. */
uint8_t cf_off_preempt; /**< @brief Offset of @p p_preempt
field. */
uint8_t cf_off_time; /**< @brief Offset of @p p_time field. */
};
#define GET_CH_KERNEL_MAJOR(codedVersion) ((codedVersion >> 11) & 0x1f)
#define GET_CH_KERNEL_MINOR(codedVersion) ((codedVersion >> 6) & 0x1f)
#define GET_CH_KERNEL_PATCH(codedVersion) ((codedVersion >> 0) & 0x3f)
/**
* @brief ChibiOS thread states.
*/
const char *ChibiOS_thread_states[] = {
"READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING",
"WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE",
"FINAL"
};
#define CHIBIOS_NUM_STATES (sizeof(ChibiOS_thread_states)/sizeof(char *))
/* Maximum ChibiOS thread name. There is no real limit set by ChibiOS but 64
* chars ought to be enough.
*/
#define CHIBIOS_THREAD_NAME_STR_SIZE (64)
struct ChibiOS_params {
const char *target_name;
struct ChibiOS_chdebug *signature;
const struct rtos_register_stacking *stacking_info;
};
struct ChibiOS_params ChibiOS_params_list[] = {
{
"cortex_m", /* target_name */
0,
NULL, /* stacking_info */
},
{
"hla_target", /* target_name */
0,
NULL, /* stacking_info */
}
};
#define CHIBIOS_NUM_PARAMS ((int)(sizeof(ChibiOS_params_list)/sizeof(struct ChibiOS_params)))
static int ChibiOS_detect_rtos(struct target *target);
static int ChibiOS_create(struct target *target);
static int ChibiOS_update_threads(struct rtos *rtos);
static int ChibiOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
static int ChibiOS_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[]);
struct rtos_type ChibiOS_rtos = {
.name = "ChibiOS",
.detect_rtos = ChibiOS_detect_rtos,
.create = ChibiOS_create,
.update_threads = ChibiOS_update_threads,
.get_thread_reg_list = ChibiOS_get_thread_reg_list,
.get_symbol_list_to_lookup = ChibiOS_get_symbol_list_to_lookup,
};
enum ChibiOS_symbol_values {
ChibiOS_VAL_rlist = 0,
ChibiOS_VAL_ch_debug = 1,
ChibiOS_VAL_chSysInit = 2
};
static char *ChibiOS_symbol_list[] = {
"rlist", /* Thread ready list*/
"ch_debug", /* Memory Signatur containing offsets of fields in rlist*/
"chSysInit", /* Necessary part of API, used for ChibiOS detection*/
NULL
};
static int ChibiOS_update_memory_signature(struct rtos *rtos)
{
int retval;
struct ChibiOS_params *param;
struct ChibiOS_chdebug *signature;
param = (struct ChibiOS_params *) rtos->rtos_specific_params;
/* Free existing memory description.*/
if (param->signature) {
free(param->signature);
param->signature = 0;
}
signature = malloc(sizeof(*signature));
if (!signature) {
LOG_ERROR("Could not allocate space for ChibiOS/RT memory signature");
return -1;
}
retval = target_read_buffer(rtos->target,
rtos->symbols[ChibiOS_VAL_ch_debug].address,
sizeof(*signature),
(uint8_t *) signature);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read ChibiOS/RT memory signature from target");
goto errfree;
}
if (strncmp(signature->ch_identifier, "main", 4) != 0) {
LOG_ERROR("Memory signature identifier does not contain magic bytes.");
goto errfree;
}
if (signature->ch_size < sizeof(*signature)) {
LOG_ERROR("ChibiOS/RT memory signature claims to be smaller "
"than expected");
goto errfree;
}
if (signature->ch_size > sizeof(*signature)) {
LOG_WARNING("ChibiOS/RT memory signature claims to be bigger than"
" expected. Assuming compatibility...");
}
/* Convert endianness of version field */
const uint8_t *versionTarget = (const uint8_t *)
&signature->ch_version;
signature->ch_version = rtos->target->endianness == TARGET_LITTLE_ENDIAN ?
le_to_h_u32(versionTarget) : be_to_h_u32(versionTarget);
const uint16_t ch_version = signature->ch_version;
LOG_INFO("Successfully loaded memory map of ChibiOS/RT target "
"running version %i.%i.%i", GET_CH_KERNEL_MAJOR(ch_version),
GET_CH_KERNEL_MINOR(ch_version), GET_CH_KERNEL_PATCH(ch_version));
/* Currently, we have the inherent assumption that all address pointers
* are 32 bit wide. */
if (signature->ch_ptrsize != sizeof(uint32_t)) {
LOG_ERROR("ChibiOS/RT target memory signature claims an address"
"width unequal to 32 bits!");
free(signature);
return -1;
}
param->signature = signature;
return 0;
errfree:
/* Error reading the ChibiOS memory structure */
free(signature);
param->signature = 0;
return -1;
}
static int ChibiOS_update_stacking(struct rtos *rtos)
{
/* Sometimes the stacking can not be determined only by looking at the
* target name but only a runtime.
*
* For example, this is the case for cortex-m4 targets and ChibiOS which
* only stack the FPU registers if it is enabled during ChibiOS build.
*
* Terminating which stacking is used is target depending.
*
* Assumptions:
* - Once ChibiOS is actually initialized, the stacking is fixed.
* - During startup code, the FPU might not be initialized and the
* detection might fail.
* - Since no threads are running during startup, the problem is solved
* by delaying stacking detection until there are more threads
* available than the current execution. In which case
* ChibiOS_get_thread_reg_list is called.
*/
int retval;
if (!rtos->rtos_specific_params)
return -1;
struct ChibiOS_params *param;
param = (struct ChibiOS_params *) rtos->rtos_specific_params;
/* Check for armv7m with *enabled* FPU, i.e. a Cortex M4 */
struct armv7m_common *armv7m_target = target_to_armv7m(rtos->target);
if (is_armv7m(armv7m_target)) {
if (armv7m_target->fp_feature == FPv4_SP) {
/* Found ARM v7m target which includes a FPU */
uint32_t cpacr;
retval = target_read_u32(rtos->target, FPU_CPACR, &cpacr);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read CPACR register to check FPU state");
return -1;
}
/* Check if CP10 and CP11 are set to full access.
* In ChibiOS this is done in ResetHandler() in crt0.c */
if (cpacr & 0x00F00000) {
/* Found target with enabled FPU */
/* FIXME: Need to figure out how to specify the FPU registers */
LOG_ERROR("ChibiOS ARM v7m targets with enabled FPU "
" are NOT supported");
return -1;
}
}
/* Found ARM v7m target with no or disabled FPU */
param->stacking_info = &rtos_chibios_arm_v7m_stacking;
return 0;
}
return -1;
}
static int ChibiOS_update_threads(struct rtos *rtos)
{
int retval;
const struct ChibiOS_params *param;
int tasks_found = 0;
int rtos_valid = -1;
if (!rtos->rtos_specific_params)
return -1;
if (!rtos->symbols) {
LOG_ERROR("No symbols for ChibiOS");
return -3;
}
param = (const struct ChibiOS_params *) rtos->rtos_specific_params;
/* Update the memory signature saved in the target memory */
if (!param->signature) {
retval = ChibiOS_update_memory_signature(rtos);
if (retval != ERROR_OK) {
LOG_ERROR("Reading the memory signature of ChibiOS/RT failed");
return retval;
}
}
/* wipe out previous thread details if any */
int j;
if (rtos->thread_details) {
for (j = 0; j < rtos->thread_count; j++) {
struct thread_detail *current_thread = &rtos->thread_details[j];
if (current_thread->display_str != NULL)
free(current_thread->display_str);
if (current_thread->thread_name_str != NULL)
free(current_thread->thread_name_str);
if (current_thread->extra_info_str != NULL)
free(current_thread->extra_info_str);
}
free(rtos->thread_details);
rtos->thread_details = NULL;
rtos->thread_count = 0;
}
/* ChibiOS does not save the current thread count. We have to first
* parse the double linked thread list to check for errors and the number of
* threads. */
const uint32_t rlist = rtos->symbols[ChibiOS_VAL_rlist].address;
const struct ChibiOS_chdebug *signature = param->signature;
uint32_t current;
uint32_t previous;
uint32_t older;
current = rlist;
previous = rlist;
while (1) {
retval = target_read_u32(rtos->target,
current + signature->cf_off_newer, &current);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read next ChibiOS thread");
return retval;
}
/* Could be NULL if the kernel is not initialized yet or if the
* registry is corrupted. */
if (current == 0) {
LOG_ERROR("ChibiOS registry integrity check failed, NULL pointer");
rtos_valid = 0;
break;
}
/* Fetch previous thread in the list as a integrity check. */
retval = target_read_u32(rtos->target,
current + signature->cf_off_older, &older);
if ((retval != ERROR_OK) || (older == 0) || (older != previous)) {
LOG_ERROR("ChibiOS registry integrity check failed, "
"double linked list violation");
rtos_valid = 0;
break;
}
/* Check for full iteration of the linked list. */
if (current == rlist)
break;
tasks_found++;
previous = current;
}
if (!rtos_valid) {
/* No RTOS, there is always at least the current execution, though */
LOG_INFO("Only showing current execution because of a broken "
"ChibiOS thread registry.");
const char tmp_thread_name[] = "Current Execution";
const char tmp_thread_extra_info[] = "No RTOS thread";
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail));
rtos->thread_details->threadid = 1;
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = (char *) malloc(
sizeof(tmp_thread_extra_info));
strcpy(rtos->thread_details->extra_info_str, tmp_thread_extra_info);
rtos->thread_details->thread_name_str = (char *) malloc(
sizeof(tmp_thread_name));
strcpy(rtos->thread_details->thread_name_str, tmp_thread_name);
rtos->current_thread = 1;
rtos->thread_count = 1;
return ERROR_OK;
}
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail) * tasks_found);
if (!rtos->thread_details) {
LOG_ERROR("Could not allocate space for thread details");
return -1;
}
rtos->thread_count = tasks_found;
/* Loop through linked list. */
struct thread_detail *curr_thrd_details = rtos->thread_details;
while (curr_thrd_details < rtos->thread_details + tasks_found) {
uint32_t name_ptr = 0;
char tmp_str[CHIBIOS_THREAD_NAME_STR_SIZE];
retval = target_read_u32(rtos->target,
current + signature->cf_off_newer, &current);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read next ChibiOS thread");
return -6;
}
/* Check for full iteration of the linked list. */
if (current == rlist)
break;
/* Save the thread pointer */
curr_thrd_details->threadid = current;
/* read the name pointer */
retval = target_read_u32(rtos->target,
current + signature->cf_off_name, &name_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read ChibiOS thread name pointer from target");
return retval;
}
/* Read the thread name */
retval = target_read_buffer(rtos->target, name_ptr,
CHIBIOS_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from ChibiOS target");
return retval;
}
tmp_str[CHIBIOS_THREAD_NAME_STR_SIZE - 1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
curr_thrd_details->thread_name_str = (char *)malloc(
strlen(tmp_str) + 1);
strcpy(curr_thrd_details->thread_name_str, tmp_str);
/* State info */
uint8_t threadState;
const char *state_desc;
retval = target_read_u8(rtos->target,
current + signature->cf_off_state, &threadState);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread state from ChibiOS target");
return retval;
}
if (threadState < CHIBIOS_NUM_STATES)
state_desc = ChibiOS_thread_states[threadState];
else
state_desc = "Unknown state";
curr_thrd_details->extra_info_str = (char *)malloc(strlen(
state_desc)+1);
strcpy(curr_thrd_details->extra_info_str, state_desc);
curr_thrd_details->exists = true;
curr_thrd_details->display_str = NULL;
curr_thrd_details++;
}
uint32_t current_thrd;
/* NOTE: By design, cf_off_name equals readylist_current_offset */
retval = target_read_u32(rtos->target,
rlist + signature->cf_off_name,
&current_thrd);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read current Thread from ChibiOS target");
return retval;
}
rtos->current_thread = current_thrd;
return 0;
}
static int ChibiOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list)
{
int retval;
const struct ChibiOS_params *param;
uint32_t stack_ptr = 0;
*hex_reg_list = NULL;
if ((rtos == NULL) || (thread_id == 0) ||
(rtos->rtos_specific_params == NULL))
return -1;
param = (const struct ChibiOS_params *) rtos->rtos_specific_params;
if (!param->signature)
return -1;
/* Update stacking if it can only be determined from runtime information */
if ((param->stacking_info == 0) &&
(ChibiOS_update_stacking(rtos) != ERROR_OK)) {
LOG_ERROR("Failed to determine exact stacking for the target type %s", rtos->target->type->name);
return -1;
}
/* Read the stack pointer */
retval = target_read_u32(rtos->target,
thread_id + param->signature->cf_off_ctx, &stack_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading stack frame from ChibiOS thread");
return retval;
}
return rtos_generic_stack_read(rtos->target, param->stacking_info, stack_ptr, hex_reg_list);
}
static int ChibiOS_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(ChibiOS_symbol_list));
for (i = 0; i < ARRAY_SIZE(ChibiOS_symbol_list); i++)
(*symbol_list)[i].symbol_name = ChibiOS_symbol_list[i];
return 0;
}
static int ChibiOS_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
(target->rtos->symbols[ChibiOS_VAL_rlist].address != 0) &&
(target->rtos->symbols[ChibiOS_VAL_chSysInit].address != 0)) {
if (target->rtos->symbols[ChibiOS_VAL_ch_debug].address == 0) {
LOG_INFO("It looks like the target is running ChibiOS without "
"ch_debug.");
return 0;
}
/* looks like ChibiOS with memory map enabled.*/
return 1;
}
return 0;
}
static int ChibiOS_create(struct target *target)
{
int i = 0;
while ((i < CHIBIOS_NUM_PARAMS) &&
(0 != strcmp(ChibiOS_params_list[i].target_name, target->type->name))) {
i++;
}
if (i >= CHIBIOS_NUM_PARAMS) {
LOG_WARNING("Could not find target \"%s\" in ChibiOS compatibility "
"list", target->type->name);
return -1;
}
target->rtos->rtos_specific_params = (void *) &ChibiOS_params_list[i];
return 0;
}

View File

@ -0,0 +1,479 @@
/***************************************************************************
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "rtos.h"
#include "helper/log.h"
#include "helper/types.h"
#include "rtos_standard_stackings.h"
#define FREERTOS_MAX_PRIORITIES 63
#define FreeRTOS_STRUCT(int_type, ptr_type, list_prev_offset)
struct FreeRTOS_params {
const char *target_name;
const unsigned char thread_count_width;
const unsigned char pointer_width;
const unsigned char list_next_offset;
const unsigned char list_width;
const unsigned char list_elem_next_offset;
const unsigned char list_elem_content_offset;
const unsigned char thread_stack_offset;
const unsigned char thread_name_offset;
const struct rtos_register_stacking *stacking_info;
};
const struct FreeRTOS_params FreeRTOS_params_list[] = {
{
"cortex_m", /* target_name */
4, /* thread_count_width; */
4, /* pointer_width; */
16, /* list_next_offset; */
20, /* list_width; */
8, /* list_elem_next_offset; */
12, /* list_elem_content_offset */
0, /* thread_stack_offset; */
52, /* thread_name_offset; */
&rtos_standard_Cortex_M3_stacking, /* stacking_info */
},
{
"hla_target", /* target_name */
4, /* thread_count_width; */
4, /* pointer_width; */
16, /* list_next_offset; */
20, /* list_width; */
8, /* list_elem_next_offset; */
12, /* list_elem_content_offset */
0, /* thread_stack_offset; */
52, /* thread_name_offset; */
&rtos_standard_Cortex_M3_stacking, /* stacking_info */
}
};
#define FREERTOS_NUM_PARAMS ((int)(sizeof(FreeRTOS_params_list)/sizeof(struct FreeRTOS_params)))
static int FreeRTOS_detect_rtos(struct target *target);
static int FreeRTOS_create(struct target *target);
static int FreeRTOS_update_threads(struct rtos *rtos);
static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
static int FreeRTOS_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[]);
struct rtos_type FreeRTOS_rtos = {
.name = "FreeRTOS",
.detect_rtos = FreeRTOS_detect_rtos,
.create = FreeRTOS_create,
.update_threads = FreeRTOS_update_threads,
.get_thread_reg_list = FreeRTOS_get_thread_reg_list,
.get_symbol_list_to_lookup = FreeRTOS_get_symbol_list_to_lookup,
};
enum FreeRTOS_symbol_values {
FreeRTOS_VAL_pxCurrentTCB = 0,
FreeRTOS_VAL_pxReadyTasksLists = 1,
FreeRTOS_VAL_xDelayedTaskList1 = 2,
FreeRTOS_VAL_xDelayedTaskList2 = 3,
FreeRTOS_VAL_pxDelayedTaskList = 4,
FreeRTOS_VAL_pxOverflowDelayedTaskList = 5,
FreeRTOS_VAL_xPendingReadyList = 6,
FreeRTOS_VAL_xTasksWaitingTermination = 7,
FreeRTOS_VAL_xSuspendedTaskList = 8,
FreeRTOS_VAL_uxCurrentNumberOfTasks = 9,
FreeRTOS_VAL_uxTopUsedPriority = 10,
};
static char *FreeRTOS_symbol_list[] = {
"pxCurrentTCB",
"pxReadyTasksLists",
"xDelayedTaskList1",
"xDelayedTaskList2",
"pxDelayedTaskList",
"pxOverflowDelayedTaskList",
"xPendingReadyList",
"xTasksWaitingTermination",
"xSuspendedTaskList",
"uxCurrentNumberOfTasks",
"uxTopUsedPriority",
NULL
};
/* TODO: */
/* this is not safe for little endian yet */
/* may be problems reading if sizes are not 32 bit long integers. */
/* test mallocs for failure */
static int FreeRTOS_update_threads(struct rtos *rtos)
{
int i = 0;
int retval;
int tasks_found = 0;
const struct FreeRTOS_params *param;
if (rtos->rtos_specific_params == NULL)
return -1;
param = (const struct FreeRTOS_params *) rtos->rtos_specific_params;
if (rtos->symbols == NULL) {
LOG_ERROR("No symbols for FreeRTOS");
return -3;
}
if (rtos->symbols[FreeRTOS_VAL_uxCurrentNumberOfTasks].address == 0) {
LOG_ERROR("Don't have the number of threads in FreeRTOS");
return -2;
}
int thread_list_size = 0;
retval = target_read_buffer(rtos->target,
rtos->symbols[FreeRTOS_VAL_uxCurrentNumberOfTasks].address,
param->thread_count_width,
(uint8_t *)&thread_list_size);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read FreeRTOS thread count from target");
return retval;
}
/* wipe out previous thread details if any */
if (rtos->thread_details != NULL) {
int j;
for (j = 0; j < rtos->thread_count; j++) {
if (rtos->thread_details[j].display_str != NULL) {
free(rtos->thread_details[j].display_str);
rtos->thread_details[j].display_str = NULL;
}
if (rtos->thread_details[j].thread_name_str != NULL) {
free(rtos->thread_details[j].thread_name_str);
rtos->thread_details[j].thread_name_str = NULL;
}
if (rtos->thread_details[j].extra_info_str != NULL) {
free(rtos->thread_details[j].extra_info_str);
rtos->thread_details[j].extra_info_str = NULL;
}
}
free(rtos->thread_details);
rtos->thread_details = NULL;
}
/* read the current thread */
retval = target_read_buffer(rtos->target,
rtos->symbols[FreeRTOS_VAL_pxCurrentTCB].address,
param->pointer_width,
(uint8_t *)&rtos->current_thread);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading current thread in FreeRTOS thread list");
return retval;
}
if ((thread_list_size == 0) || (rtos->current_thread == 0)) {
/* Either : No RTOS threads - there is always at least the current execution though */
/* OR : No current thread - all threads suspended - show the current execution
* of idling */
char tmp_str[] = "Current Execution";
thread_list_size++;
tasks_found++;
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail) * thread_list_size);
if (!rtos->thread_details) {
LOG_ERROR("Error allocating memory for %d threads", thread_list_size);
return ERROR_FAIL;
}
rtos->thread_details->threadid = 1;
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = NULL;
rtos->thread_details->thread_name_str = (char *) malloc(sizeof(tmp_str));
strcpy(rtos->thread_details->thread_name_str, tmp_str);
if (thread_list_size == 1) {
rtos->thread_count = 1;
return ERROR_OK;
}
} else {
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail) * thread_list_size);
if (!rtos->thread_details) {
LOG_ERROR("Error allocating memory for %d threads", thread_list_size);
return ERROR_FAIL;
}
}
/* Find out how many lists are needed to be read from pxReadyTasksLists, */
int64_t max_used_priority = 0;
retval = target_read_buffer(rtos->target,
rtos->symbols[FreeRTOS_VAL_uxTopUsedPriority].address,
param->pointer_width,
(uint8_t *)&max_used_priority);
if (retval != ERROR_OK)
return retval;
if (max_used_priority > FREERTOS_MAX_PRIORITIES) {
LOG_ERROR("FreeRTOS maximum used priority is unreasonably big, not proceeding: %" PRId64 "",
max_used_priority);
return ERROR_FAIL;
}
symbol_address_t *list_of_lists =
(symbol_address_t *)malloc(sizeof(symbol_address_t) *
(max_used_priority+1 + 5));
if (!list_of_lists) {
LOG_ERROR("Error allocating memory for %" PRId64 " priorities", max_used_priority);
return ERROR_FAIL;
}
int num_lists;
for (num_lists = 0; num_lists <= max_used_priority; num_lists++)
list_of_lists[num_lists] = rtos->symbols[FreeRTOS_VAL_pxReadyTasksLists].address +
num_lists * param->list_width;
list_of_lists[num_lists++] = rtos->symbols[FreeRTOS_VAL_xDelayedTaskList1].address;
list_of_lists[num_lists++] = rtos->symbols[FreeRTOS_VAL_xDelayedTaskList2].address;
list_of_lists[num_lists++] = rtos->symbols[FreeRTOS_VAL_xPendingReadyList].address;
list_of_lists[num_lists++] = rtos->symbols[FreeRTOS_VAL_xSuspendedTaskList].address;
list_of_lists[num_lists++] = rtos->symbols[FreeRTOS_VAL_xTasksWaitingTermination].address;
for (i = 0; i < num_lists; i++) {
if (list_of_lists[i] == 0)
continue;
/* Read the number of threads in this list */
int64_t list_thread_count = 0;
retval = target_read_buffer(rtos->target,
list_of_lists[i],
param->thread_count_width,
(uint8_t *)&list_thread_count);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading number of threads in FreeRTOS thread list");
free(list_of_lists);
return retval;
}
if (list_thread_count == 0)
continue;
/* Read the location of first list item */
uint64_t prev_list_elem_ptr = -1;
uint64_t list_elem_ptr = 0;
retval = target_read_buffer(rtos->target,
list_of_lists[i] + param->list_next_offset,
param->pointer_width,
(uint8_t *)&list_elem_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading first thread item location in FreeRTOS thread list");
free(list_of_lists);
return retval;
}
while ((list_thread_count > 0) && (list_elem_ptr != 0) &&
(list_elem_ptr != prev_list_elem_ptr) &&
(tasks_found < thread_list_size)) {
/* Get the location of the thread structure. */
rtos->thread_details[tasks_found].threadid = 0;
retval = target_read_buffer(rtos->target,
list_elem_ptr + param->list_elem_content_offset,
param->pointer_width,
(uint8_t *)&(rtos->thread_details[tasks_found].threadid));
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread list item object in FreeRTOS thread list");
free(list_of_lists);
return retval;
}
/* get thread name */
#define FREERTOS_THREAD_NAME_STR_SIZE (200)
char tmp_str[FREERTOS_THREAD_NAME_STR_SIZE];
/* Read the thread name */
retval = target_read_buffer(rtos->target,
rtos->thread_details[tasks_found].threadid + param->thread_name_offset,
FREERTOS_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading first thread item location in FreeRTOS thread list");
free(list_of_lists);
return retval;
}
tmp_str[FREERTOS_THREAD_NAME_STR_SIZE-1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
rtos->thread_details[tasks_found].thread_name_str =
(char *)malloc(strlen(tmp_str)+1);
strcpy(rtos->thread_details[tasks_found].thread_name_str, tmp_str);
rtos->thread_details[tasks_found].display_str = NULL;
rtos->thread_details[tasks_found].exists = true;
if (rtos->thread_details[tasks_found].threadid == rtos->current_thread) {
char running_str[] = "Running";
rtos->thread_details[tasks_found].extra_info_str = (char *) malloc(
sizeof(running_str));
strcpy(rtos->thread_details[tasks_found].extra_info_str,
running_str);
} else
rtos->thread_details[tasks_found].extra_info_str = NULL;
tasks_found++;
list_thread_count--;
prev_list_elem_ptr = list_elem_ptr;
list_elem_ptr = 0;
retval = target_read_buffer(rtos->target,
prev_list_elem_ptr + param->list_elem_next_offset,
param->pointer_width,
(uint8_t *)&list_elem_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading next thread item location in FreeRTOS thread list");
free(list_of_lists);
return retval;
}
}
}
free(list_of_lists);
rtos->thread_count = tasks_found;
return 0;
}
static int FreeRTOS_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list)
{
int retval;
const struct FreeRTOS_params *param;
int64_t stack_ptr = 0;
*hex_reg_list = NULL;
if (rtos == NULL)
return -1;
if (thread_id == 0)
return -2;
if (rtos->rtos_specific_params == NULL)
return -1;
param = (const struct FreeRTOS_params *) rtos->rtos_specific_params;
/* Read the stack pointer */
retval = target_read_buffer(rtos->target,
thread_id + param->thread_stack_offset,
param->pointer_width,
(uint8_t *)&stack_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading stack frame from FreeRTOS thread");
return retval;
}
return rtos_generic_stack_read(rtos->target, param->stacking_info, stack_ptr, hex_reg_list);
}
static int FreeRTOS_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(FreeRTOS_symbol_list));
for (i = 0; i < ARRAY_SIZE(FreeRTOS_symbol_list); i++)
(*symbol_list)[i].symbol_name = FreeRTOS_symbol_list[i];
return 0;
}
#if 0
static int FreeRTOS_set_current_thread(struct rtos *rtos, threadid_t thread_id)
{
return 0;
}
static int FreeRTOS_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_id, char **info)
{
int retval;
const struct FreeRTOS_params *param;
if (rtos == NULL)
return -1;
if (thread_id == 0)
return -2;
if (rtos->rtos_specific_params == NULL)
return -3;
param = (const struct FreeRTOS_params *) rtos->rtos_specific_params;
#define FREERTOS_THREAD_NAME_STR_SIZE (200)
char tmp_str[FREERTOS_THREAD_NAME_STR_SIZE];
/* Read the thread name */
retval = target_read_buffer(rtos->target,
thread_id + param->thread_name_offset,
FREERTOS_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading first thread item location in FreeRTOS thread list");
return retval;
}
tmp_str[FREERTOS_THREAD_NAME_STR_SIZE-1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
*info = (char *)malloc(strlen(tmp_str)+1);
strcpy(*info, tmp_str);
return 0;
}
#endif
static int FreeRTOS_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
(target->rtos->symbols[FreeRTOS_VAL_pxReadyTasksLists].address != 0)) {
/* looks like FreeRTOS */
return 1;
}
return 0;
}
static int FreeRTOS_create(struct target *target)
{
int i = 0;
while ((i < FREERTOS_NUM_PARAMS) &&
(0 != strcmp(FreeRTOS_params_list[i].target_name, target->type->name))) {
i++;
}
if (i >= FREERTOS_NUM_PARAMS) {
LOG_ERROR("Could not find target in FreeRTOS compatibility list");
return -1;
}
target->rtos->rtos_specific_params = (void *) &FreeRTOS_params_list[i];
return 0;
}

View File

@ -0,0 +1,34 @@
# ***************************************************************************
# * Copyright (C) 2011 by Broadcom Corporation *
# * Evan Hunter - ehunter@broadcom.com *
# * *
# * 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 *
# * (at your option) any later version. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU General Public License *
# * along with this program; if not, write to the *
# * Free Software Foundation, Inc., *
# * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
# ***************************************************************************
include $(top_srcdir)/common.mk
METASOURCES = AUTO
noinst_LTLIBRARIES = librtos.la
noinst_HEADERS = rtos.h rtos_standard_stackings.h rtos_ecos_stackings.h linux_header.h rtos_chibios_stackings.h
librtos_la_SOURCES = rtos.c rtos_standard_stackings.c rtos_ecos_stackings.c rtos_chibios_stackings.c FreeRTOS.c ThreadX.c eCos.c linux.c ChibiOS.c
librtos_la_CFLAGS =
if IS_MINGW
# FD_* macros are sloppy with their signs on MinGW32 platform
librtos_la_CFLAGS += -Wno-sign-compare
endif
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in

View File

@ -0,0 +1,664 @@
# Makefile.in generated by automake 1.13.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2012 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# ***************************************************************************
# * Copyright (C) 2011 by Broadcom Corporation *
# * Evan Hunter - ehunter@broadcom.com *
# * *
# * 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 *
# * (at your option) any later version. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU General Public License *
# * along with this program; if not, write to the *
# * Free Software Foundation, Inc., *
# * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
# ***************************************************************************
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
DIST_COMMON = $(top_srcdir)/common.mk $(srcdir)/Makefile.in \
$(srcdir)/Makefile.am $(top_srcdir)/depcomp $(noinst_HEADERS)
@INTERNAL_JIMTCL_TRUE@am__append_1 = -I$(top_srcdir)/jimtcl \
@INTERNAL_JIMTCL_TRUE@ -I$(top_builddir)/jimtcl
# FD_* macros are sloppy with their signs on MinGW32 platform
@IS_MINGW_TRUE@am__append_2 = -Wno-sign-compare
subdir = src/rtos
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config_subdir.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librtos_la_LIBADD =
am_librtos_la_OBJECTS = librtos_la-rtos.lo \
librtos_la-rtos_standard_stackings.lo \
librtos_la-rtos_ecos_stackings.lo \
librtos_la-rtos_chibios_stackings.lo librtos_la-FreeRTOS.lo \
librtos_la-ThreadX.lo librtos_la-eCos.lo librtos_la-linux.lo \
librtos_la-ChibiOS.lo
librtos_la_OBJECTS = $(am_librtos_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
librtos_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(librtos_la_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(librtos_la_SOURCES)
DIST_SOURCES = $(librtos_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
HEADERS = $(noinst_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
doxygen_as_html = @doxygen_as_html@
doxygen_as_pdf = @doxygen_as_pdf@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
subdirs = @subdirs@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
# common flags used in openocd build
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src \
-I$(top_srcdir)/src/helper -DPKGDATADIR=\"$(pkgdatadir)\" \
-DPKGLIBDIR=\"$(pkglibdir)\" $(am__append_1)
METASOURCES = AUTO
noinst_LTLIBRARIES = librtos.la
noinst_HEADERS = rtos.h rtos_standard_stackings.h rtos_ecos_stackings.h linux_header.h rtos_chibios_stackings.h
librtos_la_SOURCES = rtos.c rtos_standard_stackings.c rtos_ecos_stackings.c rtos_chibios_stackings.c FreeRTOS.c ThreadX.c eCos.c linux.c ChibiOS.c
librtos_la_CFLAGS = $(am__append_2)
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/common.mk $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/rtos/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu src/rtos/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_srcdir)/common.mk:
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
librtos.la: $(librtos_la_OBJECTS) $(librtos_la_DEPENDENCIES) $(EXTRA_librtos_la_DEPENDENCIES)
$(AM_V_CCLD)$(librtos_la_LINK) $(librtos_la_OBJECTS) $(librtos_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-ChibiOS.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-FreeRTOS.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-ThreadX.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-eCos.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-linux.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-rtos.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-rtos_chibios_stackings.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-rtos_ecos_stackings.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtos_la-rtos_standard_stackings.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
librtos_la-rtos.lo: rtos.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-rtos.lo -MD -MP -MF $(DEPDIR)/librtos_la-rtos.Tpo -c -o librtos_la-rtos.lo `test -f 'rtos.c' || echo '$(srcdir)/'`rtos.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-rtos.Tpo $(DEPDIR)/librtos_la-rtos.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtos.c' object='librtos_la-rtos.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-rtos.lo `test -f 'rtos.c' || echo '$(srcdir)/'`rtos.c
librtos_la-rtos_standard_stackings.lo: rtos_standard_stackings.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-rtos_standard_stackings.lo -MD -MP -MF $(DEPDIR)/librtos_la-rtos_standard_stackings.Tpo -c -o librtos_la-rtos_standard_stackings.lo `test -f 'rtos_standard_stackings.c' || echo '$(srcdir)/'`rtos_standard_stackings.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-rtos_standard_stackings.Tpo $(DEPDIR)/librtos_la-rtos_standard_stackings.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtos_standard_stackings.c' object='librtos_la-rtos_standard_stackings.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-rtos_standard_stackings.lo `test -f 'rtos_standard_stackings.c' || echo '$(srcdir)/'`rtos_standard_stackings.c
librtos_la-rtos_ecos_stackings.lo: rtos_ecos_stackings.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-rtos_ecos_stackings.lo -MD -MP -MF $(DEPDIR)/librtos_la-rtos_ecos_stackings.Tpo -c -o librtos_la-rtos_ecos_stackings.lo `test -f 'rtos_ecos_stackings.c' || echo '$(srcdir)/'`rtos_ecos_stackings.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-rtos_ecos_stackings.Tpo $(DEPDIR)/librtos_la-rtos_ecos_stackings.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtos_ecos_stackings.c' object='librtos_la-rtos_ecos_stackings.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-rtos_ecos_stackings.lo `test -f 'rtos_ecos_stackings.c' || echo '$(srcdir)/'`rtos_ecos_stackings.c
librtos_la-rtos_chibios_stackings.lo: rtos_chibios_stackings.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-rtos_chibios_stackings.lo -MD -MP -MF $(DEPDIR)/librtos_la-rtos_chibios_stackings.Tpo -c -o librtos_la-rtos_chibios_stackings.lo `test -f 'rtos_chibios_stackings.c' || echo '$(srcdir)/'`rtos_chibios_stackings.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-rtos_chibios_stackings.Tpo $(DEPDIR)/librtos_la-rtos_chibios_stackings.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtos_chibios_stackings.c' object='librtos_la-rtos_chibios_stackings.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-rtos_chibios_stackings.lo `test -f 'rtos_chibios_stackings.c' || echo '$(srcdir)/'`rtos_chibios_stackings.c
librtos_la-FreeRTOS.lo: FreeRTOS.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-FreeRTOS.lo -MD -MP -MF $(DEPDIR)/librtos_la-FreeRTOS.Tpo -c -o librtos_la-FreeRTOS.lo `test -f 'FreeRTOS.c' || echo '$(srcdir)/'`FreeRTOS.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-FreeRTOS.Tpo $(DEPDIR)/librtos_la-FreeRTOS.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='FreeRTOS.c' object='librtos_la-FreeRTOS.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-FreeRTOS.lo `test -f 'FreeRTOS.c' || echo '$(srcdir)/'`FreeRTOS.c
librtos_la-ThreadX.lo: ThreadX.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-ThreadX.lo -MD -MP -MF $(DEPDIR)/librtos_la-ThreadX.Tpo -c -o librtos_la-ThreadX.lo `test -f 'ThreadX.c' || echo '$(srcdir)/'`ThreadX.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-ThreadX.Tpo $(DEPDIR)/librtos_la-ThreadX.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ThreadX.c' object='librtos_la-ThreadX.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-ThreadX.lo `test -f 'ThreadX.c' || echo '$(srcdir)/'`ThreadX.c
librtos_la-eCos.lo: eCos.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-eCos.lo -MD -MP -MF $(DEPDIR)/librtos_la-eCos.Tpo -c -o librtos_la-eCos.lo `test -f 'eCos.c' || echo '$(srcdir)/'`eCos.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-eCos.Tpo $(DEPDIR)/librtos_la-eCos.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='eCos.c' object='librtos_la-eCos.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-eCos.lo `test -f 'eCos.c' || echo '$(srcdir)/'`eCos.c
librtos_la-linux.lo: linux.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-linux.lo -MD -MP -MF $(DEPDIR)/librtos_la-linux.Tpo -c -o librtos_la-linux.lo `test -f 'linux.c' || echo '$(srcdir)/'`linux.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-linux.Tpo $(DEPDIR)/librtos_la-linux.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='linux.c' object='librtos_la-linux.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-linux.lo `test -f 'linux.c' || echo '$(srcdir)/'`linux.c
librtos_la-ChibiOS.lo: ChibiOS.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -MT librtos_la-ChibiOS.lo -MD -MP -MF $(DEPDIR)/librtos_la-ChibiOS.Tpo -c -o librtos_la-ChibiOS.lo `test -f 'ChibiOS.c' || echo '$(srcdir)/'`ChibiOS.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtos_la-ChibiOS.Tpo $(DEPDIR)/librtos_la-ChibiOS.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ChibiOS.c' object='librtos_la-ChibiOS.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtos_la_CFLAGS) $(CFLAGS) -c -o librtos_la-ChibiOS.lo `test -f 'ChibiOS.c' || echo '$(srcdir)/'`ChibiOS.c
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,485 @@
/***************************************************************************
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "rtos.h"
#include "helper/log.h"
#include "helper/types.h"
#include "rtos_standard_stackings.h"
static int ThreadX_detect_rtos(struct target *target);
static int ThreadX_create(struct target *target);
static int ThreadX_update_threads(struct rtos *rtos);
static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
static int ThreadX_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[]);
struct ThreadX_thread_state {
int value;
char *desc;
};
struct ThreadX_thread_state ThreadX_thread_states[] = {
{ 0, "Ready" },
{ 1, "Completed" },
{ 2, "Terminated" },
{ 3, "Suspended" },
{ 4, "Sleeping" },
{ 5, "Waiting - Queue" },
{ 6, "Waiting - Semaphore" },
{ 7, "Waiting - Event flag" },
{ 8, "Waiting - Memory" },
{ 9, "Waiting - Memory" },
{ 10, "Waiting - I/O" },
{ 11, "Waiting - Filesystem" },
{ 12, "Waiting - Network" },
{ 13, "Waiting - Mutex" },
};
#define THREADX_NUM_STATES (sizeof(ThreadX_thread_states)/sizeof(struct ThreadX_thread_state))
struct ThreadX_params {
char *target_name;
unsigned char pointer_width;
unsigned char thread_stack_offset;
unsigned char thread_name_offset;
unsigned char thread_state_offset;
unsigned char thread_next_offset;
const struct rtos_register_stacking *stacking_info;
};
const struct ThreadX_params ThreadX_params_list[] = {
{
"cortex_m", /* target_name */
4, /* pointer_width; */
8, /* thread_stack_offset; */
40, /* thread_name_offset; */
48, /* thread_state_offset; */
136, /* thread_next_offset */
&rtos_standard_Cortex_M3_stacking, /* stacking_info */
},
{
"cortex_r4", /* target_name */
4, /* pointer_width; */
8, /* thread_stack_offset; */
40, /* thread_name_offset; */
48, /* thread_state_offset; */
136, /* thread_next_offset */
&rtos_standard_Cortex_R4_stacking, /* stacking_info */
},
};
#define THREADX_NUM_PARAMS ((int)(sizeof(ThreadX_params_list)/sizeof(struct ThreadX_params)))
enum ThreadX_symbol_values {
ThreadX_VAL_tx_thread_current_ptr = 0,
ThreadX_VAL_tx_thread_created_ptr = 1,
ThreadX_VAL_tx_thread_created_count = 2,
};
static char *ThreadX_symbol_list[] = {
"_tx_thread_current_ptr",
"_tx_thread_created_ptr",
"_tx_thread_created_count",
NULL
};
const struct rtos_type ThreadX_rtos = {
.name = "ThreadX",
.detect_rtos = ThreadX_detect_rtos,
.create = ThreadX_create,
.update_threads = ThreadX_update_threads,
.get_thread_reg_list = ThreadX_get_thread_reg_list,
.get_symbol_list_to_lookup = ThreadX_get_symbol_list_to_lookup,
};
static int ThreadX_update_threads(struct rtos *rtos)
{
int retval;
int tasks_found = 0;
int thread_list_size = 0;
const struct ThreadX_params *param;
if (rtos == NULL)
return -1;
if (rtos->rtos_specific_params == NULL)
return -3;
param = (const struct ThreadX_params *) rtos->rtos_specific_params;
if (rtos->symbols == NULL) {
LOG_ERROR("No symbols for ThreadX");
return -4;
}
if (rtos->symbols[ThreadX_VAL_tx_thread_created_count].address == 0) {
LOG_ERROR("Don't have the number of threads in ThreadX");
return -2;
}
/* read the number of threads */
retval = target_read_buffer(rtos->target,
rtos->symbols[ThreadX_VAL_tx_thread_created_count].address,
4,
(uint8_t *)&thread_list_size);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read ThreadX thread count from target");
return retval;
}
/* wipe out previous thread details if any */
if (rtos->thread_details != NULL) {
int j;
for (j = 0; j < rtos->thread_count; j++) {
if (rtos->thread_details[j].display_str != NULL) {
free(rtos->thread_details[j].display_str);
rtos->thread_details[j].display_str = NULL;
}
if (rtos->thread_details[j].thread_name_str != NULL) {
free(rtos->thread_details[j].thread_name_str);
rtos->thread_details[j].thread_name_str = NULL;
}
if (rtos->thread_details[j].extra_info_str != NULL) {
free(rtos->thread_details[j].extra_info_str);
rtos->thread_details[j].extra_info_str = NULL;
}
}
free(rtos->thread_details);
rtos->thread_details = NULL;
}
/* read the current thread id */
retval = target_read_buffer(rtos->target,
rtos->symbols[ThreadX_VAL_tx_thread_current_ptr].address,
4,
(uint8_t *)&rtos->current_thread);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read ThreadX current thread from target");
return retval;
}
if ((thread_list_size == 0) || (rtos->current_thread == 0)) {
/* Either : No RTOS threads - there is always at least the current execution though */
/* OR : No current thread - all threads suspended - show the current execution
* of idling */
char tmp_str[] = "Current Execution";
thread_list_size++;
tasks_found++;
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail) * thread_list_size);
rtos->thread_details->threadid = 1;
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = NULL;
rtos->thread_details->thread_name_str = (char *) malloc(sizeof(tmp_str));
strcpy(rtos->thread_details->thread_name_str, tmp_str);
if (thread_list_size == 0) {
rtos->thread_count = 1;
return ERROR_OK;
}
} else {
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail) * thread_list_size);
}
/* Read the pointer to the first thread */
int64_t thread_ptr = 0;
retval = target_read_buffer(rtos->target,
rtos->symbols[ThreadX_VAL_tx_thread_created_ptr].address,
param->pointer_width,
(uint8_t *)&thread_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read ThreadX thread location from target");
return retval;
}
/* loop over all threads */
int64_t prev_thread_ptr = 0;
while ((thread_ptr != prev_thread_ptr) && (tasks_found < thread_list_size)) {
#define THREADX_THREAD_NAME_STR_SIZE (200)
char tmp_str[THREADX_THREAD_NAME_STR_SIZE];
unsigned int i = 0;
int64_t name_ptr = 0;
/* Save the thread pointer */
rtos->thread_details[tasks_found].threadid = thread_ptr;
/* read the name pointer */
retval = target_read_buffer(rtos->target,
thread_ptr + param->thread_name_offset,
param->pointer_width,
(uint8_t *)&name_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read ThreadX thread name pointer from target");
return retval;
}
/* Read the thread name */
retval =
target_read_buffer(rtos->target,
name_ptr,
THREADX_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from ThreadX target");
return retval;
}
tmp_str[THREADX_THREAD_NAME_STR_SIZE-1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
rtos->thread_details[tasks_found].thread_name_str =
(char *)malloc(strlen(tmp_str)+1);
strcpy(rtos->thread_details[tasks_found].thread_name_str, tmp_str);
/* Read the thread status */
int64_t thread_status = 0;
retval = target_read_buffer(rtos->target,
thread_ptr + param->thread_state_offset,
4,
(uint8_t *)&thread_status);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread state from ThreadX target");
return retval;
}
for (i = 0; (i < THREADX_NUM_STATES) &&
(ThreadX_thread_states[i].value != thread_status); i++) {
/* empty */
}
char *state_desc;
if (i < THREADX_NUM_STATES)
state_desc = ThreadX_thread_states[i].desc;
else
state_desc = "Unknown state";
rtos->thread_details[tasks_found].extra_info_str = (char *)malloc(strlen(
state_desc)+1);
strcpy(rtos->thread_details[tasks_found].extra_info_str, state_desc);
rtos->thread_details[tasks_found].exists = true;
rtos->thread_details[tasks_found].display_str = NULL;
tasks_found++;
prev_thread_ptr = thread_ptr;
/* Get the location of the next thread structure. */
thread_ptr = 0;
retval = target_read_buffer(rtos->target,
prev_thread_ptr + param->thread_next_offset,
param->pointer_width,
(uint8_t *) &thread_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading next thread pointer in ThreadX thread list");
return retval;
}
}
rtos->thread_count = tasks_found;
return 0;
}
static int ThreadX_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list)
{
int retval;
const struct ThreadX_params *param;
*hex_reg_list = NULL;
if (rtos == NULL)
return -1;
if (thread_id == 0)
return -2;
if (rtos->rtos_specific_params == NULL)
return -3;
param = (const struct ThreadX_params *) rtos->rtos_specific_params;
/* Read the stack pointer */
int64_t stack_ptr = 0;
retval = target_read_buffer(rtos->target,
thread_id + param->thread_stack_offset,
param->pointer_width,
(uint8_t *)&stack_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading stack frame from ThreadX thread");
return retval;
}
return rtos_generic_stack_read(rtos->target, param->stacking_info, stack_ptr, hex_reg_list);
}
static int ThreadX_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(ThreadX_symbol_list));
for (i = 0; i < ARRAY_SIZE(ThreadX_symbol_list); i++)
(*symbol_list)[i].symbol_name = ThreadX_symbol_list[i];
return 0;
}
static int ThreadX_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
(target->rtos->symbols[ThreadX_VAL_tx_thread_created_ptr].address != 0)) {
/* looks like ThreadX */
return 1;
}
return 0;
}
#if 0
static int ThreadX_set_current_thread(struct rtos *rtos, threadid_t thread_id)
{
return 0;
}
static int ThreadX_get_thread_detail(struct rtos *rtos,
threadid_t thread_id,
struct thread_detail *detail)
{
unsigned int i = 0;
int retval;
#define THREADX_THREAD_NAME_STR_SIZE (200)
char tmp_str[THREADX_THREAD_NAME_STR_SIZE];
const struct ThreadX_params *param;
if (rtos == NULL)
return -1;
if (thread_id == 0)
return -2;
if (rtos->rtos_specific_params == NULL)
return -3;
param = (const struct ThreadX_params *) rtos->rtos_specific_params;
if (rtos->symbols == NULL) {
LOG_ERROR("No symbols for ThreadX");
return -3;
}
detail->threadid = thread_id;
int64_t name_ptr = 0;
/* read the name pointer */
retval = target_read_buffer(rtos->target,
thread_id + param->thread_name_offset,
param->pointer_width,
(uint8_t *)&name_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read ThreadX thread name pointer from target");
return retval;
}
/* Read the thread name */
retval = target_read_buffer(rtos->target,
name_ptr,
THREADX_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from ThreadX target");
return retval;
}
tmp_str[THREADX_THREAD_NAME_STR_SIZE-1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
detail->thread_name_str = (char *)malloc(strlen(tmp_str)+1);
/* Read the thread status */
int64_t thread_status = 0;
retval =
target_read_buffer(rtos->target,
thread_id + param->thread_state_offset,
4,
(uint8_t *)&thread_status);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread state from ThreadX target");
return retval;
}
for (i = 0; (i < THREADX_NUM_STATES) &&
(ThreadX_thread_states[i].value != thread_status); i++) {
/* empty */
}
char *state_desc;
if (i < THREADX_NUM_STATES)
state_desc = ThreadX_thread_states[i].desc;
else
state_desc = "Unknown state";
detail->extra_info_str = (char *)malloc(strlen(state_desc)+1);
detail->exists = true;
detail->display_str = NULL;
return 0;
}
#endif
static int ThreadX_create(struct target *target)
{
int i = 0;
while ((i < THREADX_NUM_PARAMS) &&
(0 != strcmp(ThreadX_params_list[i].target_name, target->type->name))) {
i++;
}
if (i >= THREADX_NUM_PARAMS) {
LOG_ERROR("Could not find target in ThreadX compatibility list");
return -1;
}
target->rtos->rtos_specific_params = (void *) &ThreadX_params_list[i];
target->rtos->current_thread = 0;
target->rtos->thread_details = NULL;
return 0;
}

View File

@ -0,0 +1,415 @@
/***************************************************************************
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "rtos.h"
#include "helper/log.h"
#include "helper/types.h"
#include "rtos_ecos_stackings.h"
static int eCos_detect_rtos(struct target *target);
static int eCos_create(struct target *target);
static int eCos_update_threads(struct rtos *rtos);
static int eCos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
static int eCos_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[]);
struct eCos_thread_state {
int value;
char *desc;
};
struct eCos_thread_state eCos_thread_states[] = {
{ 0, "Ready" },
{ 1, "Sleeping" },
{ 2, "Countsleep" },
{ 4, "Suspended" },
{ 8, "Creating" },
{ 16, "Exited" }
};
#define ECOS_NUM_STATES (sizeof(eCos_thread_states)/sizeof(struct eCos_thread_state))
struct eCos_params {
char *target_name;
unsigned char pointer_width;
unsigned char thread_stack_offset;
unsigned char thread_name_offset;
unsigned char thread_state_offset;
unsigned char thread_next_offset;
unsigned char thread_uniqueid_offset;
const struct rtos_register_stacking *stacking_info;
};
const struct eCos_params eCos_params_list[] = {
{
"cortex_m", /* target_name */
4, /* pointer_width; */
0x0c, /* thread_stack_offset; */
0x9c, /* thread_name_offset; */
0x3c, /* thread_state_offset; */
0xa0, /* thread_next_offset */
0x4c, /* thread_uniqueid_offset */
&rtos_eCos_Cortex_M3_stacking /* stacking_info */
}
};
#define ECOS_NUM_PARAMS ((int)(sizeof(eCos_params_list)/sizeof(struct eCos_params)))
enum eCos_symbol_values {
eCos_VAL_thread_list = 0,
eCos_VAL_current_thread_ptr = 1
};
static char *eCos_symbol_list[] = {
"Cyg_Thread::thread_list",
"Cyg_Scheduler_Base::current_thread",
NULL
};
const struct rtos_type eCos_rtos = {
.name = "eCos",
.detect_rtos = eCos_detect_rtos,
.create = eCos_create,
.update_threads = eCos_update_threads,
.get_thread_reg_list = eCos_get_thread_reg_list,
.get_symbol_list_to_lookup = eCos_get_symbol_list_to_lookup,
};
static int eCos_update_threads(struct rtos *rtos)
{
int retval;
int tasks_found = 0;
int thread_list_size = 0;
const struct eCos_params *param;
if (rtos == NULL)
return -1;
if (rtos->rtos_specific_params == NULL)
return -3;
param = (const struct eCos_params *) rtos->rtos_specific_params;
if (rtos->symbols == NULL) {
LOG_ERROR("No symbols for eCos");
return -4;
}
if (rtos->symbols[eCos_VAL_thread_list].address == 0) {
LOG_ERROR("Don't have the thread list head");
return -2;
}
/* wipe out previous thread details if any */
if (rtos->thread_details != NULL) {
int j;
for (j = 0; j < rtos->thread_count; j++) {
if (rtos->thread_details[j].display_str != NULL) {
free(rtos->thread_details[j].display_str);
rtos->thread_details[j].display_str = NULL;
}
if (rtos->thread_details[j].thread_name_str != NULL) {
free(rtos->thread_details[j].thread_name_str);
rtos->thread_details[j].thread_name_str = NULL;
}
if (rtos->thread_details[j].extra_info_str != NULL) {
free(rtos->thread_details[j].extra_info_str);
rtos->thread_details[j].extra_info_str = NULL;
}
}
free(rtos->thread_details);
rtos->thread_details = NULL;
}
/* determine the number of current threads */
uint32_t thread_list_head = rtos->symbols[eCos_VAL_thread_list].address;
uint32_t thread_index;
target_read_buffer(rtos->target,
thread_list_head,
param->pointer_width,
(uint8_t *) &thread_index);
uint32_t first_thread = thread_index;
do {
thread_list_size++;
retval = target_read_buffer(rtos->target,
thread_index + param->thread_next_offset,
param->pointer_width,
(uint8_t *) &thread_index);
if (retval != ERROR_OK)
return retval;
} while (thread_index != first_thread);
/* read the current thread id */
uint32_t current_thread_addr;
retval = target_read_buffer(rtos->target,
rtos->symbols[eCos_VAL_current_thread_ptr].address,
4,
(uint8_t *)&current_thread_addr);
if (retval != ERROR_OK)
return retval;
rtos->current_thread = 0;
retval = target_read_buffer(rtos->target,
current_thread_addr + param->thread_uniqueid_offset,
2,
(uint8_t *)&rtos->current_thread);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read eCos current thread from target");
return retval;
}
if ((thread_list_size == 0) || (rtos->current_thread == 0)) {
/* Either : No RTOS threads - there is always at least the current execution though */
/* OR : No current thread - all threads suspended - show the current execution
* of idling */
char tmp_str[] = "Current Execution";
thread_list_size++;
tasks_found++;
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail) * thread_list_size);
rtos->thread_details->threadid = 1;
rtos->thread_details->exists = true;
rtos->thread_details->display_str = NULL;
rtos->thread_details->extra_info_str = NULL;
rtos->thread_details->thread_name_str = (char *) malloc(sizeof(tmp_str));
strcpy(rtos->thread_details->thread_name_str, tmp_str);
if (thread_list_size == 0) {
rtos->thread_count = 1;
return ERROR_OK;
}
} else {
/* create space for new thread details */
rtos->thread_details = (struct thread_detail *) malloc(
sizeof(struct thread_detail) * thread_list_size);
}
/* loop over all threads */
thread_index = first_thread;
do {
#define ECOS_THREAD_NAME_STR_SIZE (200)
char tmp_str[ECOS_THREAD_NAME_STR_SIZE];
unsigned int i = 0;
uint32_t name_ptr = 0;
uint32_t prev_thread_ptr;
/* Save the thread pointer */
uint16_t thread_id;
retval = target_read_buffer(rtos->target,
thread_index + param->thread_uniqueid_offset,
2,
(uint8_t *)&thread_id);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read eCos thread id from target");
return retval;
}
rtos->thread_details[tasks_found].threadid = thread_id;
/* read the name pointer */
retval = target_read_buffer(rtos->target,
thread_index + param->thread_name_offset,
param->pointer_width,
(uint8_t *)&name_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Could not read eCos thread name pointer from target");
return retval;
}
/* Read the thread name */
retval =
target_read_buffer(rtos->target,
name_ptr,
ECOS_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from eCos target");
return retval;
}
tmp_str[ECOS_THREAD_NAME_STR_SIZE-1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");
rtos->thread_details[tasks_found].thread_name_str =
(char *)malloc(strlen(tmp_str)+1);
strcpy(rtos->thread_details[tasks_found].thread_name_str, tmp_str);
/* Read the thread status */
int64_t thread_status = 0;
retval = target_read_buffer(rtos->target,
thread_index + param->thread_state_offset,
4,
(uint8_t *)&thread_status);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread state from eCos target");
return retval;
}
for (i = 0; (i < ECOS_NUM_STATES) && (eCos_thread_states[i].value != thread_status); i++) {
/*
* empty
*/
}
char *state_desc;
if (i < ECOS_NUM_STATES)
state_desc = eCos_thread_states[i].desc;
else
state_desc = "Unknown state";
rtos->thread_details[tasks_found].extra_info_str = (char *)malloc(strlen(
state_desc)+1);
strcpy(rtos->thread_details[tasks_found].extra_info_str, state_desc);
rtos->thread_details[tasks_found].exists = true;
rtos->thread_details[tasks_found].display_str = NULL;
tasks_found++;
prev_thread_ptr = thread_index;
/* Get the location of the next thread structure. */
thread_index = rtos->symbols[eCos_VAL_thread_list].address;
retval = target_read_buffer(rtos->target,
prev_thread_ptr + param->thread_next_offset,
param->pointer_width,
(uint8_t *) &thread_index);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading next thread pointer in eCos thread list");
return retval;
}
} while (thread_index != first_thread);
rtos->thread_count = tasks_found;
return 0;
}
static int eCos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list)
{
int retval;
const struct eCos_params *param;
*hex_reg_list = NULL;
if (rtos == NULL)
return -1;
if (thread_id == 0)
return -2;
if (rtos->rtos_specific_params == NULL)
return -3;
param = (const struct eCos_params *) rtos->rtos_specific_params;
/* Find the thread with that thread id */
uint16_t id = 0;
uint32_t thread_list_head = rtos->symbols[eCos_VAL_thread_list].address;
uint32_t thread_index;
target_read_buffer(rtos->target, thread_list_head, param->pointer_width,
(uint8_t *)&thread_index);
bool done = false;
while (!done) {
retval = target_read_buffer(rtos->target,
thread_index + param->thread_uniqueid_offset,
2,
(uint8_t *)&id);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading unique id from eCos thread");
return retval;
}
if (id == thread_id) {
done = true;
break;
}
target_read_buffer(rtos->target,
thread_index + param->thread_next_offset,
param->pointer_width,
(uint8_t *) &thread_index);
}
if (done) {
/* Read the stack pointer */
int64_t stack_ptr = 0;
retval = target_read_buffer(rtos->target,
thread_index + param->thread_stack_offset,
param->pointer_width,
(uint8_t *)&stack_ptr);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading stack frame from eCos thread");
return retval;
}
return rtos_generic_stack_read(rtos->target,
param->stacking_info,
stack_ptr,
hex_reg_list);
}
return -1;
}
static int eCos_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[])
{
unsigned int i;
*symbol_list = (symbol_table_elem_t *) malloc(
sizeof(symbol_table_elem_t) * ARRAY_SIZE(eCos_symbol_list));
for (i = 0; i < ARRAY_SIZE(eCos_symbol_list); i++)
(*symbol_list)[i].symbol_name = eCos_symbol_list[i];
return 0;
}
static int eCos_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
(target->rtos->symbols[eCos_VAL_thread_list].address != 0)) {
/* looks like eCos */
return 1;
}
return 0;
}
static int eCos_create(struct target *target)
{
int i = 0;
while ((i < ECOS_NUM_PARAMS) &&
(0 != strcmp(eCos_params_list[i].target_name, target->type->name))) {
i++;
}
if (i >= ECOS_NUM_PARAMS) {
LOG_ERROR("Could not find target in eCos compatibility list");
return -1;
}
target->rtos->rtos_specific_params = (void *) &eCos_params_list[i];
target->rtos->current_thread = 0;
target->rtos->thread_details = NULL;
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
/* gdb script to update the header file
according to kernel version and build option
before executing function awareness
kernel symbol must be loaded : symbol vmlinux
define awareness
set logging off
set logging file linux_header.h
set logging on
printf "#define QAT %p\n",&((struct task_struct *)(0))->stack
set $a=&((struct list_head *)(0))->next
set $a=(int)$a+(int)&((struct task_struct *)(0))->tasks
printf "#define NEXT %p\n",$a
printf "#define COMM %p\n",&((struct task_struct *)(0))->comm
printf "#define MEM %p\n",&((struct task_struct *)(0))->mm
printf "#define ONCPU %p\n",&((struct task_struct *)(0))->on_cpu
printf "#define PID %p\n",&((struct task_struct *)(0))->pid
printf "#define CPU_CONT %p\n",&((struct thread_info *)(0))->cpu_context
printf "#define PREEMPT %p\n",&((struct thread_info *)(0))->preempt_count
printf "#define MM_CTX %p\n",&((struct mm_struct *)(0))->context
end
*/
#define QAT 0x4
#define NEXT 0x1b0
#define COMM 0x2d4
#define MEM 0x1cc
#define ONCPU 0x18
#define PID 0x1f4
#define CPU_CONT 0x1c
#define PREEMPT 0x4
#define MM_CTX 0x160

View File

@ -0,0 +1,508 @@
/***************************************************************************
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtos.h"
#include "target/target.h"
#include "helper/log.h"
#include "helper/binarybuffer.h"
#include "server/gdb_server.h"
/* RTOSs */
extern struct rtos_type FreeRTOS_rtos;
extern struct rtos_type ThreadX_rtos;
extern struct rtos_type eCos_rtos;
extern struct rtos_type Linux_os;
extern struct rtos_type ChibiOS_rtos;
static struct rtos_type *rtos_types[] = {
&ThreadX_rtos,
&FreeRTOS_rtos,
&eCos_rtos,
&Linux_os,
&ChibiOS_rtos,
NULL
};
int rtos_thread_packet(struct connection *connection, char *packet, int packet_size);
int rtos_smp_init(struct target *target)
{
if (target->rtos->type->smp_init)
return target->rtos->type->smp_init(target);
return ERROR_TARGET_INIT_FAILED;
}
static int os_alloc(struct target *target, struct rtos_type *ostype)
{
struct rtos *os = target->rtos = calloc(1, sizeof(struct rtos));
if (!os)
return JIM_ERR;
os->type = ostype;
os->current_threadid = -1;
os->current_thread = 0;
os->symbols = NULL;
os->target = target;
/* RTOS drivers can override the packet handler in _create(). */
os->gdb_thread_packet = rtos_thread_packet;
return JIM_OK;
}
static void os_free(struct target *target)
{
if (!target->rtos)
return;
if (target->rtos->symbols)
free(target->rtos->symbols);
free(target->rtos);
target->rtos = NULL;
}
static int os_alloc_create(struct target *target, struct rtos_type *ostype)
{
int ret = os_alloc(target, ostype);
if (JIM_OK == ret) {
ret = target->rtos->type->create(target);
if (ret != JIM_OK)
os_free(target);
}
return ret;
}
int rtos_create(Jim_GetOptInfo *goi, struct target *target)
{
int x;
char *cp;
struct Jim_Obj *res;
if (!goi->isconfigure && goi->argc != 0) {
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS");
return JIM_ERR;
}
os_free(target);
Jim_GetOpt_String(goi, &cp, NULL);
if (0 == strcmp(cp, "auto")) {
/* Auto detect tries to look up all symbols for each RTOS,
* and runs the RTOS driver's _detect() function when GDB
* finds all symbols for any RTOS. See rtos_qsymbol(). */
target->rtos_auto_detect = true;
/* rtos_qsymbol() will iterate over all RTOSes. Allocate
* target->rtos here, and set it to the first RTOS type. */
return os_alloc(target, rtos_types[0]);
}
for (x = 0; rtos_types[x]; x++)
if (0 == strcmp(cp, rtos_types[x]->name))
return os_alloc_create(target, rtos_types[x]);
Jim_SetResultFormatted(goi->interp, "Unknown RTOS type %s, try one of: ", cp);
res = Jim_GetResult(goi->interp);
for (x = 0; rtos_types[x]; x++)
Jim_AppendStrings(goi->interp, res, rtos_types[x]->name, ", ", NULL);
Jim_AppendStrings(goi->interp, res, " or auto", NULL);
return JIM_ERR;
}
int gdb_thread_packet(struct connection *connection, char *packet, int packet_size)
{
struct target *target = get_target_from_connection(connection);
if (target->rtos == NULL)
return rtos_thread_packet(connection, packet, packet_size); /* thread not
*found*/
return target->rtos->gdb_thread_packet(connection, packet, packet_size);
}
static char *next_symbol(struct rtos *os, char *cur_symbol, uint64_t cur_addr)
{
symbol_table_elem_t *s;
if (!os->symbols)
os->type->get_symbol_list_to_lookup(&os->symbols);
if (!cur_symbol[0])
return os->symbols[0].symbol_name;
for (s = os->symbols; s->symbol_name; s++)
if (!strcmp(s->symbol_name, cur_symbol)) {
s->address = cur_addr;
s++;
return s->symbol_name;
}
return NULL;
}
/* rtos_qsymbol() processes and replies to all qSymbol packets from GDB.
*
* GDB sends a qSymbol:: packet (empty address, empty name) to notify
* that it can now answer qSymbol::hexcodedname queries, to look up symbols.
*
* If the qSymbol packet has no address that means GDB did not find the
* symbol, in which case auto-detect will move on to try the next RTOS.
*
* rtos_qsymbol() then calls the next_symbol() helper function, which
* iterates over symbol names for the current RTOS until it finds the
* symbol in the received GDB packet, and then returns the next entry
* in the list of symbols.
*
* If GDB replied about the last symbol for the RTOS and the RTOS was
* specified explicitly, then no further symbol lookup is done. When
* auto-detecting, the RTOS driver _detect() function must return success.
*
* rtos_qsymbol() returns 1 if an RTOS has been detected, or 0 otherwise.
*/
int rtos_qsymbol(struct connection *connection, char *packet, int packet_size)
{
int rtos_detected = 0;
uint64_t addr;
size_t reply_len;
char reply[GDB_BUFFER_SIZE], cur_sym[GDB_BUFFER_SIZE / 2] = "", *next_sym;
struct target *target = get_target_from_connection(connection);
struct rtos *os = target->rtos;
reply_len = sprintf(reply, "OK");
if (!os)
goto done;
/* Decode any symbol name in the packet*/
int len = unhexify(cur_sym, strchr(packet + 8, ':') + 1, strlen(strchr(packet + 8, ':') + 1));
cur_sym[len] = 0;
if ((strcmp(packet, "qSymbol::") != 0) && /* GDB is not offering symbol lookup for the first time */
(!sscanf(packet, "qSymbol:%" SCNx64 ":", &addr))) { /* GDB did not found an address for a symbol */
/* GDB could not find an address for the previous symbol */
if (!target->rtos_auto_detect) {
LOG_WARNING("RTOS %s not detected. (GDB could not find symbol \'%s\')", os->type->name, cur_sym);
goto done;
} else {
/* Autodetecting RTOS - try next RTOS */
if (!rtos_try_next(target))
goto done;
/* Next RTOS selected - invalidate current symbol */
cur_sym[0] = '\x00';
}
}
next_sym = next_symbol(os, cur_sym, addr);
if (!next_sym) {
/* No more symbols need looking up */
if (!target->rtos_auto_detect) {
rtos_detected = 1;
goto done;
}
if (os->type->detect_rtos(target)) {
LOG_INFO("Auto-detected RTOS: %s", os->type->name);
rtos_detected = 1;
goto done;
} else {
LOG_WARNING("No RTOS could be auto-detected!");
goto done;
}
}
if (8 + (strlen(next_sym) * 2) + 1 > sizeof(reply)) {
LOG_ERROR("ERROR: RTOS symbol '%s' name is too long for GDB!", next_sym);
goto done;
}
reply_len = snprintf(reply, sizeof(reply), "qSymbol:");
reply_len += hexify(reply + reply_len, next_sym, 0, sizeof(reply) - reply_len);
done:
gdb_put_packet(connection, reply, reply_len);
return rtos_detected;
}
int rtos_thread_packet(struct connection *connection, char *packet, int packet_size)
{
struct target *target = get_target_from_connection(connection);
if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
if ((target->rtos != NULL) && (target->rtos->thread_details != NULL) &&
(target->rtos->thread_count != 0)) {
threadid_t threadid = 0;
int found = -1;
sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);
if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
if (target->rtos->thread_details[thread_num].exists)
found = thread_num;
}
}
}
if (found == -1) {
gdb_put_packet(connection, "E01", 3); /* thread not found */
return ERROR_OK;
}
struct thread_detail *detail = &target->rtos->thread_details[found];
int str_size = 0;
if (detail->display_str != NULL)
str_size += strlen(detail->display_str);
if (detail->thread_name_str != NULL)
str_size += strlen(detail->thread_name_str);
if (detail->extra_info_str != NULL)
str_size += strlen(detail->extra_info_str);
char *tmp_str = (char *) malloc(str_size + 7);
char *tmp_str_ptr = tmp_str;
if (detail->display_str != NULL)
tmp_str_ptr += sprintf(tmp_str_ptr, "%s", detail->display_str);
if (detail->thread_name_str != NULL) {
if (tmp_str_ptr != tmp_str)
tmp_str_ptr += sprintf(tmp_str_ptr, " : ");
tmp_str_ptr += sprintf(tmp_str_ptr, "%s", detail->thread_name_str);
}
if (detail->extra_info_str != NULL) {
if (tmp_str_ptr != tmp_str)
tmp_str_ptr += sprintf(tmp_str_ptr, " : ");
tmp_str_ptr +=
sprintf(tmp_str_ptr, " : %s", detail->extra_info_str);
}
assert(strlen(tmp_str) ==
(size_t) (tmp_str_ptr - tmp_str));
char *hex_str = (char *) malloc(strlen(tmp_str) * 2 + 1);
int pkt_len = hexify(hex_str, tmp_str, 0, strlen(tmp_str) * 2 + 1);
gdb_put_packet(connection, hex_str, pkt_len);
free(hex_str);
free(tmp_str);
return ERROR_OK;
}
gdb_put_packet(connection, "", 0);
return ERROR_OK;
} else if (strncmp(packet, "qSymbol", 7) == 0) {
if (rtos_qsymbol(connection, packet, packet_size) == 1) {
target->rtos_auto_detect = false;
target->rtos->type->create(target);
target->rtos->type->update_threads(target->rtos);
}
return ERROR_OK;
} else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
int i;
if ((target->rtos != NULL) && (target->rtos->thread_count != 0)) {
char *out_str = (char *) malloc(17 * target->rtos->thread_count + 5);
char *tmp_str = out_str;
tmp_str += sprintf(tmp_str, "m");
for (i = 0; i < target->rtos->thread_count; i++) {
if (i != 0)
tmp_str += sprintf(tmp_str, ",");
tmp_str += sprintf(tmp_str, "%016" PRIx64,
target->rtos->thread_details[i].threadid);
}
tmp_str[0] = 0;
gdb_put_packet(connection, out_str, strlen(out_str));
} else
gdb_put_packet(connection, "", 0);
return ERROR_OK;
} else if (strncmp(packet, "qsThreadInfo", 12) == 0) {
gdb_put_packet(connection, "l", 1);
return ERROR_OK;
} else if (strncmp(packet, "qAttached", 9) == 0) {
gdb_put_packet(connection, "1", 1);
return ERROR_OK;
} else if (strncmp(packet, "qOffsets", 8) == 0) {
char offsets[] = "Text=0;Data=0;Bss=0";
gdb_put_packet(connection, offsets, sizeof(offsets)-1);
return ERROR_OK;
} else if (strncmp(packet, "qCRC:", 5) == 0) {
/* make sure we check this before "qC" packet below
* otherwise it gets incorrectly handled */
return GDB_THREAD_PACKET_NOT_CONSUMED;
} else if (strncmp(packet, "qC", 2) == 0) {
if (target->rtos != NULL) {
char buffer[19];
int size;
size = snprintf(buffer, 19, "QC%016" PRIx64, target->rtos->current_thread);
gdb_put_packet(connection, buffer, size);
} else
gdb_put_packet(connection, "QC0", 3);
return ERROR_OK;
} else if (packet[0] == 'T') { /* Is thread alive? */
threadid_t threadid;
int found = -1;
sscanf(packet, "T%" SCNx64, &threadid);
if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
if (target->rtos->thread_details[thread_num].exists)
found = thread_num;
}
}
}
if (found != -1)
gdb_put_packet(connection, "OK", 2); /* thread alive */
else
gdb_put_packet(connection, "E01", 3); /* thread not found */
return ERROR_OK;
} else if (packet[0] == 'H') { /* Set current thread ( 'c' for step and continue, 'g' for
* all other operations ) */
if ((packet[1] == 'g') && (target->rtos != NULL))
sscanf(packet, "Hg%16" SCNx64, &target->rtos->current_threadid);
gdb_put_packet(connection, "OK", 2);
return ERROR_OK;
}
return GDB_THREAD_PACKET_NOT_CONSUMED;
}
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;
if ((target->rtos != NULL) && (current_threadid != -1) &&
(current_threadid != 0) &&
((current_threadid != target->rtos->current_thread) ||
(target->smp))) { /* in smp several current thread are possible */
char *hex_reg_list;
target->rtos->type->get_thread_reg_list(target->rtos,
current_threadid,
&hex_reg_list);
if (hex_reg_list != NULL) {
gdb_put_packet(connection, hex_reg_list, strlen(hex_reg_list));
free(hex_reg_list);
return ERROR_OK;
}
}
return ERROR_FAIL;
}
int rtos_generic_stack_read(struct target *target,
const struct rtos_register_stacking *stacking,
int64_t stack_ptr,
char **hex_reg_list)
{
int list_size = 0;
char *tmp_str_ptr;
int64_t new_stack_ptr;
int i;
int retval;
if (stack_ptr == 0) {
LOG_ERROR("Error: null stack pointer in thread");
return -5;
}
/* Read the stack */
uint8_t *stack_data = (uint8_t *) malloc(stacking->stack_registers_size);
uint32_t address = stack_ptr;
if (stacking->stack_growth_direction == 1)
address -= stacking->stack_registers_size;
retval = target_read_buffer(target, address, stacking->stack_registers_size, stack_data);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading stack frame from thread");
return retval;
}
#if 0
LOG_OUTPUT("Stack Data :");
for (i = 0; i < stacking->stack_registers_size; i++)
LOG_OUTPUT("%02X", stack_data[i]);
LOG_OUTPUT("\r\n");
#endif
for (i = 0; i < stacking->num_output_registers; i++)
list_size += stacking->register_offsets[i].width_bits/8;
*hex_reg_list = (char *)malloc(list_size*2 + 1);
tmp_str_ptr = *hex_reg_list;
new_stack_ptr = stack_ptr - stacking->stack_growth_direction *
stacking->stack_registers_size;
if (stacking->stack_alignment != 0) {
/* Align new stack pointer to x byte boundary */
new_stack_ptr =
(new_stack_ptr & (~((int64_t) stacking->stack_alignment - 1))) +
((stacking->stack_growth_direction == -1) ? stacking->stack_alignment : 0);
}
for (i = 0; i < stacking->num_output_registers; i++) {
int j;
for (j = 0; j < stacking->register_offsets[i].width_bits/8; j++) {
if (stacking->register_offsets[i].offset == -1)
tmp_str_ptr += sprintf(tmp_str_ptr, "%02x", 0);
else if (stacking->register_offsets[i].offset == -2)
tmp_str_ptr += sprintf(tmp_str_ptr, "%02x",
((uint8_t *)&new_stack_ptr)[j]);
else
tmp_str_ptr += sprintf(tmp_str_ptr, "%02x",
stack_data[stacking->register_offsets[i].offset + j]);
}
}
/* LOG_OUTPUT("Output register string: %s\r\n", *hex_reg_list); */
return ERROR_OK;
}
int rtos_try_next(struct target *target)
{
struct rtos *os = target->rtos;
struct rtos_type **type = rtos_types;
if (!os)
return 0;
while (*type && os->type != *type)
type++;
if (!*type || !*(++type))
return 0;
os->type = *type;
if (os->symbols) {
free(os->symbols);
os->symbols = NULL;
}
return 1;
}
int rtos_update_threads(struct target *target)
{
if ((target->rtos != NULL) && (target->rtos->type != NULL))
target->rtos->type->update_threads(target->rtos);
return ERROR_OK;
}

View File

@ -0,0 +1,105 @@
/***************************************************************************
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef RTOS_H
#define RTOS_H
#include "server/server.h"
#include <jim-nvp.h>
typedef int64_t threadid_t;
typedef int64_t symbol_address_t;
struct reg;
/**
* Table should be terminated by an element with NULL in symbol_name
*/
typedef struct symbol_table_elem_struct {
char *symbol_name;
symbol_address_t address;
} symbol_table_elem_t;
struct thread_detail {
threadid_t threadid;
bool exists;
char *display_str;
char *thread_name_str;
char *extra_info_str;
};
struct rtos {
const struct rtos_type *type;
symbol_table_elem_t *symbols;
struct target *target;
/* add a context variable instead of global variable */
int64_t current_threadid;
threadid_t current_thread;
struct thread_detail *thread_details;
int thread_count;
int (*gdb_thread_packet)(struct connection *connection, char *packet, int packet_size);
void *rtos_specific_params;
};
struct rtos_type {
char *name;
int (*detect_rtos)(struct target *target);
int (*create)(struct target *target);
int (*smp_init)(struct target *target);
int (*update_threads)(struct rtos *rtos);
int (*get_thread_reg_list)(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
int (*get_symbol_list_to_lookup)(symbol_table_elem_t *symbol_list[]);
int (*clean)(struct target *target);
char * (*ps_command)(struct target *target);
};
struct stack_register_offset {
signed short offset; /* offset in bytes from stack head, or -1 to indicate
* register is not stacked, or -2 to indicate this is the
* stack pointer register */
unsigned short width_bits;
};
struct rtos_register_stacking {
unsigned char stack_registers_size;
signed char stack_growth_direction;
unsigned char num_output_registers;
unsigned char stack_alignment;
const struct stack_register_offset *register_offsets;
};
#define GDB_THREAD_PACKET_NOT_CONSUMED (-40)
int rtos_create(Jim_GetOptInfo *goi, struct target *target);
int rtos_generic_stack_read(struct target *target,
const struct rtos_register_stacking *stacking,
int64_t stack_ptr,
char **hex_reg_list);
int rtos_try_next(struct target *target);
int gdb_thread_packet(struct connection *connection, char *packet, int packet_size);
int rtos_get_gdb_reg_list(struct connection *connection);
int rtos_update_threads(struct target *target);
int rtos_smp_init(struct target *target);
/* function for handling symbol access */
int rtos_qsymbol(struct connection *connection, char *packet, int packet_size);
#endif /* RTOS_H */

View File

@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (C) 2012 by Matthias Blaicher *
* Matthias Blaicher - matthias@blaicher.com *
* *
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtos.h"
static const struct stack_register_offset rtos_chibios_arm_v7m_stack_offsets[] = {
{ -1, 32 }, /* r0 */
{ -1, 32 }, /* r1 */
{ -1, 32 }, /* r2 */
{ -1, 32 }, /* r3 */
{ 0x00, 32 }, /* r4 */
{ 0x04, 32 }, /* r5 */
{ 0x08, 32 }, /* r6 */
{ 0x0c, 32 }, /* r7 */
{ 0x10, 32 }, /* r8 */
{ 0x14, 32 }, /* r9 */
{ 0x18, 32 }, /* r10 */
{ 0x1c, 32 }, /* r11 */
{ -1, 32 }, /* r12 */
{ -2, 32 }, /* sp */
{ -1, 32 }, /* lr */
{ 0x20, 32 }, /* pc */
{ -1, 96 }, /* FPA1 */
{ -1, 96 }, /* FPA2 */
{ -1, 96 }, /* FPA3 */
{ -1, 96 }, /* FPA4 */
{ -1, 96 }, /* FPA5 */
{ -1, 96 }, /* FPA6 */
{ -1, 96 }, /* FPA7 */
{ -1, 96 }, /* FPA8 */
{ -1, 32 }, /* FPS */
{ -1, 32 }, /* xPSR */
};
const struct rtos_register_stacking rtos_chibios_arm_v7m_stacking = {
0x24, /* stack_registers_size */
-1, /* stack_growth_direction */
26, /* num_output_registers */
0, /* stack_alignment */
rtos_chibios_arm_v7m_stack_offsets /* register_offsets */
};

View File

@ -0,0 +1,32 @@
/***************************************************************************
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef INCLUDED_RTOS_CHIBIOS_STACKINGS_H_
#define INCLUDED_RTOS_CHIBIOS_STACKINGS_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtos.h"
extern const struct rtos_register_stacking rtos_chibios_arm_v7m_stacking;
#endif /* ifndef INCLUDED_RTOS_CHIBIOS_STACKINGS_H_ */

View File

@ -0,0 +1,60 @@
/***************************************************************************
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtos.h"
static const struct stack_register_offset rtos_eCos_Cortex_M3_stack_offsets[] = {
{ 0x0c, 32 }, /* r0 */
{ 0x10, 32 }, /* r1 */
{ 0x14, 32 }, /* r2 */
{ 0x18, 32 }, /* r3 */
{ 0x1c, 32 }, /* r4 */
{ 0x20, 32 }, /* r5 */
{ 0x24, 32 }, /* r6 */
{ 0x28, 32 }, /* r7 */
{ 0x2c, 32 }, /* r8 */
{ 0x30, 32 }, /* r9 */
{ 0x34, 32 }, /* r10 */
{ 0x38, 32 }, /* r11 */
{ 0x3c, 32 }, /* r12 */
{ -2, 32 }, /* sp */
{ -1, 32 }, /* lr */
{ 0x40, 32 }, /* pc */
{ -1, 96 }, /* FPA1 */
{ -1, 96 }, /* FPA2 */
{ -1, 96 }, /* FPA3 */
{ -1, 96 }, /* FPA4 */
{ -1, 96 }, /* FPA5 */
{ -1, 96 }, /* FPA6 */
{ -1, 96 }, /* FPA7 */
{ -1, 96 }, /* FPA8 */
{ -1, 32 }, /* FPS */
{ -1, 32 }, /* xPSR */
};
const struct rtos_register_stacking rtos_eCos_Cortex_M3_stacking = {
0x44, /* stack_registers_size */
-1, /* stack_growth_direction */
26, /* num_output_registers */
8, /* stack_alignment */
rtos_eCos_Cortex_M3_stack_offsets /* register_offsets */
};

View File

@ -0,0 +1,30 @@
/***************************************************************************
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef INCLUDED_RTOS_STANDARD_STACKINGS_H_
#define INCLUDED_RTOS_STANDARD_STACKINGS_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtos.h"
extern const struct rtos_register_stacking rtos_eCos_Cortex_M3_stacking;
#endif /* ifndef INCLUDED_RTOS_STANDARD_STACKINGS_H_ */

View File

@ -0,0 +1,101 @@
/***************************************************************************
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtos.h"
static const struct stack_register_offset rtos_standard_Cortex_M3_stack_offsets[] = {
{ 0x20, 32 }, /* r0 */
{ 0x24, 32 }, /* r1 */
{ 0x28, 32 }, /* r2 */
{ 0x2c, 32 }, /* r3 */
{ 0x00, 32 }, /* r4 */
{ 0x04, 32 }, /* r5 */
{ 0x08, 32 }, /* r6 */
{ 0x0c, 32 }, /* r7 */
{ 0x10, 32 }, /* r8 */
{ 0x14, 32 }, /* r9 */
{ 0x18, 32 }, /* r10 */
{ 0x1c, 32 }, /* r11 */
{ 0x30, 32 }, /* r12 */
{ -2, 32 }, /* sp */
{ 0x34, 32 }, /* lr */
{ 0x38, 32 }, /* pc */
{ -1, 96 }, /* FPA1 */
{ -1, 96 }, /* FPA2 */
{ -1, 96 }, /* FPA3 */
{ -1, 96 }, /* FPA4 */
{ -1, 96 }, /* FPA5 */
{ -1, 96 }, /* FPA6 */
{ -1, 96 }, /* FPA7 */
{ -1, 96 }, /* FPA8 */
{ -1, 32 }, /* FPS */
{ 0x3c, 32 }, /* xPSR */
};
static const struct stack_register_offset rtos_standard_Cortex_R4_stack_offsets[] = {
{ 0x08, 32 }, /* r0 (a1) */
{ 0x0c, 32 }, /* r1 (a2) */
{ 0x10, 32 }, /* r2 (a3) */
{ 0x14, 32 }, /* r3 (a4) */
{ 0x18, 32 }, /* r4 (v1) */
{ 0x1c, 32 }, /* r5 (v2) */
{ 0x20, 32 }, /* r6 (v3) */
{ 0x24, 32 }, /* r7 (v4) */
{ 0x28, 32 }, /* r8 (a1) */
{ 0x2c, 32 }, /* r9 (sb) */
{ 0x30, 32 }, /* r10 (sl) */
{ 0x34, 32 }, /* r11 (fp) */
{ 0x38, 32 }, /* r12 (ip) */
{ -2, 32 }, /* sp */
{ 0x3c, 32 }, /* lr */
{ 0x40, 32 }, /* pc */
{ -1, 96 }, /* FPA1 */
{ -1, 96 }, /* FPA2 */
{ -1, 96 }, /* FPA3 */
{ -1, 96 }, /* FPA4 */
{ -1, 96 }, /* FPA5 */
{ -1, 96 }, /* FPA6 */
{ -1, 96 }, /* FPA7 */
{ -1, 96 }, /* FPA8 */
{ -1, 32 }, /* FPS */
{ 0x04, 32 }, /* CSPR */
};
const struct rtos_register_stacking rtos_standard_Cortex_M3_stacking = {
0x40, /* stack_registers_size */
-1, /* stack_growth_direction */
26, /* num_output_registers */
8, /* stack_alignment */
rtos_standard_Cortex_M3_stack_offsets /* register_offsets */
};
const struct rtos_register_stacking rtos_standard_Cortex_R4_stacking = {
0x48, /* stack_registers_size */
-1, /* stack_growth_direction */
26, /* num_output_registers */
8, /* stack_alignment */
rtos_standard_Cortex_R4_stack_offsets /* register_offsets */
};

View File

@ -0,0 +1,33 @@
/***************************************************************************
* Copyright (C) 2011 by Broadcom Corporation *
* Evan Hunter - ehunter@broadcom.com *
* *
* 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 *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef INCLUDED_RTOS_STANDARD_STACKINGS_H_
#define INCLUDED_RTOS_STANDARD_STACKINGS_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtos.h"
extern const struct rtos_register_stacking rtos_standard_Cortex_M3_stacking;
extern const struct rtos_register_stacking rtos_standard_Cortex_R4_stacking;
#endif /* ifndef INCLUDED_RTOS_STANDARD_STACKINGS_H_ */