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