diff options
Diffstat (limited to 'src/core/hle/kernel/session.h')
| -rw-r--r-- | src/core/hle/kernel/session.h | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index 8ec889967..8e4e010b8 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h | |||
| @@ -19,12 +19,13 @@ namespace IPC { | |||
| 19 | enum DescriptorType : u32 { | 19 | enum DescriptorType : u32 { |
| 20 | // Buffer related desciptors types (mask : 0x0F) | 20 | // Buffer related desciptors types (mask : 0x0F) |
| 21 | StaticBuffer = 0x02, | 21 | StaticBuffer = 0x02, |
| 22 | PXIBuffer = 0x04, | 22 | PXIBuffer = 0x04, |
| 23 | MappedBuffer = 0x08, | 23 | MappedBuffer = 0x08, |
| 24 | // Handle related descriptors types (mask : 0x30, but need to check for buffer related descriptors first ) | 24 | // Handle related descriptors types (mask : 0x30, but need to check for buffer related |
| 25 | CopyHandle = 0x00, | 25 | // descriptors first ) |
| 26 | MoveHandle = 0x10, | 26 | CopyHandle = 0x00, |
| 27 | CallingPid = 0x20, | 27 | MoveHandle = 0x10, |
| 28 | CallingPid = 0x20, | ||
| 28 | }; | 29 | }; |
| 29 | 30 | ||
| 30 | /** | 31 | /** |
| @@ -34,24 +35,28 @@ enum DescriptorType : u32 { | |||
| 34 | * @param translate_params_size Size of the translate parameters in words. Up to 63. | 35 | * @param translate_params_size Size of the translate parameters in words. Up to 63. |
| 35 | * @return The created IPC header. | 36 | * @return The created IPC header. |
| 36 | * | 37 | * |
| 37 | * Normal parameters are sent directly to the process while the translate parameters might go through modifications and checks by the kernel. | 38 | * Normal parameters are sent directly to the process while the translate parameters might go |
| 39 | * through modifications and checks by the kernel. | ||
| 38 | * The translate parameters are described by headers generated with the IPC::*Desc functions. | 40 | * The translate parameters are described by headers generated with the IPC::*Desc functions. |
| 39 | * | 41 | * |
| 40 | * @note While #normal_params is equivalent to the number of normal parameters, #translate_params_size includes the size occupied by the translate parameters headers. | 42 | * @note While #normal_params is equivalent to the number of normal parameters, |
| 43 | * #translate_params_size includes the size occupied by the translate parameters headers. | ||
| 41 | */ | 44 | */ |
| 42 | constexpr u32 MakeHeader(u16 command_id, unsigned int normal_params, unsigned int translate_params_size) { | 45 | constexpr u32 MakeHeader(u16 command_id, unsigned int normal_params, |
| 43 | return (u32(command_id) << 16) | ((u32(normal_params) & 0x3F) << 6) | (u32(translate_params_size) & 0x3F); | 46 | unsigned int translate_params_size) { |
| 47 | return (u32(command_id) << 16) | ((u32(normal_params) & 0x3F) << 6) | | ||
| 48 | (u32(translate_params_size) & 0x3F); | ||
| 44 | } | 49 | } |
| 45 | 50 | ||
| 46 | union Header { | 51 | union Header { |
| 47 | u32 raw; | 52 | u32 raw; |
| 48 | BitField< 0, 6, u32> translate_params_size; | 53 | BitField<0, 6, u32> translate_params_size; |
| 49 | BitField< 6, 6, u32> normal_params; | 54 | BitField<6, 6, u32> normal_params; |
| 50 | BitField<16, 16, u32> command_id; | 55 | BitField<16, 16, u32> command_id; |
| 51 | }; | 56 | }; |
| 52 | 57 | ||
| 53 | inline Header ParseHeader(u32 header) { | 58 | inline Header ParseHeader(u32 header) { |
| 54 | return{ header }; | 59 | return {header}; |
| 55 | } | 60 | } |
| 56 | 61 | ||
| 57 | constexpr u32 MoveHandleDesc(u32 num_handles = 1) { | 62 | constexpr u32 MoveHandleDesc(u32 num_handles = 1) { |
| @@ -80,27 +85,29 @@ constexpr u32 StaticBufferDesc(u32 size, u8 buffer_id) { | |||
| 80 | 85 | ||
| 81 | union StaticBufferDescInfo { | 86 | union StaticBufferDescInfo { |
| 82 | u32 raw; | 87 | u32 raw; |
| 83 | BitField< 10, 4, u32> buffer_id; | 88 | BitField<10, 4, u32> buffer_id; |
| 84 | BitField< 14, 18, u32> size; | 89 | BitField<14, 18, u32> size; |
| 85 | }; | 90 | }; |
| 86 | 91 | ||
| 87 | inline StaticBufferDescInfo ParseStaticBufferDesc(const u32 desc) { | 92 | inline StaticBufferDescInfo ParseStaticBufferDesc(const u32 desc) { |
| 88 | return{ desc }; | 93 | return {desc}; |
| 89 | } | 94 | } |
| 90 | 95 | ||
| 91 | /** | 96 | /** |
| 92 | * @brief Creates a header describing a buffer to be sent over PXI. | 97 | * @brief Creates a header describing a buffer to be sent over PXI. |
| 93 | * @param size Size of the buffer. Max 0x00FFFFFF. | 98 | * @param size Size of the buffer. Max 0x00FFFFFF. |
| 94 | * @param buffer_id The Id of the buffer. Max 0xF. | 99 | * @param buffer_id The Id of the buffer. Max 0xF. |
| 95 | * @param is_read_only true if the buffer is read-only. If false, the buffer is considered to have read-write access. | 100 | * @param is_read_only true if the buffer is read-only. If false, the buffer is considered to have |
| 101 | * read-write access. | ||
| 96 | * @return The created PXI buffer header. | 102 | * @return The created PXI buffer header. |
| 97 | * | 103 | * |
| 98 | * The next value is a phys-address of a table located in the BASE memregion. | 104 | * The next value is a phys-address of a table located in the BASE memregion. |
| 99 | */ | 105 | */ |
| 100 | inline u32 PXIBufferDesc(u32 size, unsigned buffer_id, bool is_read_only) { | 106 | inline u32 PXIBufferDesc(u32 size, unsigned buffer_id, bool is_read_only) { |
| 101 | u32 type = PXIBuffer; | 107 | u32 type = PXIBuffer; |
| 102 | if (is_read_only) type |= 0x2; | 108 | if (is_read_only) |
| 103 | return type | (size << 8) | ((buffer_id & 0xF) << 4); | 109 | type |= 0x2; |
| 110 | return type | (size << 8) | ((buffer_id & 0xF) << 4); | ||
| 104 | } | 111 | } |
| 105 | 112 | ||
| 106 | enum MappedBufferPermissions { | 113 | enum MappedBufferPermissions { |
| @@ -115,12 +122,12 @@ constexpr u32 MappedBufferDesc(u32 size, MappedBufferPermissions perms) { | |||
| 115 | 122 | ||
| 116 | union MappedBufferDescInfo { | 123 | union MappedBufferDescInfo { |
| 117 | u32 raw; | 124 | u32 raw; |
| 118 | BitField< 4, 28, u32> size; | 125 | BitField<4, 28, u32> size; |
| 119 | BitField< 1, 2, MappedBufferPermissions> perms; | 126 | BitField<1, 2, MappedBufferPermissions> perms; |
| 120 | }; | 127 | }; |
| 121 | 128 | ||
| 122 | inline MappedBufferDescInfo ParseMappedBufferDesc(const u32 desc) { | 129 | inline MappedBufferDescInfo ParseMappedBufferDesc(const u32 desc) { |
| 123 | return{ desc }; | 130 | return {desc}; |
| 124 | } | 131 | } |
| 125 | 132 | ||
| 126 | inline DescriptorType GetDescriptorType(u32 descriptor) { | 133 | inline DescriptorType GetDescriptorType(u32 descriptor) { |
| @@ -153,7 +160,8 @@ static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of | |||
| 153 | * @return Pointer to command buffer | 160 | * @return Pointer to command buffer |
| 154 | */ | 161 | */ |
| 155 | inline u32* GetCommandBuffer(const int offset = 0) { | 162 | inline u32* GetCommandBuffer(const int offset = 0) { |
| 156 | return (u32*)Memory::GetPointer(GetCurrentThread()->GetTLSAddress() + kCommandHeaderOffset + offset); | 163 | return (u32*)Memory::GetPointer(GetCurrentThread()->GetTLSAddress() + kCommandHeaderOffset + |
| 164 | offset); | ||
| 157 | } | 165 | } |
| 158 | 166 | ||
| 159 | /** | 167 | /** |
| @@ -183,10 +191,14 @@ public: | |||
| 183 | Session(); | 191 | Session(); |
| 184 | ~Session() override; | 192 | ~Session() override; |
| 185 | 193 | ||
| 186 | std::string GetTypeName() const override { return "Session"; } | 194 | std::string GetTypeName() const override { |
| 195 | return "Session"; | ||
| 196 | } | ||
| 187 | 197 | ||
| 188 | static const HandleType HANDLE_TYPE = HandleType::Session; | 198 | static const HandleType HANDLE_TYPE = HandleType::Session; |
| 189 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | 199 | HandleType GetHandleType() const override { |
| 200 | return HANDLE_TYPE; | ||
| 201 | } | ||
| 190 | 202 | ||
| 191 | /** | 203 | /** |
| 192 | * Handles a synchronous call to this session using HLE emulation. Emulated <-> emulated calls | 204 | * Handles a synchronous call to this session using HLE emulation. Emulated <-> emulated calls |
| @@ -205,5 +217,4 @@ public: | |||
| 205 | ASSERT_MSG(!ShouldWait(), "object unavailable!"); | 217 | ASSERT_MSG(!ShouldWait(), "object unavailable!"); |
| 206 | } | 218 | } |
| 207 | }; | 219 | }; |
| 208 | |||
| 209 | } | 220 | } |