a93daeef974fa85f014a281199f77f6d00fd1855
[openocd.git] / src / rtos / rtos.h
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 ***************************************************************************/
20
21 #ifndef RTOS_H
22 #define RTOS_H
23
24 #include "server/server.h"
25 #include <helper/types.h>
26 #include <jim-nvp.h>
27
28 typedef int64_t threadid_t;
29 typedef int64_t symbol_address_t;
30
31 struct reg;
32
33 /**
34 * Table should be terminated by an element with NULL in symbol_name
35 */
36 typedef struct symbol_table_elem_struct {
37 char *symbol_name;
38 symbol_address_t address;
39
40 } symbol_table_elem_t;
41
42 struct thread_detail {
43 threadid_t threadid;
44 bool exists;
45 char *display_str;
46 char *thread_name_str;
47 char *extra_info_str;
48 };
49
50 struct rtos {
51 const struct rtos_type *type;
52
53 symbol_table_elem_t *symbols;
54 struct target *target;
55 /* add a context variable instead of global variable */
56 int64_t current_threadid;
57 threadid_t current_thread;
58 struct thread_detail *thread_details;
59 int thread_count;
60 int (*gdb_thread_packet)(struct connection *connection, char *packet, int packet_size);
61 void *rtos_specific_params;
62 };
63
64 struct rtos_type {
65 char *name;
66 int (*detect_rtos)(struct target *target);
67 int (*create)(struct target *target);
68 int (*smp_init)(struct target *target);
69 int (*update_threads)(struct rtos *rtos);
70 int (*get_thread_reg_list)(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
71 int (*get_symbol_list_to_lookup)(symbol_table_elem_t *symbol_list[]);
72 int (*clean)(struct target *target);
73 char * (*ps_command)(struct target *target);
74 };
75
76 struct stack_register_offset {
77 signed short offset; /* offset in bytes from stack head, or -1 to indicate
78 * register is not stacked, or -2 to indicate this is the
79 * stack pointer register */
80 unsigned short width_bits;
81 };
82
83 struct rtos_register_stacking {
84 unsigned char stack_registers_size;
85 signed char stack_growth_direction;
86 unsigned char num_output_registers;
87 unsigned char stack_alignment;
88 const struct stack_register_offset *register_offsets;
89 };
90
91 #define GDB_THREAD_PACKET_NOT_CONSUMED (-40)
92
93 int rtos_create(Jim_GetOptInfo *goi, struct target *target);
94 int rtos_generic_stack_read(struct target *target,
95 const struct rtos_register_stacking *stacking,
96 int64_t stack_ptr,
97 char **hex_reg_list);
98 int rtos_try_next(struct target *target);
99 int gdb_thread_packet(struct connection *connection, char *packet, int packet_size);
100 int rtos_get_gdb_reg_list(struct connection *connection);
101 int rtos_update_threads(struct target *target);
102 int rtos_smp_init(struct target *target);
103 /* function for handling symbol access */
104 int rtos_qsymbol(struct connection *connection, char *packet, int packet_size);
105 int str_to_hex(char *hex_dst, char *src);
106
107 #endif /* RTOS_H */