2 * udebug - debug ring buffer library
4 * Copyright (C) 2023 Felix Fietkau <nbd@nbd.name>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #ifndef __UDEBUG_UTIL_H
19 #define __UDEBUG_UTIL_H
23 #include "udebug-proto.h"
25 #define UDEBUG_TIMEOUT 1000
27 __hidden
int udebug_buf_open(struct udebug_buf
*buf
, int fd
, uint32_t ring_size
, uint32_t data_size
);
28 __hidden
struct udebug_client_msg
*
29 udebug_send_and_wait(struct udebug
*ctx
, struct udebug_client_msg
*msg
, int *rfd
);
31 static inline int32_t u32_sub(uint32_t a
, uint32_t b
)
36 static inline int32_t u32_max(uint32_t a
, uint32_t b
)
38 return u32_sub(a
, b
) > 0 ? a
: b
;
41 static inline void u32_set(void *ptr
, uint32_t val
)
43 volatile uint32_t *v
= ptr
;
47 static inline uint32_t u32_get(void *ptr
)
49 volatile uint32_t *v
= ptr
;