2011-04-14 03:25:01 -05:00
|
|
|
/***************************************************************************
|
|
|
|
* 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 *
|
2016-05-16 15:41:00 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
2011-04-14 03:25:01 -05:00
|
|
|
***************************************************************************/
|
|
|
|
|
2015-09-21 14:07:46 -05:00
|
|
|
#ifndef OPENOCD_RTOS_RTOS_H
|
|
|
|
#define OPENOCD_RTOS_RTOS_H
|
2011-04-14 03:25:01 -05:00
|
|
|
|
|
|
|
#include "server/server.h"
|
|
|
|
#include <jim-nvp.h>
|
|
|
|
|
2011-04-18 10:43:51 -05:00
|
|
|
typedef int64_t threadid_t;
|
|
|
|
typedef int64_t symbol_address_t;
|
2011-04-14 03:25:01 -05:00
|
|
|
|
|
|
|
struct reg;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Table should be terminated by an element with NULL in symbol_name
|
|
|
|
*/
|
2012-01-30 09:32:53 -06:00
|
|
|
typedef struct symbol_table_elem_struct {
|
2014-09-11 16:07:10 -05:00
|
|
|
const char *symbol_name;
|
2011-04-14 03:25:01 -05:00
|
|
|
symbol_address_t address;
|
2014-10-25 02:20:10 -05:00
|
|
|
bool optional;
|
2011-04-14 03:25:01 -05:00
|
|
|
} symbol_table_elem_t;
|
|
|
|
|
2012-01-30 09:32:53 -06:00
|
|
|
struct thread_detail {
|
2011-04-14 03:25:01 -05:00
|
|
|
threadid_t threadid;
|
|
|
|
bool exists;
|
2012-01-30 09:32:53 -06:00
|
|
|
char *thread_name_str;
|
|
|
|
char *extra_info_str;
|
2011-04-14 03:25:01 -05:00
|
|
|
};
|
|
|
|
|
2012-01-30 09:32:53 -06:00
|
|
|
struct rtos {
|
2011-04-14 03:25:01 -05:00
|
|
|
const struct rtos_type *type;
|
|
|
|
|
2012-01-30 09:32:53 -06:00
|
|
|
symbol_table_elem_t *symbols;
|
2011-04-14 03:25:01 -05:00
|
|
|
struct target *target;
|
2012-01-03 09:07:55 -06:00
|
|
|
/* add a context variable instead of global variable */
|
|
|
|
int64_t current_threadid;
|
2011-04-14 03:25:01 -05:00
|
|
|
threadid_t current_thread;
|
2012-01-30 09:32:53 -06:00
|
|
|
struct thread_detail *thread_details;
|
2011-04-14 03:25:01 -05:00
|
|
|
int thread_count;
|
2014-02-14 14:48:52 -06:00
|
|
|
int (*gdb_thread_packet)(struct connection *connection, char const *packet, int packet_size);
|
2017-02-17 07:45:00 -06:00
|
|
|
int (*gdb_target_for_threadid)(struct connection *connection, int64_t thread_id, struct target **p_target);
|
2012-01-30 09:32:53 -06:00
|
|
|
void *rtos_specific_params;
|
2011-04-14 03:25:01 -05:00
|
|
|
};
|
|
|
|
|
2017-05-03 12:46:11 -05:00
|
|
|
struct rtos_reg {
|
|
|
|
uint32_t number;
|
|
|
|
uint32_t size;
|
2019-05-16 15:47:57 -05:00
|
|
|
uint8_t value[16];
|
2017-05-03 12:46:11 -05:00
|
|
|
};
|
|
|
|
|
2012-01-30 09:32:53 -06:00
|
|
|
struct rtos_type {
|
2014-09-11 16:07:10 -05:00
|
|
|
const char *name;
|
2017-10-29 05:39:51 -05:00
|
|
|
bool (*detect_rtos)(struct target *target);
|
2012-01-30 09:32:53 -06:00
|
|
|
int (*create)(struct target *target);
|
2012-01-03 09:12:50 -06:00
|
|
|
int (*smp_init)(struct target *target);
|
2012-01-30 09:32:53 -06:00
|
|
|
int (*update_threads)(struct rtos *rtos);
|
2017-05-03 12:46:11 -05:00
|
|
|
int (*get_thread_reg_list)(struct rtos *rtos, int64_t thread_id,
|
|
|
|
struct rtos_reg **reg_list, int *num_regs);
|
2012-01-30 09:32:53 -06:00
|
|
|
int (*get_symbol_list_to_lookup)(symbol_table_elem_t *symbol_list[]);
|
2012-01-03 09:12:50 -06:00
|
|
|
int (*clean)(struct target *target);
|
2012-01-03 09:18:22 -06:00
|
|
|
char * (*ps_command)(struct target *target);
|
2011-04-14 03:25:01 -05:00
|
|
|
};
|
|
|
|
|
2012-01-30 09:32:53 -06:00
|
|
|
struct stack_register_offset {
|
2017-05-03 12:46:11 -05:00
|
|
|
unsigned short number; /* register number */
|
2012-01-30 09:32:53 -06:00
|
|
|
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 */
|
2011-04-14 03:25:01 -05:00
|
|
|
unsigned short width_bits;
|
|
|
|
};
|
|
|
|
|
2012-01-30 09:32:53 -06:00
|
|
|
struct rtos_register_stacking {
|
|
|
|
unsigned char stack_registers_size;
|
|
|
|
signed char stack_growth_direction;
|
|
|
|
unsigned char num_output_registers;
|
2015-10-05 13:51:10 -05:00
|
|
|
/* Some targets require evaluating the stack to determine the
|
|
|
|
* actual stack pointer for a process. If this field is NULL,
|
|
|
|
* just use stacking->stack_registers_size * stack_growth_direction
|
|
|
|
* to calculate adjustment.
|
|
|
|
*/
|
|
|
|
int64_t (*calculate_process_stack)(struct target *target,
|
|
|
|
const uint8_t *stack_data,
|
|
|
|
const struct rtos_register_stacking *stacking,
|
|
|
|
int64_t stack_ptr);
|
2012-01-30 09:32:53 -06:00
|
|
|
const struct stack_register_offset *register_offsets;
|
2011-04-14 03:25:01 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GDB_THREAD_PACKET_NOT_CONSUMED (-40)
|
|
|
|
|
2012-01-30 09:32:53 -06:00
|
|
|
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,
|
2017-05-03 12:46:11 -05:00
|
|
|
struct rtos_reg **reg_list,
|
|
|
|
int *num_regs);
|
2012-01-30 09:32:53 -06:00
|
|
|
int rtos_try_next(struct target *target);
|
2014-02-14 14:48:52 -06:00
|
|
|
int gdb_thread_packet(struct connection *connection, char const *packet, int packet_size);
|
2017-05-03 12:46:11 -05:00
|
|
|
int rtos_get_gdb_reg(struct connection *connection, int reg_num);
|
2012-01-03 08:34:14 -06:00
|
|
|
int rtos_get_gdb_reg_list(struct connection *connection);
|
2012-01-30 09:32:53 -06:00
|
|
|
int rtos_update_threads(struct target *target);
|
2014-02-01 03:17:17 -06:00
|
|
|
void rtos_free_threadlist(struct rtos *rtos);
|
2012-01-03 09:12:50 -06:00
|
|
|
int rtos_smp_init(struct target *target);
|
2012-01-03 10:12:29 -06:00
|
|
|
/* function for handling symbol access */
|
2014-02-14 14:48:52 -06:00
|
|
|
int rtos_qsymbol(struct connection *connection, char const *packet, int packet_size);
|
2011-04-14 03:25:01 -05:00
|
|
|
|
2015-09-21 14:07:46 -05:00
|
|
|
#endif /* OPENOCD_RTOS_RTOS_H */
|