orca-sim
Classes | Enumerations | Functions
orcasim::gdbrsp Namespace Reference

Classes

class  GdbProcessorBase
 
struct  GdbProcessorState
 Defines a generic state model for use within processor models. More...
 
class  RspServer
 
class  UdpAsyncServer
 This class implements an asynchonous udp server. More...
 

Enumerations

enum  UdpAsyncError { UdpAsyncError::SOCKET_OPEN, UdpAsyncError::SOCKET_BIND, UdpAsyncError::SELECT_ERR, UdpAsyncError::TIMEOUT_EXCEEDED }
 

Functions

int strhti (char *buffer, int length)
 String-to-int. More...
 
int strfind (char *buffer, char find, int limit)
 String find. More...
 
void hexstr (char *output, char *input, uint32_t integers)
 String to hex. More...
 
uint32_t endswap (uint32_t value)
 Endianess Swap. More...
 

Enumeration Type Documentation

§ UdpAsyncError

Enumerator
SOCKET_OPEN 
SOCKET_BIND 
SELECT_ERR 
TIMEOUT_EXCEEDED 

Definition at line 46 of file UdpAsyncServer.hpp.

46  {
47  SOCKET_OPEN, // socket could not be opened, see fd limit or permission
48  SOCKET_BIND, // socket could not bind, see if port is in use
49  SELECT_ERR,
51 };

Function Documentation

§ endswap()

uint32_t orcasim::gdbrsp::endswap ( uint32_t  value)

Endianess Swap.

Definition at line 77 of file DataConvertionHelper.cpp.

77  {
78  uint32_t tmp;
79 
80  tmp = ((value << 8) & 0xFF00FF00) | ((value >> 8) & 0xFF00FF);
81  value = (tmp << 16) | (tmp >> 16);
82 
83  return value;
84 }

§ hexstr()

void orcasim::gdbrsp::hexstr ( char *  output,
char *  input,
uint32_t  integers 
)

String to hex.

Definition at line 61 of file DataConvertionHelper.cpp.

61  {
62  uint32_t mask = 0xFFFFFFFF;
63 
64  uint32_t* input_i = (uint32_t*)input;
65  uint32_t output_i = 0;
66 
67  // converts integer by integer
68  for (uint32_t i =0; i < integers; i++) {
69  // TODO(a): check whether the two lines below are equivalent
70  // snprintf(&output[output_i],
71  // sizeof(&output[output_i]), "%08x", endswap(input_i[i] & mask));
72  sprintf(&output[output_i], "%08x", endswap(input_i[i] & mask));
73  output_i += 8;
74  }
75 }
uint32_t endswap(uint32_t value)
Endianess Swap.

§ strfind()

int orcasim::gdbrsp::strfind ( char *  buffer,
char  find,
int  limit 
)

String find.

Definition at line 53 of file DataConvertionHelper.cpp.

53  {
54  for (int i = 0; i < limit; i++)
55  if (buffer[i] == find) return i;
56 
57  return -1;
58 }

§ strhti()

int orcasim::gdbrsp::strhti ( char *  buffer,
int  length 
)

String-to-int.

Definition at line 31 of file DataConvertionHelper.cpp.

31  {
32  char tmp[length];
33 
34  for (int i = 0; i < length; i++)
35  tmp[i] = '\0';
36 
37  for (int i = 0; i < length; i++) {
38  // is [0-9] digit
39  if (buffer[i] >= 48 && buffer[i] <= 57) {
40  tmp[i] = buffer[i];
41  // is [a-f] digit
42  } else if (buffer[i] >= 97 && buffer[i] <= 122) {
43  tmp[i] = buffer[i];
44  } else {
45  break;
46  }
47  }
48 
49  return static_cast<int>(strtol(tmp, NULL, 16));
50 }