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