diff --git a/base-hw/include/base/native_types.h b/base-hw/include/base/native_types.h index 7c7837eef4..4e0f1925d5 100644 --- a/base-hw/include/base/native_types.h +++ b/base-hw/include/base/native_types.h @@ -57,17 +57,17 @@ namespace Genode * \param MAX_SIZE maximum size the object is allowed to take */ template - struct Message; + struct Message_tpl; /** - * Message that is communicated from a thread creator to the new thread + * Information that a thread creator hands out to a new thread */ class Start_info; /** * Memory region that is exclusive to every thread and known by the kernel */ - struct Native_utcb; + class Native_utcb; struct Cap_dst_policy { @@ -119,7 +119,7 @@ namespace Genode } template -class Genode::Message +class Genode::Message_tpl { private: @@ -150,8 +150,9 @@ class Genode::Message * \return buf_size size of receive buffer */ void info_about_await_request(void * & buf_base, size_t & buf_size) + const { - buf_base = this; + buf_base = (void *)this; buf_size = MAX_SIZE; } @@ -165,10 +166,11 @@ class Genode::Message */ void info_about_send_request(void * & msg_base, size_t & msg_size, void * & buf_base, size_t & buf_size) + const { - msg_base = this; + msg_base = (void *)this; msg_size = _size(); - buf_base = this; + buf_base = (void *)this; buf_size = MAX_SIZE; } @@ -179,8 +181,9 @@ class Genode::Message * \return msg_size size of complete send-message data */ void info_about_send_reply(void * & msg_base, size_t & msg_size) + const { - msg_base = this; + msg_base = (void *)this; msg_size = _size(); } @@ -250,19 +253,28 @@ class Genode::Start_info Native_thread_id thread_id() const { return _thread_id; } }; -struct Genode::Native_utcb +class Genode::Native_utcb { - enum { SIZE = 1 << MIN_MAPPING_SIZE_LOG2 }; + private: - union { - uint8_t data[SIZE]; - Message message; - Start_info start_info; - }; + uint8_t _data[1 << MIN_MAPPING_SIZE_LOG2]; - size_t size() const { return SIZE; } + public: - void * base() const { return (void *)data; } + typedef Message_tpl Message; + + + /*************** + ** Accessors ** + ***************/ + + Message * message() const { return (Message *)_data; } + + Start_info * start_info() const { return (Start_info *)_data; } + + size_t size() const { return sizeof(_data)/sizeof(_data[0]); } + + void * base() const { return (void *)_data; } }; #endif /* _BASE__NATIVE_TYPES_H_ */ diff --git a/base-hw/src/base/ipc.cc b/base-hw/src/base/ipc.cc index a56b6dbb7a..c7801895b2 100644 --- a/base-hw/src/base/ipc.cc +++ b/base-hw/src/base/ipc.cc @@ -79,12 +79,12 @@ void Ipc_client::_call() /* send request and receive corresponding reply */ unsigned const local_name = Ipc_ostream::_dst.local_name(); Native_utcb * const utcb = Thread_base::myself()->utcb(); - utcb->message.prepare_send(_snd_msg->buf, _write_offset, local_name); + utcb->message()->prepare_send(_snd_msg->buf, _write_offset, local_name); if (Kernel::send_request_msg(Ipc_ostream::_dst.dst())) { PERR("failed to receive reply"); throw Blocking_canceled(); } - utcb->message.finish_receive(_rcv_msg->buf, _rcv_msg->size()); + utcb->message()->finish_receive(_rcv_msg->buf, _rcv_msg->size()); /* reset unmarshaller */ _write_offset = _read_offset = RPC_OBJECT_ID_SIZE; @@ -129,7 +129,7 @@ void Ipc_server::_wait() throw Blocking_canceled(); } Native_utcb * const utcb = Thread_base::myself()->utcb(); - utcb->message.finish_receive(_rcv_msg->buf, _rcv_msg->size()); + utcb->message()->finish_receive(_rcv_msg->buf, _rcv_msg->size()); /* update server state */ _prepare_next_reply_wait(); @@ -140,7 +140,7 @@ void Ipc_server::_reply() { unsigned const local_name = Ipc_ostream::_dst.local_name(); Native_utcb * const utcb = Thread_base::myself()->utcb(); - utcb->message.prepare_send(_snd_msg->buf, _write_offset, local_name); + utcb->message()->prepare_send(_snd_msg->buf, _write_offset, local_name); Kernel::send_reply_msg(0); } @@ -155,12 +155,12 @@ void Ipc_server::_reply_wait() /* send reply and receive next request */ unsigned const local_name = Ipc_ostream::_dst.local_name(); Native_utcb * const utcb = Thread_base::myself()->utcb(); - utcb->message.prepare_send(_snd_msg->buf, _write_offset, local_name); + utcb->message()->prepare_send(_snd_msg->buf, _write_offset, local_name); if (Kernel::send_reply_msg(1)) { PERR("failed to receive request"); throw Blocking_canceled(); } - utcb->message.finish_receive(_rcv_msg->buf, _rcv_msg->size()); + utcb->message()->finish_receive(_rcv_msg->buf, _rcv_msg->size()); /* update server state */ _prepare_next_reply_wait(); diff --git a/base-hw/src/base/thread/thread_bootstrap.cc b/base-hw/src/base/thread/thread_bootstrap.cc index 524660d7f3..bdae1927f3 100644 --- a/base-hw/src/base/thread/thread_bootstrap.cc +++ b/base-hw/src/base/thread/thread_bootstrap.cc @@ -21,5 +21,5 @@ void Genode::Thread_base::_thread_bootstrap() { Native_utcb * const utcb = Thread_base::myself()->utcb(); - _tid.thread_id = utcb->start_info.thread_id(); + _tid.thread_id = utcb->start_info()->thread_id(); } diff --git a/base-hw/src/core/kernel/kernel.cc b/base-hw/src/core/kernel/kernel.cc index 611e2e2880..5b5b8e2fb1 100644 --- a/base-hw/src/core/kernel/kernel.cc +++ b/base-hw/src/core/kernel/kernel.cc @@ -234,7 +234,7 @@ extern "C" void kernel() static Native_utcb utcb; static Thread t(Priority::MAX, "core"); _main_thread_utcb = &utcb; - _main_thread_utcb->start_info.init(t.id()); + _main_thread_utcb->start_info()->init(t.id()); t.ip = (addr_t)CORE_MAIN;; t.sp = (addr_t)s + STACK_SIZE; t.init(0, core_id(), &utcb, 1); diff --git a/base-hw/src/core/kernel/thread.cc b/base-hw/src/core/kernel/thread.cc index 6e2533be8e..a2bc5ab7db 100644 --- a/base-hw/src/core/kernel/thread.cc +++ b/base-hw/src/core/kernel/thread.cc @@ -452,7 +452,7 @@ void Thread::_call_await_request_msg() { void * buf_base; size_t buf_size; - _utcb_phys->message.info_about_await_request(buf_base, buf_size); + _utcb_phys->message()->info_about_await_request(buf_base, buf_size); Ipc_node::await_request(buf_base, buf_size); } @@ -469,8 +469,8 @@ void Thread::_call_send_request_msg() size_t msg_size; void * buf_base; size_t buf_size; - _utcb_phys->message.info_about_send_request(msg_base, msg_size, - buf_base, buf_size); + _utcb_phys->message()->info_about_send_request(msg_base, msg_size, + buf_base, buf_size); Ipc_node::send_request_await_reply(dst, msg_base, msg_size, buf_base, buf_size); } @@ -480,7 +480,7 @@ void Thread::_call_send_reply_msg() { void * msg_base; size_t msg_size; - _utcb_phys->message.info_about_send_reply(msg_base, msg_size); + _utcb_phys->message()->info_about_send_reply(msg_base, msg_size); Ipc_node::send_reply(msg_base, msg_size); bool const await_request_msg = user_arg_1(); if (await_request_msg) { _call_await_request_msg(); } diff --git a/base-hw/src/core/platform_thread.cc b/base-hw/src/core/platform_thread.cc index 321fd816cf..0f48717e00 100644 --- a/base-hw/src/core/platform_thread.cc +++ b/base-hw/src/core/platform_thread.cc @@ -201,7 +201,7 @@ int Platform_thread::start(void * const ip, void * const sp, return -1; } /* start executing new thread */ - _utcb_phys->start_info.init(_id); + _utcb_phys->start_info()->init(_id); _tlb = Kernel::start_thread(_id, cpu_id, _pd_id, _utcb_phys); if (!_tlb) { PERR("failed to start thread"); diff --git a/base-hw/src/platform/main_bootstrap.cc b/base-hw/src/platform/main_bootstrap.cc index 9968452e75..1ba940bf3b 100644 --- a/base-hw/src/platform/main_bootstrap.cc +++ b/base-hw/src/platform/main_bootstrap.cc @@ -36,7 +36,7 @@ void Genode::platform_main_bootstrap() static bool main_thread_id_valid = 0; if (!main_thread_id_valid) { Native_utcb * const utcb = Thread_base::myself()->utcb(); - _main_thread_id = utcb->startup_info.thread_id(); + _main_thread_id = utcb->start_info()->thread_id(); main_thread_id_valid = 1; } }