mirror of
https://github.com/citra-emu/citra.git
synced 2024-12-19 20:31:06 +00:00
move push out of class body and add u8 u16 bool specializations
This commit is contained in:
parent
501e23ce59
commit
fb70c9683c
@ -10,7 +10,8 @@
|
|||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header
|
/// Offset into command buffer of header
|
||||||
|
static const int kCommandHeaderOffset = 0x80;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the command buffer in the current thread's TLS
|
* Returns a pointer to the command buffer in the current thread's TLS
|
||||||
@ -26,8 +27,8 @@ inline u32* GetCommandBuffer(const int offset = 0) {
|
|||||||
offset);
|
offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int kStaticBuffersOffset =
|
/// Offset into static buffers, relative to command buffer header
|
||||||
0x100; ///< Offset into static buffers, relative to command buffer header
|
static const int kStaticBuffersOffset = 0x100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the static buffers area in the current thread's TLS
|
* Returns a pointer to the static buffers area in the current thread's TLS
|
||||||
|
@ -62,14 +62,8 @@ public:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void Push(T value);
|
void Push(T value);
|
||||||
|
|
||||||
void Push(u32 value) {
|
|
||||||
cmdbuf[index++] = value;
|
|
||||||
}
|
|
||||||
template <typename First, typename... Other>
|
template <typename First, typename... Other>
|
||||||
void Push(const First& first_value, const Other&... other_values) {
|
void Push(const First& first_value, const Other&... other_values);
|
||||||
Push(first_value);
|
|
||||||
Push(other_values...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copies the content of the given trivially copyable class to the buffer as a normal
|
* @brief Copies the content of the given trivially copyable class to the buffer as a normal
|
||||||
@ -77,59 +71,96 @@ public:
|
|||||||
* @note: The input class must be correctly packed/padded to fit hardware layout.
|
* @note: The input class must be correctly packed/padded to fit hardware layout.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PushRaw(const T& value) {
|
void PushRaw(const T& value);
|
||||||
static_assert(std::is_trivially_copyable<T>(), "Raw types should be trivially copyable");
|
|
||||||
std::memcpy(cmdbuf + index, &value, sizeof(T));
|
|
||||||
index += (sizeof(T) + 3) / 4; // round up to word length
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO : ensure that translate params are added after all regular params
|
// TODO : ensure that translate params are added after all regular params
|
||||||
template <typename... H>
|
template <typename... H>
|
||||||
void PushCopyHandles(H... handles) {
|
void PushCopyHandles(H... handles);
|
||||||
Push(CopyHandleDesc(sizeof...(H)));
|
|
||||||
Push(static_cast<Kernel::Handle>(handles)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... H>
|
template <typename... H>
|
||||||
void PushMoveHandles(H... handles) {
|
void PushMoveHandles(H... handles);
|
||||||
Push(MoveHandleDesc(sizeof...(H)));
|
|
||||||
Push(static_cast<Kernel::Handle>(handles)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PushCurrentPIDHandle() {
|
void PushCurrentPIDHandle();
|
||||||
Push(CallingPidDesc());
|
|
||||||
Push(u32(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PushStaticBuffer(VAddr buffer_vaddr, u32 size, u8 buffer_id) {
|
void PushStaticBuffer(VAddr buffer_vaddr, u32 size, u8 buffer_id);
|
||||||
Push(StaticBufferDesc(size, buffer_id));
|
|
||||||
Push(buffer_vaddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PushMappedBuffer(VAddr buffer_vaddr, u32 size, MappedBufferPermissions perms) {
|
void PushMappedBuffer(VAddr buffer_vaddr, u32 size, MappedBufferPermissions perms);
|
||||||
Push(MappedBufferDesc(size, perms));
|
|
||||||
Push(buffer_vaddr);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Push ///
|
/// Push ///
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void RequestBuilder::Push<u32>(u32 value) {
|
inline void RequestBuilder::Push(u32 value) {
|
||||||
Push(value);
|
cmdbuf[index++] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void RequestBuilder::PushRaw(const T& value) {
|
||||||
|
static_assert(std::is_trivially_copyable<T>(), "Raw types should be trivially copyable");
|
||||||
|
std::memcpy(cmdbuf + index, &value, sizeof(T));
|
||||||
|
index += (sizeof(T) + 3) / 4; // round up to word length
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void RequestBuilder::Push<u64>(u64 value) {
|
inline void RequestBuilder::Push(u8 value) {
|
||||||
|
PushRaw(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline void RequestBuilder::Push(u16 value) {
|
||||||
|
PushRaw(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline void RequestBuilder::Push(u64 value) {
|
||||||
Push(static_cast<u32>(value));
|
Push(static_cast<u32>(value));
|
||||||
Push(static_cast<u32>(value >> 32));
|
Push(static_cast<u32>(value >> 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void RequestBuilder::Push<ResultCode>(ResultCode value) {
|
inline void RequestBuilder::Push(bool value) {
|
||||||
|
Push(u8(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline void RequestBuilder::Push(ResultCode value) {
|
||||||
Push(value.raw);
|
Push(value.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename First, typename... Other>
|
||||||
|
void RequestBuilder::Push(const First& first_value, const Other&... other_values) {
|
||||||
|
Push(first_value);
|
||||||
|
Push(other_values...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... H>
|
||||||
|
inline void RequestBuilder::PushCopyHandles(H... handles) {
|
||||||
|
Push(CopyHandleDesc(sizeof...(H)));
|
||||||
|
Push(static_cast<Kernel::Handle>(handles)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... H>
|
||||||
|
inline void RequestBuilder::PushMoveHandles(H... handles) {
|
||||||
|
Push(MoveHandleDesc(sizeof...(H)));
|
||||||
|
Push(static_cast<Kernel::Handle>(handles)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void RequestBuilder::PushCurrentPIDHandle() {
|
||||||
|
Push(CallingPidDesc());
|
||||||
|
Push(u32(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void RequestBuilder::PushStaticBuffer(VAddr buffer_vaddr, u32 size, u8 buffer_id) {
|
||||||
|
Push(StaticBufferDesc(size, buffer_id));
|
||||||
|
Push(buffer_vaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void RequestBuilder::PushMappedBuffer(VAddr buffer_vaddr, u32 size,
|
||||||
|
MappedBufferPermissions perms) {
|
||||||
|
Push(MappedBufferDesc(size, perms));
|
||||||
|
Push(buffer_vaddr);
|
||||||
|
}
|
||||||
|
|
||||||
class RequestParser : public RequestHelperBase {
|
class RequestParser : public RequestHelperBase {
|
||||||
public:
|
public:
|
||||||
RequestParser(u32* command_buffer, Header command_header)
|
RequestParser(u32* command_buffer, Header command_header)
|
||||||
@ -197,24 +228,60 @@ public:
|
|||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PopRaw(T& value);
|
void PopRaw(T& value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads the next normal parameters as a struct, by copying it into a new value
|
||||||
|
* @note: The output class must be correctly packed/padded to fit hardware layout.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
T PopRaw();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Pop ///
|
/// Pop ///
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline u32 RequestParser::Pop<u32>() {
|
inline u32 RequestParser::Pop() {
|
||||||
return cmdbuf[index++];
|
return cmdbuf[index++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void RequestParser::PopRaw(T& value) {
|
||||||
|
static_assert(std::is_trivially_copyable<T>(), "Raw types should be trivially copyable");
|
||||||
|
std::memcpy(&value, cmdbuf + index, sizeof(T));
|
||||||
|
index += (sizeof(T) + 3) / 4; // round up to word length
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T RequestParser::PopRaw() {
|
||||||
|
T value;
|
||||||
|
PopRaw(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline u64 RequestParser::Pop<u64>() {
|
inline u8 RequestParser::Pop() {
|
||||||
|
return PopRaw<u8>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline u16 RequestParser::Pop() {
|
||||||
|
return PopRaw<u16>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline u64 RequestParser::Pop() {
|
||||||
const u64 lsw = Pop<u32>();
|
const u64 lsw = Pop<u32>();
|
||||||
const u64 msw = Pop<u32>();
|
const u64 msw = Pop<u32>();
|
||||||
return msw << 32 | lsw;
|
return msw << 32 | lsw;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline ResultCode RequestParser::Pop<ResultCode>() {
|
inline bool RequestParser::Pop() {
|
||||||
|
return Pop<u8>() != 0; // != 0 to remove warning C4800
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline ResultCode RequestParser::Pop() {
|
||||||
return ResultCode{Pop<u32>()};
|
return ResultCode{Pop<u32>()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,11 +344,4 @@ inline VAddr RequestParser::PopMappedBuffer(size_t* data_size,
|
|||||||
return Pop<VAddr>();
|
return Pop<VAddr>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void RequestParser::PopRaw(T& value) {
|
|
||||||
static_assert(std::is_trivially_copyable<T>(), "Raw types should be trivially copyable");
|
|
||||||
std::memcpy(&value, cmdbuf + index, sizeof(T));
|
|
||||||
index += (sizeof(T) + 3) / 4; // round up to word length
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace IPC
|
} // namespace IPC
|
||||||
|
@ -101,7 +101,7 @@ void CheckNew3DS(IPC::RequestBuilder& rb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.Push(u32(is_new_3ds ? 1 : 0));
|
rb.Push(is_new_3ds);
|
||||||
|
|
||||||
LOG_WARNING(Service_PTM, "(STUBBED) called isNew3DS = 0x%08x", static_cast<u32>(is_new_3ds));
|
LOG_WARNING(Service_PTM, "(STUBBED) called isNew3DS = 0x%08x", static_cast<u32>(is_new_3ds));
|
||||||
}
|
}
|
||||||
|
@ -189,11 +189,9 @@ static void SetSpacialDithering(Interface* self) {
|
|||||||
* 2 : u8, 0 = Disabled, 1 = Enabled
|
* 2 : u8, 0 = Disabled, 1 = Enabled
|
||||||
*/
|
*/
|
||||||
static void GetSpacialDithering(Interface* self) {
|
static void GetSpacialDithering(Interface* self) {
|
||||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
IPC::RequestBuilder rb(Kernel::GetCommandBuffer(), 0xA, 2, 0);
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
cmd_buff[0] = IPC::MakeHeader(0xA, 2, 0);
|
rb.Push(bool(spacial_dithering_enabled));
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
||||||
cmd_buff[2] = spacial_dithering_enabled;
|
|
||||||
|
|
||||||
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user