2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Block-driver interface
|
|
|
|
* \author Christian Helmuth
|
|
|
|
* \author Sebastian Sumpf
|
2013-12-03 14:41:14 +00:00
|
|
|
* \author Stefan kalkowski
|
2011-12-22 15:19:25 +00:00
|
|
|
* \date 2011-05-23
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-01-16 14:33:56 +00:00
|
|
|
* Copyright (C) 2011-2017 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2011-12-22 15:19:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__BLOCK__DRIVER_H_
|
|
|
|
#define _INCLUDE__BLOCK__DRIVER_H_
|
|
|
|
|
|
|
|
#include <base/exception.h>
|
|
|
|
#include <base/stdint.h>
|
2013-12-03 14:41:14 +00:00
|
|
|
#include <base/signal.h>
|
2019-01-21 09:48:39 +00:00
|
|
|
#include <base/ram_allocator.h>
|
2014-02-06 14:23:17 +00:00
|
|
|
#include <block_session/rpc_object.h>
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
namespace Block {
|
2016-12-23 13:53:30 +00:00
|
|
|
class Driver_session_base;
|
2014-02-06 14:23:17 +00:00
|
|
|
class Driver_session;
|
|
|
|
class Driver;
|
2013-12-03 14:41:14 +00:00
|
|
|
struct Driver_factory;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
struct Block::Driver_session_base : Genode::Interface
|
2016-12-23 13:53:30 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Acknowledges a packet processed by the driver to the client
|
|
|
|
*
|
|
|
|
* \param packet the packet to acknowledge
|
|
|
|
* \param success indicated whether the processing was successful
|
|
|
|
*
|
|
|
|
* \throw Ack_congestion
|
|
|
|
*/
|
|
|
|
virtual void ack_packet(Packet_descriptor &packet,
|
|
|
|
bool success) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Block::Driver_session : public Driver_session_base,
|
|
|
|
public Block::Session_rpc_object
|
2014-02-06 14:23:17 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2017-01-09 14:18:49 +00:00
|
|
|
* \param rm region map of local address space, used to attach
|
|
|
|
* the packet-stream buffer to the local address space
|
2014-02-06 14:23:17 +00:00
|
|
|
* \param tx_ds dataspace used as communication buffer
|
|
|
|
* for the tx packet stream
|
|
|
|
* \param ep entry point used for packet-stream channel
|
|
|
|
*/
|
2017-01-09 14:18:49 +00:00
|
|
|
Driver_session(Genode::Region_map &rm,
|
|
|
|
Genode::Dataspace_capability tx_ds,
|
|
|
|
Genode::Rpc_entrypoint &ep)
|
|
|
|
: Session_rpc_object(rm, tx_ds, ep) { }
|
2014-02-06 14:23:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-03 14:41:14 +00:00
|
|
|
/**
|
|
|
|
* Interface to be implemented by the device-specific driver code
|
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
class Block::Driver : Genode::Interface
|
2013-12-03 14:41:14 +00:00
|
|
|
{
|
2014-02-06 14:23:17 +00:00
|
|
|
private:
|
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
/*
|
|
|
|
* Noncopyable
|
|
|
|
*/
|
|
|
|
Driver(Driver const &);
|
|
|
|
Driver &operator = (Driver const &);
|
|
|
|
|
2019-01-21 09:48:39 +00:00
|
|
|
Genode::Ram_allocator &_ram;
|
2017-01-16 14:33:56 +00:00
|
|
|
|
2016-12-23 13:53:30 +00:00
|
|
|
Driver_session_base *_session = nullptr;
|
2014-02-06 14:23:17 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Exceptions
|
|
|
|
*/
|
|
|
|
class Io_error : public ::Genode::Exception { };
|
|
|
|
class Request_congestion : public ::Genode::Exception { };
|
|
|
|
|
2017-01-16 14:33:56 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2019-01-21 09:48:39 +00:00
|
|
|
Driver(Genode::Ram_allocator &ram) : _ram(ram) { }
|
2017-01-16 14:33:56 +00:00
|
|
|
|
2015-01-06 14:02:26 +00:00
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
virtual ~Driver() { }
|
|
|
|
|
2014-02-06 14:23:17 +00:00
|
|
|
/**
|
2019-04-03 14:05:10 +00:00
|
|
|
* Request block-device information
|
2014-02-06 14:23:17 +00:00
|
|
|
*/
|
2019-04-03 14:05:10 +00:00
|
|
|
virtual Session::Info info() const = 0;
|
2014-02-06 14:23:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read from medium
|
|
|
|
*
|
|
|
|
* \param block_number number of first block to read
|
|
|
|
* \param block_count number of blocks to read
|
|
|
|
* \param buffer output buffer for read request
|
|
|
|
* \param packet packet descriptor from the client
|
|
|
|
*
|
|
|
|
* \throw Request_congestion
|
|
|
|
*
|
|
|
|
* Note: should be overridden by DMA non-capable devices
|
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
virtual void read(sector_t /* block_number */,
|
|
|
|
Genode::size_t /* block_count */,
|
|
|
|
char * /* buffer */,
|
|
|
|
Packet_descriptor & /* packet */) {
|
2014-02-06 14:23:17 +00:00
|
|
|
throw Io_error(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write to medium
|
|
|
|
*
|
|
|
|
* \param block_number number of first block to write
|
|
|
|
* \param block_count number of blocks to write
|
|
|
|
* \param buffer buffer for write request
|
|
|
|
* \param packet packet descriptor from the client
|
|
|
|
*
|
|
|
|
* \throw Request_congestion
|
|
|
|
*
|
|
|
|
* Note: should be overridden by DMA non-capable, non-ROM devices
|
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
virtual void write(sector_t /* block_number */,
|
|
|
|
Genode::size_t /* block_count */,
|
|
|
|
const char * /* buffer */,
|
|
|
|
Packet_descriptor & /* packet */) {
|
2014-02-06 14:23:17 +00:00
|
|
|
throw Io_error(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read from medium using DMA
|
|
|
|
*
|
|
|
|
* \param block_number number of first block to read
|
|
|
|
* \param block_count number of blocks to read
|
|
|
|
* \param phys phyiscal address of read buffer
|
|
|
|
* \param packet packet descriptor from the client
|
|
|
|
*
|
|
|
|
* \throw Request_congestion
|
|
|
|
*
|
|
|
|
* Note: should be overridden by DMA capable devices
|
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
virtual void read_dma(sector_t /* block_number */,
|
|
|
|
Genode::size_t /* block_count */,
|
|
|
|
Genode::addr_t /* phys */,
|
|
|
|
Packet_descriptor & /* packet */) {
|
2014-02-06 14:23:17 +00:00
|
|
|
throw Io_error(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write to medium using DMA
|
|
|
|
*
|
|
|
|
* \param block_number number of first block to write
|
|
|
|
* \param block_count number of blocks to write
|
|
|
|
* \param phys physical address of write buffer
|
|
|
|
* \param packet packet descriptor from the client
|
|
|
|
*
|
|
|
|
* \throw Request_congestion
|
|
|
|
*
|
|
|
|
* Note: should be overridden by DMA capable, non-ROM devices
|
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
virtual void write_dma(sector_t /* block_number */,
|
|
|
|
Genode::size_t /* block_count */,
|
|
|
|
Genode::addr_t /* phys */,
|
|
|
|
Packet_descriptor & /* packet */) {
|
2014-02-06 14:23:17 +00:00
|
|
|
throw Io_error(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if DMA is enabled for driver
|
|
|
|
*
|
|
|
|
* \return true if DMA is enabled, false otherwise
|
|
|
|
*
|
|
|
|
* Note: has to be overriden by DMA-capable devices
|
|
|
|
*/
|
|
|
|
virtual bool dma_enabled() { return false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate buffer which is suitable for DMA.
|
|
|
|
*
|
|
|
|
* Note: has to be overriden by DMA-capable devices
|
|
|
|
*/
|
|
|
|
virtual Genode::Ram_dataspace_capability
|
2021-04-08 15:44:11 +00:00
|
|
|
alloc_dma_buffer(Genode::size_t size, Genode::Cache cache) {
|
|
|
|
return _ram.alloc(size, cache); }
|
2014-02-06 14:23:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free buffer which is suitable for DMA.
|
|
|
|
*
|
|
|
|
* Note: has to be overriden by DMA-capable devices
|
|
|
|
*/
|
|
|
|
virtual void free_dma_buffer(Genode::Ram_dataspace_capability c) {
|
2019-01-21 09:48:39 +00:00
|
|
|
return _ram.free(c); }
|
2014-02-06 14:23:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Synchronize with device.
|
|
|
|
*
|
|
|
|
* Note: should be overriden by (e.g. intermediate) components,
|
|
|
|
* which cache data
|
|
|
|
*/
|
|
|
|
virtual void sync() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Informs the driver that the client session was closed
|
|
|
|
*
|
|
|
|
* Note: drivers with state (e.g. asynchronously working)
|
2015-03-20 16:50:41 +00:00
|
|
|
* should override this method, and reset their internal state
|
2014-02-06 14:23:17 +00:00
|
|
|
*/
|
|
|
|
virtual void session_invalidated() { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set single session component of the driver
|
|
|
|
*
|
|
|
|
* Session might get used to acknowledge requests.
|
|
|
|
*/
|
2016-12-23 13:53:30 +00:00
|
|
|
void session(Driver_session_base *session) {
|
2014-02-06 14:23:17 +00:00
|
|
|
if (!(_session = session)) session_invalidated(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Acknowledge a packet after processing finished to the client
|
|
|
|
*
|
|
|
|
* \param p packet to acknowledge
|
|
|
|
*/
|
|
|
|
void ack_packet(Packet_descriptor &p, bool success = true) {
|
|
|
|
if (_session) _session->ack_packet(p, success); }
|
2013-12-03 14:41:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for constructing the driver object
|
|
|
|
*/
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 14:42:15 +00:00
|
|
|
struct Block::Driver_factory : Genode::Interface
|
2013-12-03 14:41:14 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Construct new driver
|
|
|
|
*/
|
|
|
|
virtual Driver *create() = 0;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
/**
|
2013-12-03 14:41:14 +00:00
|
|
|
* Destroy driver
|
2011-12-22 15:19:25 +00:00
|
|
|
*/
|
2013-12-03 14:41:14 +00:00
|
|
|
virtual void destroy(Driver *driver) = 0;
|
|
|
|
};
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#endif /* _BLOCK__DRIVER_H_ */
|