1 #ifndef __UDEBUG_UTIL_H
2 #define __UDEBUG_UTIL_H
4 #include <libubox/blobmsg.h>
7 #define UDEBUG_TIMEOUT 1000
16 uintptr_t flags
[8 / sizeof(uintptr_t)];
25 enum udebug_client_msg_type
{
34 struct udebug_client_msg
{
40 uint32_t ring_size
, data_size
;
44 } __attribute__((packed
, aligned(4)));
46 static inline struct udebug_ptr
*
47 udebug_ring_ptr(struct udebug_hdr
*hdr
, uint32_t idx
)
49 struct udebug_ptr
*ring
= (struct udebug_ptr
*)&hdr
[1];
50 return &ring
[idx
& (hdr
->ring_size
- 1)];
53 static inline void *udebug_buf_ptr(struct udebug_buf
*buf
, uint32_t ofs
)
55 return buf
->data
+ (ofs
& (buf
->data_size
- 1));
58 int udebug_id_cmp(const void *k1
, const void *k2
, void *ptr
);
59 __hidden
int udebug_buf_open(struct udebug_buf
*buf
, int fd
, uint32_t ring_size
, uint32_t data_size
);
60 __hidden
struct udebug_client_msg
*__udebug_poll(struct udebug
*ctx
, int *fd
, bool wait
);
61 __hidden
void udebug_send_msg(struct udebug
*ctx
, struct udebug_client_msg
*msg
,
62 struct blob_attr
*meta
, int fd
);
63 __hidden
void __udebug_disconnect(struct udebug
*ctx
, bool reconnect
);
65 static inline int32_t u32_sub(uint32_t a
, uint32_t b
)
70 static inline int32_t u32_max(uint32_t a
, uint32_t b
)
72 return u32_sub(a
, b
) > 0 ? a
: b
;
75 static inline void u32_set(void *ptr
, uint32_t val
)
77 volatile uint32_t *v
= ptr
;
81 static inline uint32_t u32_get(void *ptr
)
83 volatile uint32_t *v
= ptr
;