AM: implement external title database IPC functions

Correct use of these functions allows applications that require
the external (SD) title database (e.g. title installers) to check
if it exists, and if not, have it created.
This commit is contained in:
Daz Jones 2015-12-01 01:37:43 +00:00
parent 416cc38797
commit 5daecd8d24
2 changed files with 43 additions and 0 deletions

View File

@ -112,3 +112,15 @@ Result AM_GetTitleProductCode(u8 mediatype, u64 titleID, char* productCode);
* @param fileHandle Handle of the CIA file to read.
*/
Result AM_GetCiaFileInfo(u8 mediatype, AM_TitleEntry *titleEntry, Handle fileHandle);
/**
* @brief Initializes the external (SD) title database.
* @param overwrite Overwrites the database if it already exists.
*/
Result AM_InitializeExternalTitleDatabase(bool overwrite);
/**
* @brief Queries whether the external title database is available.
* @param[out] available Pointer to output the availability status to.
*/
Result AM_QueryAvailableExternalTitleDatabase(bool* available);

View File

@ -233,3 +233,34 @@ Result AM_GetCiaFileInfo(u8 mediatype, AM_TitleEntry *titleEntry, Handle fileHan
return (Result)cmdbuf[1];
}
Result AM_InitializeExternalTitleDatabase(bool overwrite)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x18,2,0); // 0x180080
cmdbuf[1] = 1; // No other media type is accepted
cmdbuf[2] = overwrite;
if(R_FAILED(ret = svcSendSyncRequest(amHandle))) return ret;
return (Result)cmdbuf[1];
}
Result AM_QueryAvailableExternalTitleDatabase(bool* available)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x19,1,0); // 0x190040
cmdbuf[1] = 1; // No other media type is accepted
if(R_FAILED(ret = svcSendSyncRequest(amHandle))) return ret;
if(R_FAILED(ret = (Result)cmdbuf[1])) return ret;
// Only accept this if the command was a success
if(available) *available = cmdbuf[2];
return ret;
}