foc: determine number of CPUs

Issue #814
Fixes #578
This commit is contained in:
Alexander Boettcher 2013-07-24 09:48:54 +02:00 committed by Norman Feske
parent 1a82b664ef
commit 435b8dd252
2 changed files with 25 additions and 0 deletions

View File

@ -159,6 +159,7 @@ namespace Genode {
addr_t vm_start() const { return _vm_start; }
size_t vm_size() const { return _vm_size; }
Rom_fs *rom_fs() { return &_rom_fs; }
unsigned num_cpus() const;
void wait_for_exit();
};

View File

@ -35,6 +35,7 @@ namespace Fiasco {
#include <l4/sys/thread.h>
#include <l4/sys/types.h>
#include <l4/sys/utcb.h>
#include <l4/sys/scheduler.h>
static l4_kernel_info_t *kip;
}
@ -511,4 +512,27 @@ void Platform::wait_for_exit()
}
unsigned Platform::num_cpus() const {
using namespace Genode;
using namespace Fiasco;
l4_sched_cpu_set_t cpus = l4_sched_cpu_set(0, 0, 1);
l4_umword_t cpus_max;
l4_msgtag_t res = l4_scheduler_info(L4_BASE_SCHEDULER_CAP, &cpus_max,
&cpus);
if (l4_error(res)) {
PERR("could not detect number of CPUs - assuming 1 CPU");
return 1;
}
unsigned cpus_online = 0;
for (unsigned i = 0; i < sizeof(cpus.map) * 8; i++)
if ((cpus.map >> i) & 0x1)
cpus_online ++;
return cpus_online;
}
void Core_parent::exit(int exit_value) { }