L4Re/departure

Changeset

498:0acb88011ba2
2023-03-04 Paul Boddie raw files shortlog changelog graph Added close method and resource deallocation.
libexec/include/exec/internal_pager.h (file) libexec/lib/src/internal_pager.cc (file)
     1.1 --- a/libexec/include/exec/internal_pager.h	Sat Mar 04 19:02:34 2023 +0100
     1.2 +++ b/libexec/include/exec/internal_pager.h	Sat Mar 04 19:03:27 2023 +0100
     1.3 @@ -42,6 +42,10 @@
     1.4    virtual void *interface()
     1.5    { return static_cast<PagerObject *>(this); }
     1.6  
     1.7 +  /* Resource methods. */
     1.8 +
     1.9 +  virtual void close();
    1.10 +
    1.11    /* Notification methods, implementing PagerObject. */
    1.12  
    1.13    virtual long exception(l4_exc_regs_t regs,
     2.1 --- a/libexec/lib/src/internal_pager.cc	Sat Mar 04 19:02:34 2023 +0100
     2.2 +++ b/libexec/lib/src/internal_pager.cc	Sat Mar 04 19:03:27 2023 +0100
     2.3 @@ -23,6 +23,7 @@
     2.4  #include <l4/re/c/dataspace.h>
     2.5  #include <l4/util/util.h>
     2.6  
     2.7 +#include <ipc/cap_alloc.h>
     2.8  #include <mem/memory_utils.h>
     2.9  #include <systypes/base.h>
    2.10  
    2.11 @@ -52,6 +53,27 @@
    2.12  
    2.13  
    2.14  
    2.15 +/* Close the pager. */
    2.16 +
    2.17 +void InternalPager::close()
    2.18 +{
    2.19 +  printf("Internal pager closing...\n");
    2.20 +
    2.21 +  /* Unmap all regions. */
    2.22 +
    2.23 +  MappedRegions::iterator it;
    2.24 +
    2.25 +  for (it = _regions.begin(); it != _regions.end(); it++)
    2.26 +  {
    2.27 +    MappedRegion &r = it->second;
    2.28 +
    2.29 +    printf("Free %lx\n", r.ds);
    2.30 +    ipc_cap_free_um(r.ds);
    2.31 +  }
    2.32 +}
    2.33 +
    2.34 +
    2.35 +
    2.36  /* Handle a general exception. */
    2.37  
    2.38  long InternalPager::exception(l4_exc_regs_t regs, l4_snd_fpage_t *region)