2 * Copyright (c) 2016 Apple Inc. All rights reserved.
14 * A range of virtual memory
17 mach_vm_offset_t addr
;
18 mach_vm_offset_t size
;
21 #define _V_ADDR(g) ((g)->addr)
22 #define _V_SIZE(g) ((g)->size)
23 #define V_SETADDR(g, a) ((g)->addr = (a))
24 #define V_SETSIZE(g, z) ((g)->size = (z))
25 #define V_ENDADDR(g) (_V_ADDR(g) + _V_SIZE(g))
27 static __inline
const mach_vm_offset_t
V_ADDR(const struct vm_range
*vr
) {
30 static __inline
const mach_vm_offset_t
V_SIZE(const struct vm_range
*vr
) {
33 static __inline
const size_t V_SIZEOF(const struct vm_range
*vr
) {
34 assert((typeof (vr
->size
))(size_t)_V_SIZE(vr
) == _V_SIZE(vr
));
35 return (size_t)_V_SIZE(vr
);
39 * A range of offsets into a file
46 #define F_OFF(f) ((f)->off)
47 #define F_SIZE(f) ((f)->size)
53 STAILQ_ENTRY(region
) r_linkage
;
55 struct vm_range r_range
;
57 #define R_RANGE(r) (&(r)->r_range)
58 #define _R_ADDR(r) _V_ADDR(R_RANGE(r))
59 #define _R_SIZE(r) _V_SIZE(R_RANGE(r))
60 #define R_SIZEOF(r) V_SIZEOF(R_RANGE(r))
61 #define R_SETADDR(r, a) V_SETADDR(R_RANGE(r), (a))
62 #define R_SETSIZE(r, z) V_SETSIZE(R_RANGE(r), (z))
63 #define R_ENDADDR(r) (_R_ADDR(r) + _R_SIZE(r))
65 vm_region_submap_info_data_64_t r_info
;
66 vm_page_info_basic_data_t r_pageinfo
;
73 boolean_t r_insharedregion
, r_inzfodregion
, r_incommregion
;
76 * This field may be non-NULL if the region is a read-only part
77 * of a mapped file (i.e. the shared cache) and thus
78 * doesn't need to be copied.
81 const struct libent
*fr_libent
;
82 const char *fr_pathname
;
87 * These (optional) fields are filled in after we parse the information
88 * about the dylibs we've mapped, as provided by dyld.
90 struct subregion
**r_subregions
;
91 unsigned r_nsubregions
;
93 const struct regionop
*r_op
;
96 static __inline
const mach_vm_offset_t
R_ADDR(const struct region
*r
) {
99 static __inline
const mach_vm_offset_t
R_SIZE(const struct region
*r
) {
104 * Describes the disposition of the region after a walker returns
107 WALK_CONTINUE
, // press on ..
108 WALK_DELETE_REGION
, // discard this region, then continue
109 WALK_TERMINATE
, // early termination, no error
110 WALK_ERROR
, // early termination, error
114 struct write_segment_data
;
116 typedef walk_return_t
walk_region_cbfn_t(struct region
*, void *);
119 void (*rop_print
)(const struct region
*);
120 walk_return_t (*rop_write
)(const struct region
*, struct write_segment_data
*);
121 void (*rop_delete
)(struct region
*);
124 #define ROP_PRINT(r) (((r)->r_op->rop_print)(r))
125 #define ROP_WRITE(r, w) (((r)->r_op->rop_write)(r, w))
126 #define ROP_DELETE(r) (((r)->r_op->rop_delete)(r))
128 extern const struct regionop vanilla_ops
, sparse_ops
, zfod_ops
;
129 extern const struct regionop fileref_ops
;
133 #endif /* _REGION_H */