build: add helper/types.h to config.h
[openocd/libswd.git] / src / rtos / rtos.h
blobd8335b4a82e022210563be2fe4364c3ca6a72ca9
1 /***************************************************************************
2 * Copyright (C) 2011 by Broadcom Corporation *
3 * Evan Hunter - ehunter@broadcom.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef RTOS_H
22 #define RTOS_H
24 #include "server/server.h"
25 #include <jim-nvp.h>
27 typedef int64_t threadid_t;
28 typedef int64_t symbol_address_t;
30 struct reg;
32 /**
33 * Table should be terminated by an element with NULL in symbol_name
35 typedef struct symbol_table_elem_struct {
36 char *symbol_name;
37 symbol_address_t address;
39 } symbol_table_elem_t;
41 struct thread_detail {
42 threadid_t threadid;
43 bool exists;
44 char *display_str;
45 char *thread_name_str;
46 char *extra_info_str;
49 struct rtos {
50 const struct rtos_type *type;
52 symbol_table_elem_t *symbols;
53 struct target *target;
54 /* add a context variable instead of global variable */
55 int64_t current_threadid;
56 threadid_t current_thread;
57 struct thread_detail *thread_details;
58 int thread_count;
59 int (*gdb_thread_packet)(struct connection *connection, char *packet, int packet_size);
60 void *rtos_specific_params;
63 struct rtos_type {
64 char *name;
65 int (*detect_rtos)(struct target *target);
66 int (*create)(struct target *target);
67 int (*smp_init)(struct target *target);
68 int (*update_threads)(struct rtos *rtos);
69 int (*get_thread_reg_list)(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
70 int (*get_symbol_list_to_lookup)(symbol_table_elem_t *symbol_list[]);
71 int (*clean)(struct target *target);
72 char * (*ps_command)(struct target *target);
75 struct stack_register_offset {
76 signed short offset; /* offset in bytes from stack head, or -1 to indicate
77 * register is not stacked, or -2 to indicate this is the
78 * stack pointer register */
79 unsigned short width_bits;
82 struct rtos_register_stacking {
83 unsigned char stack_registers_size;
84 signed char stack_growth_direction;
85 unsigned char num_output_registers;
86 unsigned char stack_alignment;
87 const struct stack_register_offset *register_offsets;
90 #define GDB_THREAD_PACKET_NOT_CONSUMED (-40)
92 int rtos_create(Jim_GetOptInfo *goi, struct target *target);
93 int rtos_generic_stack_read(struct target *target,
94 const struct rtos_register_stacking *stacking,
95 int64_t stack_ptr,
96 char **hex_reg_list);
97 int rtos_try_next(struct target *target);
98 int gdb_thread_packet(struct connection *connection, char *packet, int packet_size);
99 int rtos_get_gdb_reg_list(struct connection *connection);
100 int rtos_update_threads(struct target *target);
101 int rtos_smp_init(struct target *target);
102 /* function for handling symbol access */
103 int rtos_qsymbol(struct connection *connection, char *packet, int packet_size);
104 int str_to_hex(char *hex_dst, char *src);
106 #endif /* RTOS_H */