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_PROTO_H
19 #define __UDEBUG_PROTO_H
30 uintptr_t flags
[8 / sizeof(uintptr_t)];
39 enum udebug_client_msg_type
{
48 struct udebug_client_msg
{
54 uint32_t ring_size
, data_size
;
58 } __attribute__((packed
, aligned(4)));
60 static inline struct udebug_ptr
*
61 udebug_ring_ptr(struct udebug_hdr
*hdr
, uint32_t idx
)
63 struct udebug_ptr
*ring
= (struct udebug_ptr
*)&hdr
[1];
64 return &ring
[idx
& (hdr
->ring_size
- 1)];
67 static inline void *udebug_buf_ptr(struct udebug_buf
*buf
, uint32_t ofs
)
69 return buf
->data
+ (ofs
& (buf
->data_size
- 1));