L4Re/departure

Annotated libexec/include/exec/process_creating.h

652:e4d464fd40c1
6 months ago Paul Boddie Make more pages available to the block and filesystem servers. libc_newlib
paul@477 1
/*
paul@477 2
 * Support for executing code in new tasks and threads.
paul@477 3
 *
paul@615 4
 * Copyright (C) 2022, 2023, 2024 Paul Boddie <paul@boddie.org.uk>
paul@477 5
 *
paul@477 6
 * This program is free software; you can redistribute it and/or
paul@477 7
 * modify it under the terms of the GNU General Public License as
paul@477 8
 * published by the Free Software Foundation; either version 2 of
paul@477 9
 * the License, or (at your option) any later version.
paul@477 10
 *
paul@477 11
 * This program is distributed in the hope that it will be useful,
paul@477 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@477 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@477 14
 * GNU General Public License for more details.
paul@477 15
 *
paul@477 16
 * You should have received a copy of the GNU General Public License
paul@477 17
 * along with this program; if not, write to the Free Software
paul@477 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@477 19
 * Boston, MA  02110-1301, USA
paul@477 20
 */
paul@477 21
paul@477 22
#pragma once
paul@477 23
paul@524 24
#include <mutex>
paul@524 25
paul@477 26
#include <exec/elf.h>
paul@477 27
#include <exec/external_pager.h>
paul@477 28
#include <exec/memory.h>
paul@477 29
#include <exec/process.h>
paul@543 30
#include <exec/process_monitor.h>
paul@477 31
#include <ipc/map.h>
paul@477 32
paul@477 33
paul@477 34
paul@483 35
/* Process creator functionality. */
paul@477 36
paul@483 37
class ProcessCreating
paul@477 38
{
paul@477 39
protected:
paul@524 40
  std::mutex _lock;
paul@524 41
paul@527 42
  /* Region mapper program file. */
paul@524 43
paul@477 44
  const char *_rm_filename;
paul@527 45
  file_t *_rm_file;
paul@477 46
paul@543 47
  /* External pager and process monitor. */
paul@477 48
paul@487 49
  ExternalPager *_exec_pager = NULL;
paul@543 50
  ProcessMonitor *_monitor = NULL;
paul@477 51
paul@487 52
  /* Process construction. */
paul@487 53
paul@477 54
  Process _process;
paul@477 55
paul@477 56
  /* Stack and payload descriptions. */
paul@477 57
paul@495 58
  ExplicitSegment *_rm_stack = NULL;
paul@487 59
  Payload *_rm_payload = NULL;
paul@477 60
paul@495 61
  ExplicitSegment *_program_stack = NULL;
paul@487 62
  Payload *_program_payload = NULL;
paul@477 63
paul@477 64
  /* IPC gate for communication within the created task, plus allocated
paul@477 65
     capability. */
paul@477 66
paul@543 67
  l4_cap_idx_t _internal_pager, _mapped_internal_pager;
paul@477 68
paul@477 69
  /* Utility methods. */
paul@477 70
paul@477 71
  long start_pager();
paul@477 72
paul@477 73
  long init_region_mapper();
paul@477 74
paul@477 75
  long init_program(file_t *file);
paul@477 76
paul@489 77
  long init_external_pager(l4_cap_idx_t *pager);
paul@477 78
paul@543 79
  long configure_task();
paul@543 80
paul@543 81
  long allocate_internal_pager();
paul@477 82
paul@477 83
  void init_region(struct exec_region *regions,
paul@477 84
                   struct ipc_mapped_cap *mapped_caps,
paul@477 85
                   struct exec_region &r, unsigned int &index);
paul@477 86
paul@489 87
  long start_region_mapper(l4_cap_idx_t pager);
paul@477 88
paul@584 89
  long start_program(l4_cap_idx_t monitor, int argc, const char *argv[],
paul@615 90
                     l4_cap_idx_t reader, l4_cap_idx_t writer);
paul@477 91
paul@615 92
  long _start(int argc, const char *argv[], l4_cap_idx_t reader,
paul@615 93
              l4_cap_idx_t writer, l4_cap_idx_t process);
paul@559 94
paul@477 95
public:
paul@527 96
  explicit ProcessCreating(const char *rm_filename, file_t *rm_file);
paul@477 97
paul@559 98
  virtual long init_process_monitor(l4_cap_idx_t *monitor);
paul@559 99
paul@615 100
  virtual long start(int argc, const char *argv[], l4_cap_idx_t reader,
paul@615 101
                     l4_cap_idx_t writer, l4_cap_idx_t process);
paul@477 102
};
paul@477 103
paul@477 104
/* vim: tabstop=2 expandtab shiftwidth=2
paul@477 105
*/