|
|
@ -8,6 +8,7 @@
|
|
|
|
#include <tuple>
|
|
|
|
#include <tuple>
|
|
|
|
#include <type_traits>
|
|
|
|
#include <type_traits>
|
|
|
|
#include <utility>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "core/hle/ipc.h"
|
|
|
|
#include "core/hle/ipc.h"
|
|
|
|
#include "core/hle/kernel/handle_table.h"
|
|
|
|
#include "core/hle/kernel/handle_table.h"
|
|
|
|
#include "core/hle/kernel/hle_ipc.h"
|
|
|
|
#include "core/hle/kernel/hle_ipc.h"
|
|
|
@ -117,7 +118,8 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
void PushCurrentPIDHandle();
|
|
|
|
void PushCurrentPIDHandle();
|
|
|
|
|
|
|
|
|
|
|
|
void PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8 buffer_id);
|
|
|
|
[[deprecated]] void PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8 buffer_id);
|
|
|
|
|
|
|
|
void PushStaticBuffer(const std::vector<u8>& buffer, u8 buffer_id);
|
|
|
|
|
|
|
|
|
|
|
|
void PushMappedBuffer(VAddr buffer_vaddr, size_t size, MappedBufferPermissions perms);
|
|
|
|
void PushMappedBuffer(VAddr buffer_vaddr, size_t size, MappedBufferPermissions perms);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -195,6 +197,16 @@ inline void RequestBuilder::PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8
|
|
|
|
Push(buffer_vaddr);
|
|
|
|
Push(buffer_vaddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void RequestBuilder::PushStaticBuffer(const std::vector<u8>& buffer, u8 buffer_id) {
|
|
|
|
|
|
|
|
ASSERT_MSG(buffer_id < MAX_STATIC_BUFFERS, "Invalid static buffer id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Push(StaticBufferDesc(buffer.size(), buffer_id));
|
|
|
|
|
|
|
|
// This address will be replaced by the correct static buffer address during IPC translation.
|
|
|
|
|
|
|
|
Push<VAddr>(0xDEADC0DE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context->AddStaticBuffer(buffer_id, buffer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void RequestBuilder::PushMappedBuffer(VAddr buffer_vaddr, size_t size,
|
|
|
|
inline void RequestBuilder::PushMappedBuffer(VAddr buffer_vaddr, size_t size,
|
|
|
|
MappedBufferPermissions perms) {
|
|
|
|
MappedBufferPermissions perms) {
|
|
|
|
Push(MappedBufferDesc(size, perms));
|
|
|
|
Push(MappedBufferDesc(size, perms));
|
|
|
@ -295,17 +307,23 @@ public:
|
|
|
|
* @brief Pops the static buffer vaddr
|
|
|
|
* @brief Pops the static buffer vaddr
|
|
|
|
* @return The virtual address of the buffer
|
|
|
|
* @return The virtual address of the buffer
|
|
|
|
* @param[out] data_size If non-null, the pointed value will be set to the size of the data
|
|
|
|
* @param[out] data_size If non-null, the pointed value will be set to the size of the data
|
|
|
|
* @param[out] useStaticBuffersToGetVaddr Indicates if we should read the vaddr from the static
|
|
|
|
|
|
|
|
* buffers (which is the correct thing to do, but no service presently implement it) instead of
|
|
|
|
|
|
|
|
* using the same value as the process who sent the request
|
|
|
|
|
|
|
|
* given by the source process
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Static buffers must be set up before any IPC request using those is sent.
|
|
|
|
* In real services, static buffers must be set up before any IPC request using those is sent.
|
|
|
|
* It is the duty of the process (usually services) to allocate and set up the receiving static
|
|
|
|
* It is the duty of the process (usually services) to allocate and set up the receiving static
|
|
|
|
* buffer information
|
|
|
|
* buffer information. Our HLE services do not need to set up the buffers beforehand.
|
|
|
|
* Please note that the setup uses virtual addresses.
|
|
|
|
* Please note that the setup uses virtual addresses.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAddr PopStaticBuffer(size_t* data_size = nullptr, bool useStaticBuffersToGetVaddr = false);
|
|
|
|
[[deprecated]] VAddr PopStaticBuffer(size_t* data_size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Pops a static buffer from the IPC request buffer.
|
|
|
|
|
|
|
|
* @return The buffer that was copied from the IPC request originator.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* In real services, static buffers must be set up before any IPC request using those is sent.
|
|
|
|
|
|
|
|
* It is the duty of the process (usually services) to allocate and set up the receiving static
|
|
|
|
|
|
|
|
* buffer information. Our HLE services do not need to set up the buffers beforehand.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
const std::vector<u8>& PopStaticBuffer();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Pops the mapped buffer vaddr
|
|
|
|
* @brief Pops the mapped buffer vaddr
|
|
|
@ -451,21 +469,21 @@ inline std::tuple<Kernel::SharedPtr<T>...> RequestParser::PopObjects() {
|
|
|
|
std::index_sequence_for<T...>{});
|
|
|
|
std::index_sequence_for<T...>{});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline VAddr RequestParser::PopStaticBuffer(size_t* data_size, bool useStaticBuffersToGetVaddr) {
|
|
|
|
inline VAddr RequestParser::PopStaticBuffer(size_t* data_size) {
|
|
|
|
const u32 sbuffer_descriptor = Pop<u32>();
|
|
|
|
const u32 sbuffer_descriptor = Pop<u32>();
|
|
|
|
StaticBufferDescInfo bufferInfo{sbuffer_descriptor};
|
|
|
|
StaticBufferDescInfo bufferInfo{sbuffer_descriptor};
|
|
|
|
if (data_size != nullptr)
|
|
|
|
if (data_size != nullptr)
|
|
|
|
*data_size = bufferInfo.size;
|
|
|
|
*data_size = bufferInfo.size;
|
|
|
|
if (!useStaticBuffersToGetVaddr)
|
|
|
|
return Pop<VAddr>();
|
|
|
|
return Pop<VAddr>();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
ASSERT_MSG(0, "remove the assert if multiprocess/IPC translation are implemented.");
|
|
|
|
inline const std::vector<u8>& RequestParser::PopStaticBuffer() {
|
|
|
|
// The buffer has already been copied to the static buffer by the kernel during
|
|
|
|
const u32 sbuffer_descriptor = Pop<u32>();
|
|
|
|
// translation
|
|
|
|
// Pop the address from the incoming request buffer
|
|
|
|
Pop<VAddr>(); // Pop the calling process buffer address
|
|
|
|
Pop<VAddr>();
|
|
|
|
// and get the vaddr from the static buffers
|
|
|
|
|
|
|
|
return cmdbuf[(0x100 >> 2) + bufferInfo.buffer_id * 2 + 1];
|
|
|
|
StaticBufferDescInfo buffer_info{sbuffer_descriptor};
|
|
|
|
}
|
|
|
|
return context->GetStaticBuffer(buffer_info.buffer_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline VAddr RequestParser::PopMappedBuffer(size_t* data_size,
|
|
|
|
inline VAddr RequestParser::PopMappedBuffer(size_t* data_size,
|
|
|
|