Zephyr API Documentation
4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
generic.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2021 EPAM Systems
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
12
13
#ifndef __XEN_GENERIC_H__
14
#define __XEN_GENERIC_H__
15
16
#include <
zephyr/xen/public/xen.h
>
17
24
26
27
#define XEN_PAGE_SIZE 4096
28
#define XEN_PAGE_SHIFT 12
29
30
#define XEN_PFN_UP(x) (unsigned long)(((x) + XEN_PAGE_SIZE-1) >> XEN_PAGE_SHIFT)
31
#define XEN_PFN_DOWN(x) (unsigned long)((x) >> XEN_PAGE_SHIFT)
32
#define XEN_PFN_PHYS(x) ((unsigned long)(x) << XEN_PAGE_SHIFT)
33
#define XEN_PHYS_PFN(x) (unsigned long)((x) >> XEN_PAGE_SHIFT)
34
35
#define xen_to_phys(x) ((unsigned long) (x))
36
#define xen_to_virt(x) ((void *) (x))
37
38
#define xen_virt_to_gfn(_virt) (XEN_PFN_DOWN(xen_to_phys(_virt)))
39
#define xen_gfn_to_virt(_gfn) (xen_to_virt(XEN_PFN_PHYS(_gfn)))
40
41
/*
42
* Atomically exchange value on "ptr" position. If value on "ptr" contains
43
* "old", then store and return "new". Otherwise, return the "old" value.
44
*/
45
#define synch_cmpxchg(ptr, old, new) \
46
({ __typeof__(*ptr) stored = old; \
47
__atomic_compare_exchange_n(ptr, &stored, new, 0, __ATOMIC_SEQ_CST, \
48
__ATOMIC_SEQ_CST) ? new : old; \
49
})
50
52
54
55
#endif
/* __XEN_GENERIC_H__ */
xen.h
zephyr
xen
generic.h
Generated on
for Zephyr API Documentation by
1.16.1