Merge pull request #225 from Dazzozo/am-title-database

AM: implement external title database IPC functions
This commit is contained in:
fincs 2015-12-01 11:33:49 +01:00
commit 50e804d4d2
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;
}