mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-30 08:03:59 +00:00
parent
f55d06fd5c
commit
70b1ae3d1b
@ -245,17 +245,19 @@ Device_component::Device_component(Registry<Device_component> & registry,
|
||||
});
|
||||
};
|
||||
|
||||
auto default_domain_fn = [&] () {
|
||||
session.domain_registry().with_default_domain(add_range_fn); };
|
||||
|
||||
/* attach reserved memory ranges to IOMMU domains */
|
||||
device.for_each_io_mmu(
|
||||
/* non-empty list fn */
|
||||
[&] (Driver::Device::Io_mmu const &io_mmu) {
|
||||
session.domain_registry().with_domain(io_mmu.name,
|
||||
add_range_fn,
|
||||
[&] () { }); },
|
||||
default_domain_fn); },
|
||||
|
||||
/* empty list fn */
|
||||
[&] () {
|
||||
session.domain_registry().with_default_domain(add_range_fn); }
|
||||
default_domain_fn
|
||||
);
|
||||
|
||||
} catch(...) {
|
||||
|
@ -60,23 +60,8 @@ struct Config_helper
|
||||
Driver::Device::Pci_config const & cfg)
|
||||
: _env(env), _dev(dev), _cfg(cfg) { _config.scan(); }
|
||||
|
||||
void enable(Driver::Io_mmu_domain_registry & domain_registry)
|
||||
void enable()
|
||||
{
|
||||
auto enable_fn = [&] (Driver::Io_mmu::Domain & domain) {
|
||||
domain.enable_pci_device(_io_mem.cap(),
|
||||
{ _cfg.bus_num, _cfg.dev_num, _cfg.func_num });
|
||||
};
|
||||
|
||||
_dev.for_each_io_mmu(
|
||||
/* non-empty list fn */
|
||||
[&] (Driver::Device::Io_mmu const &io_mmu) {
|
||||
domain_registry.with_domain(io_mmu.name, enable_fn, [&] () {}); },
|
||||
|
||||
/* empty list fn */
|
||||
[&] () {
|
||||
domain_registry.with_default_domain(enable_fn); }
|
||||
);
|
||||
|
||||
_config.power_on(delayer(_env));
|
||||
|
||||
Config::Command::access_t cmd =
|
||||
@ -107,7 +92,7 @@ struct Config_helper
|
||||
_config.write<Config::Command>(cmd);
|
||||
}
|
||||
|
||||
void disable(Driver::Io_mmu_domain_registry & domain_registry)
|
||||
void disable()
|
||||
{
|
||||
Config::Command::access_t cmd =
|
||||
_config.read<Config::Command>();
|
||||
@ -118,21 +103,6 @@ struct Config_helper
|
||||
_config.write<Config::Command>(cmd);
|
||||
|
||||
_config.power_off();
|
||||
|
||||
auto disable_fn = [&] (Driver::Io_mmu::Domain & domain) {
|
||||
domain.disable_pci_device(_io_mem.cap(),
|
||||
{ _cfg.bus_num, _cfg.dev_num, _cfg.func_num });
|
||||
};
|
||||
|
||||
_dev.for_each_io_mmu(
|
||||
/* non-empty list fn */
|
||||
[&] (Driver::Device::Io_mmu const &io_mmu) {
|
||||
domain_registry.with_domain(io_mmu.name, disable_fn, [&] () {}); },
|
||||
|
||||
/* empty list fn */
|
||||
[&] () {
|
||||
domain_registry.with_default_domain(disable_fn); }
|
||||
);
|
||||
}
|
||||
|
||||
void apply_quirks()
|
||||
@ -165,20 +135,18 @@ struct Config_helper
|
||||
|
||||
|
||||
void Driver::pci_enable(Env & env,
|
||||
Driver::Io_mmu_domain_registry & domain_registry,
|
||||
Device const & dev)
|
||||
{
|
||||
dev.for_pci_config([&] (Device::Pci_config const & pc) {
|
||||
Config_helper(env, dev, pc).enable(domain_registry); });
|
||||
Config_helper(env, dev, pc).enable(); });
|
||||
}
|
||||
|
||||
|
||||
void Driver::pci_disable(Env & env,
|
||||
Driver::Io_mmu_domain_registry & domain_registry,
|
||||
Device const & dev)
|
||||
{
|
||||
dev.for_pci_config([&] (Device::Pci_config const & pc) {
|
||||
Config_helper(env, dev, pc).disable(domain_registry); });
|
||||
Config_helper(env, dev, pc).disable(); });
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,10 +28,8 @@ namespace Driver {
|
||||
class Device_pd;
|
||||
|
||||
void pci_enable(Genode::Env & env,
|
||||
Io_mmu_domain_registry & domain_registry,
|
||||
Device const & dev);
|
||||
void pci_disable(Genode::Env & env,
|
||||
Io_mmu_domain_registry & domain_registry,
|
||||
Device const & dev);
|
||||
void pci_apply_quirks(Genode::Env & env, Device const & dev);
|
||||
void pci_msi_enable(Genode::Env & env, Device_component & dc,
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <dataspace/client.h>
|
||||
#include <base/attached_io_mem_dataspace.h>
|
||||
|
||||
#include <device.h>
|
||||
#include <pci.h>
|
||||
@ -231,40 +232,51 @@ void Session_component::update_devices_rom()
|
||||
|
||||
void Session_component::enable_device(Device const & device)
|
||||
{
|
||||
pci_enable(_env, domain_registry(), device);
|
||||
|
||||
auto fn = [&] (Driver::Io_mmu::Domain & domain) {
|
||||
device.for_pci_config([&] (Device::Pci_config const & cfg) {
|
||||
Attached_io_mem_dataspace io_mem { _env, cfg.addr, 0x1000 };
|
||||
domain.enable_pci_device(io_mem.cap(),
|
||||
{cfg.bus_num, cfg.dev_num, cfg.func_num});
|
||||
});
|
||||
domain.enable_device();
|
||||
};
|
||||
|
||||
auto default_domain_fn = [&] () { _domain_registry.with_default_domain(fn); };
|
||||
|
||||
device.for_each_io_mmu(
|
||||
/* non-empty list fn */
|
||||
[&] (Device::Io_mmu const & io_mmu) {
|
||||
_domain_registry.with_domain(io_mmu.name, fn, [&] () { }); },
|
||||
_domain_registry.with_domain(io_mmu.name, fn, default_domain_fn);
|
||||
},
|
||||
|
||||
/* empty list fn */
|
||||
[&] () {
|
||||
_domain_registry.with_default_domain(fn); }
|
||||
default_domain_fn
|
||||
);
|
||||
|
||||
pci_enable(_env, device);
|
||||
}
|
||||
|
||||
|
||||
void Session_component::disable_device(Device const & device)
|
||||
{
|
||||
pci_disable(_env, domain_registry(), device);
|
||||
pci_disable(_env, device);
|
||||
|
||||
auto fn = [&] (Driver::Io_mmu::Domain & domain) {
|
||||
device.for_pci_config([&] (Device::Pci_config const & cfg) {
|
||||
domain.disable_pci_device({cfg.bus_num, cfg.dev_num, cfg.func_num});
|
||||
});
|
||||
domain.disable_device();
|
||||
};
|
||||
|
||||
auto default_domain_fn = [&] () { _domain_registry.with_default_domain(fn); };
|
||||
|
||||
device.for_each_io_mmu(
|
||||
/* non-empty list fn */
|
||||
[&] (Device::Io_mmu const & io_mmu) {
|
||||
_domain_registry.with_domain(io_mmu.name, fn, [&] () { }); },
|
||||
_domain_registry.with_domain(io_mmu.name, fn, default_domain_fn); },
|
||||
|
||||
/* empty list fn */
|
||||
[&] () {
|
||||
_domain_registry.with_default_domain(fn); }
|
||||
default_domain_fn
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user