genode/repos/ports-foc/src/lib/l4lx/include/task.h
Norman Feske 62b1c55399 Integrate CAP session into PD session
This patch integrates the functionality of the former CAP session into
the PD session and unifies the approch of supplementing the generic PD
session with kernel-specific functionality. The latter is achieved by
the new 'Native_pd' interface. The kernel-specific interface can be
obtained via the Pd_session::native_pd accessor function. The
kernel-specific interfaces are named Nova_native_pd, Foc_native_pd, and
Linux_native_pd.

The latter change allowed for to deduplication of the
pd_session_component code among the various base platforms.

To retain API compatibility, we keep the 'Cap_session' and
'Cap_connection' around. But those classes have become mere wrappers
around the PD session interface.

Issue #1841
2016-03-07 12:34:44 +01:00

91 lines
1.8 KiB
C++

/*
* \brief Tasks for l4lx support library.
* \author Stefan Kalkowski
* \date 2011-04-27
*/
/*
* Copyright (C) 2011-2013 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 _L4LX__TASK_H_
#define _L4LX__TASK_H_
/* Genode includes */
#include <pd_session/connection.h>
#include <foc_native_pd/client.h>
#include <util/avl_tree.h>
namespace Fiasco {
#include <l4/sys/types.h>
#include <l4/sys/consts.h>
}
namespace L4lx {
class Task : public Genode::Avl_node<Task>
{
private:
Fiasco::l4_cap_idx_t _ref;
Genode::Pd_connection _pd;
Genode::Foc_native_pd_client _native_pd { _pd.native_pd() };
Genode::Native_capability _cap;
public:
/*****************
** Constructor **
*****************/
Task(Fiasco::l4_cap_idx_t ref)
:
_ref(ref), _cap(_native_pd.task_cap())
{
using namespace Fiasco;
/* remap task cap to given cap slot */
l4_task_map(L4_BASE_TASK_CAP, L4_BASE_TASK_CAP,
l4_obj_fpage(_cap.dst(), 0, L4_FPAGE_RWX),
_ref | L4_ITEM_MAP);
}
/***************
** Accessors **
***************/
Fiasco::l4_cap_idx_t ref() { return _ref; }
/************************
** Avl_node interface **
************************/
bool higher(Task *n) { return n->_ref > _ref; }
Task *find_by_ref(Fiasco::l4_cap_idx_t ref)
{
if (_ref == ref) return this;
Task *n = Genode::Avl_node<Task>::child(ref > _ref);
return n ? n->find_by_ref(ref) : 0;
}
};
class Task_tree : public Genode::Avl_tree<Task>
{
public:
Task* find_by_ref(Fiasco::l4_cap_idx_t ref) {
return this->first() ? this->first()->find_by_ref(ref) : 0; }
};
}
#endif /* _L4LX__TASK_H_ */