summaryrefslogtreecommitdiff
path: root/src/core/hle/result.h
diff options
context:
space:
mode:
authorGravatar bunnei2017-10-31 19:26:11 -0400
committerGravatar bunnei2017-10-31 19:26:11 -0400
commit34571f4d2e80a3194a3c4cb697dba674d11a35b4 (patch)
treeb2b4b70d7a5bdea95ef5d44733eedf7e6b3b7009 /src/core/hle/result.h
parentexternals: Update dynarmic and xbyak. (diff)
downloadyuzu-34571f4d2e80a3194a3c4cb697dba674d11a35b4.tar.gz
yuzu-34571f4d2e80a3194a3c4cb697dba674d11a35b4.tar.xz
yuzu-34571f4d2e80a3194a3c4cb697dba674d11a35b4.zip
hle: Use Switch formatted result codes.
Diffstat (limited to 'src/core/hle/result.h')
-rw-r--r--src/core/hle/result.h240
1 files changed, 59 insertions, 181 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 47b6e2b23..10ddc4feb 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -11,41 +11,14 @@
11#include "common/common_funcs.h" 11#include "common/common_funcs.h"
12#include "common/common_types.h" 12#include "common/common_types.h"
13 13
14// All the constants in this file come from http://3dbrew.org/wiki/Error_codes 14// All the constants in this file come from http://switchbrew.org/index.php?title=Error_codes
15 15
16/** 16/**
17 * Detailed description of the error. Code 0 always means success. Codes 1000 and above are 17 * Detailed description of the error. Code 0 always means success.
18 * considered "well-known" and have common values between all modules. The meaning of other codes
19 * vary by module.
20 */ 18 */
21enum class ErrorDescription : u32 { 19enum class ErrorDescription : u32 {
22 Success = 0, 20 Success = 0,
23 21 RemoteProcessDead = 301,
24 // Codes 1000 and above are considered "well-known" and have common values between all modules.
25 InvalidSection = 1000,
26 TooLarge = 1001,
27 NotAuthorized = 1002,
28 AlreadyDone = 1003,
29 InvalidSize = 1004,
30 InvalidEnumValue = 1005,
31 InvalidCombination = 1006,
32 NoData = 1007,
33 Busy = 1008,
34 MisalignedAddress = 1009,
35 MisalignedSize = 1010,
36 OutOfMemory = 1011,
37 NotImplemented = 1012,
38 InvalidAddress = 1013,
39 InvalidPointer = 1014,
40 InvalidHandle = 1015,
41 NotInitialized = 1016,
42 AlreadyInitialized = 1017,
43 NotFound = 1018,
44 CancelRequested = 1019,
45 AlreadyExists = 1020,
46 OutOfRange = 1021,
47 Timeout = 1022,
48 InvalidResultValue = 1023,
49}; 22};
50 23
51/** 24/**
@@ -56,150 +29,64 @@ enum class ErrorDescription : u32 {
56enum class ErrorModule : u32 { 29enum class ErrorModule : u32 {
57 Common = 0, 30 Common = 0,
58 Kernel = 1, 31 Kernel = 1,
59 Util = 2, 32 FS = 2,
60 FileServer = 3, 33 NvidiaTransferMemory = 3,
61 LoaderServer = 4, 34 NCM = 5,
62 TCB = 5, 35 DD = 6,
63 OS = 6, 36 LR = 8,
64 DBG = 7, 37 Loader = 9,
65 DMNT = 8, 38 CMIF = 10,
66 PDN = 9, 39 HIPC = 11,
67 GX = 10, 40 PM = 15,
68 I2C = 11, 41 NS = 16,
69 GPIO = 12, 42 HTC = 18,
70 DD = 13, 43 SM = 21,
71 CODEC = 14, 44 RO = 22,
72 SPI = 15, 45 SDMMC = 24,
73 PXI = 16, 46 SPL = 26,
74 FS = 17, 47 ETHC = 100,
75 DI = 18, 48 I2C = 101,
76 HID = 19, 49 Settings = 105,
77 CAM = 20, 50 NIFM = 110,
78 PI = 21, 51 Display = 114,
79 PM = 22, 52 NTC = 116,
80 PM_LOW = 23, 53 FGM = 117,
81 FSI = 24, 54 PCIE = 120,
82 SRV = 25, 55 Friends = 121,
83 NDM = 26, 56 SSL = 123,
84 NWM = 27, 57 Account = 124,
85 SOC = 28, 58 Mii = 126,
86 LDR = 29, 59 AM = 128,
87 ACC = 30, 60 PlayReport = 129,
88 RomFS = 31, 61 PCV = 133,
89 AM = 32, 62 OMM = 134,
90 HIO = 33, 63 NIM = 137,
91 Updater = 34, 64 PSC = 138,
92 MIC = 35, 65 USB = 140,
93 FND = 36, 66 BTM = 143,
94 MP = 37, 67 ERPT = 147,
95 MPWL = 38, 68 APM = 148,
96 AC = 39, 69 NPNS = 154,
97 HTTP = 40, 70 ARP = 157,
98 DSP = 41, 71 BOOT = 158,
99 SND = 42, 72 NFC = 161,
100 DLP = 43, 73 UserlandAssert = 162,
101 HIO_LOW = 44, 74 UserlandCrash = 168,
102 CSND = 45, 75 HID = 203,
103 SSL = 46, 76 Capture = 206,
104 AM_LOW = 47, 77 TC = 651,
105 NEX = 48, 78 GeneralWebApplet = 800,
106 Friends = 49, 79 WifiWebAuthApplet = 809,
107 RDT = 50, 80 WhitelistedApplet = 810,
108 Applet = 51, 81 ShopN = 811,
109 NIM = 52,
110 PTM = 53,
111 MIDI = 54,
112 MC = 55,
113 SWC = 56,
114 FatFS = 57,
115 NGC = 58,
116 CARD = 59,
117 CARDNOR = 60,
118 SDMC = 61,
119 BOSS = 62,
120 DBM = 63,
121 Config = 64,
122 PS = 65,
123 CEC = 66,
124 IR = 67,
125 UDS = 68,
126 PL = 69,
127 CUP = 70,
128 Gyroscope = 71,
129 MCU = 72,
130 NS = 73,
131 News = 74,
132 RO = 75,
133 GD = 76,
134 CardSPI = 77,
135 EC = 78,
136 WebBrowser = 79,
137 Test = 80,
138 ENC = 81,
139 PIA = 82,
140 ACT = 83,
141 VCTL = 84,
142 OLV = 85,
143 NEIA = 86,
144 NPNS = 87,
145
146 AVD = 90,
147 L2B = 91,
148 MVD = 92,
149 NFC = 93,
150 UART = 94,
151 SPM = 95,
152 QTM = 96,
153 NFP = 97,
154
155 Application = 254,
156 InvalidResult = 255
157};
158
159/// A less specific error cause.
160enum class ErrorSummary : u32 {
161 Success = 0,
162 NothingHappened = 1,
163 WouldBlock = 2,
164 OutOfResource = 3, ///< There are no more kernel resources (memory, table slots) to
165 ///< execute the operation.
166 NotFound = 4, ///< A file or resource was not found.
167 InvalidState = 5,
168 NotSupported = 6, ///< The operation is not supported or not implemented.
169 InvalidArgument = 7, ///< Returned when a passed argument is invalid in the current runtime
170 ///< context. (Invalid handle, out-of-bounds pointer or size, etc.)
171 WrongArgument = 8, ///< Returned when a passed argument is in an incorrect format for use
172 ///< with the function. (E.g. Invalid enum value)
173 Canceled = 9,
174 StatusChanged = 10,
175 Internal = 11,
176
177 InvalidResult = 63
178};
179
180/// The severity of the error.
181enum class ErrorLevel : u32 {
182 Success = 0,
183 Info = 1,
184
185 Status = 25,
186 Temporary = 26,
187 Permanent = 27,
188 Usage = 28,
189 Reinitialize = 29,
190 Reset = 30,
191 Fatal = 31
192}; 82};
193 83
194/// Encapsulates a CTR-OS error code, allowing it to be separated into its constituent fields. 84/// Encapsulates a CTR-OS error code, allowing it to be separated into its constituent fields.
195union ResultCode { 85union ResultCode {
196 u32 raw; 86 u32 raw;
197 87
198 BitField<0, 10, u32> description; 88 BitField<0, 9, ErrorModule> module;
199 BitField<10, 8, ErrorModule> module; 89 BitField<9, 13, u32> description;
200
201 BitField<21, 6, ErrorSummary> summary;
202 BitField<27, 5, ErrorLevel> level;
203 90
204 // The last bit of `level` is checked by apps and the kernel to determine if a result code is an 91 // The last bit of `level` is checked by apps and the kernel to determine if a result code is an
205 // error 92 // error
@@ -207,14 +94,11 @@ union ResultCode {
207 94
208 constexpr explicit ResultCode(u32 raw) : raw(raw) {} 95 constexpr explicit ResultCode(u32 raw) : raw(raw) {}
209 96
210 constexpr ResultCode(ErrorDescription description, ErrorModule module, ErrorSummary summary, 97 constexpr ResultCode(ErrorModule module, ErrorDescription description)
211 ErrorLevel level) 98 : ResultCode(module, static_cast<u32>(description)) {}
212 : ResultCode(static_cast<u32>(description), module, summary, level) {}
213 99
214 constexpr ResultCode(u32 description_, ErrorModule module_, ErrorSummary summary_, 100 constexpr ResultCode(ErrorModule module_, u32 description_)
215 ErrorLevel level_) 101 : raw(module.FormatValue(module_) | description.FormatValue(description_)) {}
216 : raw(description.FormatValue(description_) | module.FormatValue(module_) |
217 summary.FormatValue(summary_) | level.FormatValue(level_)) {}
218 102
219 constexpr ResultCode& operator=(const ResultCode& o) { 103 constexpr ResultCode& operator=(const ResultCode& o) {
220 raw = o.raw; 104 raw = o.raw;
@@ -243,12 +127,6 @@ constexpr bool operator!=(const ResultCode& a, const ResultCode& b) {
243/// The default success `ResultCode`. 127/// The default success `ResultCode`.
244constexpr ResultCode RESULT_SUCCESS(0); 128constexpr ResultCode RESULT_SUCCESS(0);
245 129
246/// Might be returned instead of a dummy success for unimplemented APIs.
247constexpr ResultCode UnimplementedFunction(ErrorModule module) {
248 return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported,
249 ErrorLevel::Permanent);
250}
251
252/** 130/**
253 * This is an optional value type. It holds a `ResultCode` and, if that code is a success code, 131 * This is an optional value type. It holds a `ResultCode` and, if that code is a success code,
254 * also holds a result of type `T`. If the code is an error code then trying to access the inner 132 * also holds a result of type `T`. If the code is an error code then trying to access the inner