1.1 --- a/libexec/lib/src/internal_pager.cc Fri Mar 24 16:14:44 2023 +0100
1.2 +++ b/libexec/lib/src/internal_pager.cc Sat Mar 25 18:45:42 2023 +0100
1.3 @@ -101,8 +101,8 @@
1.4
1.5 /* Obtain a region supporting the fault address. */
1.6
1.7 - MemoryArea *r;
1.8 - long err = _area.find(addr, &r);
1.9 + MemoryArea *r, *parent;
1.10 + long err = _area.find(addr, &r, &parent);
1.11
1.12 if (!err)
1.13 {
1.14 @@ -170,6 +170,38 @@
1.15 return err;
1.16 }
1.17
1.18 +long InternalPager::detach(address_t addr, address_t size, map_flags_t flags,
1.19 + address_t *start, address_t *rsize, l4_cap_idx_t *ds)
1.20 +{
1.21 + /* Obtain the region supporting the given address.
1.22 + NOTE: All regions within the given range should be detached. */
1.23 +
1.24 + MemoryArea *r, *parent;
1.25 + long err = _area.find(addr, &r, &parent);
1.26 +
1.27 + if (!err)
1.28 + {
1.29 + *start = r->area_start();
1.30 + *rsize = r->area_end() - r->area_start();
1.31 + *ds = r->dataspace();
1.32 + parent->remove(*r);
1.33 +
1.34 + /* Explicitly reply so that the dataspace can be released. */
1.35 +
1.36 + complete_RegionMapper_detach(*start, *rsize, *ds);
1.37 +
1.38 + /* Free the dataspace reference in this component. Since the same dataspace
1.39 + will have multiple capability indexes, it can be unconditionally
1.40 + released. */
1.41 +
1.42 + _dataspaces.erase(*ds);
1.43 + ipc_cap_free_um(*ds);
1.44 + return IPC_MESSAGE_SENT;
1.45 + }
1.46 +
1.47 + return err;
1.48 +}
1.49 +
1.50 long InternalPager::reserve_area(address_t *start, address_t size,
1.51 map_flags_t flags, unsigned char align)
1.52 {