Introduce Module_LibnxBinder result codes (based on Android status_t) and binderConvertErrorCode

This commit is contained in:
fincs 2018-08-31 13:58:12 +02:00
parent 819a6f0d89
commit a62fae427b
3 changed files with 50 additions and 0 deletions

View File

@ -24,6 +24,8 @@ Result binderTransactParcel(
void* parcel_reply, size_t parcel_reply_size,
u32 flags);
Result binderConvertErrorCode(s32 code);
Result binderAdjustRefcount(Binder* b, s32 addval, s32 type);
Result binderGetNativeHandle(Binder* b, u32 unk0, Event *event_out);

View File

@ -23,6 +23,7 @@
enum {
Module_Kernel=1,
Module_Libnx=345,
Module_LibnxBinder=347,
Module_LibnxNvidia=348,
};
@ -80,6 +81,27 @@ enum {
LibnxError_NvbufFailedToInitialize,
};
/// libnx binder error codes
enum {
LibnxBinderError_Unknown=1,
LibnxBinderError_NoMemory,
LibnxBinderError_InvalidOperation,
LibnxBinderError_BadValue,
LibnxBinderError_BadType,
LibnxBinderError_NameNotFound,
LibnxBinderError_PermissionDenied,
LibnxBinderError_NoInit,
LibnxBinderError_AlreadyExists,
LibnxBinderError_DeadObject,
LibnxBinderError_FailedTransaction,
LibnxBinderError_BadIndex,
LibnxBinderError_NotEnoughData,
LibnxBinderError_WouldBlock,
LibnxBinderError_TimedOut,
LibnxBinderError_UnknownTransaction,
LibnxBinderError_FdsNotAllowed,
};
/// libnx nvidia error codes
enum {
LibnxNvidiaError_Unknown=1,

View File

@ -179,6 +179,32 @@ Result binderTransactParcel(
return rc;
}
Result binderConvertErrorCode(s32 code)
{
if (code >= 0)
return 0;
switch (-code) {
case 1: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_PermissionDenied);
case 2: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_NameNotFound);
case 11: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_WouldBlock);
case 12: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_NoMemory);
case 17: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_AlreadyExists);
case 19: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_NoInit);
case 22: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_BadValue);
case 32: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_DeadObject);
case 38: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_InvalidOperation);
case 61: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_NotEnoughData);
case 74: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_UnknownTransaction);
case 75: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_BadIndex);
case 110: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_TimedOut);
case -(INT32_MIN+7): return MAKERESULT(Module_LibnxBinder, LibnxBinderError_FdsNotAllowed);
case -(INT32_MIN+2): return MAKERESULT(Module_LibnxBinder, LibnxBinderError_FailedTransaction);
case -(INT32_MIN+1): return MAKERESULT(Module_LibnxBinder, LibnxBinderError_BadType);
default: return MAKERESULT(Module_LibnxBinder, LibnxBinderError_Unknown);
}
}
Result binderAdjustRefcount(Binder* b, s32 addval, s32 type)
{
if (!b->created)