This commit is contained in:
shchmue 2019-12-21 17:53:54 -07:00
commit abcdb137f9
7 changed files with 221 additions and 6 deletions

View File

@ -51,7 +51,8 @@ static inline Result condvarWait(CondVar* c, Mutex* m)
*/ */
static inline Result condvarWake(CondVar* c, int num) static inline Result condvarWake(CondVar* c, int num)
{ {
return svcSignalProcessWideKey(c, num); svcSignalProcessWideKey(c, num);
return 0;
} }
/** /**

View File

@ -472,10 +472,9 @@ Result svcWaitProcessWideKeyAtomic(u32* key, u32* tag_location, u32 self_tag, u6
/** /**
* @brief Performs a condition variable wake-up operation in userspace. * @brief Performs a condition variable wake-up operation in userspace.
* @return Result code.
* @note Syscall number 0x1D. * @note Syscall number 0x1D.
*/ */
Result svcSignalProcessWideKey(u32* key, s32 num); void svcSignalProcessWideKey(u32* key, s32 num);
///@} ///@}

View File

@ -262,6 +262,128 @@ typedef struct {
u32 extra_color; ///< Extra Color. u32 extra_color; ///< Extra Color.
} SetSysHomeMenuScheme; } SetSysHomeMenuScheme;
typedef struct {
u8 offset[0x6];
} SetCalAccelerometerOffset;
typedef struct {
u8 scale[0x6];
} SetCalAccelerometerScale;
typedef struct {
u8 cert[0x70];
} SetCalAmiiboEcdsaCertificate;
typedef struct {
u8 cert[0x20];
} SetCalAmiiboEcqvBlsCertificate;
typedef struct {
u8 key[0x44];
} SetCalAmiiboEcqvBlsKey;
typedef struct {
u8 cert[0x90];
} SetCalAmiiboEcqvBlsRootCertificate;
typedef struct {
u8 cert[0x14];
} SetCalAmiiboEcqvCertificate;
typedef struct {
u8 key[0x54];
} SetCalAmiiboKey;
typedef struct {
u8 calibration[0x9];
} SetCalAnalogStickFactoryCalibration;
typedef struct {
u8 parameter[0x12];
} SetCalAnalogStickModelParameter;
typedef struct {
u8 battery_lot[0x18];
} SetCalBatteryLot;
typedef struct {
u8 bd_addr[0x6];
} SetCalBdAddress;
typedef struct {
u8 cfg[0x1E];
} SetCalConfigurationId1;
typedef struct {
u8 offset[0x6];
} SetCalConsoleSixAxisSensorHorizontalOffset;
typedef struct {
u32 code[0x4]; ///< Country code.
} SetCalCountryCode;
typedef struct {
u32 offset; ///< Relative to current position.
u8 cert[0x17C];
} SetCalEccB233DeviceCertificate;
typedef struct {
u8 key[0x58];
} SetCalEccB233DeviceKey;
typedef struct {
u8 cert[0x400];
} SetCalGameCardCertificate;
typedef struct {
u32 size; ///< Size of the entire key.
u8 key[0x130];
} SetCalGameCardKey;
typedef struct {
u8 offset[0x6];
} SetCalGyroscopeOffset;
typedef struct {
u8 scale[0x6];
} SetCalGyroscopeScale;
typedef struct {
u8 addr[0x6]; ///< Mac address.
} SetCalMacAddress;
typedef struct {
u32 offset; ///< Relative to current position.
u8 cert[0x23C];
} SetCalRsa2048DeviceCertificate;
typedef struct {
u32 size; ///< Size of the entire key.
u8 key[0x240];
} SetCalRsa2048DeviceKey;
typedef struct {
u8 number[0x18];
} SetCalSerialNumber;
typedef struct {
u8 parameter[0x5A];
} SetCalSpeakerParameter;
typedef struct {
u32 size; ///< Size of the certificate data.
u8 cert[0x800];
} SetCalSslCertificate;
typedef struct {
u32 size; ///< Size of the entire key.
u8 key[0x130];
} SetCalSslKey;
typedef struct {
u32 code; ///< Region code.
} SetCalRegionCode;
/// Initialize set. /// Initialize set.
Result setInitialize(void); Result setInitialize(void);
@ -885,3 +1007,33 @@ Result setsysGetTouchScreenMode(SetSysTouchScreenMode *out);
* @param[in] mode \ref SetSysTouchScreenMode * @param[in] mode \ref SetSysTouchScreenMode
*/ */
Result setsysSetTouchScreenMode(SetSysTouchScreenMode mode); Result setsysSetTouchScreenMode(SetSysTouchScreenMode mode);
/// Initialize setcal.
Result setcalInitialize(void);
/// Exit setcal.
void setcalExit(void);
/// Gets the Service object for the actual setcal service session.
Service* setcalGetServiceSession(void);
/// Gets the \ref SetCalEccB233DeviceCertificate.
Result setcalGetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out);
/// Gets the \ref SetCalRsa2048DeviceCertificate.
Result setcalGetEticketDeviceCertificate(SetCalRsa2048DeviceCertificate *out);
/// Gets the \ref SetCalSslKey.
Result setcalGetSslKey(SetCalSslKey *out);
/// Gets the \ref SetCalSslCertificate.
Result setcalGetSslCertificate(SetCalSslCertificate *out);
/// Gets the \ref SetCalGameCardKey.
Result setcalGetGameCardKey(SetCalGameCardKey *out);
/// Gets the \ref SetCalGameCardCertificate.
Result setcalGetGameCardCertificate(SetCalGameCardCertificate *out);
/// Gets the \ref SetCalRsa2048DeviceKey.
Result setcalGetEticketDeviceKey(SetCalRsa2048DeviceKey *out);

