]> git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/src/libpmem2/map.h
import ceph 16.2.7
[ceph.git] / ceph / src / pmdk / src / libpmem2 / map.h
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright 2019-2020, Intel Corporation */
3
4 /*
5 * map.h -- internal definitions for libpmem2
6 */
7 #ifndef PMEM2_MAP_H
8 #define PMEM2_MAP_H
9
10 #include <stddef.h>
11 #include <stdbool.h>
12 #include "libpmem2.h"
13 #include "os.h"
14 #include "source.h"
15 #include "vm_reservation.h"
16
17 #ifdef _WIN32
18 #include <windows.h>
19 #endif
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 typedef int (*pmem2_deep_flush_fn)(struct pmem2_map *map,
26 void *ptr, size_t size);
27
28 struct pmem2_map {
29 void *addr; /* base address */
30 size_t reserved_length; /* length of the mapping reservation */
31 size_t content_length; /* length of the mapped content */
32 /* effective persistence granularity */
33 enum pmem2_granularity effective_granularity;
34
35 pmem2_persist_fn persist_fn;
36 pmem2_flush_fn flush_fn;
37 pmem2_drain_fn drain_fn;
38 pmem2_deep_flush_fn deep_flush_fn;
39
40 pmem2_memmove_fn memmove_fn;
41 pmem2_memcpy_fn memcpy_fn;
42 pmem2_memset_fn memset_fn;
43
44 struct pmem2_source source;
45 struct pmem2_vm_reservation *reserv;
46 };
47
48 enum pmem2_granularity get_min_granularity(bool eADR, bool is_pmem,
49 enum pmem2_sharing_type sharing);
50 struct pmem2_map *pmem2_map_find(const void *addr, size_t len);
51 int pmem2_register_mapping(struct pmem2_map *map);
52 int pmem2_unregister_mapping(struct pmem2_map *map);
53 void pmem2_map_init(void);
54 void pmem2_map_fini(void);
55
56 int pmem2_validate_offset(const struct pmem2_config *cfg,
57 size_t *offset, size_t alignment);
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif /* map.h */