Unify ipc_msgbuf.h across base platforms

Besides unifying the Msgbuf_base classes across all platforms, this
patch merges the Ipc_marshaller functionality into Msgbuf_base, which
leads to several further simplifications. For example, this patch
eventually moves the Native_connection_state and removes all state
from the former Ipc_server to the actual server loop, which not only
makes the flow of control and information much more obvious, but is
also more flexible. I.e., on NOVA, we don't even have the notion of
reply-and-wait. Now, we are no longer forced to pretend otherwise.

Issue #1832
This commit is contained in:
Norman Feske
2016-03-18 22:53:25 +01:00
committed by Christian Helmuth
parent 0c299c5e08
commit f186587cab
74 changed files with 2058 additions and 2952 deletions

View File

@@ -1,140 +0,0 @@
/*
* \brief IPC message buffers
* \author Martin Stein
* \author Stefan Kalkowski
* \date 2012-01-03
*/
/*
* Copyright (C) 2012-2015 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__BASE__IPC_MSGBUF_H_
#define _INCLUDE__BASE__IPC_MSGBUF_H_
#include <base/native_capability.h>
#include <base/stdint.h>
#include <util/string.h>
namespace Genode {
class Native_utcb;
class Ipc_marshaller;
/**
* IPC message buffer layout
*/
class Msgbuf_base;
/**
* Instance of IPC message buffer with specified buffer size
*
* 'Msgbuf_base' must be the last class this class inherits from.
*/
template <unsigned BUF_SIZE> class Msgbuf;
}
class Genode::Msgbuf_base
{
public:
enum { MAX_CAP_ARGS = 4 };
private:
friend class Native_utcb;
friend class Ipc_marshaller;
size_t const _capacity; /* buffer size in bytes */
size_t _data_size = 0; /* marshalled data in bytes */
Native_capability _caps[MAX_CAP_ARGS]; /* capability buffer */
size_t _snd_cap_cnt = 0; /* capability counter */
size_t _rcv_cap_cnt = 0; /* capability counter */
public:
/*************************************************
** 'buf' must be the last member of this class **
*************************************************/
char buf[]; /* begin of actual message buffer */
Msgbuf_base(size_t capacity) : _capacity(capacity) { }
void const * base() const { return &buf; }
/**
* Return size of message buffer
*/
size_t capacity() const { return _capacity; }
/**
* Return pointer of message data payload
*/
void *data() { return &buf[0]; }
void const *data() const { return &buf[0]; }
size_t data_size() const { return _data_size; }
/**
* Reset capability buffer.
*/
void reset()
{
_snd_cap_cnt = 0;
_rcv_cap_cnt = 0;
}
/**
* Return how many capabilities are accepted by this message buffer
*/
size_t cap_rcv_window() { return _rcv_cap_cnt; }
/**
* Set how many capabilities are accepted by this message buffer
*/
void cap_rcv_window(size_t cnt) { _rcv_cap_cnt = cnt; }
/**
* Add capability to buffer
*/
void cap_add(Native_capability const &cap)
{
if (_snd_cap_cnt < MAX_CAP_ARGS)
_caps[_snd_cap_cnt++] = cap;
}
/**
* Return last capability from buffer.
*/
Native_capability cap_get()
{
return (_rcv_cap_cnt < _snd_cap_cnt)
? _caps[_rcv_cap_cnt++] : Native_capability();
}
};
template <unsigned BUF_SIZE>
class Genode::Msgbuf : public Genode::Msgbuf_base
{
public:
/**************************************************
** 'buf' must be the first member of this class **
**************************************************/
char buf[BUF_SIZE];
/**
* Constructor
*/
Msgbuf() : Msgbuf_base(BUF_SIZE) { }
};
#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */