1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-09-19 21:43:44 +01:00

Improved UMS interface.

This commit is contained in:
Pablo Curiel 2020-12-23 14:43:12 -04:00
parent 736f2e155b
commit 6f43764e1b
4 changed files with 22 additions and 23 deletions

@ -1 +1 @@
Subproject commit 2c6eaf1396f06629241d94c8cec79fc49ee24c5c
Subproject commit d02e10f3c38ee54b8b2f72343a61d8626a27d1c3

View file

@ -86,7 +86,7 @@ NcmContentMetaDatabase *titleGetNcmDatabaseByStorageId(u8 storage_id);
/// Returns a pointer to a ncm storage handle using a NcmStorageId value.
NcmContentStorage *titleGetNcmStorageByStorageId(u8 storage_id);
/// Returns a pointer to a dynamically allocated buffer of pointers to TitleApplicationMetadata entries, as well as their count. The allocated buffer must be freed by the calling function.
/// Returns a pointer to a dynamically allocated array of pointers to TitleApplicationMetadata entries, as well as their count. The allocated buffer must be freed by the calling function.
/// If 'is_system' is true, TitleApplicationMetadata entries from available system titles (NcmStorageId_BuiltInSystem) will be returned.
/// Otherwise, TitleApplicationMetadata entries from user applications with available content data (NcmStorageId_Any) will be returned.
/// Returns NULL if an error occurs.
@ -104,7 +104,7 @@ bool titleGetUserApplicationData(u64 app_id, TitleUserApplicationData *out);
/// Orphan titles are patches or add-on contents with no NsApplicationControlData available for their parent user application ID.
bool titleAreOrphanTitlesAvailable(void);
/// Returns a pointer to a dynamically allocated buffer of pointers to TitleInfo entries from orphan titles, as well as their count. The allocated buffer must be freed by the calling function.
/// Returns a pointer to a dynamically allocated array of pointers to TitleInfo entries from orphan titles, as well as their count. The allocated buffer must be freed by the calling function.
/// Returns NULL if an error occurs.
TitleInfo **titleGetInfoFromOrphanTitles(u32 *out_count);

View file

@ -113,35 +113,36 @@ bool umsIsDeviceInfoUpdated(void)
return ret;
}
u32 umsGetDeviceCount(void)
{
mutexLock(&g_umsMutex);
u32 count = (g_umsInterfaceInit ? g_umsDeviceCount : 0);
mutexUnlock(&g_umsMutex);
return count;
}
bool umsGetDeviceByIndex(u32 idx, UsbHsFsDevice *out_device)
UsbHsFsDevice *umsGetDevices(u32 *out_count)
{
mutexLock(&g_umsMutex);
bool ret = false;
UsbHsFsDevice *devices = NULL;
if (!g_umsInterfaceInit || !g_umsDeviceCount || !g_umsDevices || idx >= g_umsDeviceCount || !out_device)
if (!g_umsInterfaceInit || !g_umsDeviceCount || !g_umsDevices || !out_count)
{
LOGFILE("Invalid parameters!");
goto end;
}
/* Copy device data. */
memcpy(out_device, &(g_umsDevices[idx]), sizeof(UsbHsFsDevice));
/* Allocate memory for the output devices. */
devices = calloc(g_umsDeviceCount, sizeof(UsbHsFsDevice));
if (!devices)
{
LOGFILE("Failed to allocate memory for %u devices!", g_umsDeviceCount);
goto end;
}
ret = true;
/* Copy device data. */
memcpy(devices, g_umsDevices, g_umsDeviceCount * sizeof(UsbHsFsDevice));
/* Update output device count. */
*out_count = g_umsDeviceCount;
end:
mutexUnlock(&g_umsMutex);
return ret;
return devices;
}
static bool umsCreateDetectionThread(void)

View file

@ -32,10 +32,8 @@ void umsExit(void);
/// Returns true if USB Mass Storage device info has been updated.
bool umsIsDeviceInfoUpdated(void);
/// Returns the available USB Mass Storage device count.
u32 umsGetDeviceCount(void);
/// Saves USB Mass Storage device info to 'out_device' using the provided index.
bool umsGetDeviceByIndex(u32 idx, UsbHsFsDevice *out_device);
/// Returns a pointer to a dynamically allocated array of UsbHsFsDevice elements. The allocated buffer must be freed by the calling function.
/// Returns NULL if an error occurs.
UsbHsFsDevice *umsGetDevices(u32 *out_count);
#endif /* __UMS_H__ */