Skip to content

Commit 8f92087

Browse files
committed
OSD-GDB server: Adds following features
(1) Connect to GDB over TCP (2) Send and Recieve data to/from the client (3) Receive RSP packet from the client (4) Validate the obtained packet using checksum (5) Send RSP packet to the client
1 parent 59de556 commit 8f92087

2 files changed

Lines changed: 422 additions & 0 deletions

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/* Copyright 2018 The Open SoC Debug Project
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
#ifndef OSD_GDBSERVER_H
17+
#define OSD_GDBSERVER_H
18+
19+
#include <osd/hostmod.h>
20+
#include <osd/osd.h>
21+
22+
#include <stdlib.h>
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/**
29+
* @defgroup libosd-gdbserver OSD-GDB server utility
30+
* @ingroup libosd
31+
*
32+
* @{
33+
*/
34+
35+
struct connection;
36+
37+
/**
38+
* Connect GDB server with GDB
39+
*
40+
* @return OSD_OK on success, any other value indicates an error
41+
*/
42+
osd_result add_connection(char *name, char *port);
43+
44+
/**
45+
* Read a character from the obtained buffer
46+
*/
47+
osd_result get_char(struct connection *c, int client_fd, int *ch);
48+
49+
/**
50+
* Read data from the GDB client
51+
*
52+
* @param c the connection object
53+
* @param client_fd the client_fd of the GDB
54+
*
55+
* @return OSD_OK on success, any other value indicates an error
56+
*
57+
* @see put_data()
58+
*/
59+
osd_result get_data(struct connection *c, int client_fd);
60+
61+
/**
62+
* Write data to the GDB client
63+
*
64+
* @param c the connection object
65+
* @param client_fd the client_fd of the GDB
66+
* @param data the data to write to the connected client
67+
* @param len the length of the data to be written
68+
* @return OSD_OK on success, any other value indicates an error
69+
*
70+
* @see get_data()
71+
*/
72+
osd_result put_data(struct connection *c, int client_fd, char *data, int len);
73+
74+
/**
75+
*
76+
* Get the packet-data from obtained buffer $<packet-data>#<checksum>
77+
*
78+
* @param c the connection object
79+
* @param client_fd the client_fd of the GDB
80+
* @param buffer the packet-data obtained from the connected client
81+
* @param len the length of the packet-data
82+
* @return OSD_OK on success, any other value indicates an error
83+
*
84+
* @see put_packet()
85+
*/
86+
osd_result get_packet(struct connection *c, int client_fd, char *buffer,
87+
int *len);
88+
89+
/**
90+
* Verify the checksum of obtained packet
91+
*
92+
* @param c the connection object
93+
* @param client_fd the client_fd of the GDB
94+
* @param ver_checksum indicates if the obtained checksum is correct or not
95+
* @param buffer the packet-data obtained from the connected client
96+
* @param len the length of the packet-data
97+
* @return OSD_OK on success, any other value indicates an error
98+
*/
99+
osd_result validate_packet(struct connection *c, int client_fd,
100+
bool *ver_checksum, int *len, char *buffer);
101+
102+
/**
103+
*
104+
* Send the packet-data to the buffer $<packet-data>#<checksum>
105+
*
106+
* @param c the connection object
107+
* @param client_fd the client_fd of the GDB
108+
* @param buffer the packet-data to send to the connected client
109+
* @param len the length of the packet-data
110+
* @return OSD_OK on success, any other value indicates an error
111+
*
112+
* @see get_packet()
113+
*/
114+
osd_result put_packet(struct connection *c, int client_fd, char *buffer,
115+
int len);
116+
117+
/**@}*/ /* end of doxygen group libosd-gdbserver */
118+
119+
#ifdef __cplusplus
120+
}
121+
#endif
122+
123+
#endif // OSD_GDBSERVER_H

0 commit comments

Comments
 (0)