remote_rom: improvements and refactoring

Avoid a runtime warning message since our backend does not provide
such constructor functions yet. If a backend requires them, it should
initiate their execution by itself within the backend init functions.

In coherence with the size_guard idea, the remote_rom packets are are
separated into a simple layer packet and a data packet. While basically
only managing common control informations, the layer packet may carry
any payload. The data packet, instead, manages the transmission of the
actual ROM payload and can be attached to the layer packet. This
simplifies the management of the notification packets UPDATE and SIGNAL
since they do not contain fields like 'offset' or 'payload_size'
anymore.

Now, a single thread manages all incoming RPC calls, signals and (thus)
network packets. This will hopefully make further synchronization
enhancements a lot easier.

Further changes:
* Following data packets are identified as such by their offset instead
  of their packet type field. This simplifies the protocol.
* reduced redundancy in the packet building code
* rewrap lines with >79 columns
* fix compiler warnings
* split backend code
* Remove a few unnecessary include and using directives.
* In order to avoid global variables across modules, 'verbose' is a
  member variable now. Later, its value may be set via constructor.
* The nested Rx class is merged with Backend_base. This way, we avoid
  unnecessary maintenance as long as we don't have a clear design for
  ROM multiplexing which may require the management of multiple IP
  addresses etc.
* The HANDLER template argument is removed since client and server
  inherit from Backend_base anyway. The receive method is virtual now.
* The signals packet_avail and ready_to_ack are directly passed to the
  same signal handler now.
* Remove unnecessarily public/protected visibility from some members.
* Remove and add unnecessary and, due to inclusion order, secretly
  missing include directives, respectively.
This commit is contained in:
Edgard Schmidt
2018-10-11 15:53:20 +02:00
committed by Norman Feske
parent 5627797e77
commit c137c595c8
17 changed files with 709 additions and 631 deletions

View File

@@ -14,6 +14,8 @@
#ifndef __INCLUDE__REMOTE_ROM__BACKEND_BASE_H_
#define __INCLUDE__REMOTE_ROM__BACKEND_BASE_H_
#include <base/env.h>
#include <rom_forwarder.h>
#include <rom_receiver.h>
@@ -22,17 +24,19 @@ namespace Remote_rom {
struct Backend_client_base;
class Exception : public ::Genode::Exception { };
Backend_server_base &backend_init_server(Genode::Env &env, Genode::Allocator &alloc);
Backend_client_base &backend_init_client(Genode::Env &env, Genode::Allocator &alloc);
Backend_server_base &backend_init_server(Genode::Env &env,
Genode::Allocator &alloc);
Backend_client_base &backend_init_client(Genode::Env &env,
Genode::Allocator &alloc);
};
struct Remote_rom::Backend_server_base
struct Remote_rom::Backend_server_base : Genode::Interface
{
virtual void send_update() = 0;
virtual void register_forwarder(Rom_forwarder_base *forwarder) = 0;
};
struct Remote_rom::Backend_client_base
struct Remote_rom::Backend_client_base : Genode::Interface
{
virtual void register_receiver(Rom_receiver_base *receiver) = 0;
};

View File

@@ -15,17 +15,19 @@
#define __INCLUDE__REMOTE_ROM__ROM_FORWARDER_H_
#include <base/stdint.h>
#include <util/interface.h>
namespace Remote_rom {
using Genode::size_t;
struct Rom_forwarder_base;
}
struct Remote_rom::Rom_forwarder_base
struct Remote_rom::Rom_forwarder_base : Genode::Interface
{
virtual const char *module_name() const = 0;
virtual size_t content_size() const = 0;
virtual size_t transfer_content(char *dst, size_t dst_len, size_t offset=0) const = 0;
virtual size_t transfer_content(char *dst, size_t dst_len,
size_t offset=0) const = 0;
};
#endif

View File

@@ -15,13 +15,14 @@
#define __INCLUDE__REMOTE_ROM__ROM_RECEIVER_H_
#include <base/stdint.h>
#include <util/interface.h>
namespace Remote_rom {
using Genode::size_t;
struct Rom_receiver_base;
}
struct Remote_rom::Rom_receiver_base
struct Remote_rom::Rom_receiver_base : Genode::Interface
{
virtual const char *module_name() const = 0;
virtual char* start_new_content(size_t len) = 0;