libubox
C utility functions for OpenWrt.
udebug-proto.h
Go to the documentation of this file.
1
/*
2
* udebug - debug ring buffer library
3
*
4
* Copyright (C) 2023 Felix Fietkau <nbd@nbd.name>
5
*
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.
9
*
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.
17
*/
18
#ifndef __UDEBUG_PROTO_H
19
#define __UDEBUG_PROTO_H
20
21
#include "
udebug.h
"
22
23
struct
udebug_hdr
{
24
uint32_t
ring_size
;
25
uint32_t
data_size
;
26
27
uint32_t
format
;
28
uint32_t
sub_format
;
29
30
uintptr_t
flags
[8 /
sizeof
(uintptr_t)];
31
uintptr_t
notify
;
32
33
uint32_t
head_hi
;
34
uint32_t
head
;
35
uint32_t
data_head
;
36
uint32_t
data_used
;
37
};
38
39
enum
udebug_client_msg_type
{
40
CL_MSG_RING_ADD
,
41
CL_MSG_RING_REMOVE
,
42
CL_MSG_RING_NOTIFY
,
43
CL_MSG_GET_HANDLE
,
44
CL_MSG_RING_GET
,
45
CL_MSG_ERROR
,
46
};
47
48
struct
udebug_client_msg
{
49
uint8_t
type
;
50
uint8_t
_pad
[3];
51
uint32_t
id
;
52
union
{
53
struct
{
54
uint32_t
ring_size
,
data_size
;
55
};
56
uint32_t
notify_mask
;
57
};
58
}
__attribute__
((packed, aligned(4)));
59
60
static
inline
struct
udebug_ptr
*
61
udebug_ring_ptr
(
struct
udebug_hdr
*hdr, uint32_t idx)
62
{
63
struct
udebug_ptr
*ring = (
struct
udebug_ptr
*)&hdr[1];
64
return
&ring[idx & (hdr->
ring_size
- 1)];
65
}
66
67
static
inline
void
*
udebug_buf_ptr
(
struct
udebug_buf
*buf, uint32_t ofs)
68
{
69
return
buf->
data
+ (ofs & (buf->
data_size
- 1));
70
}
71
72
#endif
udebug_buf
Definition:
udebug.h:71
udebug_buf::data
void * data
Definition:
udebug.h:79
udebug_buf::data_size
size_t data_size
Definition:
udebug.h:80
udebug_client_msg
Definition:
udebug-proto.h:48
udebug_client_msg::ring_size
uint32_t ring_size
Definition:
udebug-proto.h:54
udebug_client_msg::notify_mask
uint32_t notify_mask
Definition:
udebug-proto.h:56
udebug_client_msg::_pad
uint8_t _pad[3]
Definition:
udebug-proto.h:50
udebug_client_msg::id
uint32_t id
Definition:
udebug-proto.h:51
udebug_client_msg::data_size
uint32_t data_size
Definition:
udebug-proto.h:54
udebug_client_msg::type
uint8_t type
Definition:
udebug-proto.h:49
udebug_hdr
Definition:
udebug-proto.h:23
udebug_hdr::notify
uintptr_t notify
Definition:
udebug-proto.h:31
udebug_hdr::head_hi
uint32_t head_hi
Definition:
udebug-proto.h:33
udebug_hdr::ring_size
uint32_t ring_size
Definition:
udebug-proto.h:24
udebug_hdr::flags
uintptr_t flags[8/sizeof(uintptr_t)]
Definition:
udebug-proto.h:30
udebug_hdr::data_head
uint32_t data_head
Definition:
udebug-proto.h:35
udebug_hdr::data_used
uint32_t data_used
Definition:
udebug-proto.h:36
udebug_hdr::sub_format
uint32_t sub_format
Definition:
udebug-proto.h:28
udebug_hdr::format
uint32_t format
Definition:
udebug-proto.h:27
udebug_hdr::data_size
uint32_t data_size
Definition:
udebug-proto.h:25
udebug_hdr::head
uint32_t head
Definition:
udebug-proto.h:34
udebug_ptr
Definition:
udebug.h:115
udebug_client_msg_type
udebug_client_msg_type
Definition:
udebug-proto.h:39
CL_MSG_RING_ADD
@ CL_MSG_RING_ADD
Definition:
udebug-proto.h:40
CL_MSG_RING_REMOVE
@ CL_MSG_RING_REMOVE
Definition:
udebug-proto.h:41
CL_MSG_RING_NOTIFY
@ CL_MSG_RING_NOTIFY
Definition:
udebug-proto.h:42
CL_MSG_GET_HANDLE
@ CL_MSG_GET_HANDLE
Definition:
udebug-proto.h:43
CL_MSG_RING_GET
@ CL_MSG_RING_GET
Definition:
udebug-proto.h:44
CL_MSG_ERROR
@ CL_MSG_ERROR
Definition:
udebug-proto.h:45
udebug_ring_ptr
static struct udebug_ptr * udebug_ring_ptr(struct udebug_hdr *hdr, uint32_t idx)
Definition:
udebug-proto.h:61
__attribute__
struct udebug_client_msg __attribute__((packed, aligned(4)))
udebug_buf_ptr
static void * udebug_buf_ptr(struct udebug_buf *buf, uint32_t ofs)
Definition:
udebug-proto.h:67
udebug.h
udebug-proto.h
Generated on Tue Mar 12 2024 03:37:18 for libubox by
1.9.1