L4Re/departure

Annotated libexec/include/exec/process_creating.h

524:86d76cd9a8d3
19 months ago Paul Boddie Made the process creation activity sequential and introduced a missing reset operation so that more than one process can be successfully created.
paul@477 1
/*
paul@477 2
 * Support for executing code in new tasks and threads.
paul@477 3
 *
paul@477 4
 * Copyright (C) 2022, 2023 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@477 30
#include <ipc/map.h>
paul@477 31
paul@477 32
paul@477 33
paul@483 34
/* Process creator functionality. */
paul@477 35
paul@483 36
class ProcessCreating
paul@477 37
{
paul@477 38
protected:
paul@524 39
  std::mutex _lock;
paul@524 40
paul@524 41
  /* Region mapper program filename. */
paul@524 42
paul@477 43
  const char *_rm_filename;
paul@477 44
paul@477 45
  /* External pager configuration. */
paul@477 46
paul@487 47
  ExternalPager *_exec_pager = NULL;
paul@477 48
paul@487 49
  /* Process construction. */
paul@487 50
paul@477 51
  Process _process;
paul@477 52
paul@477 53
  /* Stack and payload descriptions. */
paul@477 54
paul@495 55
  ExplicitSegment *_rm_stack = NULL;
paul@487 56
  Payload *_rm_payload = NULL;
paul@477 57
paul@495 58
  ExplicitSegment *_program_stack = NULL;
paul@487 59
  Payload *_program_payload = NULL;
paul@477 60
paul@477 61
  /* IPC gate for communication within the created task, plus allocated
paul@477 62
     capability. */
paul@477 63
paul@477 64
  l4_cap_idx_t _ipc_gate, _ipc_gate_cap;
paul@477 65
paul@477 66
  /* Utility methods. */
paul@477 67
paul@477 68
  long start_pager();
paul@477 69
paul@477 70
  long init_region_mapper();
paul@477 71
paul@477 72
  long init_program(file_t *file);
paul@477 73
paul@489 74
  long init_external_pager(l4_cap_idx_t *pager);
paul@477 75
paul@489 76
  long configure_task(l4_cap_idx_t pager);
paul@477 77
paul@477 78
  long create_ipc_gate();
paul@477 79
paul@477 80
  void init_region(struct exec_region *regions,
paul@477 81
                   struct ipc_mapped_cap *mapped_caps,
paul@477 82
                   struct exec_region &r, unsigned int &index);
paul@477 83
paul@489 84
  long start_region_mapper(l4_cap_idx_t pager);
paul@477 85
paul@477 86
  long start_program(int argc, const char *argv[]);
paul@477 87
paul@477 88
public:
paul@483 89
  explicit ProcessCreating(const char *rm_filename);
paul@477 90
paul@505 91
  virtual long start(int argc, const char *argv[], l4_cap_idx_t *process);
paul@477 92
};
paul@477 93
paul@477 94
/* vim: tabstop=2 expandtab shiftwidth=2
paul@477 95
*/