libnx  v4.8.0
result.h
Go to the documentation of this file.
1 /**
2  * @file result.h
3  * @brief Switch result code tools.
4  * @copyright libnx Authors
5  */
6 #pragma once
7 #include "types.h"
8 
9 /// Checks whether a result code indicates success.
10 #define R_SUCCEEDED(res) ((res)==0)
11 /// Checks whether a result code indicates failure.
12 #define R_FAILED(res) ((res)!=0)
13 /// Returns the module ID of a result code.
14 #define R_MODULE(res) ((res)&0x1FF)
15 /// Returns the description of a result code.
16 #define R_DESCRIPTION(res) (((res)>>9)&0x1FFF)
17 /// Masks out unused bits in a result code, retrieving the actual value for use in comparisons.
18 #define R_VALUE(res) ((res)&0x3FFFFF)
19 
20 /// Builds a result code from its constituent components.
21 #define MAKERESULT(module,description) \
22  ((((module)&0x1FF)) | ((description)&0x1FFF)<<9)
23 
24 /// Builds a kernel error result code.
25 #define KERNELRESULT(description) \
26  MAKERESULT(Module_Kernel, KernelError_##description)
27 
28 /// Module values
29 enum {
30  Module_Kernel=1,
31  Module_Libnx=345,
32  Module_HomebrewAbi=346,
33  Module_HomebrewLoader=347,
34  Module_LibnxNvidia=348,
35  Module_LibnxBinder=349,
36 };
37 
38 /// Kernel error codes
39 enum {
40  KernelError_OutOfSessions=7,
41  KernelError_InvalidCapabilityDescriptor=14,
42  KernelError_NotImplemented=33,
43  KernelError_ThreadTerminating=59,
44  KernelError_OutOfDebugEvents=70,
45  KernelError_InvalidSize=101,
46  KernelError_InvalidAddress=102,
47  KernelError_ResourceExhausted=103,
48  KernelError_OutOfMemory=104,
49  KernelError_OutOfHandles=105,
50  KernelError_InvalidMemoryState=106,
51  KernelError_InvalidMemoryPermissions=108,
52  KernelError_InvalidMemoryRange=110,
53  KernelError_InvalidPriority=112,
54  KernelError_InvalidCoreId=113,
55  KernelError_InvalidHandle=114,
56  KernelError_InvalidUserBuffer=115,
57  KernelError_InvalidCombination=116,
58  KernelError_TimedOut=117,
59  KernelError_Cancelled=118,
60  KernelError_OutOfRange=119,
61  KernelError_InvalidEnumValue=120,
62  KernelError_NotFound=121,
63  KernelError_AlreadyExists=122,
64  KernelError_ConnectionClosed=123,
65  KernelError_UnhandledUserInterrupt=124,
66  KernelError_InvalidState=125,
67  KernelError_ReservedValue=126,
68  KernelError_InvalidHwBreakpoint=127,
69  KernelError_FatalUserException=128,
70  KernelError_OwnedByAnotherProcess=129,
71  KernelError_ConnectionRefused=131,
72  KernelError_OutOfResource=132,
73  KernelError_IpcMapFailed=259,
74  KernelError_IpcCmdbufTooSmall=260,
75  KernelError_NotDebugged=520,
76 };
77 
78 /// libnx error codes
79 enum {
80  LibnxError_BadReloc=1,
81  LibnxError_OutOfMemory,
82  LibnxError_AlreadyMapped,
83  LibnxError_BadGetInfo_Stack,
84  LibnxError_BadGetInfo_Heap,
85  LibnxError_BadQueryMemory,
86  LibnxError_AlreadyInitialized,
87  LibnxError_NotInitialized,
88  LibnxError_NotFound,
89  LibnxError_IoError,
90  LibnxError_BadInput,
91  LibnxError_BadReent,
92  LibnxError_BufferProducerError,
93  LibnxError_HandleTooEarly,
94  LibnxError_HeapAllocFailed,
95  LibnxError_TooManyOverrides,
96  LibnxError_ParcelError,
97  LibnxError_BadGfxInit,
98  LibnxError_BadGfxEventWait,
99  LibnxError_BadGfxQueueBuffer,
100  LibnxError_BadGfxDequeueBuffer,
101  LibnxError_AppletCmdidNotFound,
102  LibnxError_BadAppletReceiveMessage,
103  LibnxError_BadAppletNotifyRunning,
104  LibnxError_BadAppletGetCurrentFocusState,
105  LibnxError_BadAppletGetOperationMode,
106  LibnxError_BadAppletGetPerformanceMode,
107  LibnxError_BadUsbCommsRead,
108  LibnxError_BadUsbCommsWrite,
109  LibnxError_InitFail_SM,
110  LibnxError_InitFail_AM,
111  LibnxError_InitFail_HID,
112  LibnxError_InitFail_FS,
113  LibnxError_BadGetInfo_Rng,
114  LibnxError_JitUnavailable,
115  LibnxError_WeirdKernel,
116  LibnxError_IncompatSysVer,
117  LibnxError_InitFail_Time,
118  LibnxError_TooManyDevOpTabs,
119  LibnxError_DomainMessageUnknownType,
120  LibnxError_DomainMessageTooManyObjectIds,
121  LibnxError_AppletFailedToInitialize,
122  LibnxError_ApmFailedToInitialize,
123  LibnxError_NvinfoFailedToInitialize,
124  LibnxError_NvbufFailedToInitialize,
125  LibnxError_LibAppletBadExit,
126  LibnxError_InvalidCmifOutHeader,
127  LibnxError_ShouldNotHappen,
128  LibnxError_Timeout,
129 };
130 
131 /// libnx binder error codes
132 enum {
133  LibnxBinderError_Unknown=1,
134  LibnxBinderError_NoMemory,
135  LibnxBinderError_InvalidOperation,
136  LibnxBinderError_BadValue,
137  LibnxBinderError_BadType,
138  LibnxBinderError_NameNotFound,
139  LibnxBinderError_PermissionDenied,
140  LibnxBinderError_NoInit,
141  LibnxBinderError_AlreadyExists,
142  LibnxBinderError_DeadObject,
143  LibnxBinderError_FailedTransaction,
144  LibnxBinderError_BadIndex,
145  LibnxBinderError_NotEnoughData,
146  LibnxBinderError_WouldBlock,
147  LibnxBinderError_TimedOut,
148  LibnxBinderError_UnknownTransaction,
149  LibnxBinderError_FdsNotAllowed,
150 };
151 
152 /// libnx nvidia error codes
153 enum {
154  LibnxNvidiaError_Unknown=1,
155  LibnxNvidiaError_NotImplemented, ///< Maps to Nvidia: 1
156  LibnxNvidiaError_NotSupported, ///< Maps to Nvidia: 2
157  LibnxNvidiaError_NotInitialized, ///< Maps to Nvidia: 3
158  LibnxNvidiaError_BadParameter, ///< Maps to Nvidia: 4
159  LibnxNvidiaError_Timeout, ///< Maps to Nvidia: 5
160  LibnxNvidiaError_InsufficientMemory, ///< Maps to Nvidia: 6
161  LibnxNvidiaError_ReadOnlyAttribute, ///< Maps to Nvidia: 7
162  LibnxNvidiaError_InvalidState, ///< Maps to Nvidia: 8
163  LibnxNvidiaError_InvalidAddress, ///< Maps to Nvidia: 9
164  LibnxNvidiaError_InvalidSize, ///< Maps to Nvidia: 10
165  LibnxNvidiaError_BadValue, ///< Maps to Nvidia: 11
166  LibnxNvidiaError_AlreadyAllocated, ///< Maps to Nvidia: 13
167  LibnxNvidiaError_Busy, ///< Maps to Nvidia: 14
168  LibnxNvidiaError_ResourceError, ///< Maps to Nvidia: 15
169  LibnxNvidiaError_CountMismatch, ///< Maps to Nvidia: 16
170  LibnxNvidiaError_SharedMemoryTooSmall, ///< Maps to Nvidia: 0x1000
171  LibnxNvidiaError_FileOperationFailed, ///< Maps to Nvidia: 0x30003
172  LibnxNvidiaError_IoctlFailed, ///< Maps to Nvidia: 0x3000F
173 };
@ LibnxNvidiaError_NotImplemented
Maps to Nvidia: 1.
Definition: result.h:155
@ LibnxNvidiaError_InvalidSize
Maps to Nvidia: 10.
Definition: result.h:164
@ LibnxNvidiaError_NotSupported
Maps to Nvidia: 2.
Definition: result.h:156
@ LibnxNvidiaError_ReadOnlyAttribute
Maps to Nvidia: 7.
Definition: result.h:161
@ LibnxNvidiaError_CountMismatch
Maps to Nvidia: 16.
Definition: result.h:169
@ LibnxNvidiaError_BadParameter
Maps to Nvidia: 4.
Definition: result.h:158
@ LibnxNvidiaError_InvalidState
Maps to Nvidia: 8.
Definition: result.h:162
@ LibnxNvidiaError_FileOperationFailed
Maps to Nvidia: 0x30003.
Definition: result.h:171
@ LibnxNvidiaError_InvalidAddress
Maps to Nvidia: 9.
Definition: result.h:163
@ LibnxNvidiaError_SharedMemoryTooSmall
Maps to Nvidia: 0x1000.
Definition: result.h:170
@ LibnxNvidiaError_IoctlFailed
Maps to Nvidia: 0x3000F.
Definition: result.h:172
@ LibnxNvidiaError_NotInitialized
Maps to Nvidia: 3.
Definition: result.h:157
@ LibnxNvidiaError_BadValue
Maps to Nvidia: 11.
Definition: result.h:165
@ LibnxNvidiaError_ResourceError
Maps to Nvidia: 15.
Definition: result.h:168
@ LibnxNvidiaError_Timeout
Maps to Nvidia: 5.
Definition: result.h:159
@ LibnxNvidiaError_InsufficientMemory
Maps to Nvidia: 6.
Definition: result.h:160
@ LibnxNvidiaError_Busy
Maps to Nvidia: 14.
Definition: result.h:167
@ LibnxNvidiaError_AlreadyAllocated
Maps to Nvidia: 13.
Definition: result.h:166
Various system types.