parent
db20e1d87b
commit
ee7f965061
|
@ -11,10 +11,10 @@
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <base/component.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/printf.h>
|
|
||||||
#include <base/sleep.h>
|
#include <util/volatile_object.h>
|
||||||
#include <cap_session/connection.h>
|
|
||||||
|
|
||||||
#include <os/attached_rom_dataspace.h>
|
#include <os/attached_rom_dataspace.h>
|
||||||
|
|
||||||
|
@ -22,62 +22,59 @@
|
||||||
#include "pci_device_config.h"
|
#include "pci_device_config.h"
|
||||||
#include "device_pd.h"
|
#include "device_pd.h"
|
||||||
|
|
||||||
using namespace Genode;
|
namespace Platform {
|
||||||
using namespace Platform;
|
struct Main;
|
||||||
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
struct Platform::Main
|
||||||
{
|
{
|
||||||
printf("platform driver started\n");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize server entry point
|
|
||||||
*/
|
|
||||||
static Cap_connection cap;
|
|
||||||
static Rpc_entrypoint ep(&cap, STACK_SIZE, "platform_ep");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use sliced heap to allocate each session component at a separate
|
* Use sliced heap to allocate each session component at a separate
|
||||||
* dataspace.
|
* dataspace.
|
||||||
*/
|
*/
|
||||||
static Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
|
Genode::Sliced_heap sliced_heap;
|
||||||
|
|
||||||
|
Genode::Env &_env;
|
||||||
|
|
||||||
/**
|
Genode::Lazy_volatile_object<Genode::Attached_rom_dataspace> acpi_rom;
|
||||||
* If we are running with ACPI support, wait for the first report_rom
|
Genode::Lazy_volatile_object<Platform::Root> root;
|
||||||
*/
|
|
||||||
bool wait_for_acpi = true;
|
|
||||||
char * report_addr = nullptr;
|
|
||||||
|
|
||||||
try {
|
Genode::Signal_handler<Platform::Main> _acpi_report;
|
||||||
char yesno[4];
|
|
||||||
Genode::config()->xml_node().attribute("acpi").value(yesno, sizeof(yesno));
|
|
||||||
wait_for_acpi = strcmp(yesno, "no");
|
|
||||||
} catch (...) { }
|
|
||||||
|
|
||||||
if (wait_for_acpi) {
|
void acpi_update()
|
||||||
static Attached_rom_dataspace acpi_rom("acpi");
|
{
|
||||||
|
acpi_rom->update();
|
||||||
|
|
||||||
Signal_receiver sig_rec;
|
if (!acpi_rom->valid() || root.constructed())
|
||||||
Signal_context sig_ctx;
|
return;
|
||||||
Signal_context_capability sig_cap = sig_rec.manage(&sig_ctx);
|
|
||||||
|
|
||||||
acpi_rom.sigh(sig_cap);
|
const char * report_addr = acpi_rom->local_addr<const char>();
|
||||||
|
|
||||||
while (!acpi_rom.valid()) {
|
root.construct(_env, &sliced_heap, report_addr);
|
||||||
sig_rec.wait_for_signal();
|
_env.parent().announce(_env.ep().manage(*root));
|
||||||
acpi_rom.update();
|
|
||||||
}
|
|
||||||
report_addr = acpi_rom.local_addr<char>();
|
|
||||||
sig_rec.dissolve(&sig_ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
Main(Genode::Env &env)
|
||||||
* Let the entry point serve the PCI root interface
|
:
|
||||||
*/
|
sliced_heap(env.ram(), env.rm()),
|
||||||
static Platform::Root root(&ep, &sliced_heap, report_addr, cap);
|
_env(env),
|
||||||
|
_acpi_report(_env.ep(), *this, &Main::acpi_update)
|
||||||
|
{
|
||||||
|
typedef Genode::String<8> Value;
|
||||||
|
Value const wait_for_acpi = Genode::config()->xml_node().attribute_value("acpi", Value("yes"));
|
||||||
|
|
||||||
env()->parent()->announce(ep.manage(&root));
|
if (wait_for_acpi == "yes") {
|
||||||
|
/* for ACPI support, wait for the first valid acpi report */
|
||||||
|
acpi_rom.construct("acpi");
|
||||||
|
acpi_rom->sigh(_acpi_report);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Genode::sleep_forever();
|
/* non ACPI platform case */
|
||||||
return 0;
|
root.construct(_env, &sliced_heap, nullptr);
|
||||||
}
|
_env.parent().announce(_env.ep().manage(*root));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Genode::size_t Component::stack_size() { return STACK_SIZE; }
|
||||||
|
void Component::construct(Genode::Env &env) { static Platform::Main main(env); }
|
||||||
|
|
|
@ -1011,11 +1011,12 @@ class Platform::Root : public Genode::Root_component<Session_component>
|
||||||
* \param md_alloc meta-data allocator for allocating PCI-session
|
* \param md_alloc meta-data allocator for allocating PCI-session
|
||||||
* components and PCI-device components
|
* components and PCI-device components
|
||||||
*/
|
*/
|
||||||
Root(Genode::Rpc_entrypoint *ep, Genode::Allocator *md_alloc,
|
Root(Genode::Env &env, Genode::Allocator *md_alloc,
|
||||||
const char *acpi_rom, Genode::Cap_connection &cap)
|
const char *acpi_rom)
|
||||||
:
|
:
|
||||||
Genode::Root_component<Session_component>(ep, md_alloc),
|
Genode::Root_component<Session_component>(&env.ep().rpc_ep(),
|
||||||
_device_pd_ep(&cap, STACK_SIZE, "device_pd_slave")
|
md_alloc),
|
||||||
|
_device_pd_ep(&env.pd(), STACK_SIZE, "device_pd_slave")
|
||||||
{
|
{
|
||||||
/* enforce initial bus scan */
|
/* enforce initial bus scan */
|
||||||
bus_valid();
|
bus_valid();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user