mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-11 20:01:48 +00:00
parent
d6a312f438
commit
8c7d34ff21
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/misc_math.h>
|
#include <util/misc_math.h>
|
||||||
|
#include <util/construct_at.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
|
|
||||||
/* board-specific includes */
|
/* board-specific includes */
|
||||||
@ -111,29 +112,16 @@ struct Platform::Property_message
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct Placeable : T
|
|
||||||
{
|
|
||||||
template <typename... ARGS>
|
|
||||||
Placeable(ARGS... args) : T(args...) { }
|
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
void construct_request(typename T::Request *, ARGS... args)
|
void construct_request(typename T::Request *, ARGS... args)
|
||||||
{
|
{
|
||||||
new ((typename T::Request *)payload)
|
construct_at<typename T::Request>(payload, args...);
|
||||||
Placeable<typename T::Request>(args...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename>
|
|
||||||
void construct_request(...) { }
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void construct_response(typename T::Response *)
|
void construct_response(typename T::Response *)
|
||||||
{
|
{
|
||||||
new (payload) Placeable<typename T::Response>;
|
construct_at<typename T::Response>(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename>
|
template <typename>
|
||||||
@ -159,8 +147,6 @@ struct Platform::Property_message
|
|||||||
construct_response<TAG>(0);
|
construct_response<TAG>(0);
|
||||||
construct_request<TAG>(0, request_args...);
|
construct_request<TAG>(0, request_args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
@ -175,7 +161,7 @@ struct Platform::Property_message
|
|||||||
template <typename POLICY, typename... REQUEST_ARGS>
|
template <typename POLICY, typename... REQUEST_ARGS>
|
||||||
typename POLICY::Response const &append(REQUEST_ARGS... request_args)
|
typename POLICY::Response const &append(REQUEST_ARGS... request_args)
|
||||||
{
|
{
|
||||||
auto *tag = new (buffer + buf_size) Tag<POLICY>(request_args...);
|
auto *tag = construct_at<Tag<POLICY> >(buffer + buf_size, request_args...);
|
||||||
|
|
||||||
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
||||||
|
|
||||||
@ -185,7 +171,7 @@ struct Platform::Property_message
|
|||||||
template <typename POLICY, typename... REQUEST_ARGS>
|
template <typename POLICY, typename... REQUEST_ARGS>
|
||||||
void append_no_response(REQUEST_ARGS... request_args)
|
void append_no_response(REQUEST_ARGS... request_args)
|
||||||
{
|
{
|
||||||
new (buffer + buf_size) Tag<POLICY>(request_args...);
|
construct_at<Tag<POLICY> >(buffer + buf_size, request_args...);
|
||||||
|
|
||||||
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
||||||
}
|
}
|
||||||
@ -218,8 +204,6 @@ struct Platform::Property_message
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _PLATFORM__PROPERTY_MESSAGE_H_ */
|
#endif /* _PLATFORM__PROPERTY_MESSAGE_H_ */
|
||||||
|
@ -56,8 +56,6 @@ struct Platform::Framebuffer_message : Framebuffer_info
|
|||||||
log(" addr: ", Genode::Hex(addr));
|
log(" addr: ", Genode::Hex(addr));
|
||||||
log(" size: ", Genode::Hex(size));
|
log(" size: ", Genode::Hex(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _FRAMEBUFFER_MESSAGE_H_ */
|
#endif /* _FRAMEBUFFER_MESSAGE_H_ */
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/mmio.h>
|
#include <util/mmio.h>
|
||||||
|
#include <util/construct_at.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <os/attached_mmio.h>
|
#include <os/attached_mmio.h>
|
||||||
#include <base/attached_ram_dataspace.h>
|
#include <base/attached_ram_dataspace.h>
|
||||||
@ -84,7 +85,7 @@ class Mbox : Genode::Attached_mmio
|
|||||||
template <typename MESSAGE, typename... ARGS>
|
template <typename MESSAGE, typename... ARGS>
|
||||||
MESSAGE &message(ARGS... args)
|
MESSAGE &message(ARGS... args)
|
||||||
{
|
{
|
||||||
return *(new (_msg_buffer.local_addr<void>()) MESSAGE(args...));
|
return *Genode::construct_at<MESSAGE>(_msg_buffer.local_addr<void>(), args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MESSAGE>
|
template <typename MESSAGE>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/misc_math.h>
|
#include <util/misc_math.h>
|
||||||
|
#include <util/construct_at.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
|
|
||||||
/* board-specific includes */
|
/* board-specific includes */
|
||||||
@ -111,29 +112,16 @@ struct Driver::Property_message
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct Placeable : T
|
|
||||||
{
|
|
||||||
template <typename... ARGS>
|
|
||||||
Placeable(ARGS... args) : T(args...) { }
|
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
void construct_request(typename T::Request *, ARGS... args)
|
void construct_request(typename T::Request *, ARGS... args)
|
||||||
{
|
{
|
||||||
new ((typename T::Request *)payload)
|
construct_at<typename T::Request>(payload, args...);
|
||||||
Placeable<typename T::Request>(args...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename>
|
|
||||||
void construct_request(...) { }
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void construct_response(typename T::Response *)
|
void construct_response(typename T::Response *)
|
||||||
{
|
{
|
||||||
new (payload) Placeable<typename T::Response>;
|
construct_at<typename T::Response>(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename>
|
template <typename>
|
||||||
@ -159,8 +147,6 @@ struct Driver::Property_message
|
|||||||
construct_response<TAG>(0);
|
construct_response<TAG>(0);
|
||||||
construct_request<TAG>(0, request_args...);
|
construct_request<TAG>(0, request_args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
@ -175,7 +161,7 @@ struct Driver::Property_message
|
|||||||
template <typename POLICY, typename... REQUEST_ARGS>
|
template <typename POLICY, typename... REQUEST_ARGS>
|
||||||
typename POLICY::Response const &append(REQUEST_ARGS... request_args)
|
typename POLICY::Response const &append(REQUEST_ARGS... request_args)
|
||||||
{
|
{
|
||||||
auto *tag = new (buffer + buf_size) Tag<POLICY>(request_args...);
|
auto *tag = construct_at<Tag<POLICY> >(buffer + buf_size, request_args...);
|
||||||
|
|
||||||
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
||||||
|
|
||||||
@ -185,7 +171,7 @@ struct Driver::Property_message
|
|||||||
template <typename POLICY, typename... REQUEST_ARGS>
|
template <typename POLICY, typename... REQUEST_ARGS>
|
||||||
void append_no_response(REQUEST_ARGS... request_args)
|
void append_no_response(REQUEST_ARGS... request_args)
|
||||||
{
|
{
|
||||||
new (buffer + buf_size) Tag<POLICY>(request_args...);
|
construct_at<Tag<POLICY> >(buffer + buf_size, request_args...);
|
||||||
|
|
||||||
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
buf_size += sizeof(Tag<POLICY>) + Tag<POLICY>::payload_size();
|
||||||
}
|
}
|
||||||
@ -218,8 +204,6 @@ struct Driver::Property_message
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SRC__DRIVERS__PLATFORM__RPI__PROPERTY_MESSAGE_H_ */
|
#endif /* _SRC__DRIVERS__PLATFORM__RPI__PROPERTY_MESSAGE_H_ */
|
||||||
|
@ -56,8 +56,6 @@ struct Platform::Framebuffer_message : Framebuffer_info
|
|||||||
log(" addr: ", Genode::Hex(addr));
|
log(" addr: ", Genode::Hex(addr));
|
||||||
log(" size: ", Genode::Hex(size));
|
log(" size: ", Genode::Hex(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _FRAMEBUFFER_MESSAGE_H_ */
|
#endif /* _FRAMEBUFFER_MESSAGE_H_ */
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/mmio.h>
|
#include <util/mmio.h>
|
||||||
|
#include <util/construct_at.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <os/attached_mmio.h>
|
#include <os/attached_mmio.h>
|
||||||
#include <base/attached_ram_dataspace.h>
|
#include <base/attached_ram_dataspace.h>
|
||||||
@ -84,7 +85,7 @@ class Mbox : Genode::Attached_mmio
|
|||||||
template <typename MESSAGE, typename... ARGS>
|
template <typename MESSAGE, typename... ARGS>
|
||||||
MESSAGE &message(ARGS... args)
|
MESSAGE &message(ARGS... args)
|
||||||
{
|
{
|
||||||
return *(new (_msg_buffer.local_addr<void>()) MESSAGE(args...));
|
return *Genode::construct_at<MESSAGE>(_msg_buffer.local_addr<void>(), args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MESSAGE>
|
template <typename MESSAGE>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user