ARMv8: Update rtos_reg storage from 8 to 16 bytes
[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, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
18
19 #ifndef OPENOCD_RTOS_RTOS_H
20 #define OPENOCD_RTOS_RTOS_H
21
22 #include "server/server.h"
23 #include <jim-nvp.h>
24
25 typedef int64_t threadid_t;
26 typedef int64_t symbol_address_t;
27
28 struct reg;
29
30 /**
31 * Table should be terminated by an element with NULL in symbol_name
32 */
33 typedef struct symbol_table_elem_struct {
34 const char *symbol_name;
35 symbol_address_t address;
36 bool optional;
37 } symbol_table_elem_t;
38
39 struct thread_detail {
40 threadid_t threadid;
41 bool exists;
42 char *thread_name_str;
43 char *extra_info_str;
44 };
45
46 struct rtos {
47 const struct rtos_type *type;
48
49 symbol_table_elem_t *symbols;
50 struct target *target;
51 /* add a context variable instead of global variable */
52 int64_t current_threadid;
53 threadid_t current_thread;
54 struct thread_detail *thread_details;
55 int thread_count;
56 int (*gdb_thread_packet)(struct connection *connection, char const *packet, int packet_size);
57 int (*gdb_target_for_threadid)(struct connection *connection, int64_t thread_id, struct target **p_target);
58 void *rtos_specific_params;
59 };
60
61 struct rtos_reg {
62 uint32_t number;
63 uint32_t size;
64 uint8_t value[16];
65 };
66
67 struct rtos_type {
68 const char *name;
69 bool (*detect_rtos)(struct target *target);
70 int (*create)(struct target *target);
71 int (*smp_init)(struct target *target);
72 int (*update_threads)(struct rtos *rtos);
73 int (*get_thread_reg_list)(struct rtos *rtos, int64_t thread_id,
74 struct rtos_reg **reg_list, int *num_regs);
75 int (*get_symbol_list_to_lookup)(symbol_table_elem_t *symbol_list[]);
76 int (*clean)(struct target *target);
77 char * (*ps_command)(struct target *target);
78 };
79
80 struct stack_register_offset {
81 unsigned short number; /* register number */
82 signed short offset; /* offset in bytes from stack head, or -1 to indicate
83 * register is not stacked, or -2 to indicate this is the
84 * stack pointer register */
85 unsigned short width_bits;
86 };
87
88 struct rtos_register_stacking {
89 unsigned char stack_registers_size;
90 signed char stack_growth_direction;
91 unsigned char num_output_registers;
92 /* Some targets require evaluating the stack to determine the
93 * actual stack pointer for a process. If this field is NULL,
94 * just use stacking->stack_registers_size * stack_growth_direction
95 * to calculate adjustment.
96 */
97 int64_t (*calculate_process_stack)(struct target *target,
98 const uint8_t *stack_data,
99 const struct rtos_register_stacking *stacking,
100 int64_t stack_ptr);
101 const struct stack_register_offset *register_offsets;
102 };
103
104 #define GDB_THREAD_PACKET_NOT_CONSUMED (-40)
105
106 int rtos_create(Jim_GetOptInfo *goi, struct target *target);
107 int rtos_generic_stack_read(struct target *target,
108 const struct rtos_register_stacking *stacking,
109 int64_t stack_ptr,
110 struct rtos_reg **reg_list,
111 int *num_regs);
112 int rtos_try_next(struct target *target);
113 int gdb_thread_packet(struct connection *connection, char const *packet, int packet_size);
114 int rtos_get_gdb_reg(struct connection *connection, int reg_num);
115 int rtos_get_gdb_reg_list(struct connection *connection);
116 int rtos_update_threads(struct target *target);
117 void rtos_free_threadlist(struct rtos *rtos);
118 int rtos_smp_init(struct target *target);
119 /* function for handling symbol access */
120 int rtos_qsymbol(struct connection *connection, char const *packet, int packet_size);
121
122 #endif /* OPENOCD_RTOS_RTOS_H */