82 lines
3.4 KiB
C
82 lines
3.4 KiB
C
/**
|
||
* \file
|
||
* \brief create child process library
|
||
*/
|
||
|
||
/*
|
||
* Copyright (c) 2016, ETH Zurich.
|
||
* All rights reserved.
|
||
*
|
||
* This file is distributed under the terms in the attached LICENSE file.
|
||
* If you do not find this file, copies can be found by writing to:
|
||
* ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group.
|
||
*/
|
||
|
||
#ifndef _INIT_SPAWN_H_
|
||
#define _INIT_SPAWN_H_
|
||
|
||
#include "aos/slot_alloc.h"
|
||
#include "aos/paging.h"
|
||
#include <spawn/rpc_server.h>
|
||
|
||
|
||
|
||
struct spawninfo {
|
||
// the next in the list of spawned domains
|
||
struct spawninfo *next;
|
||
struct capref dispatcher; // < dispatcher used to start/stop the child process
|
||
|
||
domainid_t pid; // < unique id for this domain
|
||
|
||
// TODO(M2): Add fields you need to store state
|
||
// when spawning a new dispatcher,
|
||
// e.g. references to the child's
|
||
// capabilities or paging state
|
||
|
||
//afeer: see script page 84/85
|
||
struct cnoderef cspace_l1_cnode_info;
|
||
struct capref cspace_l1_cnode_cap;
|
||
|
||
struct cnoderef cspace_l2_cnode_taskcn; // < Contains information about the process itself.
|
||
struct cnoderef cspace_l2_cnode_slot_alloc_0; // < Empty L2 Node that contains space for the child’s initial slot allocator. When the new process starts creating and retyping capa- bilities, they will be stored in here.
|
||
struct cnoderef cspace_l2_cnode_slot_alloc_1; // < A second L2 Node for the slot allocator to use.
|
||
struct cnoderef cspace_l2_cnode_slot_alloc_2; // < A third L2 Node for the slot allocator to use.
|
||
struct cnoderef cspace_l2_cnode_base_pagecn; // < Each slot holds a BASE_PAGE_SIZEd RAM capability.
|
||
struct cnoderef cspace_l2_cnode_pagecn; // < Contains capabilites to the pagetable
|
||
|
||
// these capabilites are all stored in the taskcn cnode
|
||
struct capref cspace_cap_selfep; // < Endpoint to itself. You can get this capability by retyping the dispatcher capability to ObjType_EndPointLMP.
|
||
struct capref cspace_cap_initep; // < Endpoint to init
|
||
struct capref cspace_cap_dispatcher; // < Contains the dispatcher capability.The dispatcher is the equivalent of a “Process Control Block” in other operating systems. You can create one using dispatcher_create(...);
|
||
struct capref cspace_cap_rootcn; // < Contains a capability for the root (L1) CNode.
|
||
struct capref cspace_cap_dispframe; // < A capability to the dispatcher frame, used to communicate between a process and the CPU driver.
|
||
struct capref cspace_cap_argspage; // < A page containing a list of command line arguments.
|
||
struct capref cspace_cap_vspace; // < The frame capability used to store the serialized vspace
|
||
|
||
struct capref vspace_cap_l0_pagetable;
|
||
|
||
struct lmp_chan init_chan;
|
||
struct capref rpc_shared_frame;
|
||
struct aos_rpc_server rpc_server;
|
||
};
|
||
|
||
errval_t allocate_pid (const char *process_name, domainid_t *pid);
|
||
errval_t get_process_name (domainid_t pid, char *process_name, size_t *len);
|
||
errval_t get_all_pids (domainid_t *pids, size_t *count);
|
||
|
||
// parse a commandline into arguments
|
||
void spawn_parse_cmd(char *cmdline, int *argc, char **argv);
|
||
|
||
// Start a child process using the multiboot command line. Fills in si.
|
||
errval_t spawn_load_by_name(char *binary_name, struct spawninfo * si,
|
||
domainid_t *pid);
|
||
|
||
// Start a child with an explicit command line. Fills in si.
|
||
errval_t spawn_load_argv(int argc, char *argv[], struct spawninfo *si,
|
||
domainid_t *pid);
|
||
|
||
|
||
|
||
|
||
#endif /* _INIT_SPAWN_H_ */
|