embedded_debugger_mcp/tools/
types.rs1use serde::{Deserialize, Serialize};
4use schemars::JsonSchema;
5
6#[derive(Debug, Deserialize, JsonSchema)]
11pub struct ListProbesArgs {
12 }
14
15#[derive(Debug, Deserialize, JsonSchema)]
16pub struct ConnectArgs {
17 pub probe_selector: String,
19 pub target_chip: String,
21 #[serde(default = "default_speed_khz")]
23 pub speed_khz: u32,
24 #[serde(default)]
26 pub connect_under_reset: bool,
27 #[serde(default = "default_true")]
29 pub halt_after_connect: bool,
30}
31
32fn default_speed_khz() -> u32 { 4000 }
33fn default_true() -> bool { true }
34
35#[derive(Debug, Deserialize, JsonSchema)]
36pub struct DisconnectArgs {
37 pub session_id: String,
39}
40
41#[derive(Debug, Deserialize, JsonSchema)]
42pub struct ProbeInfoArgs {
43 pub session_id: String,
45}
46
47#[derive(Debug, Deserialize, JsonSchema)]
52pub struct HaltArgs {
53 pub session_id: String,
55}
56
57#[derive(Debug, Deserialize, JsonSchema)]
58pub struct RunArgs {
59 pub session_id: String,
61}
62
63#[derive(Debug, Deserialize, JsonSchema)]
64pub struct ResetArgs {
65 pub session_id: String,
67 #[serde(default = "default_reset_type")]
69 pub reset_type: String,
70 #[serde(default = "default_true")]
72 pub halt_after_reset: bool,
73}
74
75fn default_reset_type() -> String { "hardware".to_string() }
76
77#[derive(Debug, Deserialize, JsonSchema)]
78pub struct StepArgs {
79 pub session_id: String,
81}
82
83#[derive(Debug, Deserialize, JsonSchema)]
84pub struct GetStatusArgs {
85 pub session_id: String,
87}
88
89#[derive(Debug, Deserialize, JsonSchema)]
94pub struct ReadMemoryArgs {
95 pub session_id: String,
97 pub address: String,
99 pub size: usize,
101 #[serde(default = "default_format")]
103 pub format: String,
104}
105
106fn default_format() -> String { "hex".to_string() }
107
108#[derive(Debug, Deserialize, JsonSchema)]
109pub struct WriteMemoryArgs {
110 pub session_id: String,
112 pub address: String,
114 pub data: String,
116 #[serde(default = "default_format")]
118 pub format: String,
119}
120
121
122#[derive(Debug, Deserialize, JsonSchema)]
127pub struct SetBreakpointArgs {
128 pub session_id: String,
130 pub address: String,
132 #[serde(default = "default_breakpoint_type")]
134 pub breakpoint_type: String,
135}
136
137fn default_breakpoint_type() -> String { "hardware".to_string() }
138
139#[derive(Debug, Deserialize, JsonSchema)]
140pub struct ClearBreakpointArgs {
141 pub session_id: String,
143 pub address: String,
145}
146
147
148#[derive(Debug, Deserialize, JsonSchema)]
159pub struct FlashEraseArgs {
160 pub session_id: String,
162 #[serde(default = "default_erase_all")]
164 pub erase_type: String,
165 pub address: Option<String>,
167 pub size: Option<u32>,
169}
170
171fn default_erase_all() -> String { "all".to_string() }
172
173#[derive(Debug, Deserialize, JsonSchema)]
174pub struct FlashProgramArgs {
175 pub session_id: String,
177 pub file_path: String,
179 #[serde(default = "default_auto_format")]
181 pub format: String,
182 pub base_address: Option<String>,
184 #[serde(default = "default_true")]
186 pub verify: bool,
187}
188
189fn default_auto_format() -> String { "auto".to_string() }
190
191#[derive(Debug, Deserialize, JsonSchema)]
192pub struct FlashVerifyArgs {
193 pub session_id: String,
195 pub file_path: Option<String>,
197 pub data: Option<String>,
199 pub address: String,
201 pub size: u32,
203}
204
205#[derive(Debug, Deserialize, JsonSchema)]
206pub struct RunFirmwareArgs {
207 pub session_id: String,
209 pub file_path: String,
211 #[serde(default = "default_auto_format")]
213 pub format: String,
214 #[serde(default = "default_true")]
216 pub reset_after_flash: bool,
217 #[serde(default = "default_true")]
219 pub attach_rtt: bool,
220 #[serde(default = "default_rtt_timeout")]
222 pub rtt_timeout_ms: u32,
223}
224
225fn default_rtt_timeout() -> u32 { 3000 }
226
227#[derive(Debug, Deserialize, JsonSchema)]
232pub struct RttAttachArgs {
233 pub session_id: String,
235 pub control_block_address: Option<String>,
237 pub memory_ranges: Option<Vec<MemoryRange>>,
240}
241
242#[derive(Debug, Deserialize, JsonSchema)]
243pub struct MemoryRange {
244 pub start: String,
245 pub end: String,
246}
247
248#[derive(Debug, Deserialize, JsonSchema)]
249pub struct RttDetachArgs {
250 pub session_id: String,
252}
253
254#[derive(Debug, Deserialize, JsonSchema)]
255pub struct RttReadArgs {
256 pub session_id: String,
258 #[serde(default)]
260 pub channel: u32,
261 #[serde(default = "default_max_bytes")]
263 pub max_bytes: usize,
264 #[serde(default = "default_timeout_ms")]
266 pub timeout_ms: u64,
267}
268
269fn default_max_bytes() -> usize { 1024 }
270fn default_timeout_ms() -> u64 { 1000 }
271
272#[derive(Debug, Deserialize, JsonSchema)]
273pub struct RttWriteArgs {
274 pub session_id: String,
276 #[serde(default)]
278 pub channel: u32,
279 pub data: String,
281 #[serde(default = "default_encoding")]
283 pub encoding: String,
284}
285
286fn default_encoding() -> String { "utf8".to_string() }
287
288#[derive(Debug, Deserialize, JsonSchema)]
289pub struct RttChannelsArgs {
290 pub session_id: String,
292}
293
294#[derive(Debug, Serialize)]
299pub struct ProbeInfo {
300 pub identifier: String,
301 pub vendor_id: u16,
302 pub product_id: u16,
303 pub serial_number: Option<String>,
304 pub probe_type: String,
305 pub speed_khz: u32,
306 pub version: String,
307}
308
309#[derive(Debug, Serialize)]
310pub struct TargetInfo {
311 pub chip_name: String,
312 pub architecture: String,
313 pub core_type: String,
314 pub memory_map: Vec<MemoryRegion>,
315}
316
317#[derive(Debug, Serialize)]
318pub struct MemoryRegion {
319 pub name: String,
320 pub start: u64,
321 pub size: u64,
322 pub access: String,
323}
324
325#[derive(Debug, Serialize)]
326pub struct CoreInfo {
327 pub pc: u64,
328 pub sp: u64,
329 pub state: String,
330 pub halt_reason: Option<String>,
331}
332
333#[derive(Debug, Serialize)]
334pub struct SessionStatus {
335 pub session_id: String,
336 pub connected: bool,
337 pub target_state: String,
338 pub created_at: String,
339 pub last_activity: String,
340}
341
342#[derive(Debug, Serialize)]
343pub struct RegisterValue {
344 pub name: String,
345 pub value: u64,
346 pub description: Option<String>,
347}
348
349#[derive(Debug, Serialize)]
350pub struct Breakpoint {
351 pub id: u32,
352 pub address: u64,
353 pub breakpoint_type: String,
354 pub enabled: bool,
355}
356
357#[derive(Debug, Serialize)]
358pub struct FlashResult {
359 pub bytes_programmed: usize,
360 pub programming_time_ms: u64,
361 pub verification_result: bool,
362}
363
364#[derive(Debug, Serialize)]
365pub struct RttChannelInfo {
366 pub channel: u32,
367 pub name: String,
368 pub direction: String, pub buffer_size: usize,
370 pub flags: u32,
371}