mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
2b8c1af9e0
Conveying the ROM filename as the final label element simplifies routing policy and session construction. Annotations by nfeske: This commit also changes the ROM session to use base/log.h instead of base/printf.h, which produced build error of VirtualBox because the vbox headers have a '#define Log', which collides with the content of base/log.h. Hence, this commit has to take precautions to resolve this conflict. The commit alse refines the previous session-label change by adding a new 'Session_label::prefix' method and removing the use of 'char const *' from this part of the API. Fixes #1787
72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
/*
|
|
* \brief Connection to ROM file service
|
|
* \author Norman Feske
|
|
* \date 2008-08-22
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2008-2016 Genode Labs GmbH
|
|
*
|
|
* 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>
|
|
#include <base/log.h>
|
|
|
|
namespace Genode { class Rom_connection; }
|
|
|
|
|
|
class Genode::Rom_connection : public Connection<Rom_session>,
|
|
public Rom_session_client
|
|
{
|
|
public:
|
|
|
|
class Rom_connection_failed : public Parent::Exception { };
|
|
|
|
private:
|
|
|
|
Rom_session_capability _session(Parent &parent, char const *label)
|
|
{
|
|
try { return session("ram_quota=4K, label=\"%s\"", label); }
|
|
catch (...) {
|
|
error("Could not open ROM session for \"", label, "\"");
|
|
throw Rom_connection_failed();
|
|
}
|
|
}
|
|
|
|
public:
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* \param label request label and name of ROM module
|
|
*
|
|
* \throw Rom_connection_failed
|
|
*/
|
|
Rom_connection(Env &env, const char *label)
|
|
:
|
|
Connection<Rom_session>(env, _session(env.parent(), label)),
|
|
Rom_session_client(cap())
|
|
{ }
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* \noapi
|
|
* \deprecated Use the constructor with 'Env &' as first
|
|
* argument instead
|
|
*/
|
|
Rom_connection(const char *label)
|
|
:
|
|
Connection<Rom_session>(_session(*env()->parent(), label)),
|
|
Rom_session_client(cap())
|
|
{ }
|
|
};
|
|
|
|
#endif /* _INCLUDE__ROM_SESSION__CONNECTION_H_ */
|