mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 14:13:09 +00:00
hw: get rid of struct Msg and Msg::Type
Struct Msg was introduced due to the handling of pagefaults and interrupts via synchronous IPC. Its only purpose was to provide the message type in front of the typed message. Now pagefaults and interrupts are handled via signals and struct Msg is not necessary anymore. ref #958
This commit is contained in:
parent
d46b30a711
commit
f128a52e8b
@ -47,31 +47,10 @@ namespace Genode
|
||||
*/
|
||||
inline Native_thread_id thread_invalid_id() { return 0; }
|
||||
|
||||
/**
|
||||
* Message that is communicated synchronously
|
||||
*/
|
||||
struct Msg
|
||||
{
|
||||
/**
|
||||
* Types of synchronously communicated messages
|
||||
*/
|
||||
struct Type
|
||||
{
|
||||
enum Id {
|
||||
INVALID = 0,
|
||||
STARTUP = 1,
|
||||
IPC = 2,
|
||||
};
|
||||
};
|
||||
|
||||
Type::Id type;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Message that is communicated between user threads
|
||||
*/
|
||||
struct Ipc_msg : Msg
|
||||
struct Ipc_msg
|
||||
{
|
||||
size_t size;
|
||||
uint8_t data[];
|
||||
@ -136,7 +115,7 @@ namespace Genode
|
||||
struct Native_pd_args { };
|
||||
}
|
||||
|
||||
class Genode::Startup_msg : public Msg
|
||||
class Genode::Startup_msg
|
||||
{
|
||||
private:
|
||||
|
||||
@ -149,34 +128,26 @@ class Genode::Startup_msg : public Msg
|
||||
*
|
||||
* \param thread_id kernel name of the thread that is started
|
||||
*/
|
||||
void init(Native_thread_id const thread_id)
|
||||
{
|
||||
_thread_id = thread_id;
|
||||
type = Msg::Type::STARTUP;
|
||||
}
|
||||
void init(Native_thread_id const thread_id) { _thread_id = thread_id; }
|
||||
|
||||
/**
|
||||
* Return kernel name of started thread message-type-save
|
||||
*/
|
||||
Native_thread_id thread_id() const
|
||||
{
|
||||
if (type == Msg::Type::STARTUP) { return _thread_id; }
|
||||
return thread_invalid_id();
|
||||
}
|
||||
|
||||
/***************
|
||||
** Accessors **
|
||||
***************/
|
||||
|
||||
Native_thread_id thread_id() const { return _thread_id; }
|
||||
};
|
||||
|
||||
struct Genode::Native_utcb
|
||||
{
|
||||
union {
|
||||
uint8_t data[1 << MIN_MAPPING_SIZE_LOG2];
|
||||
Msg msg;
|
||||
Ipc_msg ipc_msg;
|
||||
Startup_msg startup_msg;
|
||||
};
|
||||
|
||||
void call_await_request_msg(void * & buf_base, size_t & buf_size)
|
||||
{
|
||||
msg.type = Msg::Type::INVALID;
|
||||
buf_base = base();
|
||||
buf_size = size();
|
||||
}
|
||||
@ -184,7 +155,6 @@ struct Genode::Native_utcb
|
||||
void call_send_request_msg(void * & msg_base, size_t & msg_size,
|
||||
void * & buf_base, size_t & buf_size)
|
||||
{
|
||||
msg.type = Msg::Type::IPC;
|
||||
msg_base = ipc_msg_base();
|
||||
msg_size = ipc_msg_size();
|
||||
buf_base = base();
|
||||
@ -193,7 +163,6 @@ struct Genode::Native_utcb
|
||||
|
||||
void call_send_reply_msg(void * & msg_base, size_t & msg_size)
|
||||
{
|
||||
msg.type = Msg::Type::IPC;
|
||||
msg_base = ipc_msg_base();
|
||||
msg_size = ipc_msg_size();
|
||||
}
|
||||
|
@ -315,42 +315,51 @@ namespace Kernel
|
||||
|
||||
|
||||
/**
|
||||
* Send IPC request and await corresponding IPC reply
|
||||
* Send request message and await receipt of corresponding reply message
|
||||
*
|
||||
* \param thread_id kernel name of targeted thread
|
||||
*
|
||||
* As soon as call returns, callers UTCB provides received message.
|
||||
* \retval 0 succeeded
|
||||
* \retval -1 failed
|
||||
*
|
||||
* If the call returns successful, the received message is located at the
|
||||
* base of the callers userland thread-context.
|
||||
*/
|
||||
inline void send_request_msg(unsigned const thread_id)
|
||||
inline int send_request_msg(unsigned const thread_id)
|
||||
{
|
||||
call(Call_id::SEND_REQUEST_MSG, thread_id);
|
||||
return call(Call_id::SEND_REQUEST_MSG, thread_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Await the receipt of a message
|
||||
* Await receipt of request message
|
||||
*
|
||||
* \return type of received message
|
||||
* \retval 0 succeeded
|
||||
* \retval -1 failed
|
||||
*
|
||||
* As soon as call returns, callers UTCB provides received message.
|
||||
* If the call returns successful, the received message is located at the
|
||||
* base of the callers userland thread-context.
|
||||
*/
|
||||
inline void await_request_msg()
|
||||
inline int await_request_msg()
|
||||
{
|
||||
call(Call_id::AWAIT_REQUEST_MSG);
|
||||
return call(Call_id::AWAIT_REQUEST_MSG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reply to lastly received message
|
||||
* Reply to lastly received request message
|
||||
*
|
||||
* \param await_request_msg wether the call shall await a request message
|
||||
*
|
||||
* As soon as call returns, callers UTCB provides received message if
|
||||
* await_request_msg is set.
|
||||
* \retval 0 await_request_msg == 0 or request-message receipt succeeded
|
||||
* \retval -1 await_request_msg == 1 and request-message receipt failed
|
||||
*
|
||||
* If the call returns successful and await_request_msg == 1, the received
|
||||
* message is located at the base of the callers userland thread-context.
|
||||
*/
|
||||
inline void send_reply_msg(bool const await_request_msg)
|
||||
inline int send_reply_msg(bool const await_request_msg)
|
||||
{
|
||||
call(Call_id::SEND_REPLY_MSG, await_request_msg);
|
||||
return call(Call_id::SEND_REPLY_MSG, await_request_msg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,14 +116,10 @@ Ipc_istream::~Ipc_istream() { }
|
||||
|
||||
void Ipc_client::_call()
|
||||
{
|
||||
/* send request */
|
||||
/* send request and receive corresponding reply */
|
||||
unsigned const local_name = Ipc_ostream::_dst.local_name();
|
||||
msgbuf_to_utcb(_snd_msg, _write_offset, local_name);
|
||||
Kernel::send_request_msg(Ipc_ostream::_dst.dst());
|
||||
|
||||
/* receive reply */
|
||||
Native_utcb * const utcb = Thread_base::myself()->utcb();
|
||||
if (utcb->msg.type != Msg::Type::IPC) {
|
||||
if (Kernel::send_request_msg(Ipc_ostream::_dst.dst())) {
|
||||
PERR("failed to receive reply");
|
||||
throw Blocking_canceled();
|
||||
}
|
||||
@ -166,10 +162,8 @@ void Ipc_server::_prepare_next_reply_wait()
|
||||
|
||||
void Ipc_server::_wait()
|
||||
{
|
||||
/* receive next request */
|
||||
Kernel::await_request_msg();
|
||||
Native_utcb * const utcb = Thread_base::myself()->utcb();
|
||||
if (utcb->msg.type != Msg::Type::IPC) {
|
||||
/* receive request */
|
||||
if (Kernel::await_request_msg()) {
|
||||
PERR("failed to receive request");
|
||||
throw Blocking_canceled();
|
||||
}
|
||||
@ -195,14 +189,10 @@ void Ipc_server::_reply_wait()
|
||||
_wait();
|
||||
return;
|
||||
}
|
||||
/* send reply an await request */
|
||||
/* send reply and receive next request */
|
||||
unsigned const local_name = Ipc_ostream::_dst.local_name();
|
||||
msgbuf_to_utcb(_snd_msg, _write_offset, local_name);
|
||||
Kernel::send_reply_msg(1);
|
||||
|
||||
/* fetch request */
|
||||
Native_utcb * const utcb = Thread_base::myself()->utcb();
|
||||
if (utcb->msg.type != Msg::Type::IPC) {
|
||||
if (Kernel::send_reply_msg(1)) {
|
||||
PERR("failed to receive request");
|
||||
throw Blocking_canceled();
|
||||
}
|
||||
@ -211,4 +201,3 @@ void Ipc_server::_reply_wait()
|
||||
/* update server state */
|
||||
_prepare_next_reply_wait();
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,7 @@ void Thread::_received_ipc_request(size_t const s)
|
||||
{
|
||||
switch (_state) {
|
||||
case SCHEDULED:
|
||||
user_arg_0(0);
|
||||
return;
|
||||
default:
|
||||
PERR("wrong thread state to receive IPC");
|
||||
@ -112,6 +113,7 @@ void Thread::_await_ipc_succeeded(size_t const s)
|
||||
{
|
||||
switch (_state) {
|
||||
case AWAITS_IPC:
|
||||
user_arg_0(0);
|
||||
_schedule();
|
||||
return;
|
||||
default:
|
||||
@ -126,6 +128,7 @@ void Thread::_await_ipc_failed()
|
||||
{
|
||||
switch (_state) {
|
||||
case AWAITS_IPC:
|
||||
user_arg_0(-1);
|
||||
_schedule();
|
||||
return;
|
||||
case SCHEDULED:
|
||||
@ -485,6 +488,7 @@ void Thread::_call_send_reply_msg()
|
||||
Ipc_node::send_reply(msg_base, msg_size);
|
||||
bool const await_request_msg = user_arg_1();
|
||||
if (await_request_msg) { _call_await_request_msg(); }
|
||||
else { user_arg_0(0); }
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user