genode/base/include/base/process.h
Norman Feske 959df5d46b Generalize handling of PD-session arguments
On Linux, we want to attach additional attributes to processes, i.e.,
the chroot location, the designated UID, and GID. Instead of polluting
the generic code with such Linux-specific platform details, I introduced
the new 'Native_pd_args' type, which can be customized for each
platform. The platform-dependent policy of init is factored out in the
new 'pd_args' library.

The new 'base-linux/run/lx_pd_args.run' script can be used to validate
the propagation of those attributes into core.

Note that this patch does not add the interpretation of the new UID and
PID attributes by core. This will be subject of a follow-up patch.

Related to #510.
2012-11-21 20:04:07 +01:00

96 lines
2.8 KiB
C++

/*
* \brief Process-creation interface
* \author Norman Feske
* \date 2006-06-22
*/
/*
* Copyright (C) 2006-2012 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__BASE__PROCESS_H_
#define _INCLUDE__BASE__PROCESS_H_
#include <ram_session/capability.h>
#include <rm_session/connection.h>
#include <pd_session/connection.h>
#include <cpu_session/client.h>
#include <parent/capability.h>
namespace Genode {
class Process
{
private:
Pd_connection _pd;
Thread_capability _thread0_cap;
Cpu_session_client _cpu_session_client;
Rm_session_client _rm_session_client;
static Dataspace_capability _dynamic_linker_cap;
/*
* Hook for passing additional platform-specific session
* arguments to the PD session. For example, on Linux a new
* process is created locally via 'fork' and the new PID gets
* then communicated to core via a PD-session argument.
*/
enum { PRIV_ARGBUF_LEN = 32 };
char _priv_pd_argbuf[PRIV_ARGBUF_LEN];
const char *_priv_pd_args(Parent_capability parent_cap,
Dataspace_capability elf_data_ds,
const char *name, char *const argv[]);
public:
/**
* Constructor
*
* \param elf_data_ds dataspace that contains the elf binary
* \param ram_session RAM session providing the BSS for the
* new protection domain
* \param cpu_session CPU session for the new protection domain
* \param rm_session RM session for the new protection domain
* \param parent parent of the new protection domain
* \param name name of protection domain (can be used
* for debugging)
* \param pd_args platform-specific arguments supplied to
* the PD session of the process
*
* The dataspace 'elf_data_ds' can be read-only.
*
* On construction of a protection domain, execution of the initial
* thread is started immediately.
*/
Process(Dataspace_capability elf_data_ds,
Ram_session_capability ram_session,
Cpu_session_capability cpu_session,
Rm_session_capability rm_session,
Parent_capability parent,
char const *name,
Native_pd_args const *args = 0);
/**
* Destructor
*
* When called, the protection domain gets killed.
*/
~Process();
static void dynamic_linker(Dataspace_capability dynamic_linker_cap)
{
_dynamic_linker_cap = dynamic_linker_cap;
}
Pd_session_capability pd_session_cap() const { return _pd.cap(); }
Thread_capability main_thread_cap() const { return _thread0_cap; }
};
}
#endif /* _INCLUDE__BASE__PROCESS_H_ */