L4Re/departure

Annotated libexec/include/exec/external_pager.h

652:e4d464fd40c1
6 months ago Paul Boddie Make more pages available to the block and filesystem servers. libc_newlib
paul@366 1
/*
paul@366 2
 * A system pager implementation residing in a separate task.
paul@366 3
 *
paul@631 4
 * Copyright (C) 2022, 2023, 2024 Paul Boddie <paul@boddie.org.uk>
paul@366 5
 *
paul@366 6
 * This program is free software; you can redistribute it and/or
paul@366 7
 * modify it under the terms of the GNU General Public License as
paul@366 8
 * published by the Free Software Foundation; either version 2 of
paul@366 9
 * the License, or (at your option) any later version.
paul@366 10
 *
paul@366 11
 * This program is distributed in the hope that it will be useful,
paul@366 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@366 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@366 14
 * GNU General Public License for more details.
paul@366 15
 *
paul@366 16
 * You should have received a copy of the GNU General Public License
paul@366 17
 * along with this program; if not, write to the Free Software
paul@366 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@366 19
 * Boston, MA  02110-1301, USA
paul@366 20
 */
paul@366 21
paul@366 22
#pragma once
paul@366 23
paul@550 24
#include <set>
paul@550 25
paul@504 26
#include <exec/elf.h>
paul@366 27
#include <exec/pager.h>
paul@543 28
#include <exec/process_monitor.h>
paul@504 29
#include <exec/segment.h>
paul@535 30
#include <resource/resource.h>
paul@366 31
paul@469 32
#include "parent_pager_object_interface.h"
paul@469 33
paul@366 34
paul@366 35
paul@550 36
/* Collection definitions. */
paul@550 37
paul@550 38
typedef std::set<l4_cap_idx_t> Capabilities;
paul@550 39
paul@550 40
paul@550 41
paul@366 42
/* A simple system pager also acting as a region mapper. */
paul@366 43
paul@484 44
class ExternalPager : public ExecPager, public ParentPagerObject,
paul@543 45
                      public Resource
paul@366 46
{
paul@492 47
protected:
paul@550 48
  /* Dataspace capabilities associated with regions. */
paul@550 49
paul@550 50
  Capabilities _dataspaces;
paul@504 51
paul@504 52
  /* Resources associated with the created process. */
paul@504 53
paul@504 54
  l4_cap_idx_t _task = L4_INVALID_CAP, _mapped_task = L4_INVALID_CAP,
paul@543 55
               _thread = L4_INVALID_CAP, _mapped_thread = L4_INVALID_CAP,
paul@504 56
               _parent = L4_INVALID_CAP, _mapped_parent = L4_INVALID_CAP,
paul@543 57
               _pager = L4_INVALID_CAP, _mapped_pager = L4_INVALID_CAP;
paul@543 58
paul@543 59
  ProcessMonitor *_monitor = NULL;
paul@492 60
paul@504 61
  /* Resources supporting the internal pager. */
paul@504 62
paul@504 63
  ExplicitSegment *_rm_stack = NULL;
paul@504 64
  Payload *_rm_payload = NULL;
paul@504 65
paul@366 66
public:
paul@431 67
  explicit ExternalPager(address_t start = 0, address_t end = 0);
paul@366 68
paul@489 69
  /* Server details. */
paul@489 70
paul@489 71
  virtual ipc_server_default_config_type config();
paul@489 72
paul@489 73
  virtual void *interface()
paul@489 74
  { return static_cast<ParentPagerObject *>(this); }
paul@489 75
paul@543 76
  /* Capability management. */
paul@492 77
paul@503 78
  virtual void set_pager(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap);
paul@503 79
  virtual void set_parent(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap);
paul@503 80
  virtual void set_task(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap);
paul@543 81
  virtual void set_thread(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap);
paul@543 82
paul@543 83
  /* Lifecycle management. */
paul@543 84
paul@543 85
  virtual void set_monitor(ProcessMonitor *monitor);
paul@492 86
paul@504 87
  /* Internal pager resource management. */
paul@504 88
paul@504 89
  virtual void set_payload(Payload *payload);
paul@504 90
  virtual void set_stack(ExplicitSegment *stack);
paul@504 91
paul@492 92
  /* Resource methods. */
paul@492 93
paul@492 94
  virtual void close();
paul@492 95
paul@366 96
  /* Notification methods, implementing PagerObject. */
paul@366 97
paul@366 98
  virtual long exception(l4_exc_regs_t regs,
paul@366 99
                         l4_snd_fpage_t *region);
paul@366 100
paul@366 101
  virtual long page_fault(l4_umword_t pfa, l4_umword_t pc,
paul@366 102
                          l4_snd_fpage_t *region);
paul@366 103
paul@366 104
  /* Region manager/mapper methods. */
paul@366 105
paul@631 106
  virtual long attach(address_t *start, address_t size, rm_flags_t flags,
paul@631 107
                      l4_cap_idx_t ds, rm_offset_t offset, unsigned char align);
paul@469 108
paul@469 109
  /* Parent methods. */
paul@469 110
paul@469 111
  virtual long signal(unsigned long sig, unsigned long val);
paul@366 112
};
paul@366 113
paul@366 114
/* vim: tabstop=2 expandtab shiftwidth=2
paul@366 115
*/