L4Re/departure

Annotated libexec/include/exec/process.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@324 1
/*
paul@324 2
 * Support for initialising programs in new tasks and threads.
paul@324 3
 *
paul@492 4
 * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk>
paul@324 5
 *
paul@324 6
 * This program is free software; you can redistribute it and/or
paul@324 7
 * modify it under the terms of the GNU General Public License as
paul@324 8
 * published by the Free Software Foundation; either version 2 of
paul@324 9
 * the License, or (at your option) any later version.
paul@324 10
 *
paul@324 11
 * This program is distributed in the hope that it will be useful,
paul@324 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@324 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@324 14
 * GNU General Public License for more details.
paul@324 15
 *
paul@324 16
 * You should have received a copy of the GNU General Public License
paul@324 17
 * along with this program; if not, write to the Free Software
paul@324 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@324 19
 * Boston, MA  02110-1301, USA
paul@324 20
 */
paul@324 21
paul@324 22
#pragma once
paul@324 23
paul@324 24
#include <l4/re/env.h>
paul@324 25
#include <l4/re/l4aux.h>
paul@324 26
#include <l4/sys/factory.h>
paul@324 27
#include <l4/sys/task.h>
paul@324 28
#include <l4/sys/thread.h>
paul@324 29
paul@324 30
#include <exec/stack.h>
paul@324 31
paul@324 32
paul@324 33
paul@324 34
/* UTCB properties.
paul@324 35
   See: moe/server/src/loader.cc */
paul@324 36
paul@324 37
enum exec_utcb
paul@324 38
{
paul@324 39
  Default_max_threads = 16,
paul@324 40
#ifdef ARCH_mips
paul@324 41
  Utcb_area_start = 0x73000000,
paul@324 42
#else
paul@324 43
  Utcb_area_start = 0xb3000000,
paul@324 44
#endif
paul@324 45
};
paul@324 46
paul@324 47
paul@324 48
paul@324 49
/* Capability index definitions. */
paul@324 50
paul@324 51
enum exec_task_caps
paul@324 52
{
paul@469 53
  L4_EXEC_PAGER_CAP  = 0x10UL << L4_CAP_SHIFT,
paul@469 54
  L4_EXEC_RM_CAP     = 0x11UL << L4_CAP_SHIFT,
paul@469 55
  L4_EXEC_MA_CAP     = 0x12UL << L4_CAP_SHIFT,
paul@469 56
  L4_EXEC_PARENT_CAP = 0x13UL << L4_CAP_SHIFT,
paul@469 57
  L4_EXEC_KIP_CAP    = 0x14UL << L4_CAP_SHIFT,
paul@324 58
};
paul@324 59
paul@365 60
/* The default first free capability index must follow those above. Any
paul@365 61
   additional initial capabilities must elevate the index below. */
paul@324 62
paul@324 63
enum exec_task_cap_indexes
paul@324 64
{
paul@365 65
  L4_EXEC_FIRST_FREE_CAP_INDEX  = 0x15UL,
paul@324 66
};
paul@324 67
paul@324 68
paul@324 69
paul@324 70
/* A process abstraction. */
paul@324 71
paul@324 72
class Process
paul@324 73
{
paul@324 74
protected:
paul@324 75
  l4_cap_idx_t _task = L4_INVALID_CAP;
paul@429 76
  unsigned int _thread_number;
paul@324 77
paul@370 78
  /* Common and thread environment details. */
paul@324 79
paul@324 80
  l4re_aux_t _aux;
paul@324 81
  l4re_env_t _env;
paul@324 82
paul@324 83
  /* Task and thread initialisation. */
paul@324 84
paul@474 85
  long create_task(unsigned int threads);
paul@324 86
paul@324 87
  long create_thread(l4_cap_idx_t *thread);
paul@324 88
paul@324 89
public:
paul@430 90
  explicit Process();
paul@365 91
paul@524 92
  void reset();
paul@524 93
paul@370 94
  l4_cap_idx_t allocate_cap();
paul@370 95
paul@503 96
  long configure_task(l4_cap_idx_t *task, l4_cap_idx_t *mapped_task,
paul@503 97
                      unsigned int threads = 2);
paul@324 98
paul@503 99
  long configure_thread(l4_cap_idx_t rm, l4_cap_idx_t *mapped_rm = NULL);
paul@365 100
paul@503 101
  long set_parent(l4_cap_idx_t parent, l4_cap_idx_t *mapped_parent);
paul@469 102
paul@365 103
  long map_capabilities(struct ipc_mapped_cap mapped_caps[],
paul@365 104
                        bool to_count = true);
paul@324 105
paul@503 106
  long thread_start(l4_addr_t program_start, Stack &st, l4_cap_idx_t *thread,
paul@503 107
                    l4_cap_idx_t *mapped_thread);
paul@324 108
};
paul@324 109
paul@324 110
/* vim: tabstop=2 expandtab shiftwidth=2
paul@324 111
*/