genode/repos/base-foc/src/test/cap_integrity/main.cc
Norman Feske 88b358c5ef Unification of native_capability.h
This patch establishes the sole use of generic headers across all
kernels. The common 'native_capability.h' is based on the version of
base-sel4. All traditional L4 kernels and Linux use the same
implementation of the capability-lifetime management. On base-hw, NOVA,
Fiasco.OC, and seL4, custom implementations (based on their original
mechanisms) are used, with the potential to unify them further in the
future.

This change achieves binary compatibility of dynamically linked programs
across all kernels.

Furthermore, the patch introduces a Native_capability::print method,
which allows the easy output of the kernel-specific capability
representation using the base/log.h API.

Issue #1993
2016-07-11 13:07:37 +02:00

54 lines
1.4 KiB
C++

/*
* \brief Testing capability integrity
* \author Christian Prochaska
* \author Stefan Kalkowski
* \date 2012-02-10
*
*/
/*
* Copyright (C) 2008-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.
*/
/* Genode includes */
#include <base/env.h>
#include <log_session/connection.h>
#include <foc/capability_space.h>
/* base-internal includes */
#include <base/internal/cap_map.h> /* cap_idx_alloc */
using namespace Genode;
using namespace Fiasco;
int main(int argc, char **argv)
{
printf("--- capability integrity test ---\n");
enum { COUNT = 1000 };
Cap_index* idx = cap_idx_alloc()->alloc_range(COUNT);
Fiasco::l4_cap_idx_t tid = Capability_space::kcap(env()->ram_session_cap());
/* try the first 1000 local name IDs */
for (int local_name = 0; local_name < COUNT; local_name++, idx++) {
idx->id(local_name);
l4_task_map(L4_BASE_TASK_CAP, L4_BASE_TASK_CAP,
l4_obj_fpage(tid, 0, L4_FPAGE_RWX),
idx->kcap() | L4_ITEM_MAP);
Log_session_capability log_session_cap =
reinterpret_cap_cast<Log_session>(Native_capability(*idx));
Log_session_client log_session_client(log_session_cap);
try {
log_session_client.write("test message");
} catch(...) { }
}
printf("--- finished capability integrity test ---\n");
return 0;
}