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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use NonNull;
/// Strategy for obtaining and relinquishing compiler provenance on physical
/// frame pointers.
///
/// Implement this trait to tell the allocator how to manage provenance
/// when frames enter or leave its internal free structure.
///
/// Two stories satisfy this trait, and an implementation tells one of them:
///
/// * **Create an allocation.** `create` tells the compiler an allocation begins
/// at that address, yielding fresh provenance; `destroy` tells it the
/// allocation ends. Both must be opaque to the compiler - in practice an empty
/// `asm!` block that launders the pointer, and *without* `options(nomem)`,
/// because allocating and deallocating are memory effects. This is the story a
/// kernel tells over its direct map, and the only one available when the memory
/// is accessed atomically, since there are no volatile atomic accesses.
/// * **Recover exposed provenance.** The memory is already one live allocation
/// whose provenance was exposed; `create` recovers it with
/// [`with_exposed_provenance_mut`](core::ptr::with_exposed_provenance_mut), and
/// `destroy` reads the address back out. This fits a pool that is really a host
/// allocation, as in this crate's tests.
///
/// # Safety
///
/// * `create` must return a pointer whose provenance covers the entire
/// contiguous mapping starting at `phys` - not merely the first frame. A
/// caller may access `[phys, phys + len)` through it for any `len` that stays
/// within one physically-contiguous, exclusively-owned run (e.g. a
/// multi-frame metadata bitmap carved from one usable range).
/// * `destroy` must be called exactly once per pointer returned by `create`,
/// after which the pointer must not be used.
pub unsafe