2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Connection to ROM file service
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2008-08-22
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2016-05-12 12:58:51 +00:00
|
|
|
* Copyright (C) 2008-2016 Genode Labs GmbH
|
2011-12-22 15:19:25 +00: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 _INCLUDE__ROM_SESSION__CONNECTION_H_
|
|
|
|
#define _INCLUDE__ROM_SESSION__CONNECTION_H_
|
|
|
|
|
|
|
|
#include <rom_session/client.h>
|
|
|
|
#include <base/connection.h>
|
2016-05-12 12:58:51 +00:00
|
|
|
#include <base/log.h>
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Genode { class Rom_connection; }
|
|
|
|
|
|
|
|
|
|
|
|
class Genode::Rom_connection : public Connection<Rom_session>,
|
|
|
|
public Rom_session_client
|
|
|
|
{
|
|
|
|
public:
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
class Rom_connection_failed : public Parent::Exception { };
|
|
|
|
|
2016-11-06 13:26:34 +00:00
|
|
|
enum { RAM_QUOTA = 4096UL };
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
private:
|
|
|
|
|
2016-05-12 12:58:51 +00:00
|
|
|
Rom_session_capability _session(Parent &parent, char const *label)
|
2015-03-04 20:12:14 +00:00
|
|
|
{
|
2016-11-06 13:26:34 +00:00
|
|
|
return session("ram_quota=%ld, label=\"%s\"", RAM_QUOTA, label);
|
2015-03-04 20:12:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2016-05-12 12:58:51 +00:00
|
|
|
* \param label request label and name of ROM module
|
2015-03-04 20:12:14 +00:00
|
|
|
*
|
|
|
|
* \throw Rom_connection_failed
|
|
|
|
*/
|
2016-05-12 12:58:51 +00:00
|
|
|
Rom_connection(Env &env, const char *label)
|
2016-11-08 15:37:27 +00:00
|
|
|
try :
|
2016-05-12 12:58:51 +00:00
|
|
|
Connection<Rom_session>(env, _session(env.parent(), label)),
|
2016-05-09 13:55:12 +00:00
|
|
|
Rom_session_client(cap())
|
|
|
|
{ }
|
2016-11-08 15:37:27 +00:00
|
|
|
catch (...) {
|
|
|
|
error("Could not open ROM session for \"", label, "\"");
|
|
|
|
throw Rom_connection_failed();
|
|
|
|
}
|
2016-05-09 13:55:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* \noapi
|
|
|
|
* \deprecated Use the constructor with 'Env &' as first
|
|
|
|
* argument instead
|
|
|
|
*/
|
2017-01-09 14:18:49 +00:00
|
|
|
Rom_connection(const char *label) __attribute__((deprecated))
|
2016-11-08 15:37:27 +00:00
|
|
|
try :
|
2017-01-09 14:18:49 +00:00
|
|
|
Connection<Rom_session>(_session(*env_deprecated()->parent(), label)),
|
|
|
|
Rom_session_client(cap())
|
|
|
|
{ }
|
|
|
|
catch (...) {
|
|
|
|
error("Could not open ROM session for \"", label, "\"");
|
|
|
|
throw Rom_connection_failed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* \noapi
|
|
|
|
* \deprecated Use the constructor with 'Env &' as first
|
|
|
|
* argument instead
|
|
|
|
*
|
|
|
|
* This version is deliberately used by functions that are marked as
|
|
|
|
* deprecated. If such a function called directly the
|
|
|
|
* __attribute__((deprecate)) version, we would always get a warning,
|
|
|
|
* even if the outer deprecated function is not called.
|
|
|
|
*
|
|
|
|
* It will be removed as soon as they are gone.
|
|
|
|
*/
|
|
|
|
Rom_connection(bool, const char *label)
|
|
|
|
try :
|
|
|
|
Connection<Rom_session>(_session(*env_deprecated()->parent(), label)),
|
2015-03-04 20:12:14 +00:00
|
|
|
Rom_session_client(cap())
|
|
|
|
{ }
|
2016-11-08 15:37:27 +00:00
|
|
|
catch (...) {
|
|
|
|
error("Could not open ROM session for \"", label, "\"");
|
|
|
|
throw Rom_connection_failed();
|
|
|
|
}
|
2015-03-04 20:12:14 +00:00
|
|
|
};
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__ROM_SESSION__CONNECTION_H_ */
|