time: Updated for new-ipc. Renamed _timeGetClockSession to timeGetServiceSession_SystemClock, and added it to the .h. Added timeGetServiceSession_TimeZoneService. Fixed the order of cmds. Fixed param types for timeGetTotalLocationNameCount, timeLoadLocationNameList, timeToPosixTime, and timeToPosixTimeWithMyRule. The location_name_size param for timeLoadLocationNameList was replaced with location_name_max, which is max entries instead of buffer byte-size. Internal improvements and improved docs.

This commit is contained in:
yellows8 2019-10-06 22:06:22 -04:00
parent ae582d8cb4
commit 040b33c457
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 130 additions and 431 deletions

View File

@ -7,7 +7,7 @@
#pragma once #pragma once
#include "../types.h" #include "../types.h"
#include "../services/sm.h" #include "../sf/service.h"
/// Time clock type. /// Time clock type.
typedef enum { typedef enum {
@ -28,11 +28,11 @@ typedef struct {
} TimeCalendarTime; } TimeCalendarTime;
typedef struct { typedef struct {
u32 wday; ///< 0-based day-of-week. u32 wday; ///< 0-based day-of-week.
u32 yday; ///< 0-based day-of-year. u32 yday; ///< 0-based day-of-year.
char timezoneName[8]; ///< Timezone name string. char timezoneName[8]; ///< Timezone name string.
u32 DST; ///< 0 = no DST, 1 = DST. u32 DST; ///< 0 = no DST, 1 = DST.
s32 offset; ///< Seconds relative to UTC for this timezone. s32 offset; ///< Seconds relative to UTC for this timezone.
} TimeCalendarAdditionalInfo; } TimeCalendarAdditionalInfo;
typedef struct { typedef struct {
@ -43,11 +43,27 @@ typedef struct {
char name[0x24]; char name[0x24];
} TimeLocationName; } TimeLocationName;
/// Initialize time. Used automatically during app startup.
Result timeInitialize(void); Result timeInitialize(void);
/// Exit time. Used automatically during app startup.
void timeExit(void); void timeExit(void);
/// Gets the Service object for the actual time service session.
Service* timeGetServiceSession(void); Service* timeGetServiceSession(void);
/// Gets the Service object for ISystemClock with the specified \ref TimeType. This will return NULL when the type is invalid.
Service* timeGetServiceSession_SystemClock(TimeType type);
/// Gets the Service object for ITimeZoneService.
Service* timeGetServiceSession_TimeZoneService(void);
/**
* @brief Gets the time for the specified clock.
* @param[in] type Clock to use.
* @param[out] timestamp POSIX UTC timestamp.
* @return Result code.
*/
Result timeGetCurrentTime(TimeType type, u64 *timestamp); Result timeGetCurrentTime(TimeType type, u64 *timestamp);
/** /**
@ -60,13 +76,13 @@ Result timeSetCurrentTime(TimeType type, u64 timestamp);
Result timeGetDeviceLocationName(TimeLocationName *name); Result timeGetDeviceLocationName(TimeLocationName *name);
Result timeSetDeviceLocationName(const TimeLocationName *name); Result timeSetDeviceLocationName(const TimeLocationName *name);
Result timeGetTotalLocationNameCount(u32 *total_location_name_count); Result timeGetTotalLocationNameCount(s32 *total_location_name_count);
Result timeLoadLocationNameList(u32 index, TimeLocationName *location_name_array, size_t location_name_size, u32 *location_name_count); Result timeLoadLocationNameList(s32 index, TimeLocationName *location_name_array, s32 location_name_max, s32 *location_name_count);
Result timeLoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule); Result timeLoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule);
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count);
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count);
Result timeToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info); Result timeToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info); Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count);
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count);

View File

@ -1,28 +1,19 @@
#include <string.h> #define NX_SERVICE_ASSUME_NON_DOMAIN
#include "types.h" #include "service_guard.h"
#include "result.h"
#include "arm/atomics.h"
#include "kernel/ipc.h"
#include "services/time.h" #include "services/time.h"
#include "services/sm.h"
static Service g_timeSrv; static Service g_timeSrv;
static Service g_timeUserSystemClock; static Service g_timeUserSystemClock;
static Service g_timeNetworkSystemClock; static Service g_timeNetworkSystemClock;
static Service g_timeTimeZoneService; static Service g_timeTimeZoneService;
static Service g_timeLocalSystemClock; static Service g_timeLocalSystemClock;
static u64 g_refCnt;
static Result _timeGetSession(Service* srv_out, u64 cmd_id); static Result _timeCmdGetSession(Service* srv, Service* srv_out, u32 cmd_id);
Result timeInitialize(void) NX_GENERATE_SERVICE_GUARD(time);
{
atomicIncrement64(&g_refCnt);
if (serviceIsActive(&g_timeSrv)) Result _timeInitialize(void) {
return 0; Result rc=0;
Result rc;
rc = smGetService(&g_timeSrv, "time:s"); rc = smGetService(&g_timeSrv, "time:s");
if (R_FAILED(rc)) if (R_FAILED(rc))
@ -31,75 +22,33 @@ Result timeInitialize(void)
if (R_FAILED(rc)) if (R_FAILED(rc))
return rc; return rc;
rc = _timeGetSession(&g_timeUserSystemClock, 0); rc = _timeCmdGetSession(&g_timeSrv, &g_timeUserSystemClock, 0);
if (R_SUCCEEDED(rc)) if (R_SUCCEEDED(rc))
rc = _timeGetSession(&g_timeNetworkSystemClock, 1); rc = _timeCmdGetSession(&g_timeSrv, &g_timeNetworkSystemClock, 1);
if (R_SUCCEEDED(rc)) if (R_SUCCEEDED(rc))
rc = _timeGetSession(&g_timeTimeZoneService, 3); rc = _timeCmdGetSession(&g_timeSrv, &g_timeTimeZoneService, 3);
if (R_SUCCEEDED(rc)) if (R_SUCCEEDED(rc))
rc = _timeGetSession(&g_timeLocalSystemClock, 4); rc = _timeCmdGetSession(&g_timeSrv, &g_timeLocalSystemClock, 4);
if (R_FAILED(rc))
timeExit();
return rc; return rc;
} }
void timeExit(void) void _timeCleanup(void) {
{ serviceClose(&g_timeLocalSystemClock);
if (atomicDecrement64(&g_refCnt) == 0) serviceClose(&g_timeTimeZoneService);
{ serviceClose(&g_timeNetworkSystemClock);
serviceClose(&g_timeLocalSystemClock); serviceClose(&g_timeUserSystemClock);
serviceClose(&g_timeTimeZoneService); serviceClose(&g_timeSrv);
serviceClose(&g_timeNetworkSystemClock);
serviceClose(&g_timeUserSystemClock);
serviceClose(&g_timeSrv);
}
} }
Service* timeGetServiceSession(void) { Service* timeGetServiceSession(void) {
return &g_timeSrv; return &g_timeSrv;
} }
static Result _timeGetSession(Service* srv_out, u64 cmd_id) { Service* timeGetServiceSession_SystemClock(TimeType type) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = cmd_id;
Result rc = serviceIpcDispatch(&g_timeSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc)) {
serviceCreate(srv_out, r.Handles[0]);
}
}
return rc;
}
static Service* _timeGetClockSession(TimeType type) {
if (type==TimeType_UserSystemClock) { if (type==TimeType_UserSystemClock) {
return &g_timeUserSystemClock; return &g_timeUserSystemClock;
} }
@ -114,409 +63,143 @@ static Service* _timeGetClockSession(TimeType type) {
} }
} }
Service* timeGetServiceSession_TimeZoneService(void) {
return &g_timeTimeZoneService;
}
static Result _timeCmdGetSession(Service* srv, Service* srv_out, u32 cmd_id) {
return serviceDispatch(srv, cmd_id,
.out_num_objects = 1,
.out_objects = srv_out,
);
}
static Result _timeCmdInU64NoOut(Service* srv, u64 inval, u32 cmd_id) {
return serviceDispatchIn(srv, cmd_id, inval);
}
static Result _timeCmdNoInOutU64(Service* srv, u64 *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out);
}
static Result _appletCmdNoInOutU32(Service* srv, u32 *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out);
}
Result timeGetCurrentTime(TimeType type, u64 *timestamp) { Result timeGetCurrentTime(TimeType type, u64 *timestamp) {
Service *srv = _timeGetClockSession(type); Service *srv = timeGetServiceSession_SystemClock(type);
if (srv==NULL) if (srv==NULL)
return MAKERESULT(Module_Libnx, LibnxError_BadInput); return MAKERESULT(Module_Libnx, LibnxError_BadInput);
IpcCommand c; return _timeCmdNoInOutU64(srv, timestamp, 0);
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 0;
Result rc = serviceIpcDispatch(srv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
u64 timestamp;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && timestamp) *timestamp = resp->timestamp;
}
return rc;
} }
Result timeSetCurrentTime(TimeType type, u64 timestamp) { Result timeSetCurrentTime(TimeType type, u64 timestamp) {
Service *srv = _timeGetClockSession(type); Service *srv = timeGetServiceSession_SystemClock(type);
if (srv==NULL) if (srv==NULL)
return MAKERESULT(Module_Libnx, LibnxError_BadInput); return MAKERESULT(Module_Libnx, LibnxError_BadInput);
IpcCommand c; return _timeCmdInU64NoOut(srv, timestamp, 1);
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u64 timestamp;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 1;
raw->timestamp = timestamp;
Result rc = serviceIpcDispatch(srv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
}
return rc;
} }
Result timeGetDeviceLocationName(TimeLocationName *name) { Result timeGetDeviceLocationName(TimeLocationName *name) {
IpcCommand c; if (!serviceIsActive(&g_timeTimeZoneService))
ipcInitialize(&c); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
struct { return serviceDispatchOut(&g_timeTimeZoneService, 0, *name);
u64 magic;
u64 cmd_id;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 0;
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
TimeLocationName name;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && name) memcpy(name, &resp->name, sizeof(TimeLocationName));
}
return rc;
} }
Result timeSetDeviceLocationName(const TimeLocationName *name) { Result timeSetDeviceLocationName(const TimeLocationName *name) {
IpcCommand c; if (!serviceIsActive(&g_timeTimeZoneService))
ipcInitialize(&c); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
struct { return serviceDispatchIn(&g_timeTimeZoneService, 1, *name);
u64 magic;
u64 cmd_id;
TimeLocationName name;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 1;
memcpy(&raw->name, name, sizeof(TimeLocationName));
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
}
return rc;
} }
Result timeGetTotalLocationNameCount(u32 *total_location_name_count) { Result timeGetTotalLocationNameCount(s32 *total_location_name_count) {
IpcCommand c; if (!serviceIsActive(&g_timeTimeZoneService))
ipcInitialize(&c); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
struct { return _appletCmdNoInOutU32(&g_timeTimeZoneService, (u32*)total_location_name_count, 2);
u64 magic;
u64 cmd_id;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 2;
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
u32 total_location_name_count;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && total_location_name_count) *total_location_name_count = resp->total_location_name_count;
}
return rc;
} }
Result timeLoadLocationNameList(u32 index, TimeLocationName *location_name_array, size_t location_name_size, u32 *location_name_count) { Result timeLoadLocationNameList(s32 index, TimeLocationName *location_name_array, s32 location_name_max, s32 *location_name_count) {
IpcCommand c; if (!serviceIsActive(&g_timeTimeZoneService))
ipcInitialize(&c); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
ipcAddRecvBuffer(&c, location_name_array, location_name_size, BufferType_Normal);
struct { return serviceDispatchInOut(&g_timeTimeZoneService, 3, index, *location_name_count,
u64 magic; .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
u64 cmd_id; .buffers = { { location_name_array, sizeof(TimeLocationName)*location_name_max } },
u32 index; );
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 3;
raw->index = index;
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
u32 location_name_count;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && location_name_count) *location_name_count = resp->location_name_count;
}
return rc;
} }
Result timeLoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule) { Result timeLoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule) {
IpcCommand c; if (!serviceIsActive(&g_timeTimeZoneService))
ipcInitialize(&c); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
ipcAddRecvBuffer(&c, rule, sizeof(TimeZoneRule), BufferType_Normal);
struct { return serviceDispatchIn(&g_timeTimeZoneService, 4, *name,
u64 magic; .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
u64 cmd_id; .buffers = { { rule, sizeof(TimeZoneRule) } },
TimeLocationName name; );
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 4;
memcpy(&raw->name, name, sizeof(TimeLocationName));
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
}
return rc;
} }
Result timeToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info) { Result timeToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info) {
IpcCommand c; if (!serviceIsActive(&g_timeTimeZoneService))
ipcInitialize(&c); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
ipcAddSendBuffer(&c, rule, sizeof(TimeZoneRule), BufferType_Normal);
struct { struct {
u64 magic; TimeCalendarTime caltime;
u64 cmd_id; TimeCalendarAdditionalInfo info;
u64 timestamp; } out;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 100;
raw->timestamp = timestamp;
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
TimeCalendarTime caltime;
TimeCalendarAdditionalInfo info;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && caltime) memcpy(caltime, &resp->caltime, sizeof(TimeCalendarTime));
if (R_SUCCEEDED(rc) && info) memcpy(info, &resp->info, sizeof(TimeCalendarAdditionalInfo));
}
Result rc = serviceDispatchInOut(&g_timeTimeZoneService, 100, timestamp, out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = { { rule, sizeof(TimeZoneRule) } },
);
if (R_SUCCEEDED(rc) && caltime) *caltime = out.caltime;
if (R_SUCCEEDED(rc) && info) *info = out.info;
return rc; return rc;
} }
Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info) { Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u64 timestamp;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 101;
raw->timestamp = timestamp;
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
TimeCalendarTime caltime;
TimeCalendarAdditionalInfo info;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && caltime) memcpy(caltime, &resp->caltime, sizeof(TimeCalendarTime));
if (R_SUCCEEDED(rc) && info) memcpy(info, &resp->info, sizeof(TimeCalendarAdditionalInfo));
}
return rc;
}
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count) {
if (!serviceIsActive(&g_timeTimeZoneService)) if (!serviceIsActive(&g_timeTimeZoneService))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
IpcCommand c;
ipcInitialize(&c);
ipcAddSendBuffer(&c, rule, sizeof(TimeZoneRule), BufferType_Normal);
ipcAddRecvStatic(&c, timestamp_list, sizeof(u64)*timestamp_list_count, 0);
struct { struct {
u64 magic;
u64 cmd_id;
TimeCalendarTime caltime; TimeCalendarTime caltime;
} *raw; TimeCalendarAdditionalInfo info;
} out;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 201;
raw->caltime = *caltime;
Result rc = serviceIpcDispatch(&g_timeTimeZoneService);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
u32 timestamp_count;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && timestamp_count) *timestamp_count = resp->timestamp_count;
}
Result rc = serviceDispatchInOut(&g_timeTimeZoneService, 101, timestamp, out);
if (R_SUCCEEDED(rc) && caltime) *caltime = out.caltime;
if (R_SUCCEEDED(rc) && info) *info = out.info;
return rc; return rc;
} }
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count) { Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count) {
if (!serviceIsActive(&g_timeTimeZoneService)) if (!serviceIsActive(&g_timeTimeZoneService))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
IpcCommand c; return serviceDispatchInOut(&g_timeTimeZoneService, 201, *caltime, *timestamp_count,
ipcInitialize(&c); .buffer_attrs = {
ipcAddRecvStatic(&c, timestamp_list, sizeof(u64)*timestamp_list_count, 0); SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
SfBufferAttr_HipcPointer | SfBufferAttr_Out,
struct { },
u64 magic; .buffers = {
u64 cmd_id; { rule, sizeof(TimeZoneRule) },
TimeCalendarTime caltime; { timestamp_list, sizeof(u64)*timestamp_list_count },
} *raw; },
);
raw = ipcPrepareHeader(&c, sizeof(*raw)); }
raw->magic = SFCI_MAGIC; Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, s32 timestamp_list_count, s32 *timestamp_count) {
raw->cmd_id = 202; if (!serviceIsActive(&g_timeTimeZoneService))
raw->caltime = *caltime; return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
Result rc = serviceIpcDispatch(&g_timeTimeZoneService); return serviceDispatchInOut(&g_timeTimeZoneService, 202, *caltime, *timestamp_count,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out },
if (R_SUCCEEDED(rc)) { .buffers = { { timestamp_list, sizeof(u64)*timestamp_list_count } },
IpcParsedCommand r; );
ipcParse(&r);
struct {
u64 magic;
u64 result;
u32 timestamp_count;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && timestamp_count) *timestamp_count = resp->timestamp_count;
}
return rc;
} }