mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 06:33:31 +00:00
platform driver: make device info XML optional
* The device XML information dataspace is only provided, when the client's policy states `info="yes"` * The device XM information gets changed to include the physical resource names (I/O memory and IRQ addresses) instead of virtual ids and page offset Fix #4077
This commit is contained in:
parent
6caa74a18e
commit
421d2bed40
@ -145,14 +145,14 @@
|
||||
<irq number="57"/>
|
||||
</device>
|
||||
|
||||
<policy label="usb_drv -> "> <device name="usb_host_2"/> </policy>
|
||||
<policy label="fb_drv -> ">
|
||||
<policy label="usb_drv -> " info="yes"> <device name="usb_host_2"/> </policy>
|
||||
<policy label="fb_drv -> " info="yes">
|
||||
<device name="dcss"/>
|
||||
<device name="hdmi"/>
|
||||
<device name="mipi_dsi"/>
|
||||
<device name="src"/>
|
||||
</policy>
|
||||
<policy label="gpio_drv -> ">
|
||||
<policy label="gpio_drv -> " info="yes">
|
||||
<device name="gpio1"/>
|
||||
<device name="gpio2"/>
|
||||
<device name="gpio3"/>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<irq number="87"/>
|
||||
<property name="mii" value="rmii"/>
|
||||
</device>
|
||||
<policy label="nic_drv -> "> <device name="fec"/> </policy>
|
||||
<policy label="nic_drv -> " info="yes"> <device name="fec"/> </policy>
|
||||
</config>
|
||||
<route> <any-service> <parent/> </any-service> </route>
|
||||
</start>
|
||||
|
@ -26,7 +26,7 @@
|
||||
<irq number="151"/>
|
||||
<property name="mii" value="rgmii"/>
|
||||
</device>
|
||||
<policy label="nic_drv -> "> <device name="fec"/> </policy>
|
||||
<policy label="nic_drv -> " info="yes"> <device name="fec"/> </policy>
|
||||
</config>
|
||||
<route> <any-service> <parent/> </any-service> </route>
|
||||
</start>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<irq number="135"/>
|
||||
<property name="mii" value="rgmii"/>
|
||||
</device>
|
||||
<policy label="nic_drv -> ">
|
||||
<policy label="nic_drv -> " info="yes">
|
||||
<device name="fec0"/>
|
||||
<device name="fec1"/>
|
||||
</policy>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<irq number="150"/>
|
||||
<property name="mii" value="rgmii-id"/>
|
||||
</device>
|
||||
<policy label="nic_drv -> "> <device name="fec"/> </policy>
|
||||
<policy label="nic_drv -> " info="yes"> <device name="fec"/> </policy>
|
||||
</config>
|
||||
<route> <any-service> <parent/> </any-service> </route>
|
||||
</start>
|
||||
|
@ -79,7 +79,7 @@ proc platform_drv_config_non_x86 {} {
|
||||
<property name="dr_mode" value="host"/>
|
||||
<property name="snps,dis_u2_susphy_quirk"/>
|
||||
</device>
|
||||
<policy label="usb_drv -> "> <device name="usb_host_2"/> </policy>
|
||||
<policy label="usb_drv -> " info="yes"> <device name="usb_host_2"/> </policy>
|
||||
}
|
||||
}
|
||||
if {[have_board imx6q_sabrelite]} {
|
||||
@ -98,7 +98,7 @@ proc platform_drv_config_non_x86 {} {
|
||||
<property name="fsl,usbmisc" value="usbmisc_imx"/>
|
||||
<property name="dr_mode" value="host"/>
|
||||
</device>
|
||||
<policy label="usb_drv -> ">
|
||||
<policy label="usb_drv -> " info="yes">
|
||||
<device name="mxs_phy"/>
|
||||
<device name="usbmisc_imx"/>
|
||||
<device name="imx_usb"/>
|
||||
@ -112,7 +112,7 @@ proc platform_drv_config_non_x86 {} {
|
||||
<irq number="9"/>
|
||||
<power-domain name="usb"/>
|
||||
</device>
|
||||
<policy label="usb_drv -> "> <device name="dwc_otg"/> </policy>
|
||||
<policy label="usb_drv -> " info="yes"> <device name="dwc_otg"/> </policy>
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
@ -196,14 +196,14 @@
|
||||
<property name="mii" value="rgmii-id"/>
|
||||
</device>
|
||||
|
||||
<policy label="usb_drv -> "> <device name="usb_host_2"/> </policy>
|
||||
<policy label="fb_drv -> ">
|
||||
<policy label="usb_drv -> " info="yes"> <device name="usb_host_2"/> </policy>
|
||||
<policy label="fb_drv -> " info="yes">
|
||||
<device name="dcss"/>
|
||||
<device name="hdmi"/>
|
||||
<device name="mipi_dsi"/>
|
||||
<device name="src"/>
|
||||
</policy>
|
||||
<policy label="gpio_drv -> ">
|
||||
<policy label="gpio_drv -> " info="yes">
|
||||
<device name="gpio1"/>
|
||||
<device name="gpio2"/>
|
||||
<device name="gpio3"/>
|
||||
@ -212,7 +212,7 @@
|
||||
</policy>
|
||||
<policy label="touch_drv -> "> <device name="synaptics_dsx"/> </policy>
|
||||
<policy label="sd_card_drv -> "> <device name="sdhc2"/> </policy>
|
||||
<policy label="runtime -> nic"> <device name="fec"/> </policy>
|
||||
<policy label="runtime -> nic" info="yes"> <device name="fec"/> </policy>
|
||||
</config>
|
||||
<route> <any-service> <parent/> </any-service> </route>
|
||||
</start>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<irq number="9"/>
|
||||
<power-domain name="usb"/>
|
||||
</device>
|
||||
<policy label_prefix="rpi_usb_host_drv">
|
||||
<policy label_prefix="rpi_usb_host_drv" info="yes">
|
||||
<device name="dwc_otg"/>
|
||||
</policy>
|
||||
|
||||
|
@ -31,6 +31,9 @@ struct Platform::Client : Genode::Rpc_client<Session>
|
||||
Capability<Device_interface> acquire_device(Device_name const &name) override {
|
||||
return call<Rpc_acquire_device>(name); }
|
||||
|
||||
Capability<Device_interface> acquire_single_device() override {
|
||||
return call<Rpc_acquire_single_device>(); }
|
||||
|
||||
void release_device(Capability<Device_interface> device) override {
|
||||
call<Rpc_release_device>(device); }
|
||||
|
||||
|
@ -76,6 +76,12 @@ class Platform::Connection : public Genode::Connection<Session>,
|
||||
return Client::acquire_device(name); });
|
||||
}
|
||||
|
||||
Capability<Device_interface> acquire_device()
|
||||
{
|
||||
return retry_with_upgrade(Ram_quota{6*1024}, Cap_quota{6}, [&] () {
|
||||
return Client::acquire_single_device(); });
|
||||
}
|
||||
|
||||
Ram_dataspace_capability alloc_dma_buffer(size_t size, Cache cache) override
|
||||
{
|
||||
return retry_with_upgrade(Ram_quota{size}, Cap_quota{2}, [&] () {
|
||||
@ -94,25 +100,6 @@ class Platform::Connection : public Genode::Connection<Session>,
|
||||
warning("Devices rom has invalid XML syntax"); }
|
||||
}
|
||||
|
||||
Capability<Device_interface> device_by_index(unsigned idx)
|
||||
{
|
||||
Capability<Device_interface> cap;
|
||||
|
||||
with_xml([&] (Xml_node & xml) {
|
||||
try {
|
||||
Xml_node node = xml.sub_node(idx);
|
||||
Device_name name = node.attribute_value("name",
|
||||
Device_name());
|
||||
cap = acquire_device(name.string());
|
||||
} catch(Xml_node::Nonexistent_sub_node) {
|
||||
error(__func__, ": invalid device index ", idx);
|
||||
error("device ROM content: ", xml);
|
||||
}
|
||||
});
|
||||
|
||||
return cap;
|
||||
}
|
||||
|
||||
Capability<Device_interface> device_by_type(char const * type)
|
||||
{
|
||||
using String = Genode::String<64>;
|
||||
|
@ -58,9 +58,9 @@ class Platform::Device : Interface, Noncopyable
|
||||
|
||||
struct Index { unsigned value; };
|
||||
|
||||
Device(Connection &platform, Index index)
|
||||
explicit Device(Connection &platform)
|
||||
:
|
||||
_platform(platform), _cap(platform.device_by_index(index.value))
|
||||
_platform(platform), _cap(platform.acquire_device())
|
||||
{ }
|
||||
|
||||
struct Type { String<64> name; };
|
||||
@ -70,8 +70,6 @@ class Platform::Device : Interface, Noncopyable
|
||||
_platform(platform), _cap(platform.device_by_type(type.name.string()))
|
||||
{ }
|
||||
|
||||
explicit Device(Connection &platform) : Device(platform, Index { 0 }) { }
|
||||
|
||||
~Device() { _platform.release_device(_cap); }
|
||||
};
|
||||
|
||||
|
@ -72,6 +72,11 @@ struct Platform::Session : Genode::Session
|
||||
*/
|
||||
virtual Capability<Device_interface> acquire_device(Device_name const &name) = 0;
|
||||
|
||||
/**
|
||||
* Acquire the first resp. single device of this session
|
||||
*/
|
||||
virtual Capability<Device_interface> acquire_single_device() = 0;
|
||||
|
||||
/**
|
||||
* Free server-internal data structures representing the device
|
||||
*
|
||||
@ -103,6 +108,8 @@ struct Platform::Session : Genode::Session
|
||||
GENODE_RPC_THROW(Rpc_acquire_device, Capability<Device_interface>, acquire_device,
|
||||
GENODE_TYPE_LIST(Out_of_ram, Out_of_caps),
|
||||
Device_name const &);
|
||||
GENODE_RPC_THROW(Rpc_acquire_single_device, Capability<Device_interface>,
|
||||
acquire_single_device, GENODE_TYPE_LIST(Out_of_ram, Out_of_caps));
|
||||
GENODE_RPC(Rpc_release_device, void, release_device, Capability<Device_interface>);
|
||||
GENODE_RPC_THROW(Rpc_alloc_dma_buffer, Ram_dataspace_capability,
|
||||
alloc_dma_buffer,
|
||||
@ -112,8 +119,8 @@ struct Platform::Session : Genode::Session
|
||||
GENODE_RPC(Rpc_dma_addr, addr_t, dma_addr,
|
||||
Ram_dataspace_capability);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_devices_rom, Rpc_acquire_device, Rpc_release_device,
|
||||
Rpc_alloc_dma_buffer, Rpc_free_dma_buffer,
|
||||
GENODE_RPC_INTERFACE(Rpc_devices_rom, Rpc_acquire_device, Rpc_acquire_single_device,
|
||||
Rpc_release_device, Rpc_alloc_dma_buffer, Rpc_free_dma_buffer,
|
||||
Rpc_dma_addr);
|
||||
};
|
||||
|
||||
|
@ -14,9 +14,7 @@
|
||||
#ifndef _INCLUDE__VIRTIO__MMIO_DEVICE_H_
|
||||
#define _INCLUDE__VIRTIO__MMIO_DEVICE_H_
|
||||
|
||||
#include <base/attached_dataspace.h>
|
||||
#include <os/attached_mmio.h>
|
||||
#include <util/mmio.h>
|
||||
#include <platform_session/device.h>
|
||||
#include <virtio/queue.h>
|
||||
|
||||
|
||||
@ -26,7 +24,7 @@ namespace Virtio {
|
||||
}
|
||||
|
||||
|
||||
class Virtio::Device : Genode::Attached_dataspace, Genode::Mmio
|
||||
class Virtio::Device : Platform::Device::Mmio
|
||||
{
|
||||
public:
|
||||
|
||||
@ -97,13 +95,13 @@ class Virtio::Device : Genode::Attached_dataspace, Genode::Mmio
|
||||
Device(Device const &) = delete;
|
||||
Device &operator = (Device const &) = delete;
|
||||
|
||||
Platform::Device::Irq _irq;
|
||||
|
||||
public:
|
||||
|
||||
Device(Genode::Env &env,
|
||||
Genode::Io_mem_dataspace_capability io_mem_ds,
|
||||
size_t offset)
|
||||
: Attached_dataspace(env.rm(), io_mem_ds)
|
||||
, Mmio((addr_t)local_addr<void>() + offset)
|
||||
Device(Platform::Device & device)
|
||||
:
|
||||
Platform::Device::Mmio(device), _irq(device, {0})
|
||||
{
|
||||
if (read<Magic>() != VIRTIO_MMIO_MAGIC) {
|
||||
throw Invalid_device(); }
|
||||
@ -196,6 +194,11 @@ class Virtio::Device : Genode::Attached_dataspace, Genode::Mmio
|
||||
write<InterruptAck>(isr);
|
||||
return isr;
|
||||
}
|
||||
|
||||
void irq_sigh(Signal_context_capability cap) {
|
||||
_irq.sigh(cap); }
|
||||
|
||||
void irq_ack() { _irq.ack(); }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__VIRTIO__MMIO_DEVICE_H_ */
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define _INCLUDE__VIRTIO__PCI_DEVICE_H_
|
||||
|
||||
#include <os/attached_mmio.h>
|
||||
#include <irq_session/client.h>
|
||||
#include <platform_device/client.h>
|
||||
#include <virtio/queue.h>
|
||||
|
||||
@ -96,6 +97,7 @@ class Virtio::Device
|
||||
|
||||
Genode::Env &_env;
|
||||
Platform::Device_client &_device;
|
||||
Genode::Irq_session_client _irq { _device.irq(0) };
|
||||
uint32_t _notify_offset_multiplier = 0;
|
||||
Genode::Constructible<Device_mmio> _cfg_common { };
|
||||
Genode::Constructible<Device_mmio> _dev_config { };
|
||||
@ -277,6 +279,11 @@ class Virtio::Device
|
||||
|
||||
uint32_t read_isr() {
|
||||
return _isr->read<Device_mmio::IrqReason>(); }
|
||||
|
||||
void irq_sigh(Signal_context_capability cap) {
|
||||
_irq.sigh(cap); }
|
||||
|
||||
void irq_ack() { _irq.ack_irq(); }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__VIRTIO__PCI_DEVICE_H_ */
|
||||
|
@ -29,26 +29,22 @@
|
||||
<io_mem address="0x10001000" size="0x1000"/>
|
||||
</device>
|
||||
|
||||
<device name="kmi0" type="arm,pl050">
|
||||
<device name="pl050" type="arm,pl050">
|
||||
<io_mem address="0x10006000" size="0x1000"/>
|
||||
<irq number="52"/>
|
||||
</device>
|
||||
|
||||
<device name="kmi1" type="arm,pl050">
|
||||
<io_mem address="0x10007000" size="0x1000"/>
|
||||
<irq number="52"/>
|
||||
<irq number="53"/>
|
||||
</device>
|
||||
|
||||
<!-- policy part, who owns which devices -->
|
||||
|
||||
<policy label="fb_drv -> ">
|
||||
<policy label="fb_drv -> " info="yes">
|
||||
<device name="clcd"/>
|
||||
<device name="sp810_syscon0"/>
|
||||
</policy>
|
||||
|
||||
<policy label="ps2_drv -> ">
|
||||
<device name="kmi0"/>
|
||||
<device name="kmi1"/>
|
||||
<device name="pl050"/>
|
||||
</policy>
|
||||
</config>
|
||||
</start>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<provides> <service name="ROM"/> </provides>
|
||||
<route> <any-service> <parent/> </any-service> </route>
|
||||
<config>
|
||||
<policy label_prefix="virtio_mmio_nic">
|
||||
<policy label_prefix="virtio_mmio_nic" info="yes">
|
||||
<device name="nic0"/>
|
||||
</policy>
|
||||
</config>
|
||||
@ -36,7 +36,7 @@
|
||||
</start>
|
||||
|
||||
<start name="virtio_mmio_nic">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<resource name="RAM" quantum="5M"/>
|
||||
<config mode="uplink_client"/>
|
||||
<route>
|
||||
<service name="Platform">
|
||||
|
@ -155,7 +155,7 @@ append_if $trusted_led config {
|
||||
<io_mem address="0x50004000" size="0x4000"/>
|
||||
<irq number="1"/>
|
||||
</device>
|
||||
<policy label="imx_gpio_drv -> "> <device name="gpio"/> </policy>
|
||||
<policy label="imx_gpio_drv -> " info="yes"> <device name="gpio"/> </policy>
|
||||
<policy label="sd_card_drv -> "> <device name="sd_card"/> </policy>
|
||||
</config>
|
||||
</start>
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <base/heap.h>
|
||||
#include <base/log.h>
|
||||
#include <base/signal.h>
|
||||
#include <irq_session/client.h>
|
||||
#include <nic/component.h>
|
||||
#include <root/component.h>
|
||||
#include <util/misc_math.h>
|
||||
@ -154,7 +153,6 @@ class Virtio_nic::Device : Noncopyable
|
||||
Hardware_features const _hw_features;
|
||||
Rx_queue_type _rx_vq;
|
||||
Tx_queue_type _tx_vq;
|
||||
Irq_session_client _irq;
|
||||
|
||||
void _init_virtio_device()
|
||||
{
|
||||
@ -294,7 +292,6 @@ class Virtio_nic::Device : Noncopyable
|
||||
|
||||
Device(Genode::Env &env,
|
||||
Virtio::Device &device,
|
||||
Irq_session_capability irq_cap,
|
||||
Genode::Xml_node const &xml)
|
||||
try :
|
||||
_verbose { xml.attribute_value("verbose", false) },
|
||||
@ -305,8 +302,7 @@ class Virtio_nic::Device : Noncopyable
|
||||
_buf_size(RX_VQ, xml, "rx_buffer_size") },
|
||||
_tx_vq { env.ram(), env.rm(),
|
||||
_vq_size(TX_VQ, xml, "tx_queue_size"),
|
||||
_buf_size(TX_VQ, xml, "tx_buffer_size") },
|
||||
_irq { irq_cap }
|
||||
_buf_size(TX_VQ, xml, "tx_buffer_size") }
|
||||
{ }
|
||||
catch (Tx_queue_type::Invalid_buffer_size)
|
||||
{
|
||||
@ -345,7 +341,7 @@ class Virtio_nic::Device : Noncopyable
|
||||
if ((reasons & IRQ_CONFIG_CHANGE) && _hw_features.link_status_available) {
|
||||
handle_link_state();
|
||||
}
|
||||
_irq.ack_irq();
|
||||
_device.irq_ack();
|
||||
}
|
||||
|
||||
bool tx_vq_write_pkt(char const *pkt_base,
|
||||
@ -409,8 +405,8 @@ class Virtio_nic::Device : Noncopyable
|
||||
void init(Genode::Signal_context_capability irq_handler)
|
||||
{
|
||||
_setup_virtio_queues();
|
||||
_irq.sigh(irq_handler);
|
||||
_irq.ack_irq();
|
||||
_device.irq_sigh(irq_handler);
|
||||
_device.irq_ack();
|
||||
}
|
||||
};
|
||||
|
||||
@ -528,14 +524,13 @@ class Virtio_nic::Session_component : public Nic::Session_component,
|
||||
Session_component(Genode::Env &env,
|
||||
Genode::Allocator &rx_block_md_alloc,
|
||||
Virtio::Device &device,
|
||||
Irq_session_capability irq_cap,
|
||||
Genode::Xml_node const &xml,
|
||||
Genode::size_t const tx_buf_size,
|
||||
Genode::size_t const rx_buf_size)
|
||||
:
|
||||
Nic::Session_component { tx_buf_size, rx_buf_size, Genode::CACHED,
|
||||
rx_block_md_alloc, env },
|
||||
Device { env, device, irq_cap, xml },
|
||||
Device { env, device, xml },
|
||||
_irq_handler { env.ep(), *this, &Session_component::_handle_irq },
|
||||
_link_up { link_state() }
|
||||
{
|
||||
@ -562,7 +557,6 @@ class Virtio_nic::Root : public Genode::Root_component<Session_component, Genode
|
||||
Genode::Env &_env;
|
||||
Virtio::Device &_device;
|
||||
Attached_rom_dataspace &_config_rom;
|
||||
Irq_session_capability _irq_cap;
|
||||
|
||||
Session_component *_create_session(const char *args) override
|
||||
{
|
||||
@ -583,7 +577,7 @@ class Virtio_nic::Root : public Genode::Root_component<Session_component, Genode
|
||||
|
||||
try {
|
||||
return new (md_alloc()) Session_component(
|
||||
_env, *md_alloc(), _device, _irq_cap, _config_rom.xml(),
|
||||
_env, *md_alloc(), _device, _config_rom.xml(),
|
||||
tx_buf_size, rx_buf_size);
|
||||
} catch (...) { throw Service_denied(); }
|
||||
}
|
||||
@ -593,15 +587,13 @@ class Virtio_nic::Root : public Genode::Root_component<Session_component, Genode
|
||||
Root(Env &env,
|
||||
Allocator &md_alloc,
|
||||
Virtio::Device &device,
|
||||
Irq_session_capability irq_cap,
|
||||
Attached_rom_dataspace &config_rom)
|
||||
:
|
||||
Root_component<Session_component,
|
||||
Genode::Single_client> { env.ep(), md_alloc },
|
||||
_env { env },
|
||||
_device { device },
|
||||
_config_rom { config_rom },
|
||||
_irq_cap { irq_cap }
|
||||
_config_rom { config_rom }
|
||||
{ }
|
||||
};
|
||||
|
||||
@ -681,10 +673,9 @@ class Genode::Uplink_client : public Virtio_nic::Device,
|
||||
Uplink_client(Env &env,
|
||||
Allocator &alloc,
|
||||
Virtio::Device &device,
|
||||
Irq_session_capability irq_cap,
|
||||
Genode::Xml_node const &xml)
|
||||
:
|
||||
Device { env, device, irq_cap, xml },
|
||||
Device { env, device, xml },
|
||||
Uplink_client_base { env, alloc, read_mac_address() },
|
||||
_irq_handler { env.ep(), *this, &Uplink_client::_handle_irq }
|
||||
{
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
/* local includes */
|
||||
#include "component.h"
|
||||
#include "platform_device.h"
|
||||
|
||||
namespace Virtio_mmio_nic {
|
||||
using namespace Genode;
|
||||
@ -33,50 +32,14 @@ struct Virtio_mmio_nic::Main
|
||||
{
|
||||
struct Device_not_found : Genode::Exception { };
|
||||
|
||||
struct Device_info {
|
||||
using String = Genode::String<64>;
|
||||
|
||||
String name {};
|
||||
size_t io_mem_offset = 0;
|
||||
|
||||
Device_info(Platform::Connection & platform) {
|
||||
bool found = false;
|
||||
platform.with_xml([&] (Xml_node & xml) {
|
||||
xml.for_each_sub_node("device", [&] (Xml_node node) {
|
||||
if (found) return;
|
||||
|
||||
node.for_each_sub_node("property", [&] (Xml_node node) {
|
||||
if ((node.attribute_value("name", String()) == "type") &&
|
||||
(node.attribute_value("value", String()) == "nic")) {
|
||||
found = true; }
|
||||
});
|
||||
|
||||
if (!found) return;
|
||||
|
||||
name = node.attribute_value("name", String());
|
||||
|
||||
node.for_each_sub_node("io_mem", [&] (Xml_node node) {
|
||||
io_mem_offset = node.attribute_value<size_t>("page_offset", 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
if (!found) {
|
||||
error("No device was found");
|
||||
throw Device_not_found();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Genode::Env &env;
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
Platform::Connection platform { env };
|
||||
Device_info info { platform };
|
||||
Platform::Device_client platform_device { platform.acquire_device(info.name.string()) };
|
||||
Virtio::Device virtio_device { env, platform_device.io_mem_dataspace(),
|
||||
info.io_mem_offset };
|
||||
Attached_rom_dataspace config_rom { env, "config" };
|
||||
Genode::Constructible<Virtio_nic::Root> root { };
|
||||
Genode::Constructible<Genode::Uplink_client> uplink_client { };
|
||||
Env & env;
|
||||
Heap heap { env.ram(), env.rm() };
|
||||
Platform::Connection platform { env };
|
||||
Platform::Device platform_device { platform, { "nic" } };
|
||||
Virtio::Device device { platform_device };
|
||||
Attached_rom_dataspace config_rom { env, "config" };
|
||||
Constructible<Virtio_nic::Root> root { };
|
||||
Constructible<Uplink_client> uplink_client { };
|
||||
|
||||
Main(Env &env)
|
||||
try : env(env)
|
||||
@ -89,19 +52,13 @@ struct Virtio_mmio_nic::Main
|
||||
switch (mode) {
|
||||
case Nic_driver_mode::NIC_SERVER:
|
||||
|
||||
root.construct(
|
||||
env, heap, virtio_device, platform_device.irq(0),
|
||||
config_rom);
|
||||
|
||||
root.construct( env, heap, device, config_rom);
|
||||
env.parent().announce(env.ep().manage(*root));
|
||||
break;
|
||||
|
||||
case Nic_driver_mode::UPLINK_CLIENT:
|
||||
|
||||
uplink_client.construct(
|
||||
env, heap, virtio_device, platform_device.irq(0),
|
||||
config_rom.xml());
|
||||
|
||||
uplink_client.construct( env, heap, device, config_rom.xml());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -62,9 +62,7 @@ struct Virtio_pci_nic::Main
|
||||
switch (mode) {
|
||||
case Nic_driver_mode::NIC_SERVER:
|
||||
|
||||
root.construct(
|
||||
env, heap, virtio_device, platform_device.irq(0),
|
||||
config_rom);
|
||||
root.construct(env, heap, virtio_device, config_rom);
|
||||
|
||||
env.parent().announce(env.ep().manage(*root));
|
||||
break;
|
||||
@ -72,8 +70,7 @@ struct Virtio_pci_nic::Main
|
||||
case Nic_driver_mode::UPLINK_CLIENT:
|
||||
|
||||
uplink_client.construct(
|
||||
env, heap, virtio_device, platform_device.irq(0),
|
||||
config_rom.xml());
|
||||
env, heap, virtio_device, config_rom.xml());
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* \brief Client stub for Platform::Device client
|
||||
* \author Norman Feske
|
||||
* \date 2021-04-15
|
||||
*
|
||||
* The 'Device_client' is a mere compatibilty wrapper used until the
|
||||
* driver has been coverted to the 'Platform::Device::Mmio' API.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _PLATFORM_DEVICE_H_
|
||||
#define _PLATFORM_DEVICE_H_
|
||||
|
||||
namespace Platform { struct Device_client; }
|
||||
|
||||
|
||||
struct Platform::Device_client : Rpc_client<Device_interface>
|
||||
{
|
||||
Device_client(Capability<Device_interface> cap)
|
||||
: Rpc_client<Device_interface>(cap) { }
|
||||
|
||||
Irq_session_capability irq(unsigned id = 0)
|
||||
{
|
||||
return call<Rpc_irq>(id);
|
||||
}
|
||||
|
||||
Io_mem_session_capability io_mem(unsigned id, Range &range, Cache cache)
|
||||
{
|
||||
return call<Rpc_io_mem>(id, range, cache);
|
||||
}
|
||||
|
||||
Io_mem_dataspace_capability io_mem_dataspace(unsigned id = 0)
|
||||
{
|
||||
Range range { };
|
||||
return Io_mem_session_client(io_mem(id, range, UNCACHED)).dataspace();
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _PLATFORM_DEVICE_H_ */
|
@ -124,25 +124,19 @@ Driver::Device::io_mem(unsigned idx, Range &range, Cache cache, Session_componen
|
||||
|
||||
void Driver::Device::report(Xml_generator & xml, Session_component & sc)
|
||||
{
|
||||
unsigned io_mem_id = 0;
|
||||
unsigned irq_id = 0;
|
||||
|
||||
static constexpr addr_t page_off_mask = (addr_t)((1 << 12) - 1);
|
||||
|
||||
xml.node("device", [&] () {
|
||||
xml.attribute("name", name());
|
||||
xml.attribute("type", type());
|
||||
_io_mem_list.for_each([&] (Io_mem & io_mem) {
|
||||
xml.node("io_mem", [&] () {
|
||||
xml.attribute("id", io_mem_id++);
|
||||
xml.attribute("size", io_mem.size);
|
||||
xml.attribute("page_offset",
|
||||
io_mem.base & page_off_mask);
|
||||
xml.attribute("phys_addr", String<16>(Hex(io_mem.base)));
|
||||
xml.attribute("size", String<16>(Hex(io_mem.size)));
|
||||
});
|
||||
});
|
||||
_irq_list.for_each([&] (Irq &) {
|
||||
_irq_list.for_each([&] (Irq & irq) {
|
||||
xml.node("irq", [&] () {
|
||||
xml.attribute("id", irq_id++); });
|
||||
xml.attribute("number", irq.number);
|
||||
});
|
||||
});
|
||||
_property_list.for_each([&] (Property & p) {
|
||||
xml.node("property", [&] () {
|
||||
|
@ -48,17 +48,18 @@ Driver::Session_component * Driver::Root::_create_session(const char *args)
|
||||
Session_component * sc = nullptr;
|
||||
|
||||
try {
|
||||
sc = new (md_alloc()) Session_component(_env,
|
||||
_sessions,
|
||||
session_label_from_args(args),
|
||||
session_resources_from_args(args),
|
||||
session_diag_from_args(args));
|
||||
Session::Label const label { session_label_from_args(args) };
|
||||
Session_policy const policy { label, _env.config.xml() };
|
||||
|
||||
sc = new (md_alloc())
|
||||
Session_component(_env, _sessions, label,
|
||||
session_resources_from_args(args),
|
||||
session_diag_from_args(args),
|
||||
policy.attribute_value("info", false));
|
||||
|
||||
Session_policy const policy { sc->_label, _env.config.xml() };
|
||||
policy.for_each_sub_node("device", [&] (Xml_node node) {
|
||||
sc->add(node.attribute_value("name", Driver::Device::Name())); });
|
||||
} catch (Session_policy::No_policy_defined) {
|
||||
if (sc) { Genode::destroy(md_alloc(), sc); }
|
||||
error("Invalid session request, no matching policy for ",
|
||||
"'", label_from_args(args).string(), "'");
|
||||
throw Service_denied();
|
||||
|
@ -20,6 +20,7 @@ using Driver::Session_component;
|
||||
|
||||
void Session_component::produce_xml(Xml_generator &xml)
|
||||
{
|
||||
if (!_info) { return; }
|
||||
for (Device_list_element * e = _device_list.first(); e; e = e->next()) {
|
||||
e->object()->report(xml); }
|
||||
}
|
||||
@ -96,6 +97,16 @@ Session_component::acquire_device(Platform::Session::Device_name const &name)
|
||||
}
|
||||
|
||||
|
||||
Genode::Capability<Platform::Device_interface>
|
||||
Session_component::acquire_single_device()
|
||||
{
|
||||
Device_list_element * e = _device_list.first();
|
||||
if (!e) { return Capability<Platform::Device_interface>(); }
|
||||
|
||||
return acquire_device(e->object()->device());
|
||||
}
|
||||
|
||||
|
||||
void Session_component::release_device(Capability<Platform::Device_interface> device_cap)
|
||||
{
|
||||
_env.env.ep().rpc_ep().apply(device_cap, [&] (Device_component * dc) {
|
||||
@ -163,11 +174,12 @@ Session_component::Session_component(Driver::Env & env,
|
||||
Session_registry & registry,
|
||||
Label const & label,
|
||||
Resources const & resources,
|
||||
Diag const & diag)
|
||||
Diag const & diag,
|
||||
bool const info)
|
||||
: Session_object<Platform::Session>(env.env.ep(), resources, label, diag),
|
||||
Session_registry::Element(registry, *this),
|
||||
Dynamic_rom_session::Xml_producer("devices"),
|
||||
_env(env)
|
||||
_env(env), _info(info)
|
||||
{
|
||||
/*
|
||||
* FIXME: As the ROM session does not propagate Out_of_*
|
||||
|
@ -45,7 +45,8 @@ class Driver::Session_component
|
||||
Session_registry & registry,
|
||||
Label const & label,
|
||||
Resources const & resources,
|
||||
Diag const & diag);
|
||||
Diag const & diag,
|
||||
bool const info);
|
||||
~Session_component();
|
||||
|
||||
Heap & heap();
|
||||
@ -69,6 +70,7 @@ class Driver::Session_component
|
||||
|
||||
Rom_session_capability devices_rom() override;
|
||||
Device_capability acquire_device(Device_name const &) override;
|
||||
Device_capability acquire_single_device() override;
|
||||
void release_device(Device_capability) override;
|
||||
Ram_dataspace_capability alloc_dma_buffer(size_t, Cache) override;
|
||||
void free_dma_buffer(Ram_dataspace_capability ram_cap) override;
|
||||
@ -98,6 +100,7 @@ class Driver::Session_component
|
||||
List<Dma_buffer> _buffer_list { };
|
||||
Dynamic_rom_session _rom_session { _env.env.ep(), _env.env.ram(),
|
||||
_env.env.rm(), *this };
|
||||
bool const _info;
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
|
@ -40,14 +40,13 @@ struct Ps2::Main
|
||||
|
||||
using Device = Platform::Device;
|
||||
|
||||
Device _device_keyboard { _platform, Device::Index { 0 } };
|
||||
Device _device_mouse { _platform, Device::Index { 1 } };
|
||||
Device _device { _platform };
|
||||
|
||||
Device::Mmio _mmio_keyboard { _device_keyboard };
|
||||
Device::Mmio _mmio_mouse { _device_mouse };
|
||||
Device::Mmio _mmio_keyboard { _device, { 0 } };
|
||||
Device::Mmio _mmio_mouse { _device, { 1 } };
|
||||
|
||||
Device::Irq _irq_keyboard { _device_keyboard };
|
||||
Device::Irq _irq_mouse { _device_mouse };
|
||||
Device::Irq _irq_keyboard { _device, { 0 } };
|
||||
Device::Irq _irq_mouse { _device, { 1 } };
|
||||
|
||||
Pl050 _pl050 { _mmio_keyboard, _mmio_mouse };
|
||||
|
||||
|
@ -141,8 +141,8 @@ void Driver::_write_data(unsigned length,
|
||||
Driver::Driver(Env &env, Platform::Connection & platform)
|
||||
:
|
||||
Block::Driver(env.ram()),
|
||||
Platform::Device(platform, Platform::Device::Index { 0 }),
|
||||
Platform::Device::Mmio(*this, Platform::Device::Mmio::Index { 0 }),
|
||||
Platform::Device(platform),
|
||||
Platform::Device::Mmio(*this, { 0 }),
|
||||
_platform(platform),
|
||||
_timer(env)
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ class Sd_card::Driver : public Block::Driver,
|
||||
{
|
||||
using Device = Platform::Device_interface;
|
||||
|
||||
Capability<Device> device_cap = platform.device_by_index(0);
|
||||
Capability<Device> device_cap = platform.acquire_device();
|
||||
|
||||
Device::Range range { };
|
||||
Io_mem_session_client io_mem {
|
||||
|
@ -15,7 +15,7 @@
|
||||
#define _DRIVERS__INPUT__SPEC__IMX53__I2C_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/mmio.h>
|
||||
#include <platform_session/device.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
/* local includes */
|
||||
@ -27,7 +27,7 @@ namespace I2c
|
||||
}
|
||||
|
||||
|
||||
class I2c::I2c : Genode::Mmio
|
||||
class I2c::I2c : Platform::Device::Mmio
|
||||
{
|
||||
private:
|
||||
|
||||
@ -64,7 +64,7 @@ class I2c::I2c : Genode::Mmio
|
||||
|
||||
class No_ack : Genode::Exception {};
|
||||
|
||||
Irq_handler & _irq_handler;
|
||||
Irq_handler _irq_handler;
|
||||
|
||||
void _busy() { while (!read<Status::Busy>()); }
|
||||
|
||||
@ -111,9 +111,9 @@ class I2c::I2c : Genode::Mmio
|
||||
|
||||
public:
|
||||
|
||||
I2c(Genode::addr_t const base, Irq_handler &irq_handler)
|
||||
: Mmio(base),
|
||||
_irq_handler(irq_handler)
|
||||
I2c(Genode::Env & env, Platform::Device & dev)
|
||||
: Platform::Device::Mmio(dev, {0}),
|
||||
_irq_handler(env, dev)
|
||||
{
|
||||
write<Control>(0);
|
||||
write<Status>(0);
|
||||
|
@ -15,39 +15,38 @@
|
||||
#define _IRQ_HANDLER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <irq_session/client.h>
|
||||
#include <platform_session/device.h>
|
||||
|
||||
class Irq_handler
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Env &_env;
|
||||
Genode::Irq_session_client _irq;
|
||||
Genode::Io_signal_handler<Irq_handler> _handler;
|
||||
|
||||
unsigned _sem_cnt = 1;
|
||||
|
||||
void _handle() { _sem_cnt = 0; }
|
||||
|
||||
Platform::Device::Irq _irq;
|
||||
Genode::Entrypoint & _ep;
|
||||
Genode::Io_signal_handler<Irq_handler> _handler { _ep, *this, &Irq_handler::_handle };
|
||||
|
||||
public:
|
||||
|
||||
Irq_handler(Genode::Env &env, Genode::Irq_session_capability irq)
|
||||
Irq_handler(Genode::Env & env, Platform::Device & dev)
|
||||
:
|
||||
_env(env), _irq(irq),
|
||||
_handler(env.ep(), *this, &Irq_handler::_handle)
|
||||
_irq(dev, { 0 }), _ep(env.ep())
|
||||
{
|
||||
_irq.sigh(_handler);
|
||||
_irq.ack_irq();
|
||||
_irq.ack();
|
||||
}
|
||||
|
||||
void wait()
|
||||
{
|
||||
_sem_cnt++;
|
||||
while (_sem_cnt > 0)
|
||||
_env.ep().wait_and_dispatch_one_io_signal();
|
||||
_ep.wait_and_dispatch_one_io_signal();
|
||||
}
|
||||
|
||||
void ack() { _irq.ack_irq(); }
|
||||
void ack() { _irq.ack(); }
|
||||
};
|
||||
|
||||
#endif /* _IRQ_HANDLER_H_ */
|
||||
|
@ -23,42 +23,6 @@
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
namespace Platform {
|
||||
|
||||
using Device_capability = Capability<Device_interface>;
|
||||
|
||||
struct Device_client;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Transitionally wrapper for accessing platform devices used until
|
||||
* the migration to Platform::Device::Mmio API is completed.
|
||||
*/
|
||||
struct Platform::Device_client : Rpc_client<Device_interface>
|
||||
{
|
||||
Device_client(Capability<Device_interface> cap)
|
||||
: Rpc_client<Device_interface>(cap) { }
|
||||
|
||||
Irq_session_capability irq(unsigned id = 0)
|
||||
{
|
||||
return call<Rpc_irq>(id);
|
||||
}
|
||||
|
||||
Io_mem_session_capability io_mem(unsigned id, Range &range, Cache cache)
|
||||
{
|
||||
return call<Rpc_io_mem>(id, range, cache);
|
||||
}
|
||||
|
||||
Dataspace_capability io_mem_dataspace(unsigned id = 0)
|
||||
{
|
||||
Range range { };
|
||||
return Io_mem_session_client(io_mem(id, range, UNCACHED)).dataspace();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Finger_data
|
||||
{
|
||||
uint8_t status;
|
||||
@ -97,9 +61,7 @@ struct Synaptics
|
||||
enum Gpio_irq { IRQ = 135 };
|
||||
|
||||
Genode::Env &env;
|
||||
Irq_handler _i2c_irq_handler;
|
||||
Attached_dataspace _i2c_ds;
|
||||
I2c::I2c _i2c { (addr_t)_i2c_ds.local_addr<addr_t>(), _i2c_irq_handler };
|
||||
I2c::I2c _i2c;
|
||||
Gpio::Connection _gpio { env, IRQ };
|
||||
Irq_session_client _irq { _gpio.irq_session(Gpio::Session::LOW_LEVEL) };
|
||||
Io_signal_handler<Synaptics> _irq_dispatcher { env.ep(), *this, &Synaptics::_handle_irq };
|
||||
@ -153,11 +115,8 @@ struct Synaptics
|
||||
_irq.ack_irq();
|
||||
}
|
||||
|
||||
Synaptics(Env &env, Dataspace_capability io_mem,
|
||||
Irq_session_capability irq)
|
||||
: env(env),
|
||||
_i2c_irq_handler(env, irq),
|
||||
_i2c_ds(env.rm(), io_mem)
|
||||
Synaptics(Env &env, Platform::Device & i2c_dev)
|
||||
: env(env), _i2c(env, i2c_dev)
|
||||
{
|
||||
|
||||
/* set page 0 */
|
||||
@ -186,42 +145,12 @@ struct Synaptics
|
||||
|
||||
struct Main
|
||||
{
|
||||
Platform::Connection _platform_connection;
|
||||
Constructible<Synaptics> _synaptics { };
|
||||
Genode::Env & _env;
|
||||
Platform::Connection _platform { _env };
|
||||
Platform::Device _device { _platform };
|
||||
Synaptics _synaptics { _env, _device };
|
||||
|
||||
Main(Env &env)
|
||||
: _platform_connection(env)
|
||||
{
|
||||
using namespace Platform;
|
||||
|
||||
Device_capability cap;
|
||||
try {
|
||||
cap = _platform_connection.device_by_index(0);
|
||||
} catch (...) {
|
||||
error("Could not acquire device resources");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cap.valid() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
Device_client device { cap };
|
||||
|
||||
Dataspace_capability io_mem = device.io_mem_dataspace();
|
||||
if (io_mem.valid() == false) {
|
||||
Genode::warning("No 'io_mem' node present ... skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
Irq_session_capability irq = device.irq();
|
||||
if (irq.valid() == false) {
|
||||
Genode::warning("No 'irq' node present ... skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
_synaptics.construct(env, io_mem, irq);
|
||||
}
|
||||
Main(Env &env) : _env(env) { }
|
||||
};
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Main main(env); }
|
||||
|
@ -161,6 +161,7 @@ struct Virtdev_rom::Main
|
||||
static char name[DEVICE_NAME_LEN];
|
||||
snprintf(name, sizeof(name), "%s%u", _name_for_id(id), device_type_idx[id - 1]++);
|
||||
xml.attribute("name", name);
|
||||
xml.attribute("type", _name_for_id(id));
|
||||
xml.node("io_mem", [&] () {
|
||||
xml.attribute("address", addr);
|
||||
xml.attribute("size", DEVICE_SIZE);
|
||||
@ -168,10 +169,6 @@ struct Virtdev_rom::Main
|
||||
xml.node("irq", [&] () {
|
||||
xml.attribute("number", IRQ_BASE + idx);
|
||||
});
|
||||
xml.node("property", [&] () {
|
||||
xml.attribute("name", "type");
|
||||
xml.attribute("value", _name_for_id(id));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user