2012-06-25 16:31:04 +02:00
|
|
|
/**
|
|
|
|
* \brief Platform specific definitions
|
|
|
|
* \author Sebastian Sumpf
|
|
|
|
* \date 2012-07-06
|
|
|
|
*
|
|
|
|
* These functions have to be implemented on all supported platforms.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2012-2013 Genode Labs GmbH
|
2012-06-25 16:31:04 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PLATFORM_H_
|
|
|
|
#define _PLATFORM_H_
|
|
|
|
|
2013-05-17 14:40:48 +02:00
|
|
|
#include <base/printf.h>
|
|
|
|
#include <os/config.h>
|
|
|
|
#include <util/xml_node.h>
|
2015-04-29 14:00:33 +02:00
|
|
|
#include <os/signal_rpc_dispatcher.h>
|
|
|
|
#include <irq_session/capability.h>
|
2013-05-17 14:40:48 +02:00
|
|
|
|
2012-06-25 16:31:04 +02:00
|
|
|
struct Services
|
|
|
|
{
|
2013-05-17 14:40:48 +02:00
|
|
|
/* USB profiles */
|
2014-11-13 15:44:15 +01:00
|
|
|
bool hid = false;
|
|
|
|
bool stor = false;
|
|
|
|
bool nic = false;
|
|
|
|
bool raw = false;
|
2012-06-25 16:31:04 +02:00
|
|
|
|
2013-05-17 14:40:48 +02:00
|
|
|
/* Controller types */
|
2014-11-13 15:44:15 +01:00
|
|
|
bool uhci = false; /* 1.0 */
|
|
|
|
bool ehci = false; /* 2.0 */
|
|
|
|
bool xhci = false; /* 3.0 */
|
2013-05-17 14:40:48 +02:00
|
|
|
|
2014-12-02 16:04:47 +01:00
|
|
|
/*
|
|
|
|
* Screen resolution used by touch devices to convert touchscreen
|
|
|
|
* absolute coordinates to screen absolute coordinates
|
|
|
|
*/
|
2015-02-25 17:46:26 +01:00
|
|
|
bool multitouch = false;
|
|
|
|
unsigned long screen_width = 0;
|
2015-02-26 13:18:08 +01:00
|
|
|
unsigned long screen_height = 0;
|
2014-12-02 16:04:47 +01:00
|
|
|
|
2013-05-17 14:40:48 +02:00
|
|
|
Services()
|
|
|
|
{
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
try {
|
2014-12-02 16:04:47 +01:00
|
|
|
Genode::Xml_node node_hid = config()->xml_node().sub_node("hid");
|
2013-05-17 14:40:48 +02:00
|
|
|
hid = true;
|
2014-12-02 16:04:47 +01:00
|
|
|
|
|
|
|
try {
|
2015-02-25 17:46:26 +01:00
|
|
|
Genode::Xml_node node_screen = node_hid.sub_node("touchscreen");
|
2015-02-26 13:18:08 +01:00
|
|
|
node_screen.attribute("width").value(&screen_width);
|
|
|
|
node_screen.attribute("height").value(&screen_height);
|
2015-02-25 17:46:26 +01:00
|
|
|
multitouch = node_screen.attribute("multitouch").has_value("yes");
|
2014-12-02 16:04:47 +01:00
|
|
|
} catch (...) {
|
2015-02-26 13:18:08 +01:00
|
|
|
screen_width = screen_height = 0;
|
2014-12-02 16:04:47 +01:00
|
|
|
PDBG("Could not read screen resolution in config node");
|
|
|
|
}
|
2013-05-17 14:40:48 +02:00
|
|
|
} catch (Xml_node::Nonexistent_sub_node) {
|
|
|
|
PDBG("No <hid> config node found - not starting the USB HID (Input) service");
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
config()->xml_node().sub_node("storage");
|
|
|
|
stor = true;
|
|
|
|
} catch (Xml_node::Nonexistent_sub_node) {
|
|
|
|
PDBG("No <storage> config node found - not starting the USB Storage (Block) service");
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
config()->xml_node().sub_node("nic");
|
|
|
|
nic = true;
|
|
|
|
} catch (Xml_node::Nonexistent_sub_node) {
|
|
|
|
PDBG("No <nic> config node found - not starting the USB Nic (Network) service");
|
|
|
|
}
|
|
|
|
|
2014-11-13 15:44:15 +01:00
|
|
|
try {
|
|
|
|
config()->xml_node().sub_node("raw");
|
|
|
|
raw = true;
|
|
|
|
} catch (Xml_node::Nonexistent_sub_node) {
|
|
|
|
PDBG("No <raw> config node found - not starting external USB service");
|
|
|
|
}
|
|
|
|
|
2013-05-17 14:40:48 +02:00
|
|
|
try {
|
2013-05-21 16:00:04 +02:00
|
|
|
if (!config()->xml_node().attribute("uhci").has_value("yes"))
|
|
|
|
throw -1;
|
2013-05-17 14:40:48 +02:00
|
|
|
uhci = true;
|
|
|
|
PINF("Enabled UHCI (USB 1.0/1.1) support");
|
|
|
|
} catch (...) { }
|
|
|
|
|
|
|
|
try {
|
2013-05-21 16:00:04 +02:00
|
|
|
if (!config()->xml_node().attribute("ehci").has_value("yes"))
|
|
|
|
throw -1;
|
2013-05-17 14:40:48 +02:00
|
|
|
ehci = true;
|
|
|
|
PINF("Enabled EHCI (USB 2.0) support");
|
|
|
|
} catch (...) { }
|
|
|
|
|
|
|
|
try {
|
2013-05-21 16:00:04 +02:00
|
|
|
if (!config()->xml_node().attribute("xhci").has_value("yes"))
|
|
|
|
throw -1;
|
2013-05-17 14:40:48 +02:00
|
|
|
xhci = true;
|
|
|
|
PINF("Enabled XHCI (USB 3.0) support");
|
|
|
|
} catch (...) { }
|
|
|
|
|
|
|
|
if (!(uhci | ehci | xhci))
|
|
|
|
PWRN("Warning: No USB controllers enabled.\n"
|
|
|
|
"Use <config (u/e/x)hci=\"yes\"> in your 'usb_drv' configuration");
|
|
|
|
}
|
2012-06-25 16:31:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
void platform_hcd_init(Services *services);
|
2015-04-29 14:00:33 +02:00
|
|
|
Genode::Irq_session_capability platform_irq_activate(int irq);
|
2012-06-25 16:31:04 +02:00
|
|
|
|
|
|
|
#endif /* _PLATFORM_H_ */
|