-
Notifications
You must be signed in to change notification settings - Fork 15
/
udebug-priv.h
53 lines (45 loc) · 1.52 KB
/
udebug-priv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* udebug - debug ring buffer library
*
* Copyright (C) 2023 Felix Fietkau <nbd@nbd.name>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __UDEBUG_UTIL_H
#define __UDEBUG_UTIL_H
#include "blobmsg.h"
#include "udebug.h"
#include "udebug-proto.h"
#define UDEBUG_TIMEOUT 1000
__hidden int udebug_buf_open(struct udebug_buf *buf, int fd, uint32_t ring_size, uint32_t data_size);
__hidden struct udebug_client_msg *
udebug_send_and_wait(struct udebug *ctx, struct udebug_client_msg *msg, int *rfd);
static inline int32_t u32_sub(uint32_t a, uint32_t b)
{
return a - b;
}
static inline int32_t u32_max(uint32_t a, uint32_t b)
{
return u32_sub(a, b) > 0 ? a : b;
}
static inline void u32_set(void *ptr, uint32_t val)
{
volatile uint32_t *v = ptr;
*v = val;
}
static inline uint32_t u32_get(void *ptr)
{
volatile uint32_t *v = ptr;
return *v;
}
#endif