1 |
4 |
sergeykhbr |
/*
|
2 |
|
|
* Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
|
3 |
|
|
*
|
4 |
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
|
|
* you may not use this file except in compliance with the License.
|
6 |
|
|
* You may obtain a copy of the License at
|
7 |
|
|
*
|
8 |
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
9 |
|
|
*
|
10 |
|
|
* Unless required by applicable law or agreed to in writing, software
|
11 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
|
|
* See the License for the specific language governing permissions and
|
14 |
|
|
* limitations under the License.
|
15 |
|
|
*/
|
16 |
|
|
|
17 |
|
|
#ifndef __DEBUGGER_API_CORE_H__
|
18 |
|
|
#define __DEBUGGER_API_CORE_H__
|
19 |
|
|
|
20 |
|
|
#include <api_utils.h>
|
21 |
|
|
#include <iface.h>
|
22 |
|
|
#include <attribute.h>
|
23 |
|
|
|
24 |
|
|
namespace debugger {
|
25 |
|
|
|
26 |
|
|
#ifdef __cplusplus
|
27 |
|
|
extern "C" {
|
28 |
|
|
#endif
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* @defgroup dbg_core_api_g Core API methods
|
32 |
|
|
* @ingroup debugger_group
|
33 |
|
|
* @details Core methods that allow create, modify and delete base library
|
34 |
|
|
* objects such as: Attributes, Classes, Services and Interfaces
|
35 |
|
|
* @{
|
36 |
|
|
*/
|
37 |
|
|
|
38 |
|
|
/**
|
39 |
|
|
* @brief Library initialization.
|
40 |
|
|
* @details This method must be called before any other from this library.
|
41 |
|
|
*/
|
42 |
|
|
int RISCV_init();
|
43 |
|
|
|
44 |
|
|
/**
|
45 |
|
|
* @brief Destroy and cleanup all dynamically allocated objects.
|
46 |
|
|
* @details This method allows gracefully close library by stopping all running
|
47 |
|
|
* threads and free allocated resources.
|
48 |
|
|
*/
|
49 |
|
|
void RISCV_cleanup();
|
50 |
|
|
|
51 |
|
|
/**
|
52 |
|
|
* @brief Set core library configuration.
|
53 |
|
|
* @details Configuration specify all instantiated services and interconnect
|
54 |
|
|
* among them.
|
55 |
|
|
* @param [in] cfg Configuration attribute.
|
56 |
|
|
*/
|
57 |
|
|
int RISCV_set_configuration(AttributeType *cfg);
|
58 |
|
|
|
59 |
|
|
/**
|
60 |
|
|
* @brief Read library configuration.
|
61 |
|
|
* @details This method allows serialize library state and save configuration
|
62 |
|
|
* into the file in JSON format. Afterward configuration can be
|
63 |
|
|
* restored.
|
64 |
|
|
*/
|
65 |
|
|
void RISCV_get_configuration(AttributeType *cfg);
|
66 |
|
|
|
67 |
|
|
/**
|
68 |
|
|
* @brief Get current core configuration.
|
69 |
|
|
* @details JSON configuration string implements special section \c 'Global'
|
70 |
|
|
* that contains parameters not related to any specific service or
|
71 |
|
|
* class.
|
72 |
|
|
*/
|
73 |
|
|
const AttributeType *RISCV_get_global_settings();
|
74 |
|
|
|
75 |
|
|
/**
|
76 |
|
|
* @brief Registration of the class in the library kernel.
|
77 |
|
|
* @details Registering interface pointer will be put into kernel list of
|
78 |
|
|
* classes. Any plugin can add its own class interfaces.
|
79 |
|
|
* @param [in] icls Pointer on new class interface.
|
80 |
|
|
*/
|
81 |
|
|
void RISCV_register_class(IFace *icls);
|
82 |
|
|
|
83 |
|
|
/**
|
84 |
|
|
* @brief Registration of the system event (hap) listener.
|
85 |
|
|
* @details Haps are used to synchronized different threads by a specific
|
86 |
|
|
* events in a system. Now there's used such haps as:
|
87 |
|
|
* - ConfigDone
|
88 |
|
|
* - Breakpoint
|
89 |
|
|
*/
|
90 |
|
|
void RISCV_register_hap(IFace *ihap);
|
91 |
|
|
|
92 |
|
|
/**
|
93 |
|
|
* @brief Trigger system event (hap) from Service.
|
94 |
|
|
* @details This method allows to call all registered listeneres of a specific
|
95 |
|
|
* event from running Service.
|
96 |
|
|
*/
|
97 |
|
|
void RISCV_trigger_hap(IFace *isrc, int type, const char *descr);
|
98 |
|
|
|
99 |
|
|
/**
|
100 |
|
|
* @brief Get registred class interface by its name.
|
101 |
|
|
* @details This method generally used to create instances of a specific
|
102 |
|
|
* service.
|
103 |
|
|
*/
|
104 |
|
|
IFace *RISCV_get_class(const char *name);
|
105 |
|
|
|
106 |
|
|
/**
|
107 |
|
|
* @brief Create service of the specified class.
|
108 |
|
|
* @details This method creates intstance of Service and assignes all
|
109 |
|
|
* registered attributes to its initial values.
|
110 |
|
|
*/
|
111 |
|
|
IFace *RISCV_create_service(IFace *iclass, const char *name,
|
112 |
|
|
AttributeType *args);
|
113 |
|
|
|
114 |
|
|
/**
|
115 |
|
|
* @brief Get IService interface by its name.
|
116 |
|
|
* @details This method is used for interaction of different services in a
|
117 |
|
|
* system.
|
118 |
|
|
*/
|
119 |
|
|
IFace *RISCV_get_service(const char *name);
|
120 |
|
|
|
121 |
|
|
/**
|
122 |
|
|
* @brief Get interface of the specified device.
|
123 |
|
|
* @details This method can be used in runtime to implement dynamic connection
|
124 |
|
|
* of different services
|
125 |
|
|
* @code
|
126 |
|
|
* ...
|
127 |
|
|
* IUdp *iudp1 = static_cast<IUdp *>
|
128 |
|
|
* (RISCV_get_service_iface("udpboard", IFACE_UDP));
|
129 |
|
|
* ...
|
130 |
|
|
* @endcode
|
131 |
|
|
*/
|
132 |
|
|
IFace *RISCV_get_service_iface(const char *servname, const char *facename);
|
133 |
|
|
|
134 |
|
|
/**
|
135 |
|
|
* @brief Get interface of the specified device:port.
|
136 |
|
|
* @details This method can be used in runtime to implement dynamic connection
|
137 |
|
|
* of different services and their ports
|
138 |
|
|
* @code
|
139 |
|
|
* ...
|
140 |
|
|
* IMemoryOperation *imem = static_cast<IMemoryOperation *>
|
141 |
|
|
* (RISCV_get_service_port_iface("mem0", "port0",
|
142 |
|
|
* IFACE_MEMORY_OPERATION));
|
143 |
|
|
* ...
|
144 |
|
|
* @endcode
|
145 |
|
|
*/
|
146 |
|
|
IFace *RISCV_get_service_port_iface(const char *servname,
|
147 |
|
|
const char *portname,
|
148 |
|
|
const char *facename);
|
149 |
|
|
|
150 |
|
|
/**
|
151 |
|
|
* @brief Get list of services implementing specific interface.
|
152 |
|
|
* @details This method can return list of services of different classes
|
153 |
|
|
* and implementing different functionality.
|
154 |
|
|
*/
|
155 |
|
|
void RISCV_get_services_with_iface(const char *iname, AttributeType *list);
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
/**
|
159 |
|
|
* @brief Get list of all clock generators.
|
160 |
|
|
* @details Clock generator must implement IClock (and usually IThread)
|
161 |
|
|
* interfaces. CPU is a most general clock generator.
|
162 |
|
|
*/
|
163 |
|
|
void RISCV_get_clock_services(AttributeType *list);
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
/**
|
167 |
|
|
* @brief Break all threads that could be run by different services.
|
168 |
|
|
* @details This method gracefully stops all threads and allows to avoid
|
169 |
|
|
* simulation hanging on library closing stage.
|
170 |
|
|
*/
|
171 |
|
|
void RISCV_break_simulation();
|
172 |
|
|
|
173 |
|
|
/**
|
174 |
|
|
* @brief Run main loop in main thread
|
175 |
|
|
*/
|
176 |
|
|
void RISCV_dispatcher_start();
|
177 |
|
|
|
178 |
|
|
/**
|
179 |
|
|
* @brief callback from the main thread function prototype
|
180 |
|
|
*/
|
181 |
|
|
typedef void (*timer_callback_type)(void *args);
|
182 |
|
|
|
183 |
|
|
/**
|
184 |
|
|
* @brief Register timer's callback in main loop
|
185 |
|
|
*/
|
186 |
|
|
void RISCV_register_timer(int msec, int single_shot,
|
187 |
|
|
timer_callback_type cb, void *args);
|
188 |
|
|
|
189 |
|
|
/**
|
190 |
|
|
* @brief Unregister timer's callback from main loop
|
191 |
|
|
*/
|
192 |
|
|
void RISCV_unregister_timer(timer_callback_type cb);
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
#ifdef __cplusplus
|
196 |
|
|
}
|
197 |
|
|
#endif
|
198 |
|
|
|
199 |
|
|
} // namespace debugger
|
200 |
|
|
|
201 |
|
|
#endif // __DEBUGGER_API_CORE_H__
|