]> git.saurik.com Git - apple/system_cmds.git/blob - gcore.tproj/region.h
system_cmds-735.20.1.tar.gz
[apple/system_cmds.git] / gcore.tproj / region.h
1 /*
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
3 */
4
5 #include <sys/queue.h>
6 #include <sys/types.h>
7 #include <mach/mach.h>
8 #include <uuid/uuid.h>
9
10 #ifndef _REGION_H
11 #define _REGION_H
12
13 struct regionop;
14 struct subregion;
15
16 struct region {
17 STAILQ_ENTRY(region) r_linkage;
18
19 mach_vm_offset_t r_address;
20 mach_vm_offset_t r_size;
21
22 #define _R_ADDR(r) ((r)->r_address)
23 #define _R_SIZE(r) ((r)->r_size)
24 #define R_SETADDR(r, a) ((r)->r_address = (a))
25 #define R_SETSIZE(r, z) ((r)->r_size = (z))
26 #define R_ENDADDR(r) (_R_ADDR(r) + _R_SIZE(r))
27
28 vm_region_submap_info_data_64_t r_info;
29 vm_page_info_basic_data_t r_pageinfo;
30
31 #ifdef CONFIG_PURGABLE
32 int r_purgable;
33 #endif
34 #ifdef CONFIG_SUBMAP
35 int r_depth;
36 #endif
37 boolean_t
38 r_insharedregion,
39 r_inzfodregion,
40 r_incommregion;
41
42 #ifdef CONFIG_REFSC
43 /*
44 * This field may be non-NULL if the region is a read-only part
45 * of a mapped file (i.e. the shared cache) and thus
46 * doesn't need to be copied.
47 */
48 struct {
49 const struct libent *fr_libent;
50 off_t fr_offset;
51 } *r_fileref;
52 #endif
53
54 /*
55 * These (optional) fields are filled in after we parse the information
56 * about the dylibs we've mapped, as provided by dyld.
57 */
58 struct subregion **r_subregions;
59 unsigned r_nsubregions;
60
61 const struct regionop *r_op;
62 };
63
64 static __inline const mach_vm_offset_t R_ADDR(const struct region *r) {
65 return _R_ADDR(r);
66 }
67
68 static __inline const mach_vm_offset_t R_SIZE(const struct region *r) {
69 return _R_SIZE(r);
70 }
71
72 /*
73 * Describes the disposition of the region after a walker returns
74 */
75 typedef enum {
76 WALK_CONTINUE, // press on ..
77 WALK_DELETE_REGION, // discard this region, then continue
78 WALK_TERMINATE, // early termination, no error
79 WALK_ERROR, // early termination, error
80 } walk_return_t;
81
82 struct size_core;
83 struct write_segment_data;
84
85 typedef walk_return_t walk_region_cbfn_t(struct region *, void *);
86
87 struct regionop {
88 void (*rop_print)(const struct region *);
89 walk_return_t (*rop_write)(const struct region *, struct write_segment_data *);
90 void (*rop_delete)(struct region *);
91 };
92
93 #define ROP_PRINT(r) (((r)->r_op->rop_print)(r))
94 #define ROP_WRITE(r, w) (((r)->r_op->rop_write)(r, w))
95 #define ROP_DELETE(r) (((r)->r_op->rop_delete)(r))
96
97 extern const struct regionop vanilla_ops, sparse_ops, zfod_ops;
98 #ifdef CONFIG_REFSC
99 extern const struct regionop fileref_ops;
100 #endif
101
102 struct regionhead;
103
104 #endif /* _REGION_H */