libctru  v2.4.1
result.h
Go to the documentation of this file.
1 /**
2  * @file result.h
3  * @brief 3DS result code tools
4  */
5 #pragma once
6 #include "types.h"
7 
8 /// Checks whether a result code indicates success.
9 #define R_SUCCEEDED(res) ((res)>=0)
10 /// Checks whether a result code indicates failure.
11 #define R_FAILED(res) ((res)<0)
12 /// Returns the level of a result code.
13 #define R_LEVEL(res) (((res)>>27)&0x1F)
14 /// Returns the summary of a result code.
15 #define R_SUMMARY(res) (((res)>>21)&0x3F)
16 /// Returns the module ID of a result code.
17 #define R_MODULE(res) (((res)>>10)&0xFF)
18 /// Returns the description of a result code.
19 #define R_DESCRIPTION(res) ((res)&0x3FF)
20 
21 /// Builds a result code from its constituent components.
22 #define MAKERESULT(level,summary,module,description) \
23  ((((level)&0x1F)<<27) | (((summary)&0x3F)<<21) | (((module)&0xFF)<<10) | ((description)&0x3FF))
24 
25 /// Result code level values.
26 enum
27 {
28  // >= 0
29  RL_SUCCESS = 0,
30  RL_INFO = 1,
31 
32  // < 0
33  RL_FATAL = 0x1F,
34  RL_RESET = RL_FATAL - 1,
35  RL_REINITIALIZE = RL_FATAL - 2,
36  RL_USAGE = RL_FATAL - 3,
37  RL_PERMANENT = RL_FATAL - 4,
38  RL_TEMPORARY = RL_FATAL - 5,
39  RL_STATUS = RL_FATAL - 6,
40 };
41 
42 /// Result code summary values.
43 enum
44 {
45  RS_SUCCESS = 0,
46  RS_NOP = 1,
47  RS_WOULDBLOCK = 2,
48  RS_OUTOFRESOURCE = 3,
49  RS_NOTFOUND = 4,
50  RS_INVALIDSTATE = 5,
51  RS_NOTSUPPORTED = 6,
52  RS_INVALIDARG = 7,
53  RS_WRONGARG = 8,
54  RS_CANCELED = 9,
55  RS_STATUSCHANGED = 10,
56  RS_INTERNAL = 11,
57  RS_INVALIDRESVAL = 63,
58 };
59 
60 /// Result code module values.
61 enum
62 {
63  RM_COMMON = 0,
64  RM_KERNEL = 1,
65  RM_UTIL = 2,
66  RM_FILE_SERVER = 3,
67  RM_LOADER_SERVER = 4,
68  RM_TCB = 5,
69  RM_OS = 6,
70  RM_DBG = 7,
71  RM_DMNT = 8,
72  RM_PDN = 9,
73  RM_GSP = 10,
74  RM_I2C = 11,
75  RM_GPIO = 12,
76  RM_DD = 13,
77  RM_CODEC = 14,
78  RM_SPI = 15,
79  RM_PXI = 16,
80  RM_FS = 17,
81  RM_DI = 18,
82  RM_HID = 19,
83  RM_CAM = 20,
84  RM_PI = 21,
85  RM_PM = 22,
86  RM_PM_LOW = 23,
87  RM_FSI = 24,
88  RM_SRV = 25,
89  RM_NDM = 26,
90  RM_NWM = 27,
91  RM_SOC = 28,
92  RM_LDR = 29,
93  RM_ACC = 30,
94  RM_ROMFS = 31,
95  RM_AM = 32,
96  RM_HIO = 33,
97  RM_UPDATER = 34,
98  RM_MIC = 35,
99  RM_FND = 36,
100  RM_MP = 37,
101  RM_MPWL = 38,
102  RM_AC = 39,
103  RM_HTTP = 40,
104  RM_DSP = 41,
105  RM_SND = 42,
106  RM_DLP = 43,
107  RM_HIO_LOW = 44,
108  RM_CSND = 45,
109  RM_SSL = 46,
110  RM_AM_LOW = 47,
111  RM_NEX = 48,
112  RM_FRIENDS = 49,
113  RM_RDT = 50,
114  RM_APPLET = 51,
115  RM_NIM = 52,
116  RM_PTM = 53,
117  RM_MIDI = 54,
118  RM_MC = 55,
119  RM_SWC = 56,
120  RM_FATFS = 57,
121  RM_NGC = 58,
122  RM_CARD = 59,
123  RM_CARDNOR = 60,
124  RM_SDMC = 61,
125  RM_BOSS = 62,
126  RM_DBM = 63,
127  RM_CONFIG = 64,
128  RM_PS = 65,
129  RM_CEC = 66,
130  RM_IR = 67,
131  RM_UDS = 68,
132  RM_PL = 69,
133  RM_CUP = 70,
134  RM_GYROSCOPE = 71,
135  RM_MCU = 72,
136  RM_NS = 73,
137  RM_NEWS = 74,
138  RM_RO = 75,
139  RM_GD = 76,
140  RM_CARD_SPI = 77,
141  RM_EC = 78,
142  RM_WEB_BROWSER = 79,
143  RM_TEST = 80,
144  RM_ENC = 81,
145  RM_PIA = 82,
146  RM_ACT = 83,
147  RM_VCTL = 84,
148  RM_OLV = 85,
149  RM_NEIA = 86,
150  RM_NPNS = 87,
151  RM_AVD = 90,
152  RM_L2B = 91,
153  RM_MVD = 92,
154  RM_NFC = 93,
155  RM_UART = 94,
156  RM_SPM = 95,
157  RM_QTM = 96,
158  RM_NFP = 97,
159  RM_APPLICATION = 254,
160  RM_INVALIDRESVAL = 255,
161 };
162 
163 /// Result code generic description values.
164 enum
165 {
166  RD_SUCCESS = 0,
167  RD_INVALID_RESULT_VALUE = 0x3FF,
168  RD_TIMEOUT = RD_INVALID_RESULT_VALUE - 1,
169  RD_OUT_OF_RANGE = RD_INVALID_RESULT_VALUE - 2,
170  RD_ALREADY_EXISTS = RD_INVALID_RESULT_VALUE - 3,
171  RD_CANCEL_REQUESTED = RD_INVALID_RESULT_VALUE - 4,
172  RD_NOT_FOUND = RD_INVALID_RESULT_VALUE - 5,
173  RD_ALREADY_INITIALIZED = RD_INVALID_RESULT_VALUE - 6,
174  RD_NOT_INITIALIZED = RD_INVALID_RESULT_VALUE - 7,
175  RD_INVALID_HANDLE = RD_INVALID_RESULT_VALUE - 8,
176  RD_INVALID_POINTER = RD_INVALID_RESULT_VALUE - 9,
177  RD_INVALID_ADDRESS = RD_INVALID_RESULT_VALUE - 10,
178  RD_NOT_IMPLEMENTED = RD_INVALID_RESULT_VALUE - 11,
179  RD_OUT_OF_MEMORY = RD_INVALID_RESULT_VALUE - 12,
180  RD_MISALIGNED_SIZE = RD_INVALID_RESULT_VALUE - 13,
181  RD_MISALIGNED_ADDRESS = RD_INVALID_RESULT_VALUE - 14,
182  RD_BUSY = RD_INVALID_RESULT_VALUE - 15,
183  RD_NO_DATA = RD_INVALID_RESULT_VALUE - 16,
184  RD_INVALID_COMBINATION = RD_INVALID_RESULT_VALUE - 17,
185  RD_INVALID_ENUM_VALUE = RD_INVALID_RESULT_VALUE - 18,
186  RD_INVALID_SIZE = RD_INVALID_RESULT_VALUE - 19,
187  RD_ALREADY_DONE = RD_INVALID_RESULT_VALUE - 20,
188  RD_NOT_AUTHORIZED = RD_INVALID_RESULT_VALUE - 21,
189  RD_TOO_LARGE = RD_INVALID_RESULT_VALUE - 22,
190  RD_INVALID_SELECTION = RD_INVALID_RESULT_VALUE - 23,
191 };
Various system types.