View File

@ -42,8 +42,6 @@ Result pselUiShow(PselUiSettings *ui, AccountUid *out_user) {
arg_size = sizeof(ui->settings); arg_size = sizeof(ui->settings);
} }
// TODO: Official sw supports pushing an optional additional storage from appletCreateTransferMemoryStorage with writable=0 using an input buffer, when that buffer is specified. However, sdknso itself doesn't use this besides a wrapper func. Figure out what this, and implement it?(libappletLaunch could no longer be used with this)
rc = libappletLaunch(AppletId_playerSelect, &args, arg_ptr, arg_size, &ret, sizeof(ret), &reply_size); rc = libappletLaunch(AppletId_playerSelect, &args, arg_ptr, arg_size, &ret, sizeof(ret), &reply_size);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {

View File

@ -321,7 +321,7 @@ void __libnx_init_time(void)
memset(envstr, 0, sizeof(envstr)); memset(envstr, 0, sizeof(envstr));
//Avoid using *printf. //Avoid using *printf.
strncpy(envstr, info.timezoneName, sizeof(envstr)-1); strncpy(envstr, /*info.timezoneName*/"NX", sizeof(envstr)-1); // Some tznames have numeric characters and '-'/'+', so the actual tzname can't be used.
strptr = &envstr[strlen(envstr)]; strptr = &envstr[strlen(envstr)];
*strptr++ = is_west ? '+' : '-'; *strptr++ = is_west ? '+' : '-';

View File

@ -334,6 +334,7 @@ static void _appletInfiniteSleepLoop(void) {
} }
static void NORETURN _appletExitProcess(int result_code) { static void NORETURN _appletExitProcess(int result_code) {
appletInitialize();
appletExit(); appletExit();
if (R_SUCCEEDED(g_appletExitProcessResult)) _appletInfiniteSleepLoop(); if (R_SUCCEEDED(g_appletExitProcessResult)) _appletInfiniteSleepLoop();

View File

@ -7,6 +7,7 @@
static Service g_setSrv; static Service g_setSrv;
static Service g_setsysSrv; static Service g_setsysSrv;
static Service g_setcalSrv;
static bool g_setLanguageCodesInitialized; static bool g_setLanguageCodesInitialized;
static u64 g_setLanguageCodes[0x40]; static u64 g_setLanguageCodes[0x40];
@ -44,6 +45,20 @@ Service* setsysGetServiceSession(void) {
return &g_setsysSrv; return &g_setsysSrv;
} }
NX_GENERATE_SERVICE_GUARD(setcal);
Result _setcalInitialize(void) {
return smGetService(&g_setcalSrv, "set:cal");
}
void _setcalCleanup(void) {
serviceClose(&g_setcalSrv);
}
Service* setcalGetServiceSession(void) {
return &g_setcalSrv;
}
static Result _setCmdGetHandle(Service* srv, Handle* handle_out, u32 cmd_id) { static Result _setCmdGetHandle(Service* srv, Handle* handle_out, u32 cmd_id) {
return serviceDispatch(srv, cmd_id, return serviceDispatch(srv, cmd_id,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy }, .out_handle_attrs = { SfOutHandleAttr_HipcCopy },
@ -765,3 +780,52 @@ Result setsysSetTouchScreenMode(SetSysTouchScreenMode mode) {
return _setCmdInU32NoOut(&g_setsysSrv, mode, 188); return _setCmdInU32NoOut(&g_setsysSrv, mode, 188);
} }
Result setcalGetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out) {
return serviceDispatch(&g_setcalSrv, 14,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalEccB233DeviceCertificate) } },
);
}
Result setcalGetEticketDeviceCertificate(SetCalRsa2048DeviceCertificate *out) {
return serviceDispatch(&g_setcalSrv, 15,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalRsa2048DeviceCertificate) } },
);
}
Result setcalGetSslKey(SetCalSslKey *out) {
return serviceDispatch(&g_setcalSrv, 16,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalSslKey) } },
);
}
Result setcalGetSslCertificate(SetCalSslCertificate *out) {
return serviceDispatch(&g_setcalSrv, 17,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalSslCertificate) } },
);
}
Result setcalGetGameCardKey(SetCalGameCardKey *out) {
return serviceDispatch(&g_setcalSrv, 18,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalGameCardKey) } },
);
}
Result setcalGetGameCardCertificate(SetCalGameCardCertificate *out) {
return serviceDispatch(&g_setcalSrv, 19,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalGameCardCertificate) } },
);
}
Result setcalGetEticketDeviceKey(SetCalRsa2048DeviceKey *out) {
return serviceDispatch(&g_setcalSrv, 21,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalRsa2048DeviceKey) } },
);
}