Sources: Run clang-format on everything.

This commit is contained in:
Emmanuel Gil Peyrot
2016-09-18 09:38:01 +09:00
parent fe948af095
commit dc8479928c
386 changed files with 19560 additions and 18080 deletions

View File

@ -47,7 +47,7 @@ static void GetWifiStatus(Service::Interface* self) {
// it returns a valid result without implementing full functionality.
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = 0; // Connection type set to none
cmd_buff[2] = 0; // Connection type set to none
LOG_WARNING(Service_AC, "(STUBBED) called");
}
@ -62,29 +62,29 @@ static void IsConnected(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = false; // Not connected to ac:u service
cmd_buff[2] = false; // Not connected to ac:u service
LOG_WARNING(Service_AC, "(STUBBED) called");
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010000, nullptr, "CreateDefaultConfig"},
{0x00040006, nullptr, "ConnectAsync"},
{0x00050002, nullptr, "GetConnectResult"},
{0x00080004, CloseAsync, "CloseAsync"},
{0x00090002, nullptr, "GetCloseResult"},
{0x000A0000, nullptr, "GetLastErrorCode"},
{0x000D0000, GetWifiStatus, "GetWifiStatus"},
{0x000E0042, nullptr, "GetCurrentAPInfo"},
{0x00100042, nullptr, "GetCurrentNZoneInfo"},
{0x00110042, nullptr, "GetNZoneApNumService"},
{0x00240042, nullptr, "AddDenyApType"},
{0x00270002, nullptr, "GetInfraPriority"},
{0x002D0082, nullptr, "SetRequestEulaVersion"},
{0x00300004, nullptr, "RegisterDisconnectEvent"},
{0x003C0042, nullptr, "GetAPSSIDList"},
{0x003E0042, IsConnected, "IsConnected"},
{0x00400042, nullptr, "SetClientVersion"},
{0x00010000, nullptr, "CreateDefaultConfig"},
{0x00040006, nullptr, "ConnectAsync"},
{0x00050002, nullptr, "GetConnectResult"},
{0x00080004, CloseAsync, "CloseAsync"},
{0x00090002, nullptr, "GetCloseResult"},
{0x000A0000, nullptr, "GetLastErrorCode"},
{0x000D0000, GetWifiStatus, "GetWifiStatus"},
{0x000E0042, nullptr, "GetCurrentAPInfo"},
{0x00100042, nullptr, "GetCurrentNZoneInfo"},
{0x00110042, nullptr, "GetNZoneApNumService"},
{0x00240042, nullptr, "AddDenyApType"},
{0x00270002, nullptr, "GetInfraPriority"},
{0x002D0082, nullptr, "SetRequestEulaVersion"},
{0x00300004, nullptr, "RegisterDisconnectEvent"},
{0x003C0042, nullptr, "GetAPSSIDList"},
{0x003E0042, IsConnected, "IsConnected"},
{0x00400042, nullptr, "SetClientVersion"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -6,19 +6,19 @@
#include "common/logging/log.h"
#include "core/hle/service/service.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/am_app.h"
#include "core/hle/service/am/am_net.h"
#include "core/hle/service/am/am_sys.h"
#include "core/hle/service/am/am_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace AM {
static std::array<u32, 3> am_content_count = { 0, 0, 0 };
static std::array<u32, 3> am_titles_count = { 0, 0, 0 };
static std::array<u32, 3> am_titles_list_count = { 0, 0, 0 };
static std::array<u32, 3> am_content_count = {0, 0, 0};
static std::array<u32, 3> am_titles_count = {0, 0, 0};
static std::array<u32, 3> am_titles_list_count = {0, 0, 0};
static u32 am_ticket_count = 0;
static u32 am_ticket_list_count = 0;
@ -29,7 +29,8 @@ void GetTitleCount(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_titles_count[media_type];
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_count=0x%08x", media_type, am_titles_count[media_type]);
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_count=0x%08x", media_type,
am_titles_count[media_type]);
}
void FindContentInfos(Service::Interface* self) {
@ -43,8 +44,10 @@ void FindContentInfos(Service::Interface* self) {
am_content_count[media_type] = cmd_buff[4];
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016llx, content_cound=%u, content_ids_pointer=0x%08x, content_info_pointer=0x%08x",
media_type, title_id, am_content_count[media_type], content_ids_pointer, content_info_pointer);
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016llx, content_cound=%u, "
"content_ids_pointer=0x%08x, content_info_pointer=0x%08x",
media_type, title_id, am_content_count[media_type], content_ids_pointer,
content_info_pointer);
}
void ListContentInfos(Service::Interface* self) {
@ -59,8 +62,10 @@ void ListContentInfos(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_content_count[media_type];
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, content_count=%u, title_id=0x%016" PRIx64 ", start_index=0x%08x, content_info_pointer=0x%08X",
media_type, am_content_count[media_type], title_id, start_index, content_info_pointer);
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, content_count=%u, title_id=0x%016" PRIx64
", start_index=0x%08x, content_info_pointer=0x%08X",
media_type, am_content_count[media_type], title_id, start_index,
content_info_pointer);
}
void DeleteContents(Service::Interface* self) {
@ -73,8 +78,9 @@ void DeleteContents(Service::Interface* self) {
am_content_count[media_type] = cmd_buff[4];
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016" PRIx64 ", content_count=%u, content_ids_pointer=0x%08x",
media_type, title_id, am_content_count[media_type], content_ids_pointer);
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, title_id=0x%016" PRIx64
", content_count=%u, content_ids_pointer=0x%08x",
media_type, title_id, am_content_count[media_type], content_ids_pointer);
}
void GetTitleList(Service::Interface* self) {
@ -87,8 +93,10 @@ void GetTitleList(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_titles_list_count[media_type];
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, titles_list_count=0x%08X, title_ids_output_pointer=0x%08X",
media_type, am_titles_list_count[media_type], title_ids_output_pointer);
LOG_WARNING(
Service_AM,
"(STUBBED) media_type=%u, titles_list_count=0x%08X, title_ids_output_pointer=0x%08X",
media_type, am_titles_list_count[media_type], title_ids_output_pointer);
}
void GetTitleInfo(Service::Interface* self) {
@ -101,7 +109,8 @@ void GetTitleInfo(Service::Interface* self) {
am_titles_count[media_type] = cmd_buff[2];
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, total_titles=0x%08X, title_id_list_pointer=0x%08X, title_list_pointer=0x%08X",
LOG_WARNING(Service_AM, "(STUBBED) media_type=%u, total_titles=0x%08X, "
"title_id_list_pointer=0x%08X, title_list_pointer=0x%08X",
media_type, am_titles_count[media_type], title_id_list_pointer, title_list_pointer);
}
@ -122,8 +131,9 @@ void ListDataTitleTicketInfos(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_ticket_count;
LOG_WARNING(Service_AM, "(STUBBED) ticket_count=0x%08X, title_id=0x%016" PRIx64 ", start_index=0x%08X, ticket_info_pointer=0x%08X",
am_ticket_count, title_id, start_index, ticket_info_pointer);
LOG_WARNING(Service_AM, "(STUBBED) ticket_count=0x%08X, title_id=0x%016" PRIx64
", start_index=0x%08X, ticket_info_pointer=0x%08X",
am_ticket_count, title_id, start_index, ticket_info_pointer);
}
void GetNumContentInfos(Service::Interface* self) {
@ -140,7 +150,7 @@ void DeleteTicket(Service::Interface* self) {
u64 title_id = (static_cast<u64>(cmd_buff[2]) << 32) | cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_AM, "(STUBBED) called title_id=0x%016" PRIx64 "",title_id);
LOG_WARNING(Service_AM, "(STUBBED) called title_id=0x%016" PRIx64 "", title_id);
}
void GetTicketCount(Service::Interface* self) {
@ -148,7 +158,7 @@ void GetTicketCount(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_ticket_count;
LOG_WARNING(Service_AM, "(STUBBED) called ticket_count=0x%08x",am_ticket_count);
LOG_WARNING(Service_AM, "(STUBBED) called ticket_count=0x%08x", am_ticket_count);
}
void GetTicketList(Service::Interface* self) {
@ -161,8 +171,10 @@ void GetTicketList(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = am_ticket_list_count;
LOG_WARNING(Service_AM, "(STUBBED) ticket_list_count=0x%08x, num_of_skip=0x%08x, ticket_list_pointer=0x%08x",
am_ticket_list_count, num_of_skip, ticket_list_pointer);
LOG_WARNING(
Service_AM,
"(STUBBED) ticket_list_count=0x%08x, num_of_skip=0x%08x, ticket_list_pointer=0x%08x",
am_ticket_list_count, num_of_skip, ticket_list_pointer);
}
void Init() {
@ -175,7 +187,6 @@ void Init() {
}
void Shutdown() {
}
} // namespace AM

View File

@ -9,14 +9,14 @@ namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
{0x100100C0, GetNumContentInfos, "GetNumContentInfos"},
{0x10020104, FindContentInfos, "FindContentInfos"},
{0x10030142, ListContentInfos, "ListContentInfos"},
{0x10040102, DeleteContents, "DeleteContents"},
{0x10050084, GetDataTitleInfos, "GetDataTitleInfos"},
{0x10070102, ListDataTitleTicketInfos, "ListDataTitleTicketInfos"},
{0x100900C0, nullptr, "IsDataTitleInUse"},
{0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"},
{0x100100C0, GetNumContentInfos, "GetNumContentInfos"},
{0x10020104, FindContentInfos, "FindContentInfos"},
{0x10030142, ListContentInfos, "ListContentInfos"},
{0x10040102, DeleteContents, "DeleteContents"},
{0x10050084, GetDataTitleInfos, "GetDataTitleInfos"},
{0x10070102, ListDataTitleTicketInfos, "ListDataTitleTicketInfos"},
{0x100900C0, nullptr, "IsDataTitleInUse"},
{0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"},
};
AM_APP_Interface::AM_APP_Interface() {

View File

@ -9,61 +9,61 @@ namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetTitleCount, "GetTitleCount"},
{0x00020082, GetTitleList, "GetTitleList"},
{0x00030084, GetTitleInfo, "GetTitleInfo"},
{0x000400C0, nullptr, "DeleteApplicationTitle"},
{0x000500C0, nullptr, "GetTitleProductCode"},
{0x000600C0, nullptr, "GetTitleExtDataId"},
{0x00070080, DeleteTicket, "DeleteTicket"},
{0x00080000, GetTicketCount, "GetTicketCount"},
{0x00090082, GetTicketList, "GetTicketList"},
{0x000A0000, nullptr, "GetDeviceID"},
{0x000D0084, nullptr, "GetPendingTitleInfo"},
{0x000E00C0, nullptr, "DeletePendingTitle"},
{0x00140040, nullptr, "FinalizePendingTitles"},
{0x00150040, nullptr, "DeleteAllPendingTitles"},
{0x00180080, nullptr, "InitializeTitleDatabase"},
{0x00190040, nullptr, "ReloadDBS"},
{0x001A00C0, nullptr, "GetDSiWareExportSize"},
{0x001B0144, nullptr, "ExportDSiWare"},
{0x001C0084, nullptr, "ImportDSiWare"},
{0x00230080, nullptr, "TitleIDListGetTotal2"},
{0x002400C2, nullptr, "GetTitleIDList2"},
{0x04010080, nullptr, "InstallFIRM"},
{0x04020040, nullptr, "StartInstallCIADB0"},
{0x04030000, nullptr, "StartInstallCIADB1"},
{0x04040002, nullptr, "AbortCIAInstall"},
{0x04050002, nullptr, "CloseCIAFinalizeInstall"},
{0x04060002, nullptr, "CloseCIA"},
{0x040700C2, nullptr, "FinalizeTitlesInstall"},
{0x04080042, nullptr, "GetCiaFileInfo"},
{0x040E00C2, nullptr, "InstallTitlesFinish"},
{0x040F0000, nullptr, "InstallNATIVEFIRM"},
{0x041000C0, nullptr, "DeleteTitle"},
{0x04120000, nullptr, "Initialize"},
{0x041700C0, nullptr, "MigrateAGBtoSAV"},
{0x08010000, nullptr, "OpenTicket"},
{0x08020002, nullptr, "TicketAbortInstall"},
{0x08030002, nullptr, "TicketFinalizeInstall"},
{0x08040100, nullptr, "InstallTitleBegin"},
{0x08050000, nullptr, "InstallTitleAbort"},
{0x080600C0, nullptr, "InstallTitleResume"},
{0x08070000, nullptr, "InstallTitleAbortTMD"},
{0x08080000, nullptr, "InstallTitleFinish"},
{0x080A0000, nullptr, "OpenTMD"},
{0x080B0002, nullptr, "TMDAbortInstall"},
{0x080C0042, nullptr, "TMDFinalizeInstall"},
{0x080E0040, nullptr, "OpenContentCreate"},
{0x080F0002, nullptr, "ContentAbortInstall"},
{0x08100040, nullptr, "OpenContentResume"},
{0x08120002, nullptr, "ContentFinalizeInstall"},
{0x08130000, nullptr, "GetTotalContents"},
{0x08140042, nullptr, "GetContentIndexes"},
{0x08150044, nullptr, "GetContentsInfo"},
{0x08180042, nullptr, "GetCTCert"},
{0x08190108, nullptr, "SetCertificates"},
{0x081B00C2, nullptr, "InstallTitlesFinish"},
{0x00010040, GetTitleCount, "GetTitleCount"},
{0x00020082, GetTitleList, "GetTitleList"},
{0x00030084, GetTitleInfo, "GetTitleInfo"},
{0x000400C0, nullptr, "DeleteApplicationTitle"},
{0x000500C0, nullptr, "GetTitleProductCode"},
{0x000600C0, nullptr, "GetTitleExtDataId"},
{0x00070080, DeleteTicket, "DeleteTicket"},
{0x00080000, GetTicketCount, "GetTicketCount"},
{0x00090082, GetTicketList, "GetTicketList"},
{0x000A0000, nullptr, "GetDeviceID"},
{0x000D0084, nullptr, "GetPendingTitleInfo"},
{0x000E00C0, nullptr, "DeletePendingTitle"},
{0x00140040, nullptr, "FinalizePendingTitles"},
{0x00150040, nullptr, "DeleteAllPendingTitles"},
{0x00180080, nullptr, "InitializeTitleDatabase"},
{0x00190040, nullptr, "ReloadDBS"},
{0x001A00C0, nullptr, "GetDSiWareExportSize"},
{0x001B0144, nullptr, "ExportDSiWare"},
{0x001C0084, nullptr, "ImportDSiWare"},
{0x00230080, nullptr, "TitleIDListGetTotal2"},
{0x002400C2, nullptr, "GetTitleIDList2"},
{0x04010080, nullptr, "InstallFIRM"},
{0x04020040, nullptr, "StartInstallCIADB0"},
{0x04030000, nullptr, "StartInstallCIADB1"},
{0x04040002, nullptr, "AbortCIAInstall"},
{0x04050002, nullptr, "CloseCIAFinalizeInstall"},
{0x04060002, nullptr, "CloseCIA"},
{0x040700C2, nullptr, "FinalizeTitlesInstall"},
{0x04080042, nullptr, "GetCiaFileInfo"},
{0x040E00C2, nullptr, "InstallTitlesFinish"},
{0x040F0000, nullptr, "InstallNATIVEFIRM"},
{0x041000C0, nullptr, "DeleteTitle"},
{0x04120000, nullptr, "Initialize"},
{0x041700C0, nullptr, "MigrateAGBtoSAV"},
{0x08010000, nullptr, "OpenTicket"},
{0x08020002, nullptr, "TicketAbortInstall"},
{0x08030002, nullptr, "TicketFinalizeInstall"},
{0x08040100, nullptr, "InstallTitleBegin"},
{0x08050000, nullptr, "InstallTitleAbort"},
{0x080600C0, nullptr, "InstallTitleResume"},
{0x08070000, nullptr, "InstallTitleAbortTMD"},
{0x08080000, nullptr, "InstallTitleFinish"},
{0x080A0000, nullptr, "OpenTMD"},
{0x080B0002, nullptr, "TMDAbortInstall"},
{0x080C0042, nullptr, "TMDFinalizeInstall"},
{0x080E0040, nullptr, "OpenContentCreate"},
{0x080F0002, nullptr, "ContentAbortInstall"},
{0x08100040, nullptr, "OpenContentResume"},
{0x08120002, nullptr, "ContentFinalizeInstall"},
{0x08130000, nullptr, "GetTotalContents"},
{0x08140042, nullptr, "GetContentIndexes"},
{0x08150044, nullptr, "GetContentsInfo"},
{0x08180042, nullptr, "GetCTCert"},
{0x08190108, nullptr, "SetCertificates"},
{0x081B00C2, nullptr, "InstallTitlesFinish"},
};
AM_NET_Interface::AM_NET_Interface() {

View File

@ -8,29 +8,27 @@
namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetTitleCount, "GetTitleCount"},
{0x00020082, GetTitleList, "GetTitleList"},
{0x00030084, GetTitleInfo, "GetTitleInfo"},
{0x000400C0, nullptr, "DeleteApplicationTitle"},
{0x000500C0, nullptr, "GetTitleProductCode"},
{0x000600C0, nullptr, "GetTitleExtDataId"},
{0x00070080, DeleteTicket, "DeleteTicket"},
{0x00080000, GetTicketCount, "GetTicketCount"},
{0x00090082, GetTicketList, "GetTicketList"},
{0x000A0000, nullptr, "GetDeviceID"},
{0x000D0084, nullptr, "GetPendingTitleInfo"},
{0x000E00C0, nullptr, "DeletePendingTitle"},
{0x00140040, nullptr, "FinalizePendingTitles"},
{0x00150040, nullptr, "DeleteAllPendingTitles"},
{0x00180080, nullptr, "InitializeTitleDatabase"},
{0x00190040, nullptr, "ReloadDBS"},
{0x001A00C0, nullptr, "GetDSiWareExportSize"},
{0x001B0144, nullptr, "ExportDSiWare"},
{0x001C0084, nullptr, "ImportDSiWare"},
{0x00230080, nullptr, "GetPendingTitleCount"},
{0x002400C2, nullptr, "GetPendingTitleList"}
};
const Interface::FunctionInfo FunctionTable[] = {{0x00010040, GetTitleCount, "GetTitleCount"},
{0x00020082, GetTitleList, "GetTitleList"},
{0x00030084, GetTitleInfo, "GetTitleInfo"},
{0x000400C0, nullptr, "DeleteApplicationTitle"},
{0x000500C0, nullptr, "GetTitleProductCode"},
{0x000600C0, nullptr, "GetTitleExtDataId"},
{0x00070080, DeleteTicket, "DeleteTicket"},
{0x00080000, GetTicketCount, "GetTicketCount"},
{0x00090082, GetTicketList, "GetTicketList"},
{0x000A0000, nullptr, "GetDeviceID"},
{0x000D0084, nullptr, "GetPendingTitleInfo"},
{0x000E00C0, nullptr, "DeletePendingTitle"},
{0x00140040, nullptr, "FinalizePendingTitles"},
{0x00150040, nullptr, "DeleteAllPendingTitles"},
{0x00180080, nullptr, "InitializeTitleDatabase"},
{0x00190040, nullptr, "ReloadDBS"},
{0x001A00C0, nullptr, "GetDSiWareExportSize"},
{0x001B0144, nullptr, "ExportDSiWare"},
{0x001C0084, nullptr, "ImportDSiWare"},
{0x00230080, nullptr, "GetPendingTitleCount"},
{0x002400C2, nullptr, "GetPendingTitleList"}};
AM_SYS_Interface::AM_SYS_Interface() {
Register(FunctionTable);

View File

@ -8,42 +8,40 @@
namespace Service {
namespace AM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetTitleCount, "GetTitleCount"},
{0x00020082, GetTitleList, "GetTitleList"},
{0x00030084, GetTitleInfo, "GetTitleInfo"},
{0x000400C0, nullptr, "DeleteApplicationTitle"},
{0x000500C0, nullptr, "GetTitleProductCode"},
{0x000600C0, nullptr, "GetTitleExtDataId"},
{0x00070080, DeleteTicket, "DeleteTicket"},
{0x00080000, GetTicketCount, "GetTicketCount"},
{0x00090082, GetTicketList, "GetTicketList"},
{0x000A0000, nullptr, "GetDeviceID"},
{0x000D0084, nullptr, "GetPendingTitleInfo"},
{0x000E00C0, nullptr, "DeletePendingTitle"},
{0x00140040, nullptr, "FinalizePendingTitles"},
{0x00150040, nullptr, "DeleteAllPendingTitles"},
{0x00180080, nullptr, "InitializeTitleDatabase"},
{0x00190040, nullptr, "ReloadDBS"},
{0x001A00C0, nullptr, "GetDSiWareExportSize"},
{0x001B0144, nullptr, "ExportDSiWare"},
{0x001C0084, nullptr, "ImportDSiWare"},
{0x00230080, nullptr, "TitleIDListGetTotal2"},
{0x002400C2, nullptr, "GetTitleIDList2"},
{0x04010080, nullptr, "InstallFIRM"},
{0x04020040, nullptr, "StartInstallCIADB0"},
{0x04030000, nullptr, "StartInstallCIADB1"},
{0x04040002, nullptr, "AbortCIAInstall"},
{0x04050002, nullptr, "CloseCIAFinalizeInstall"},
{0x04060002, nullptr, "CloseCIA"},
{0x040700C2, nullptr, "FinalizeTitlesInstall"},
{0x04080042, nullptr, "GetCiaFileInfo"},
{0x040E00C2, nullptr, "InstallTitlesFinish"},
{0x040F0000, nullptr, "InstallNATIVEFIRM"},
{0x041000C0, nullptr, "DeleteTitle"},
{0x04120000, nullptr, "Initialize"},
{0x041700C0, nullptr, "MigrateAGBtoSAV"}
};
const Interface::FunctionInfo FunctionTable[] = {{0x00010040, GetTitleCount, "GetTitleCount"},
{0x00020082, GetTitleList, "GetTitleList"},
{0x00030084, GetTitleInfo, "GetTitleInfo"},
{0x000400C0, nullptr, "DeleteApplicationTitle"},
{0x000500C0, nullptr, "GetTitleProductCode"},
{0x000600C0, nullptr, "GetTitleExtDataId"},
{0x00070080, DeleteTicket, "DeleteTicket"},
{0x00080000, GetTicketCount, "GetTicketCount"},
{0x00090082, GetTicketList, "GetTicketList"},
{0x000A0000, nullptr, "GetDeviceID"},
{0x000D0084, nullptr, "GetPendingTitleInfo"},
{0x000E00C0, nullptr, "DeletePendingTitle"},
{0x00140040, nullptr, "FinalizePendingTitles"},
{0x00150040, nullptr, "DeleteAllPendingTitles"},
{0x00180080, nullptr, "InitializeTitleDatabase"},
{0x00190040, nullptr, "ReloadDBS"},
{0x001A00C0, nullptr, "GetDSiWareExportSize"},
{0x001B0144, nullptr, "ExportDSiWare"},
{0x001C0084, nullptr, "ImportDSiWare"},
{0x00230080, nullptr, "TitleIDListGetTotal2"},
{0x002400C2, nullptr, "GetTitleIDList2"},
{0x04010080, nullptr, "InstallFIRM"},
{0x04020040, nullptr, "StartInstallCIADB0"},
{0x04030000, nullptr, "StartInstallCIADB1"},
{0x04040002, nullptr, "AbortCIAInstall"},
{0x04050002, nullptr, "CloseCIAFinalizeInstall"},
{0x04060002, nullptr, "CloseCIA"},
{0x040700C2, nullptr, "FinalizeTitlesInstall"},
{0x04080042, nullptr, "GetCiaFileInfo"},
{0x040E00C2, nullptr, "InstallTitlesFinish"},
{0x040F0000, nullptr, "InstallNATIVEFIRM"},
{0x041000C0, nullptr, "DeleteTitle"},
{0x04120000, nullptr, "Initialize"},
{0x041700C0, nullptr, "MigrateAGBtoSAV"}};
AM_U_Interface::AM_U_Interface() {
Register(FunctionTable);

View File

@ -7,7 +7,6 @@
#include "common/logging/log.h"
#include "core/hle/applets/applet.h"
#include "core/hle/service/service.h"
#include "core/hle/service/apt/apt.h"
#include "core/hle/service/apt/apt_a.h"
#include "core/hle/service/apt/apt_s.h"
@ -15,6 +14,7 @@
#include "core/hle/service/apt/bcfnt/bcfnt.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/ptm/ptm.h"
#include "core/hle/service/service.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/mutex.h"
@ -30,7 +30,7 @@ static bool shared_font_relocated = false;
static Kernel::SharedPtr<Kernel::Mutex> lock;
static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event
static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event
static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event
static u32 cpu_percent; ///< CPU time available to the running application
@ -51,7 +51,7 @@ void SendParameter(const MessageParameter& parameter) {
void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
u32 flags = cmd_buff[2];
u32 flags = cmd_buff[2];
cmd_buff[2] = IPC::CopyHandleDesc(2);
cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom();
@ -75,20 +75,24 @@ void GetSharedFont(Service::Interface* self) {
if (!shared_font_mem) {
LOG_ERROR(Service_APT, "shared font file missing - go dump it from your 3ds");
cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2);
cmd_buff[1] = -1; // TODO: Find the right error code
cmd_buff[1] = -1; // TODO: Find the right error code
return;
}
// The shared font has to be relocated to the new address before being passed to the application.
VAddr target_address = Memory::PhysicalToVirtualAddress(shared_font_mem->linear_heap_phys_address);
// The shared font has to be relocated to the new address before being passed to the
// application.
VAddr target_address =
Memory::PhysicalToVirtualAddress(shared_font_mem->linear_heap_phys_address);
if (!shared_font_relocated) {
BCFNT::RelocateSharedFont(shared_font_mem, target_address);
shared_font_relocated = true;
}
cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
// Since the SharedMemory interface doesn't provide the address at which the memory was allocated,
// the real APT service calculates this address by scanning the entire address space (using svcQueryMemory)
// Since the SharedMemory interface doesn't provide the address at which the memory was
// allocated,
// the real APT service calculates this address by scanning the entire address space (using
// svcQueryMemory)
// and searches for an allocation of the same size as the Shared Font.
cmd_buff[2] = target_address;
cmd_buff[3] = IPC::CopyHandleDesc();
@ -112,18 +116,19 @@ void GetLockHandle(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = applet_attributes; // Applet Attributes, this value is passed to Enable.
cmd_buff[3] = 0; // Least significant bit = power button state
cmd_buff[3] = 0; // Least significant bit = power button state
cmd_buff[4] = IPC::CopyHandleDesc();
cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom();
LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", cmd_buff[5], applet_attributes);
LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", cmd_buff[5],
applet_attributes);
}
void Enable(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 attributes = cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
parameter_event->Signal(); // Let the application know that it has been started
parameter_event->Signal(); // Let the application know that it has been started
LOG_WARNING(Service_APT, "(STUBBED) called attributes=0x%08X", attributes);
}
@ -133,7 +138,7 @@ void GetAppletManInfo(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = 0;
cmd_buff[3] = 0;
cmd_buff[4] = static_cast<u32>(AppletId::HomeMenu); // Home menu AppID
cmd_buff[4] = static_cast<u32>(AppletId::HomeMenu); // Home menu AppID
cmd_buff[5] = static_cast<u32>(AppletId::Application); // TODO(purpasmart96): Do this correctly
LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk);
@ -159,23 +164,24 @@ void IsRegistered(Service::Interface* self) {
void InquireNotification(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = static_cast<u32>(SignalType::None); // Signal type
LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
}
void SendParameter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 src_app_id = cmd_buff[1];
u32 dst_app_id = cmd_buff[2];
u32 signal_type = cmd_buff[3];
u32 buffer_size = cmd_buff[4];
u32 value = cmd_buff[5];
u32 handle = cmd_buff[6];
u32 size = cmd_buff[7];
u32 buffer = cmd_buff[8];
u32 src_app_id = cmd_buff[1];
u32 dst_app_id = cmd_buff[2];
u32 signal_type = cmd_buff[3];
u32 buffer_size = cmd_buff[4];
u32 value = cmd_buff[5];
u32 handle = cmd_buff[6];
u32 size = cmd_buff[7];
u32 buffer = cmd_buff[8];
std::shared_ptr<HLE::Applets::Applet> dest_applet = HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id));
std::shared_ptr<HLE::Applets::Applet> dest_applet =
HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id));
if (dest_applet == nullptr) {
LOG_ERROR(Service_APT, "Unknown applet id=0x%08X", dst_app_id);
@ -193,9 +199,11 @@ void SendParameter(Service::Interface* self) {
cmd_buff[1] = dest_applet->ReceiveParameter(param).raw;
LOG_WARNING(Service_APT, "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X,"
"buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X",
src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, buffer);
LOG_WARNING(
Service_APT,
"(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X,"
"buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X",
src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, buffer);
}
void ReceiveParameter(Service::Interface* self) {
@ -206,7 +214,7 @@ void ReceiveParameter(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = next_parameter.sender_id;
cmd_buff[3] = next_parameter.signal; // Signal type
cmd_buff[3] = next_parameter.signal; // Signal type
cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
cmd_buff[5] = 0x10;
cmd_buff[6] = 0;
@ -228,7 +236,7 @@ void GlanceParameter(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = next_parameter.sender_id;
cmd_buff[3] = next_parameter.signal; // Signal type
cmd_buff[3] = next_parameter.signal; // Signal type
cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
cmd_buff[5] = 0x10;
cmd_buff[6] = 0;
@ -237,32 +245,34 @@ void GlanceParameter(Service::Interface* self) {
cmd_buff[7] = (next_parameter.buffer.size() << 14) | 2;
cmd_buff[8] = buffer;
Memory::WriteBlock(buffer, next_parameter.buffer.data(), std::min(static_cast<size_t>(buffer_size), next_parameter.buffer.size()));
Memory::WriteBlock(buffer, next_parameter.buffer.data(),
std::min(static_cast<size_t>(buffer_size), next_parameter.buffer.size()));
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
}
void CancelParameter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 flag1 = cmd_buff[1];
u32 unk = cmd_buff[2];
u32 flag2 = cmd_buff[3];
u32 flag1 = cmd_buff[1];
u32 unk = cmd_buff[2];
u32 flag2 = cmd_buff[3];
u32 app_id = cmd_buff[4];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = 1; // Set to Success
cmd_buff[2] = 1; // Set to Success
LOG_WARNING(Service_APT, "(STUBBED) called flag1=0x%08X, unk=0x%08X, flag2=0x%08X, app_id=0x%08X",
flag1, unk, flag2, app_id);
LOG_WARNING(Service_APT,
"(STUBBED) called flag1=0x%08X, unk=0x%08X, flag2=0x%08X, app_id=0x%08X", flag1,
unk, flag2, app_id);
}
void PrepareToStartApplication(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 title_info1 = cmd_buff[1];
u32 title_info2 = cmd_buff[2];
u32 title_info3 = cmd_buff[3];
u32 title_info4 = cmd_buff[4];
u32 flags = cmd_buff[5];
u32 title_info1 = cmd_buff[1];
u32 title_info2 = cmd_buff[2];
u32 title_info3 = cmd_buff[3];
u32 title_info4 = cmd_buff[4];
u32 flags = cmd_buff[5];
if (flags & 0x00000100) {
unknown_ns_state_field = 1;
@ -270,25 +280,28 @@ void PrepareToStartApplication(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_APT, "(STUBBED) called title_info1=0x%08X, title_info2=0x%08X, title_info3=0x%08X,"
"title_info4=0x%08X, flags=0x%08X", title_info1, title_info2, title_info3, title_info4, flags);
LOG_WARNING(Service_APT,
"(STUBBED) called title_info1=0x%08X, title_info2=0x%08X, title_info3=0x%08X,"
"title_info4=0x%08X, flags=0x%08X",
title_info1, title_info2, title_info3, title_info4, flags);
}
void StartApplication(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 buffer1_size = cmd_buff[1];
u32 buffer2_size = cmd_buff[2];
u32 flag = cmd_buff[3];
u32 size1 = cmd_buff[4];
u32 buffer1_ptr = cmd_buff[5];
u32 size2 = cmd_buff[6];
u32 buffer2_ptr = cmd_buff[7];
u32 flag = cmd_buff[3];
u32 size1 = cmd_buff[4];
u32 buffer1_ptr = cmd_buff[5];
u32 size2 = cmd_buff[6];
u32 buffer2_ptr = cmd_buff[7];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_APT, "(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X,"
"size1=0x%08X, buffer1_ptr=0x%08X, size2=0x%08X, buffer2_ptr=0x%08X",
buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr);
LOG_WARNING(Service_APT,
"(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X,"
"size1=0x%08X, buffer1_ptr=0x%08X, size2=0x%08X, buffer2_ptr=0x%08X",
buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr);
}
void AppletUtility(Service::Interface* self) {
@ -303,14 +316,15 @@ void AppletUtility(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_APT, "(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, "
"buffer1_addr=0x%08X, buffer2_addr=0x%08X", command, buffer1_size, buffer2_size,
buffer1_addr, buffer2_addr);
LOG_WARNING(Service_APT,
"(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, "
"buffer1_addr=0x%08X, buffer2_addr=0x%08X",
command, buffer1_size, buffer2_size, buffer1_addr, buffer2_addr);
}
void SetAppCpuTimeLimit(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 value = cmd_buff[1];
u32 value = cmd_buff[1];
cpu_percent = cmd_buff[2];
if (value != 1) {
@ -393,7 +407,8 @@ void SetScreenCapPostPermission(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x55, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u", screen_capture_post_permission);
LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u",
screen_capture_post_permission);
}
void GetScreenCapPostPermission(Service::Interface* self) {
@ -402,7 +417,8 @@ void GetScreenCapPostPermission(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x56, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = static_cast<u32>(screen_capture_post_permission);
LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u", screen_capture_post_permission);
LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u",
screen_capture_post_permission);
}
void GetAppletInfo(Service::Interface* self) {
@ -418,7 +434,8 @@ void GetAppletInfo(Service::Interface* self) {
cmd_buff[7] = 0; // Applet Attributes
} else {
cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
ErrorSummary::NotFound, ErrorLevel::Status).raw;
ErrorSummary::NotFound, ErrorLevel::Status)
.raw;
}
LOG_WARNING(Service_APT, "(stubbed) called appid=%u", app_id);
}
@ -429,11 +446,15 @@ void GetStartupArgument(Service::Interface* self) {
StartupArgumentType startup_argument_type = static_cast<StartupArgumentType>(cmd_buff[2]);
if (parameter_size >= 0x300) {
LOG_ERROR(Service_APT, "Parameter size is outside the valid range (capped to 0x300): parameter_size=0x%08x", parameter_size);
LOG_ERROR(
Service_APT,
"Parameter size is outside the valid range (capped to 0x300): parameter_size=0x%08x",
parameter_size);
return;
}
LOG_WARNING(Service_APT,"(stubbed) called startup_argument_type=%u , parameter_size=0x%08x , parameter_value=0x%08x",
LOG_WARNING(Service_APT, "(stubbed) called startup_argument_type=%u , parameter_size=0x%08x , "
"parameter_value=0x%08x",
startup_argument_type, parameter_size, Memory::Read32(cmd_buff[41]));
cmd_buff[1] = RESULT_SUCCESS.raw;
@ -484,8 +505,10 @@ void Init() {
if (file.IsOpen()) {
// Create shared font memory object
using Kernel::MemoryPermission;
shared_font_mem = Kernel::SharedMemory::Create(nullptr, 0x332000, // 3272 KB
MemoryPermission::ReadWrite, MemoryPermission::Read, 0, Kernel::MemoryRegion::SYSTEM, "APT:SharedFont");
shared_font_mem =
Kernel::SharedMemory::Create(nullptr, 0x332000, // 3272 KB
MemoryPermission::ReadWrite, MemoryPermission::Read, 0,
Kernel::MemoryRegion::SYSTEM, "APT:SharedFont");
// Read shared font data
file.ReadBytes(shared_font_mem->GetPointer(), file.GetSize());
} else {
@ -497,7 +520,8 @@ void Init() {
cpu_percent = 0;
unknown_ns_state_field = 0;
screen_capture_post_permission = ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value
screen_capture_post_permission =
ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value
// TODO(bunnei): Check if these are created in Initialize or on APT process startup.
notification_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Notification");

View File

@ -46,58 +46,58 @@ static_assert(sizeof(CaptureBufferInfo) == 0x20, "CaptureBufferInfo struct has i
/// Signals used by APT functions
enum class SignalType : u32 {
None = 0x0,
AppJustStarted = 0x1,
None = 0x0,
AppJustStarted = 0x1,
LibAppJustStarted = 0x2,
LibAppFinished = 0x3,
LibAppClosed = 0xA,
ReturningToApp = 0xB,
ExitingApp = 0xC,
LibAppFinished = 0x3,
LibAppClosed = 0xA,
ReturningToApp = 0xB,
ExitingApp = 0xC,
};
/// App Id's used by APT functions
enum class AppletId : u32 {
HomeMenu = 0x101,
AlternateMenu = 0x103,
Camera = 0x110,
FriendsList = 0x112,
GameNotes = 0x113,
InternetBrowser = 0x114,
InstructionManual = 0x115,
Notifications = 0x116,
Miiverse = 0x117,
MiiversePost = 0x118,
AmiiboSettings = 0x119,
SoftwareKeyboard1 = 0x201,
Ed1 = 0x202,
PnoteApp = 0x204,
SnoteApp = 0x205,
Error = 0x206,
Mint = 0x207,
Extrapad = 0x208,
Memolib = 0x209,
Application = 0x300,
AnyLibraryApplet = 0x400,
SoftwareKeyboard2 = 0x401,
Ed2 = 0x402,
PnoteApp2 = 0x404,
SnoteApp2 = 0x405,
Error2 = 0x406,
Mint2 = 0x407,
Extrapad2 = 0x408,
Memolib2 = 0x409,
HomeMenu = 0x101,
AlternateMenu = 0x103,
Camera = 0x110,
FriendsList = 0x112,
GameNotes = 0x113,
InternetBrowser = 0x114,
InstructionManual = 0x115,
Notifications = 0x116,
Miiverse = 0x117,
MiiversePost = 0x118,
AmiiboSettings = 0x119,
SoftwareKeyboard1 = 0x201,
Ed1 = 0x202,
PnoteApp = 0x204,
SnoteApp = 0x205,
Error = 0x206,
Mint = 0x207,
Extrapad = 0x208,
Memolib = 0x209,
Application = 0x300,
AnyLibraryApplet = 0x400,
SoftwareKeyboard2 = 0x401,
Ed2 = 0x402,
PnoteApp2 = 0x404,
SnoteApp2 = 0x405,
Error2 = 0x406,
Mint2 = 0x407,
Extrapad2 = 0x408,
Memolib2 = 0x409,
};
enum class StartupArgumentType : u32 {
OtherApp = 0,
Restart = 1,
OtherApp = 0,
Restart = 1,
OtherMedia = 2,
};
enum class ScreencapPostPermission : u32 {
CleanThePermission = 0, //TODO(JamePeng): verify what "zero" means
NoExplicitSetting = 1,
EnableScreenshotPostingToMiiverse = 2,
CleanThePermission = 0, // TODO(JamePeng): verify what "zero" means
NoExplicitSetting = 1,
EnableScreenshotPostingToMiiverse = 2,
DisableScreenshotPostingToMiiverse = 3
};
@ -182,9 +182,12 @@ void GetAppletManInfo(Service::Interface* self);
void GetAppletInfo(Service::Interface* self);
/**
* APT::IsRegistered service function. This returns whether the specified AppID is registered with NS yet.
* An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home Menu uses this
* command to determine when the launched process is running and to determine when to stop using GSP etc,
* APT::IsRegistered service function. This returns whether the specified AppID is registered with
* NS yet.
* An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home Menu
* uses this
* command to determine when the launched process is running and to determine when to stop using GSP
* etc,
* while displaying the "Nintendo 3DS" loading screen.
* Inputs:
* 1 : AppID
@ -260,9 +263,11 @@ void GlanceParameter(Service::Interface* self);
* clears the flag which indicates that parameter data is available
* (same flag cleared by APT:ReceiveParameter).
* Inputs:
* 1 : Flag, when non-zero NS will compare the word after this one with a field in the NS state.
* 1 : Flag, when non-zero NS will compare the word after this one with a field in the NS
* state.
* 2 : Unknown, this is the same as the first unknown field returned by APT:ReceiveParameter.
* 3 : Flag, when non-zero NS will compare the word after this one with a field in the NS state.
* 3 : Flag, when non-zero NS will compare the word after this one with a field in the NS
* state.
* 4 : AppID
* Outputs:
* 0 : Return header

View File

@ -9,35 +9,34 @@ namespace Service {
namespace APT {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetLockHandle, "GetLockHandle?"},
{0x00020080, Initialize, "Initialize?"},
{0x00030040, Enable, "Enable?"},
{0x00040040, nullptr, "Finalize?"},
{0x00050040, GetAppletManInfo, "GetAppletManInfo"},
{0x00060040, GetAppletInfo, "GetAppletInfo"},
{0x00090040, IsRegistered, "IsRegistered"},
{0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, SendParameter, "SendParameter"},
{0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, CancelParameter, "CancelParameter"},
{0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
{0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
{0x003B0040, nullptr, "CancelLibraryApplet?"},
{0x003E0080, nullptr, "ReplySleepQuery"},
{0x00430040, NotifyToWait, "NotifyToWait?"},
{0x00440000, GetSharedFont, "GetSharedFont?"},
{0x004B00C2, AppletUtility, "AppletUtility?"},
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
{0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"}
};
{0x00010040, GetLockHandle, "GetLockHandle?"},
{0x00020080, Initialize, "Initialize?"},
{0x00030040, Enable, "Enable?"},
{0x00040040, nullptr, "Finalize?"},
{0x00050040, GetAppletManInfo, "GetAppletManInfo"},
{0x00060040, GetAppletInfo, "GetAppletInfo"},
{0x00090040, IsRegistered, "IsRegistered"},
{0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, SendParameter, "SendParameter"},
{0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, CancelParameter, "CancelParameter"},
{0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
{0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
{0x003B0040, nullptr, "CancelLibraryApplet?"},
{0x003E0080, nullptr, "ReplySleepQuery"},
{0x00430040, NotifyToWait, "NotifyToWait?"},
{0x00440000, GetSharedFont, "GetSharedFont?"},
{0x004B00C2, AppletUtility, "AppletUtility?"},
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
{0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"}};
APT_A_Interface::APT_A_Interface() {
Register(FunctionTable);

View File

@ -9,95 +9,94 @@ namespace Service {
namespace APT {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetLockHandle, "GetLockHandle"},
{0x00020080, Initialize, "Initialize"},
{0x00030040, Enable, "Enable"},
{0x00040040, nullptr, "Finalize"},
{0x00050040, GetAppletManInfo, "GetAppletManInfo"},
{0x00060040, GetAppletInfo, "GetAppletInfo"},
{0x00070000, nullptr, "GetLastSignaledAppletId"},
{0x00080000, nullptr, "CountRegisteredApplet"},
{0x00090040, nullptr, "IsRegistered"},
{0x000A0040, nullptr, "GetAttribute"},
{0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, nullptr, "SendParameter"},
{0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, nullptr, "CancelParameter"},
{0x001000C2, nullptr, "DebugFunc"},
{0x001100C0, nullptr, "MapProgramIdForDebug"},
{0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
{0x00130000, nullptr, "GetPreparationState"},
{0x00140040, nullptr, "SetPreparationState"},
{0x00010040, GetLockHandle, "GetLockHandle"},
{0x00020080, Initialize, "Initialize"},
{0x00030040, Enable, "Enable"},
{0x00040040, nullptr, "Finalize"},
{0x00050040, GetAppletManInfo, "GetAppletManInfo"},
{0x00060040, GetAppletInfo, "GetAppletInfo"},
{0x00070000, nullptr, "GetLastSignaledAppletId"},
{0x00080000, nullptr, "CountRegisteredApplet"},
{0x00090040, nullptr, "IsRegistered"},
{0x000A0040, nullptr, "GetAttribute"},
{0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, nullptr, "SendParameter"},
{0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, nullptr, "CancelParameter"},
{0x001000C2, nullptr, "DebugFunc"},
{0x001100C0, nullptr, "MapProgramIdForDebug"},
{0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
{0x00130000, nullptr, "GetPreparationState"},
{0x00140040, nullptr, "SetPreparationState"},
{0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet,"PrepareToStartLibraryApplet"},
{0x00190040, nullptr, "PrepareToStartSystemApplet"},
{0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
{0x001B00C4, nullptr, "StartApplication"},
{0x001C0000, nullptr, "WakeupApplication"},
{0x001D0000, nullptr, "CancelApplication"},
{0x001E0084, nullptr, "StartLibraryApplet"},
{0x001F0084, nullptr, "StartSystemApplet"},
{0x00200044, nullptr, "StartNewestHomeMenu"},
{0x00210000, nullptr, "OrderToCloseApplication"},
{0x00220040, nullptr, "PrepareToCloseApplication"},
{0x00230040, nullptr, "PrepareToJumpToApplication"},
{0x00240044, nullptr, "JumpToApplication"},
{0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
{0x00260000, nullptr, "PrepareToCloseSystemApplet"},
{0x00270044, nullptr, "CloseApplication"},
{0x00280044, nullptr, "CloseLibraryApplet"},
{0x00290044, nullptr, "CloseSystemApplet"},
{0x002A0000, nullptr, "OrderToCloseSystemApplet"},
{0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
{0x002C0044, nullptr, "JumpToHomeMenu"},
{0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
{0x002E0044, nullptr, "LeaveHomeMenu"},
{0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
{0x00300044, nullptr, "LeaveResidentApplet"},
{0x00310100, nullptr, "PrepareToDoApplicationJump"},
{0x00320084, nullptr, "DoApplicationJump"},
{0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
{0x00340084, nullptr, "SendDeliverArg"},
{0x00350080, nullptr, "ReceiveDeliverArg"},
{0x00360040, nullptr, "LoadSysMenuArg"},
{0x00370042, nullptr, "StoreSysMenuArg"},
{0x00380040, nullptr, "PreloadResidentApplet"},
{0x00390040, nullptr, "PrepareToStartResidentApplet"},
{0x003A0044, nullptr, "StartResidentApplet"},
{0x003B0040, nullptr, "CancelLibraryApplet"},
{0x003C0042, nullptr, "SendDspSleep"},
{0x003D0042, nullptr, "SendDspWakeUp"},
{0x003E0080, nullptr, "ReplySleepQuery"},
{0x003F0040, nullptr, "ReplySleepNotificationComplete"},
{0x00400042, nullptr, "SendCaptureBufferInfo"},
{0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
{0x00420080, nullptr, "SleepSystem"},
{0x00430040, NotifyToWait, "NotifyToWait"},
{0x00440000, GetSharedFont, "GetSharedFont"},
{0x00450040, nullptr, "GetWirelessRebootInfo"},
{0x00460104, nullptr, "Wrap"},
{0x00470104, nullptr, "Unwrap"},
{0x00480100, nullptr, "GetProgramInfo"},
{0x00490180, nullptr, "Reboot"},
{0x004A0040, nullptr, "GetCaptureInfo"},
{0x004B00C2, AppletUtility, "AppletUtility"},
{0x004C0000, nullptr, "SetFatalErrDispMode"},
{0x004D0080, nullptr, "GetAppletProgramInfo"},
{0x004E0000, nullptr, "HardwareResetAsync"},
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
{0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00520104, nullptr, "Wrap1"},
{0x00530104, nullptr, "Unwrap1"},
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
{0x00190040, nullptr, "PrepareToStartSystemApplet"},
{0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
{0x001B00C4, nullptr, "StartApplication"},
{0x001C0000, nullptr, "WakeupApplication"},
{0x001D0000, nullptr, "CancelApplication"},
{0x001E0084, nullptr, "StartLibraryApplet"},
{0x001F0084, nullptr, "StartSystemApplet"},
{0x00200044, nullptr, "StartNewestHomeMenu"},
{0x00210000, nullptr, "OrderToCloseApplication"},
{0x00220040, nullptr, "PrepareToCloseApplication"},
{0x00230040, nullptr, "PrepareToJumpToApplication"},
{0x00240044, nullptr, "JumpToApplication"},
{0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
{0x00260000, nullptr, "PrepareToCloseSystemApplet"},
{0x00270044, nullptr, "CloseApplication"},
{0x00280044, nullptr, "CloseLibraryApplet"},
{0x00290044, nullptr, "CloseSystemApplet"},
{0x002A0000, nullptr, "OrderToCloseSystemApplet"},
{0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
{0x002C0044, nullptr, "JumpToHomeMenu"},
{0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
{0x002E0044, nullptr, "LeaveHomeMenu"},
{0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
{0x00300044, nullptr, "LeaveResidentApplet"},
{0x00310100, nullptr, "PrepareToDoApplicationJump"},
{0x00320084, nullptr, "DoApplicationJump"},
{0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
{0x00340084, nullptr, "SendDeliverArg"},
{0x00350080, nullptr, "ReceiveDeliverArg"},
{0x00360040, nullptr, "LoadSysMenuArg"},
{0x00370042, nullptr, "StoreSysMenuArg"},
{0x00380040, nullptr, "PreloadResidentApplet"},
{0x00390040, nullptr, "PrepareToStartResidentApplet"},
{0x003A0044, nullptr, "StartResidentApplet"},
{0x003B0040, nullptr, "CancelLibraryApplet"},
{0x003C0042, nullptr, "SendDspSleep"},
{0x003D0042, nullptr, "SendDspWakeUp"},
{0x003E0080, nullptr, "ReplySleepQuery"},
{0x003F0040, nullptr, "ReplySleepNotificationComplete"},
{0x00400042, nullptr, "SendCaptureBufferInfo"},
{0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
{0x00420080, nullptr, "SleepSystem"},
{0x00430040, NotifyToWait, "NotifyToWait"},
{0x00440000, GetSharedFont, "GetSharedFont"},
{0x00450040, nullptr, "GetWirelessRebootInfo"},
{0x00460104, nullptr, "Wrap"},
{0x00470104, nullptr, "Unwrap"},
{0x00480100, nullptr, "GetProgramInfo"},
{0x00490180, nullptr, "Reboot"},
{0x004A0040, nullptr, "GetCaptureInfo"},
{0x004B00C2, AppletUtility, "AppletUtility"},
{0x004C0000, nullptr, "SetFatalErrDispMode"},
{0x004D0080, nullptr, "GetAppletProgramInfo"},
{0x004E0000, nullptr, "HardwareResetAsync"},
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
{0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00520104, nullptr, "Wrap1"},
{0x00530104, nullptr, "Unwrap1"},
{0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x00580002, nullptr, "GetProgramID"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"}
};
{0x00580002, nullptr, "GetProgramID"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"}};
APT_S_Interface::APT_S_Interface() {
Register(FunctionTable);

View File

@ -9,95 +9,94 @@ namespace Service {
namespace APT {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetLockHandle, "GetLockHandle"},
{0x00020080, Initialize, "Initialize"},
{0x00030040, Enable, "Enable"},
{0x00040040, nullptr, "Finalize"},
{0x00050040, GetAppletManInfo, "GetAppletManInfo"},
{0x00060040, GetAppletInfo, "GetAppletInfo"},
{0x00070000, nullptr, "GetLastSignaledAppletId"},
{0x00080000, nullptr, "CountRegisteredApplet"},
{0x00090040, IsRegistered, "IsRegistered"},
{0x000A0040, nullptr, "GetAttribute"},
{0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, SendParameter, "SendParameter"},
{0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, CancelParameter, "CancelParameter"},
{0x001000C2, nullptr, "DebugFunc"},
{0x001100C0, nullptr, "MapProgramIdForDebug"},
{0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
{0x00130000, nullptr, "GetPreparationState"},
{0x00140040, nullptr, "SetPreparationState"},
{0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
{0x00190040, nullptr, "PrepareToStartSystemApplet"},
{0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
{0x001B00C4, nullptr, "StartApplication"},
{0x001C0000, nullptr, "WakeupApplication"},
{0x001D0000, nullptr, "CancelApplication"},
{0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
{0x001F0084, nullptr, "StartSystemApplet"},
{0x00200044, nullptr, "StartNewestHomeMenu"},
{0x00210000, nullptr, "OrderToCloseApplication"},
{0x00220040, nullptr, "PrepareToCloseApplication"},
{0x00230040, nullptr, "PrepareToJumpToApplication"},
{0x00240044, nullptr, "JumpToApplication"},
{0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
{0x00260000, nullptr, "PrepareToCloseSystemApplet"},
{0x00270044, nullptr, "CloseApplication"},
{0x00280044, nullptr, "CloseLibraryApplet"},
{0x00290044, nullptr, "CloseSystemApplet"},
{0x002A0000, nullptr, "OrderToCloseSystemApplet"},
{0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
{0x002C0044, nullptr, "JumpToHomeMenu"},
{0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
{0x002E0044, nullptr, "LeaveHomeMenu"},
{0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
{0x00300044, nullptr, "LeaveResidentApplet"},
{0x00310100, nullptr, "PrepareToDoApplicationJump"},
{0x00320084, nullptr, "DoApplicationJump"},
{0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
{0x00340084, nullptr, "SendDeliverArg"},
{0x00350080, nullptr, "ReceiveDeliverArg"},
{0x00360040, nullptr, "LoadSysMenuArg"},
{0x00370042, nullptr, "StoreSysMenuArg"},
{0x00380040, nullptr, "PreloadResidentApplet"},
{0x00390040, nullptr, "PrepareToStartResidentApplet"},
{0x003A0044, nullptr, "StartResidentApplet"},
{0x003B0040, nullptr, "CancelLibraryApplet"},
{0x003C0042, nullptr, "SendDspSleep"},
{0x003D0042, nullptr, "SendDspWakeUp"},
{0x003E0080, nullptr, "ReplySleepQuery"},
{0x003F0040, nullptr, "ReplySleepNotificationComplete"},
{0x00400042, nullptr, "SendCaptureBufferInfo"},
{0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
{0x00420080, nullptr, "SleepSystem"},
{0x00430040, NotifyToWait, "NotifyToWait"},
{0x00440000, GetSharedFont, "GetSharedFont"},
{0x00450040, nullptr, "GetWirelessRebootInfo"},
{0x00460104, nullptr, "Wrap"},
{0x00470104, nullptr, "Unwrap"},
{0x00480100, nullptr, "GetProgramInfo"},
{0x00490180, nullptr, "Reboot"},
{0x004A0040, nullptr, "GetCaptureInfo"},
{0x004B00C2, AppletUtility, "AppletUtility"},
{0x004C0000, nullptr, "SetFatalErrDispMode"},
{0x004D0080, nullptr, "GetAppletProgramInfo"},
{0x004E0000, nullptr, "HardwareResetAsync"},
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
{0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00520104, nullptr, "Wrap1"},
{0x00530104, nullptr, "Unwrap1"},
{0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x00580002, nullptr, "GetProgramID"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"}
};
{0x00010040, GetLockHandle, "GetLockHandle"},
{0x00020080, Initialize, "Initialize"},
{0x00030040, Enable, "Enable"},
{0x00040040, nullptr, "Finalize"},
{0x00050040, GetAppletManInfo, "GetAppletManInfo"},
{0x00060040, GetAppletInfo, "GetAppletInfo"},
{0x00070000, nullptr, "GetLastSignaledAppletId"},
{0x00080000, nullptr, "CountRegisteredApplet"},
{0x00090040, IsRegistered, "IsRegistered"},
{0x000A0040, nullptr, "GetAttribute"},
{0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, SendParameter, "SendParameter"},
{0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, CancelParameter, "CancelParameter"},
{0x001000C2, nullptr, "DebugFunc"},
{0x001100C0, nullptr, "MapProgramIdForDebug"},
{0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
{0x00130000, nullptr, "GetPreparationState"},
{0x00140040, nullptr, "SetPreparationState"},
{0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
{0x00190040, nullptr, "PrepareToStartSystemApplet"},
{0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
{0x001B00C4, nullptr, "StartApplication"},
{0x001C0000, nullptr, "WakeupApplication"},
{0x001D0000, nullptr, "CancelApplication"},
{0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
{0x001F0084, nullptr, "StartSystemApplet"},
{0x00200044, nullptr, "StartNewestHomeMenu"},
{0x00210000, nullptr, "OrderToCloseApplication"},
{0x00220040, nullptr, "PrepareToCloseApplication"},
{0x00230040, nullptr, "PrepareToJumpToApplication"},
{0x00240044, nullptr, "JumpToApplication"},
{0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
{0x00260000, nullptr, "PrepareToCloseSystemApplet"},
{0x00270044, nullptr, "CloseApplication"},
{0x00280044, nullptr, "CloseLibraryApplet"},
{0x00290044, nullptr, "CloseSystemApplet"},
{0x002A0000, nullptr, "OrderToCloseSystemApplet"},
{0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
{0x002C0044, nullptr, "JumpToHomeMenu"},
{0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
{0x002E0044, nullptr, "LeaveHomeMenu"},
{0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
{0x00300044, nullptr, "LeaveResidentApplet"},
{0x00310100, nullptr, "PrepareToDoApplicationJump"},
{0x00320084, nullptr, "DoApplicationJump"},
{0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
{0x00340084, nullptr, "SendDeliverArg"},
{0x00350080, nullptr, "ReceiveDeliverArg"},
{0x00360040, nullptr, "LoadSysMenuArg"},
{0x00370042, nullptr, "StoreSysMenuArg"},
{0x00380040, nullptr, "PreloadResidentApplet"},
{0x00390040, nullptr, "PrepareToStartResidentApplet"},
{0x003A0044, nullptr, "StartResidentApplet"},
{0x003B0040, nullptr, "CancelLibraryApplet"},
{0x003C0042, nullptr, "SendDspSleep"},
{0x003D0042, nullptr, "SendDspWakeUp"},
{0x003E0080, nullptr, "ReplySleepQuery"},
{0x003F0040, nullptr, "ReplySleepNotificationComplete"},
{0x00400042, nullptr, "SendCaptureBufferInfo"},
{0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
{0x00420080, nullptr, "SleepSystem"},
{0x00430040, NotifyToWait, "NotifyToWait"},
{0x00440000, GetSharedFont, "GetSharedFont"},
{0x00450040, nullptr, "GetWirelessRebootInfo"},
{0x00460104, nullptr, "Wrap"},
{0x00470104, nullptr, "Unwrap"},
{0x00480100, nullptr, "GetProgramInfo"},
{0x00490180, nullptr, "Reboot"},
{0x004A0040, nullptr, "GetCaptureInfo"},
{0x004B00C2, AppletUtility, "AppletUtility"},
{0x004C0000, nullptr, "SetFatalErrDispMode"},
{0x004D0080, nullptr, "GetAppletProgramInfo"},
{0x004E0000, nullptr, "HardwareResetAsync"},
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
{0x00510080, GetStartupArgument, "GetStartupArgument"},
{0x00520104, nullptr, "Wrap1"},
{0x00530104, nullptr, "Unwrap1"},
{0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
{0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
{0x00580002, nullptr, "GetProgramID"},
{0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
{0x01020000, CheckNew3DS, "CheckNew3DS"}};
APT_U_Interface::APT_U_Interface() {
Register(FunctionTable);

View File

@ -2,10 +2,10 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/service.h"
#include "core/hle/service/boss/boss.h"
#include "core/hle/service/boss/boss_p.h"
#include "core/hle/service/boss/boss_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace BOSS {

View File

@ -11,7 +11,7 @@ namespace BOSS {
// const Interface::FunctionInfo FunctionTable[] = { };
BOSS_P_Interface::BOSS_P_Interface() {
//Register(FunctionTable);
// Register(FunctionTable);
}
} // namespace BOSS

View File

@ -8,10 +8,10 @@ namespace Service {
namespace BOSS {
const Interface::FunctionInfo FunctionTable[] = {
{0x00020100, nullptr, "GetStorageInfo"},
{0x000C0082, nullptr, "UnregisterTask"},
{0x001E0042, nullptr, "CancelTask"},
{0x00330042, nullptr, "StartBgImmediate"},
{0x00020100, nullptr, "GetStorageInfo"},
{0x000C0082, nullptr, "UnregisterTask"},
{0x001E0042, nullptr, "CancelTask"},
{0x00330042, nullptr, "StartBgImmediate"},
};
BOSS_U_Interface::BOSS_U_Interface() {

View File

@ -71,15 +71,15 @@ void GetBufferErrorInterruptEvent(Service::Interface* self) {
}
void SetReceiving(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr dest = cmd_buff[1];
u8 port = cmd_buff[2] & 0xFF;
VAddr dest = cmd_buff[1];
u8 port = cmd_buff[2] & 0xFF;
u32 image_size = cmd_buff[3];
u16 trans_unit = cmd_buff[4] & 0xFFFF;
Kernel::Event* completion_event = (Port)port == Port::Cam2 ?
completion_event_cam2.get() : completion_event_cam1.get();
Kernel::Event* completion_event =
(Port)port == Port::Cam2 ? completion_event_cam2.get() : completion_event_cam1.get();
completion_event->Signal();
@ -89,36 +89,36 @@ void SetReceiving(Service::Interface* self) {
cmd_buff[3] = Kernel::g_handle_table.Create(completion_event).MoveFrom();
LOG_WARNING(Service_CAM, "(STUBBED) called, addr=0x%X, port=%d, image_size=%d, trans_unit=%d",
dest, port, image_size, trans_unit);
dest, port, image_size, trans_unit);
}
void SetTransferLines(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32* cmd_buff = Kernel::GetCommandBuffer();
u8 port = cmd_buff[1] & 0xFF;
u8 port = cmd_buff[1] & 0xFF;
u16 transfer_lines = cmd_buff[2] & 0xFFFF;
u16 width = cmd_buff[3] & 0xFFFF;
u16 height = cmd_buff[4] & 0xFFFF;
u16 width = cmd_buff[3] & 0xFFFF;
u16 height = cmd_buff[4] & 0xFFFF;
cmd_buff[0] = IPC::MakeHeader(0x9, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, lines=%d, width=%d, height=%d",
port, transfer_lines, width, height);
LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, lines=%d, width=%d, height=%d", port,
transfer_lines, width, height);
}
void GetMaxLines(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u16 width = cmd_buff[1] & 0xFFFF;
u16 width = cmd_buff[1] & 0xFFFF;
u16 height = cmd_buff[2] & 0xFFFF;
cmd_buff[0] = IPC::MakeHeader(0xA, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = TRANSFER_BYTES / (2 * width);
LOG_WARNING(Service_CAM, "(STUBBED) called, width=%d, height=%d, lines = %d",
width, height, cmd_buff[2]);
LOG_WARNING(Service_CAM, "(STUBBED) called, width=%d, height=%d, lines = %d", width, height,
cmd_buff[2]);
}
void GetTransferBytes(Service::Interface* self) {
@ -136,7 +136,7 @@ void GetTransferBytes(Service::Interface* self) {
void SetTrimming(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u8 port = cmd_buff[1] & 0xFF;
u8 port = cmd_buff[1] & 0xFF;
bool trim = (cmd_buff[2] & 0xFF) != 0;
cmd_buff[0] = IPC::MakeHeader(0xE, 1, 0);
@ -148,17 +148,17 @@ void SetTrimming(Service::Interface* self) {
void SetTrimmingParamsCenter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u8 port = cmd_buff[1] & 0xFF;
u8 port = cmd_buff[1] & 0xFF;
s16 trimW = cmd_buff[2] & 0xFFFF;
s16 trimH = cmd_buff[3] & 0xFFFF;
s16 camW = cmd_buff[4] & 0xFFFF;
s16 camH = cmd_buff[5] & 0xFFFF;
s16 camW = cmd_buff[4] & 0xFFFF;
s16 camH = cmd_buff[5] & 0xFFFF;
cmd_buff[0] = IPC::MakeHeader(0x12, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, trimW=%d, trimH=%d, camW=%d, camH=%d",
port, trimW, trimH, camW, camH);
port, trimW, trimH, camW, camH);
}
void Activate(Service::Interface* self) {
@ -169,36 +169,35 @@ void Activate(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x13, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d",
cam_select);
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d", cam_select);
}
void FlipImage(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u8 cam_select = cmd_buff[1] & 0xFF;
u8 flip = cmd_buff[2] & 0xFF;
u8 context = cmd_buff[3] & 0xFF;
u8 flip = cmd_buff[2] & 0xFF;
u8 context = cmd_buff[3] & 0xFF;
cmd_buff[0] = IPC::MakeHeader(0x1D, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, flip=%d, context=%d",
cam_select, flip, context);
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, flip=%d, context=%d", cam_select,
flip, context);
}
void SetSize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u8 cam_select = cmd_buff[1] & 0xFF;
u8 size = cmd_buff[2] & 0xFF;
u8 context = cmd_buff[3] & 0xFF;
u8 size = cmd_buff[2] & 0xFF;
u8 context = cmd_buff[3] & 0xFF;
cmd_buff[0] = IPC::MakeHeader(0x1F, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, size=%d, context=%d",
cam_select, size, context);
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, size=%d, context=%d", cam_select,
size, context);
}
void SetFrameRate(Service::Interface* self) {
@ -210,8 +209,8 @@ void SetFrameRate(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x20, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, frame_rate=%d",
cam_select, frame_rate);
LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, frame_rate=%d", cam_select,
frame_rate);
}
void GetStereoCameraCalibrationData(Service::Interface* self) {
@ -293,10 +292,14 @@ void Init() {
AddService(new CAM_S_Interface);
AddService(new CAM_U_Interface);
completion_event_cam1 = Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam1");
completion_event_cam2 = Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam2");
interrupt_error_event = Kernel::Event::Create(ResetType::OneShot, "CAM_U::interrupt_error_event");
vsync_interrupt_error_event = Kernel::Event::Create(ResetType::OneShot, "CAM_U::vsync_interrupt_error_event");
completion_event_cam1 =
Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam1");
completion_event_cam2 =
Kernel::Event::Create(ResetType::OneShot, "CAM_U::completion_event_cam2");
interrupt_error_event =
Kernel::Event::Create(ResetType::OneShot, "CAM_U::interrupt_error_event");
vsync_interrupt_error_event =
Kernel::Event::Create(ResetType::OneShot, "CAM_U::vsync_interrupt_error_event");
}
void Shutdown() {

View File

@ -14,12 +14,7 @@
namespace Service {
namespace CAM {
enum class Port : u8 {
None = 0,
Cam1 = 1,
Cam2 = 2,
Both = Cam1 | Cam2
};
enum class Port : u8 { None = 0, Cam1 = 1, Cam2 = 2, Both = Cam1 | Cam2 };
enum class CameraSelect : u8 {
None = 0,
@ -32,28 +27,11 @@ enum class CameraSelect : u8 {
All = Out1 | In1 | Out2
};
enum class Effect : u8 {
None = 0,
Mono = 1,
Sepia = 2,
Negative = 3,
Negafilm = 4,
Sepia01 = 5
};
enum class Effect : u8 { None = 0, Mono = 1, Sepia = 2, Negative = 3, Negafilm = 4, Sepia01 = 5 };
enum class Context : u8 {
None = 0,
A = 1,
B = 2,
Both = A | B
};
enum class Context : u8 { None = 0, A = 1, B = 2, Both = A | B };
enum class Flip : u8 {
None = 0,
Horizontal = 1,
Vertical = 2,
Reverse = 3
};
enum class Flip : u8 { None = 0, Horizontal = 1, Vertical = 2, Reverse = 3 };
enum class Size : u8 {
VGA = 0,
@ -83,11 +61,7 @@ enum class FrameRate : u8 {
Rate_30_To_10 = 12
};
enum class ShutterSoundType : u8 {
Normal = 0,
Movie = 1,
MovieEnd = 2
};
enum class ShutterSoundType : u8 { Normal = 0, Movie = 1, MovieEnd = 2 };
enum class WhiteBalance : u8 {
BalanceAuto = 0,
@ -106,13 +80,7 @@ enum class WhiteBalance : u8 {
BalanceShade = Balance7000K
};
enum class PhotoMode : u8 {
Normal = 0,
Portrait = 1,
Landscape = 2,
Nightview = 3,
Letter0 = 4
};
enum class PhotoMode : u8 { Normal = 0, Portrait = 1, Landscape = 2, Nightview = 3, Letter0 = 4 };
enum class LensCorrection : u8 {
Off = 0,
@ -140,21 +108,18 @@ enum class Contrast : u8 {
High = Pattern07
};
enum class OutputFormat : u8 {
YUV422 = 0,
RGB565 = 1
};
enum class OutputFormat : u8 { YUV422 = 0, RGB565 = 1 };
/// Stereo camera calibration data.
struct StereoCameraCalibrationData {
u8 isValidRotationXY; ///< Bool indicating whether the X and Y rotation data is valid.
u8 isValidRotationXY; ///< Bool indicating whether the X and Y rotation data is valid.
INSERT_PADDING_BYTES(3);
float_le scale; ///< Scale to match the left camera image with the right.
float_le rotationZ; ///< Z axis rotation to match the left camera image with the right.
float_le translationX; ///< X axis translation to match the left camera image with the right.
float_le translationY; ///< Y axis translation to match the left camera image with the right.
float_le rotationX; ///< X axis rotation to match the left camera image with the right.
float_le rotationY; ///< Y axis rotation to match the left camera image with the right.
float_le scale; ///< Scale to match the left camera image with the right.
float_le rotationZ; ///< Z axis rotation to match the left camera image with the right.
float_le translationX; ///< X axis translation to match the left camera image with the right.
float_le translationY; ///< Y axis translation to match the left camera image with the right.
float_le rotationX; ///< X axis rotation to match the left camera image with the right.
float_le rotationY; ///< Y axis rotation to match the left camera image with the right.
float_le angleOfViewRight; ///< Right camera angle of view.
float_le angleOfViewLeft; ///< Left camera angle of view.
float_le distanceToChart; ///< Distance between cameras and measurement chart.
@ -163,7 +128,8 @@ struct StereoCameraCalibrationData {
s16_le imageHeight; ///< Image height.
INSERT_PADDING_BYTES(16);
};
static_assert(sizeof(StereoCameraCalibrationData) == 64, "StereoCameraCalibrationData structure size is wrong");
static_assert(sizeof(StereoCameraCalibrationData) == 64,
"StereoCameraCalibrationData structure size is wrong");
struct PackageParameterCameraSelect {
CameraSelect camera;
@ -188,7 +154,8 @@ struct PackageParameterCameraSelect {
s16 auto_white_balance_window_height;
};
static_assert(sizeof(PackageParameterCameraSelect) == 28, "PackageParameterCameraSelect structure size is wrong");
static_assert(sizeof(PackageParameterCameraSelect) == 28,
"PackageParameterCameraSelect structure size is wrong");
/**
* Unknown

View File

@ -8,10 +8,10 @@ namespace Service {
namespace CAM {
// Empty arrays are illegal -- commented out until an entry is added.
//const Interface::FunctionInfo FunctionTable[] = { };
// const Interface::FunctionInfo FunctionTable[] = { };
CAM_C_Interface::CAM_C_Interface() {
//Register(FunctionTable);
// Register(FunctionTable);
}
} // namespace CAM

View File

@ -8,10 +8,10 @@ namespace Service {
namespace CAM {
// Empty arrays are illegal -- commented out until an entry is added.
//const Interface::FunctionInfo FunctionTable[] = { };
// const Interface::FunctionInfo FunctionTable[] = { };
CAM_Q_Interface::CAM_Q_Interface() {
//Register(FunctionTable);
// Register(FunctionTable);
}
} // namespace CAM

View File

@ -8,10 +8,10 @@ namespace Service {
namespace CAM {
// Empty arrays are illegal -- commented out until an entry is added.
//const Interface::FunctionInfo FunctionTable[] = { };
// const Interface::FunctionInfo FunctionTable[] = { };
CAM_S_Interface::CAM_S_Interface() {
//Register(FunctionTable);
// Register(FunctionTable);
}
} // namespace CAM

View File

@ -9,68 +9,68 @@ namespace Service {
namespace CAM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, StartCapture, "StartCapture"},
{0x00020040, StopCapture, "StopCapture"},
{0x00030040, nullptr, "IsBusy"},
{0x00040040, nullptr, "ClearBuffer"},
{0x00050040, GetVsyncInterruptEvent, "GetVsyncInterruptEvent"},
{0x00060040, GetBufferErrorInterruptEvent, "GetBufferErrorInterruptEvent"},
{0x00070102, SetReceiving, "SetReceiving"},
{0x00080040, nullptr, "IsFinishedReceiving"},
{0x00090100, SetTransferLines, "SetTransferLines"},
{0x000A0080, GetMaxLines, "GetMaxLines"},
{0x000B0100, nullptr, "SetTransferBytes"},
{0x000C0040, GetTransferBytes, "GetTransferBytes"},
{0x000D0080, nullptr, "GetMaxBytes"},
{0x000E0080, SetTrimming, "SetTrimming"},
{0x000F0040, nullptr, "IsTrimming"},
{0x00100140, nullptr, "SetTrimmingParams"},
{0x00110040, nullptr, "GetTrimmingParams"},
{0x00120140, SetTrimmingParamsCenter, "SetTrimmingParamsCenter"},
{0x00130040, Activate, "Activate"},
{0x00140080, nullptr, "SwitchContext"},
{0x00150080, nullptr, "SetExposure"},
{0x00160080, nullptr, "SetWhiteBalance"},
{0x00170080, nullptr, "SetWhiteBalanceWithoutBaseUp"},
{0x00180080, nullptr, "SetSharpness"},
{0x00190080, nullptr, "SetAutoExposure"},
{0x001A0040, nullptr, "IsAutoExposure"},
{0x001B0080, nullptr, "SetAutoWhiteBalance"},
{0x001C0040, nullptr, "IsAutoWhiteBalance"},
{0x001D00C0, FlipImage, "FlipImage"},
{0x001E0200, nullptr, "SetDetailSize"},
{0x001F00C0, SetSize, "SetSize"},
{0x00200080, SetFrameRate, "SetFrameRate"},
{0x00210080, nullptr, "SetPhotoMode"},
{0x002200C0, nullptr, "SetEffect"},
{0x00230080, nullptr, "SetContrast"},
{0x00240080, nullptr, "SetLensCorrection"},
{0x002500C0, nullptr, "SetOutputFormat"},
{0x00260140, nullptr, "SetAutoExposureWindow"},
{0x00270140, nullptr, "SetAutoWhiteBalanceWindow"},
{0x00280080, nullptr, "SetNoiseFilter"},
{0x00290080, nullptr, "SynchronizeVsyncTiming"},
{0x002A0080, nullptr, "GetLatestVsyncTiming"},
{0x002B0000, GetStereoCameraCalibrationData, "GetStereoCameraCalibrationData"},
{0x002C0400, nullptr, "SetStereoCameraCalibrationData"},
{0x002D00C0, nullptr, "WriteRegisterI2c"},
{0x002E00C0, nullptr, "WriteMcuVariableI2c"},
{0x002F0080, nullptr, "ReadRegisterI2cExclusive"},
{0x00300080, nullptr, "ReadMcuVariableI2cExclusive"},
{0x00310180, nullptr, "SetImageQualityCalibrationData"},
{0x00320000, nullptr, "GetImageQualityCalibrationData"},
{0x003302C0, nullptr, "SetPackageParameterWithoutContext"},
{0x00340140, nullptr, "SetPackageParameterWithContext"},
{0x003501C0, nullptr, "SetPackageParameterWithContextDetail"},
{0x00360000, GetSuitableY2rStandardCoefficient, "GetSuitableY2rStandardCoefficient"},
{0x00370202, nullptr, "PlayShutterSoundWithWave"},
{0x00380040, PlayShutterSound, "PlayShutterSound"},
{0x00390000, DriverInitialize, "DriverInitialize"},
{0x003A0000, DriverFinalize, "DriverFinalize"},
{0x003B0000, nullptr, "GetActivatedCamera"},
{0x003C0000, nullptr, "GetSleepCamera"},
{0x003D0040, nullptr, "SetSleepCamera"},
{0x003E0040, nullptr, "SetBrightnessSynchronization"},
{0x00010040, StartCapture, "StartCapture"},
{0x00020040, StopCapture, "StopCapture"},
{0x00030040, nullptr, "IsBusy"},
{0x00040040, nullptr, "ClearBuffer"},
{0x00050040, GetVsyncInterruptEvent, "GetVsyncInterruptEvent"},
{0x00060040, GetBufferErrorInterruptEvent, "GetBufferErrorInterruptEvent"},
{0x00070102, SetReceiving, "SetReceiving"},
{0x00080040, nullptr, "IsFinishedReceiving"},
{0x00090100, SetTransferLines, "SetTransferLines"},
{0x000A0080, GetMaxLines, "GetMaxLines"},
{0x000B0100, nullptr, "SetTransferBytes"},
{0x000C0040, GetTransferBytes, "GetTransferBytes"},
{0x000D0080, nullptr, "GetMaxBytes"},
{0x000E0080, SetTrimming, "SetTrimming"},
{0x000F0040, nullptr, "IsTrimming"},
{0x00100140, nullptr, "SetTrimmingParams"},
{0x00110040, nullptr, "GetTrimmingParams"},
{0x00120140, SetTrimmingParamsCenter, "SetTrimmingParamsCenter"},
{0x00130040, Activate, "Activate"},
{0x00140080, nullptr, "SwitchContext"},
{0x00150080, nullptr, "SetExposure"},
{0x00160080, nullptr, "SetWhiteBalance"},
{0x00170080, nullptr, "SetWhiteBalanceWithoutBaseUp"},
{0x00180080, nullptr, "SetSharpness"},
{0x00190080, nullptr, "SetAutoExposure"},
{0x001A0040, nullptr, "IsAutoExposure"},
{0x001B0080, nullptr, "SetAutoWhiteBalance"},
{0x001C0040, nullptr, "IsAutoWhiteBalance"},
{0x001D00C0, FlipImage, "FlipImage"},
{0x001E0200, nullptr, "SetDetailSize"},
{0x001F00C0, SetSize, "SetSize"},
{0x00200080, SetFrameRate, "SetFrameRate"},
{0x00210080, nullptr, "SetPhotoMode"},
{0x002200C0, nullptr, "SetEffect"},
{0x00230080, nullptr, "SetContrast"},
{0x00240080, nullptr, "SetLensCorrection"},
{0x002500C0, nullptr, "SetOutputFormat"},
{0x00260140, nullptr, "SetAutoExposureWindow"},
{0x00270140, nullptr, "SetAutoWhiteBalanceWindow"},
{0x00280080, nullptr, "SetNoiseFilter"},
{0x00290080, nullptr, "SynchronizeVsyncTiming"},
{0x002A0080, nullptr, "GetLatestVsyncTiming"},
{0x002B0000, GetStereoCameraCalibrationData, "GetStereoCameraCalibrationData"},
{0x002C0400, nullptr, "SetStereoCameraCalibrationData"},
{0x002D00C0, nullptr, "WriteRegisterI2c"},
{0x002E00C0, nullptr, "WriteMcuVariableI2c"},
{0x002F0080, nullptr, "ReadRegisterI2cExclusive"},
{0x00300080, nullptr, "ReadMcuVariableI2cExclusive"},
{0x00310180, nullptr, "SetImageQualityCalibrationData"},
{0x00320000, nullptr, "GetImageQualityCalibrationData"},
{0x003302C0, nullptr, "SetPackageParameterWithoutContext"},
{0x00340140, nullptr, "SetPackageParameterWithContext"},
{0x003501C0, nullptr, "SetPackageParameterWithContextDetail"},
{0x00360000, GetSuitableY2rStandardCoefficient, "GetSuitableY2rStandardCoefficient"},
{0x00370202, nullptr, "PlayShutterSoundWithWave"},
{0x00380040, PlayShutterSound, "PlayShutterSound"},
{0x00390000, DriverInitialize, "DriverInitialize"},
{0x003A0000, DriverFinalize, "DriverFinalize"},
{0x003B0000, nullptr, "GetActivatedCamera"},
{0x003C0000, nullptr, "GetSleepCamera"},
{0x003D0040, nullptr, "SetSleepCamera"},
{0x003E0040, nullptr, "SetBrightnessSynchronization"},
};
CAM_U_Interface::CAM_U_Interface() {

View File

@ -5,10 +5,10 @@
#include "common/logging/log.h"
#include "core/hle/kernel/event.h"
#include "core/hle/service/service.h"
#include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cecd/cecd_s.h"
#include "core/hle/service/cecd/cecd_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace CECD {
@ -28,7 +28,7 @@ void GetCecStateAbbreviated(Service::Interface* self) {
void GetCecInfoEventHandle(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[3] = Kernel::g_handle_table.Create(cecinfo_event).MoveFrom(); // Event handle
LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -37,7 +37,7 @@ void GetCecInfoEventHandle(Service::Interface* self) {
void GetChangeStateEventHandle(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[3] = Kernel::g_handle_table.Create(change_state_event).MoveFrom(); // Event handle
LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -48,7 +48,8 @@ void Init() {
AddService(new CECD_U_Interface);
cecinfo_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::cecinfo_event");
change_state_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::change_state_event");
change_state_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD_U::change_state_event");
}
void Shutdown() {

View File

@ -11,11 +11,13 @@ class Interface;
namespace CECD {
enum class CecStateAbbreviated {
CEC_STATE_ABBREV_IDLE = 1, ///< Corresponds to CEC_STATE_IDLE
CEC_STATE_ABBREV_IDLE = 1, ///< Corresponds to CEC_STATE_IDLE
CEC_STATE_ABBREV_NOT_LOCAL = 2, ///< Corresponds to CEC_STATEs *FINISH*, *POST, and OVER_BOSS
CEC_STATE_ABBREV_SCANNING = 3, ///< Corresponds to CEC_STATE_SCANNING
CEC_STATE_ABBREV_WLREADY = 4, ///< Corresponds to CEC_STATE_WIRELESS_READY when some unknown bool is true
CEC_STATE_ABBREV_OTHER = 5, ///< Corresponds to CEC_STATEs besides *FINISH*, *POST, and OVER_BOSS and those listed here
CEC_STATE_ABBREV_SCANNING = 3, ///< Corresponds to CEC_STATE_SCANNING
CEC_STATE_ABBREV_WLREADY =
4, ///< Corresponds to CEC_STATE_WIRELESS_READY when some unknown bool is true
CEC_STATE_ABBREV_OTHER = 5, ///< Corresponds to CEC_STATEs besides *FINISH*, *POST, and
/// OVER_BOSS and those listed here
};
/**

View File

@ -8,10 +8,10 @@ namespace Service {
namespace CECD {
// Empty arrays are illegal -- commented out until an entry is added.
//const Interface::FunctionInfo FunctionTable[] = { };
// const Interface::FunctionInfo FunctionTable[] = { };
CECD_S_Interface::CECD_S_Interface() {
//Register(FunctionTable);
// Register(FunctionTable);
}
} // namespace CECD

View File

@ -9,10 +9,10 @@ namespace Service {
namespace CECD {
static const Interface::FunctionInfo FunctionTable[] = {
{0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"},
{0x00120104, nullptr, "ReadSavedData"},
{0x00120104, nullptr, "ReadSavedData"},
};
CECD_U_Interface::CECD_U_Interface() {

View File

@ -11,7 +11,6 @@
#include "core/file_sys/archive_systemsavedata.h"
#include "core/file_sys/file_backend.h"
#include "core/settings.h"
#include "core/hle/result.h"
#include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/cfg/cfg_i.h"
@ -19,6 +18,7 @@
#include "core/hle/service/cfg/cfg_u.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/service.h"
#include "core/settings.h"
namespace Service {
namespace CFG {
@ -33,25 +33,29 @@ namespace {
* contains information about the blocks in the file
*/
struct SaveFileConfig {
u16 total_entries; ///< The total number of set entries in the config file
u16 data_entries_offset; ///< The offset where the data for the blocks start, this is hardcoded to 0x455C as per hardware
SaveConfigBlockEntry block_entries[CONFIG_FILE_MAX_BLOCK_ENTRIES]; ///< The block headers, the maximum possible value is 1479 as per hardware
u32 unknown; ///< This field is unknown, possibly padding, 0 has been observed in hardware
u16 total_entries; ///< The total number of set entries in the config file
u16 data_entries_offset; ///< The offset where the data for the blocks start, this is hardcoded
/// to 0x455C as per hardware
SaveConfigBlockEntry block_entries[CONFIG_FILE_MAX_BLOCK_ENTRIES]; ///< The block headers, the
/// maximum possible value is
/// 1479 as per hardware
u32 unknown; ///< This field is unknown, possibly padding, 0 has been observed in hardware
};
static_assert(sizeof(SaveFileConfig) == 0x455C, "SaveFileConfig header must be exactly 0x455C bytes");
static_assert(sizeof(SaveFileConfig) == 0x455C,
"SaveFileConfig header must be exactly 0x455C bytes");
enum ConfigBlockID {
StereoCameraSettingsBlockID = 0x00050005,
SoundOutputModeBlockID = 0x00070001,
ConsoleUniqueIDBlockID = 0x00090001,
UsernameBlockID = 0x000A0000,
BirthdayBlockID = 0x000A0001,
LanguageBlockID = 0x000A0002,
CountryInfoBlockID = 0x000B0000,
CountryNameBlockID = 0x000B0001,
StateNameBlockID = 0x000B0002,
EULAVersionBlockID = 0x000D0000,
ConsoleModelBlockID = 0x000F0004,
SoundOutputModeBlockID = 0x00070001,
ConsoleUniqueIDBlockID = 0x00090001,
UsernameBlockID = 0x000A0000,
BirthdayBlockID = 0x000A0001,
LanguageBlockID = 0x000A0002,
CountryInfoBlockID = 0x000B0000,
CountryNameBlockID = 0x000B0001,
StateNameBlockID = 0x000B0002,
EULAVersionBlockID = 0x000D0000,
ConsoleModelBlockID = 0x000F0004,
};
struct UsernameBlock {
@ -68,8 +72,8 @@ struct BirthdayBlock {
static_assert(sizeof(BirthdayBlock) == 2, "BirthdayBlock must be exactly 2 bytes");
struct ConsoleModelInfo {
u8 model; ///< The console model (3DS, 2DS, etc)
u8 unknown[3]; ///< Unknown data
u8 model; ///< The console model (3DS, 2DS, etc)
u8 unknown[3]; ///< Unknown data
};
static_assert(sizeof(ConsoleModelInfo) == 4, "ConsoleModelInfo must be exactly 4 bytes");
@ -78,36 +82,36 @@ struct ConsoleCountryInfo {
u8 country_code; ///< The country code of the console
};
static_assert(sizeof(ConsoleCountryInfo) == 4, "ConsoleCountryInfo must be exactly 4 bytes");
}
static const u64 CFG_SAVE_ID = 0x00010017;
static const u64 CONSOLE_UNIQUE_ID = 0xDEADC0DE;
static const ConsoleModelInfo CONSOLE_MODEL = { NINTENDO_3DS_XL, { 0, 0, 0 } };
static const ConsoleModelInfo CONSOLE_MODEL = {NINTENDO_3DS_XL, {0, 0, 0}};
static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN;
static const UsernameBlock CONSOLE_USERNAME_BLOCK = { u"CITRA", 0, 0 };
static const BirthdayBlock PROFILE_BIRTHDAY = { 3, 25 }; // March 25th, 2014
static const UsernameBlock CONSOLE_USERNAME_BLOCK = {u"CITRA", 0, 0};
static const BirthdayBlock PROFILE_BIRTHDAY = {3, 25}; // March 25th, 2014
static const u8 SOUND_OUTPUT_MODE = SOUND_SURROUND;
static const u8 UNITED_STATES_COUNTRY_ID = 49;
/// TODO(Subv): Find what the other bytes are
static const ConsoleCountryInfo COUNTRY_INFO = { { 0, 0, 0 }, UNITED_STATES_COUNTRY_ID };
static const ConsoleCountryInfo COUNTRY_INFO = {{0, 0, 0}, UNITED_STATES_COUNTRY_ID};
/**
* TODO(Subv): Find out what this actually is, these values fix some NaN uniforms in some games,
* for example Nintendo Zone
* Thanks Normmatt for providing this information
*/
static const std::array<float, 8> STEREO_CAMERA_SETTINGS = {{
62.0f, 289.0f, 76.80000305175781f, 46.08000183105469f,
10.0f, 5.0f, 55.58000183105469f, 21.56999969482422f
}};
static_assert(sizeof(STEREO_CAMERA_SETTINGS) == 0x20, "STEREO_CAMERA_SETTINGS must be exactly 0x20 bytes");
static const std::array<float, 8> STEREO_CAMERA_SETTINGS = {
{62.0f, 289.0f, 76.80000305175781f, 46.08000183105469f, 10.0f, 5.0f, 55.58000183105469f,
21.56999969482422f}};
static_assert(sizeof(STEREO_CAMERA_SETTINGS) == 0x20,
"STEREO_CAMERA_SETTINGS must be exactly 0x20 bytes");
static const u32 CONFIG_SAVEFILE_SIZE = 0x8000;
static std::array<u8, CONFIG_SAVEFILE_SIZE> cfg_config_file_buffer;
static Service::FS::ArchiveHandle cfg_system_save_data_archive;
static const std::vector<u8> cfg_system_savedata_id = { 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x01, 0x00 };
static const std::vector<u8> cfg_system_savedata_id = {0x00, 0x00, 0x00, 0x00,
0x17, 0x00, 0x01, 0x00};
void GetCountryCodeString(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
@ -115,7 +119,9 @@ void GetCountryCodeString(Service::Interface* self) {
if (country_code_id >= country_codes.size() || 0 == country_codes[country_code_id]) {
LOG_ERROR(Service_CFG, "requested country code id=%d is invalid", country_code_id);
cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
.raw;
return;
}
@ -139,8 +145,11 @@ void GetCountryCodeID(Service::Interface* self) {
}
if (0 == country_code_id) {
LOG_ERROR(Service_CFG, "requested country code name=%c%c is invalid", country_code & 0xff, country_code >> 8);
cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
LOG_ERROR(Service_CFG, "requested country code name=%c%c is invalid", country_code & 0xff,
country_code >> 8);
cmd_buff[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
.raw;
cmd_buff[2] = 0xFFFF;
return;
}
@ -185,8 +194,8 @@ void GetSystemModel(Service::Interface* self) {
u32 data;
// TODO(Subv): Find out the correct error codes
cmd_buff[1] = Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8,
reinterpret_cast<u8*>(&data)).raw;
cmd_buff[1] =
Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8, reinterpret_cast<u8*>(&data)).raw;
cmd_buff[2] = data & 0xFF;
}
@ -195,8 +204,8 @@ void GetModelNintendo2DS(Service::Interface* self) {
u32 data;
// TODO(Subv): Find out the correct error codes
cmd_buff[1] = Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8,
reinterpret_cast<u8*>(&data)).raw;
cmd_buff[1] =
Service::CFG::GetConfigInfoBlock(0x000F0004, 4, 0x8, reinterpret_cast<u8*>(&data)).raw;
u8 model = data & 0xFF;
if (model == Service::CFG::NINTENDO_2DS)
@ -267,24 +276,29 @@ static ResultVal<void*> GetConfigInfoBlockPointer(u32 block_id, u32 size, u32 fl
// Read the header
SaveFileConfig* config = reinterpret_cast<SaveFileConfig*>(cfg_config_file_buffer.data());
auto itr = std::find_if(std::begin(config->block_entries), std::end(config->block_entries),
[&](const SaveConfigBlockEntry& entry) {
return entry.block_id == block_id;
});
auto itr =
std::find_if(std::begin(config->block_entries), std::end(config->block_entries),
[&](const SaveConfigBlockEntry& entry) { return entry.block_id == block_id; });
if (itr == std::end(config->block_entries)) {
LOG_ERROR(Service_CFG, "Config block 0x%X with flags %u and size %u was not found", block_id, flag, size);
return ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
LOG_ERROR(Service_CFG, "Config block 0x%X with flags %u and size %u was not found",
block_id, flag, size);
return ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
if ((itr->flags & flag) == 0) {
LOG_ERROR(Service_CFG, "Invalid flag %u for config block 0x%X with size %u", flag, block_id, size);
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
LOG_ERROR(Service_CFG, "Invalid flag %u for config block 0x%X with size %u", flag, block_id,
size);
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
if (itr->size != size) {
LOG_ERROR(Service_CFG, "Invalid size %u for config block 0x%X with flags %u", size, block_id, flag);
return ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
LOG_ERROR(Service_CFG, "Invalid size %u for config block 0x%X with flags %u", size,
block_id, flag);
return ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
void* pointer;
@ -318,7 +332,7 @@ ResultCode CreateConfigInfoBlk(u32 block_id, u16 size, u16 flags, const void* da
return ResultCode(-1); // TODO(Subv): Find the right error code
// Insert the block header with offset 0 for now
config->block_entries[config->total_entries] = { block_id, 0, size, flags };
config->block_entries[config->total_entries] = {block_id, 0, size, flags};
if (size > 4) {
u32 offset = config->data_entries_offset;
// Perform a search to locate the next offset for the new data
@ -326,8 +340,7 @@ ResultCode CreateConfigInfoBlk(u32 block_id, u16 size, u16 flags, const void* da
for (int i = config->total_entries - 1; i >= 0; --i) {
// Ignore the blocks that don't have a separate data offset
if (config->block_entries[i].size > 4) {
offset = config->block_entries[i].offset_or_data +
config->block_entries[i].size;
offset = config->block_entries[i].offset_or_data + config->block_entries[i].size;
break;
}
}
@ -336,8 +349,7 @@ ResultCode CreateConfigInfoBlk(u32 block_id, u16 size, u16 flags, const void* da
// Write the data at the new offset
memcpy(&cfg_config_file_buffer[offset], data, size);
}
else {
} else {
// The offset_or_data field in the header contains the data itself if it's 4 bytes or less
memcpy(&config->block_entries[config->total_entries].offset_or_data, data, size);
}
@ -384,28 +396,40 @@ ResultCode FormatConfig() {
// 0x00030001 - Unknown
res = CreateConfigInfoBlk(0x00030001, 0x8, 0xE, zero_buffer);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(StereoCameraSettingsBlockID, sizeof(STEREO_CAMERA_SETTINGS), 0xE, STEREO_CAMERA_SETTINGS.data());
if (!res.IsSuccess()) return res;
res = CreateConfigInfoBlk(StereoCameraSettingsBlockID, sizeof(STEREO_CAMERA_SETTINGS), 0xE,
STEREO_CAMERA_SETTINGS.data());
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(SoundOutputModeBlockID, sizeof(SOUND_OUTPUT_MODE), 0xE, &SOUND_OUTPUT_MODE);
if (!res.IsSuccess()) return res;
res = CreateConfigInfoBlk(SoundOutputModeBlockID, sizeof(SOUND_OUTPUT_MODE), 0xE,
&SOUND_OUTPUT_MODE);
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(ConsoleUniqueIDBlockID, sizeof(CONSOLE_UNIQUE_ID), 0xE, &CONSOLE_UNIQUE_ID);
if (!res.IsSuccess()) return res;
res = CreateConfigInfoBlk(ConsoleUniqueIDBlockID, sizeof(CONSOLE_UNIQUE_ID), 0xE,
&CONSOLE_UNIQUE_ID);
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(UsernameBlockID, sizeof(CONSOLE_USERNAME_BLOCK), 0xE, &CONSOLE_USERNAME_BLOCK);
if (!res.IsSuccess()) return res;
res = CreateConfigInfoBlk(UsernameBlockID, sizeof(CONSOLE_USERNAME_BLOCK), 0xE,
&CONSOLE_USERNAME_BLOCK);
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(BirthdayBlockID, sizeof(PROFILE_BIRTHDAY), 0xE, &PROFILE_BIRTHDAY);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(LanguageBlockID, sizeof(CONSOLE_LANGUAGE), 0xE, &CONSOLE_LANGUAGE);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(CountryInfoBlockID, sizeof(COUNTRY_INFO), 0xE, &COUNTRY_INFO);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
u16_le country_name_buffer[16][0x40] = {};
std::u16string region_name = Common::UTF8ToUTF16("Gensokyo");
@ -413,34 +437,44 @@ ResultCode FormatConfig() {
std::copy(region_name.cbegin(), region_name.cend(), country_name_buffer[i]);
}
// 0x000B0001 - Localized names for the profile Country
res = CreateConfigInfoBlk(CountryNameBlockID, sizeof(country_name_buffer), 0xE, country_name_buffer);
if (!res.IsSuccess()) return res;
res = CreateConfigInfoBlk(CountryNameBlockID, sizeof(country_name_buffer), 0xE,
country_name_buffer);
if (!res.IsSuccess())
return res;
// 0x000B0002 - Localized names for the profile State/Province
res = CreateConfigInfoBlk(StateNameBlockID, sizeof(country_name_buffer), 0xE, country_name_buffer);
if (!res.IsSuccess()) return res;
res = CreateConfigInfoBlk(StateNameBlockID, sizeof(country_name_buffer), 0xE,
country_name_buffer);
if (!res.IsSuccess())
return res;
// 0x000B0003 - Unknown, related to country/address (zip code?)
res = CreateConfigInfoBlk(0x000B0003, 0x4, 0xE, zero_buffer);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
// 0x000C0000 - Unknown
res = CreateConfigInfoBlk(0x000C0000, 0xC0, 0xE, zero_buffer);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
// 0x000C0001 - Unknown
res = CreateConfigInfoBlk(0x000C0001, 0x14, 0xE, zero_buffer);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
// 0x000D0000 - Accepted EULA version
res = CreateConfigInfoBlk(EULAVersionBlockID, 0x4, 0xE, zero_buffer);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(ConsoleModelBlockID, sizeof(CONSOLE_MODEL), 0xC, &CONSOLE_MODEL);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
// 0x00170000 - Unknown
res = CreateConfigInfoBlk(0x00170000, 0x4, 0xE, zero_buffer);
if (!res.IsSuccess()) return res;
if (!res.IsSuccess())
return res;
// Save the buffer to the file
res = UpdateConfigNANDSavegame();
@ -452,15 +486,18 @@ ResultCode FormatConfig() {
ResultCode LoadConfigNANDSaveFile() {
// Open the SystemSaveData archive 0x00010017
FileSys::Path archive_path(cfg_system_savedata_id);
auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
auto archive_result =
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
// If the archive didn't exist, create the files inside
if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
// Format the archive to create the directories
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData, FileSys::ArchiveFormatInfo(), archive_path);
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData,
FileSys::ArchiveFormatInfo(), archive_path);
// Open it again to get a valid archive now that the folder exists
archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
archive_result =
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
}
ASSERT_MSG(archive_result.Succeeded(), "Could not open the CFG SystemSaveData archive!");
@ -515,7 +552,7 @@ std::u16string GetUsername() {
}
void SetBirthday(u8 month, u8 day) {
BirthdayBlock block = { month, day };
BirthdayBlock block = {month, day};
SetConfigInfoBlock(BirthdayBlockID, sizeof(block), 4, &block);
}

View File

@ -40,16 +40,13 @@ enum SystemLanguage {
LANGUAGE_TW = 11
};
enum SoundOutputMode {
SOUND_MONO = 0,
SOUND_STEREO = 1,
SOUND_SURROUND = 2
};
enum SoundOutputMode { SOUND_MONO = 0, SOUND_STEREO = 1, SOUND_SURROUND = 2 };
/// Block header in the config savedata file
struct SaveConfigBlockEntry {
u32 block_id; ///< The id of the current block
u32 offset_or_data; ///< This is the absolute offset to the block data if the size is greater than 4 bytes, otherwise it contains the data itself
u32 offset_or_data; ///< This is the absolute offset to the block data if the size is greater
/// than 4 bytes, otherwise it contains the data itself
u16 size; ///< The size of the block
u16 flags; ///< The flags of the block, possibly used for access control
};
@ -244,7 +241,8 @@ ResultCode GetConfigInfoBlock(u32 block_id, u32 size, u32 flag, void* output);
ResultCode SetConfigInfoBlock(u32 block_id, u32 size, u32 flag, const void* input);
/**
* Creates a block with the specified id and writes the input data to the cfg savegame buffer in memory.
* Creates a block with the specified id and writes the input data to the cfg savegame buffer in
* memory.
* The config savegame file in the filesystem is not updated.
* @param block_id The id of the block we want to create
* @param size The size of the block we want to create

View File

@ -10,49 +10,49 @@ namespace CFG {
const Interface::FunctionInfo FunctionTable[] = {
// cfg common
{0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
{0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
{0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
{0x00050000, GetSystemModel, "GetSystemModel"},
{0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
{0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
{0x00080080, nullptr, "GoThroughTable"},
{0x00090040, GetCountryCodeString, "GetCountryCodeString"},
{0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
{0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
{0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
{0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
{0x00050000, GetSystemModel, "GetSystemModel"},
{0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
{0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
{0x00080080, nullptr, "GoThroughTable"},
{0x00090040, GetCountryCodeString, "GetCountryCodeString"},
{0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
// cfg:i
{0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
{0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
{0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
{0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
{0x04050000, nullptr, "GetLocalFriendCodeSeed"},
{0x04060000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x04070000, nullptr, "SecureInfoGetByte101"},
{0x04080042, nullptr, "SecureInfoGetSerialNo"},
{0x04090000, nullptr, "UpdateConfigBlk00040003"},
{0x08010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
{0x08020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
{0x08030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
{0x080400C2, nullptr, "CreateConfigInfoBlk"},
{0x08050000, nullptr, "DeleteConfigNANDSavefile"},
{0x08060000, FormatConfig, "FormatConfig"},
{0x08080000, nullptr, "UpdateConfigBlk1"},
{0x08090000, nullptr, "UpdateConfigBlk2"},
{0x080A0000, nullptr, "UpdateConfigBlk3"},
{0x080B0082, nullptr, "SetGetLocalFriendCodeSeedData"},
{0x080C0042, nullptr, "SetLocalFriendCodeSeedSignature"},
{0x080D0000, nullptr, "DeleteCreateNANDLocalFriendCodeSeed"},
{0x080E0000, nullptr, "VerifySigLocalFriendCodeSeed"},
{0x080F0042, nullptr, "GetLocalFriendCodeSeedData"},
{0x08100000, nullptr, "GetLocalFriendCodeSeed"},
{0x08110084, nullptr, "SetSecureInfo"},
{0x08120000, nullptr, "DeleteCreateNANDSecureInfo"},
{0x08130000, nullptr, "VerifySigSecureInfo"},
{0x08140042, nullptr, "SecureInfoGetData"},
{0x08150042, nullptr, "SecureInfoGetSignature"},
{0x08160000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x08170000, nullptr, "SecureInfoGetByte101"},
{0x08180042, nullptr, "SecureInfoGetSerialNo"},
{0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
{0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
{0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
{0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
{0x04050000, nullptr, "GetLocalFriendCodeSeed"},
{0x04060000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x04070000, nullptr, "SecureInfoGetByte101"},
{0x04080042, nullptr, "SecureInfoGetSerialNo"},
{0x04090000, nullptr, "UpdateConfigBlk00040003"},
{0x08010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
{0x08020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
{0x08030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
{0x080400C2, nullptr, "CreateConfigInfoBlk"},
{0x08050000, nullptr, "DeleteConfigNANDSavefile"},
{0x08060000, FormatConfig, "FormatConfig"},
{0x08080000, nullptr, "UpdateConfigBlk1"},
{0x08090000, nullptr, "UpdateConfigBlk2"},
{0x080A0000, nullptr, "UpdateConfigBlk3"},
{0x080B0082, nullptr, "SetGetLocalFriendCodeSeedData"},
{0x080C0042, nullptr, "SetLocalFriendCodeSeedSignature"},
{0x080D0000, nullptr, "DeleteCreateNANDLocalFriendCodeSeed"},
{0x080E0000, nullptr, "VerifySigLocalFriendCodeSeed"},
{0x080F0042, nullptr, "GetLocalFriendCodeSeedData"},
{0x08100000, nullptr, "GetLocalFriendCodeSeed"},
{0x08110084, nullptr, "SetSecureInfo"},
{0x08120000, nullptr, "DeleteCreateNANDSecureInfo"},
{0x08130000, nullptr, "VerifySigSecureInfo"},
{0x08140042, nullptr, "SecureInfoGetData"},
{0x08150042, nullptr, "SecureInfoGetSignature"},
{0x08160000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x08170000, nullptr, "SecureInfoGetByte101"},
{0x08180042, nullptr, "SecureInfoGetSerialNo"},
};
CFG_I_Interface::CFG_I_Interface() {

View File

@ -10,26 +10,26 @@ namespace CFG {
const Interface::FunctionInfo FunctionTable[] = {
// cfg common
{0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
{0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
{0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
{0x00050000, GetSystemModel, "GetSystemModel"},
{0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
{0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
{0x00080080, nullptr, "GoThroughTable"},
{0x00090040, GetCountryCodeString, "GetCountryCodeString"},
{0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
{0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
{0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
{0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
{0x00050000, GetSystemModel, "GetSystemModel"},
{0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
{0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
{0x00080080, nullptr, "GoThroughTable"},
{0x00090040, GetCountryCodeString, "GetCountryCodeString"},
{0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
// cfg:s
{0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
{0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
{0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
{0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
{0x04050000, nullptr, "GetLocalFriendCodeSeed"},
{0x04060000, nullptr, "SecureInfoGetRegion"},
{0x04070000, nullptr, "SecureInfoGetByte101"},
{0x04080042, nullptr, "SecureInfoGetSerialNo"},
{0x04090000, nullptr, "UpdateConfigBlk00040003"},
{0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
{0x04020082, SetConfigInfoBlk4, "SetConfigInfoBlk4"},
{0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
{0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
{0x04050000, nullptr, "GetLocalFriendCodeSeed"},
{0x04060000, nullptr, "SecureInfoGetRegion"},
{0x04070000, nullptr, "SecureInfoGetByte101"},
{0x04080042, nullptr, "SecureInfoGetSerialNo"},
{0x04090000, nullptr, "UpdateConfigBlk00040003"},
};
CFG_S_Interface::CFG_S_Interface() {

View File

@ -10,16 +10,16 @@ namespace CFG {
const Interface::FunctionInfo FunctionTable[] = {
// cfg common
{0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
{0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
{0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
{0x00050000, GetSystemModel, "GetSystemModel"},
{0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
{0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
{0x00080080, nullptr, "GoThroughTable"},
{0x00090040, GetCountryCodeString, "GetCountryCodeString"},
{0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
{0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
{0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
{0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
{0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
{0x00050000, GetSystemModel, "GetSystemModel"},
{0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
{0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
{0x00080080, nullptr, "GoThroughTable"},
{0x00090040, GetCountryCodeString, "GetCountryCodeString"},
{0x000A0040, GetCountryCodeID, "GetCountryCodeID"},
};
CFG_U_Interface::CFG_U_Interface() {

View File

@ -2,12 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/csnd_snd.h"
#include <cstring>
#include "common/alignment.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/mutex.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/csnd_snd.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace CSND_SND
@ -15,18 +15,18 @@
namespace CSND_SND {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010140, Initialize, "Initialize"},
{0x00020000, Shutdown, "Shutdown"},
{0x00030040, ExecuteType0Commands, "ExecuteType0Commands"},
{0x00040080, nullptr, "ExecuteType1Commands"},
{0x00050000, AcquireSoundChannels, "AcquireSoundChannels"},
{0x00060000, nullptr, "ReleaseSoundChannels"},
{0x00070000, nullptr, "AcquireCaptureDevice"},
{0x00080040, nullptr, "ReleaseCaptureDevice"},
{0x00090082, nullptr, "FlushDataCache"},
{0x000A0082, nullptr, "StoreDataCache"},
{0x000B0082, nullptr, "InvalidateDataCache"},
{0x000C0000, nullptr, "Reset"},
{0x00010140, Initialize, "Initialize"},
{0x00020000, Shutdown, "Shutdown"},
{0x00030040, ExecuteType0Commands, "ExecuteType0Commands"},
{0x00040080, nullptr, "ExecuteType1Commands"},
{0x00050000, AcquireSoundChannels, "AcquireSoundChannels"},
{0x00060000, nullptr, "ReleaseSoundChannels"},
{0x00070000, nullptr, "AcquireCaptureDevice"},
{0x00080040, nullptr, "ReleaseCaptureDevice"},
{0x00090082, nullptr, "FlushDataCache"},
{0x000A0082, nullptr, "StoreDataCache"},
{0x000B0082, nullptr, "InvalidateDataCache"},
{0x000C0000, nullptr, "Reset"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -44,9 +44,9 @@ void Initialize(Service::Interface* self) {
u32 size = Common::AlignUp(cmd_buff[1], Memory::PAGE_SIZE);
using Kernel::MemoryPermission;
shared_memory = Kernel::SharedMemory::Create(nullptr, size,
MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
0, Kernel::MemoryRegion::BASE, "CSND:SharedMemory");
shared_memory = Kernel::SharedMemory::Create(nullptr, size, MemoryPermission::ReadWrite,
MemoryPermission::ReadWrite, 0,
Kernel::MemoryRegion::BASE, "CSND:SharedMemory");
mutex = Kernel::Mutex::Create(false);
@ -58,7 +58,7 @@ void Initialize(Service::Interface* self) {
void ExecuteType0Commands(Service::Interface* self) {
u32* const cmd_buff = Kernel::GetCommandBuffer();
u8* const ptr = shared_memory->GetPointer(cmd_buff[1]);
u8* const ptr = shared_memory->GetPointer(cmd_buff[1]);
if (shared_memory != nullptr && ptr != nullptr) {
Type0Command command;

View File

@ -25,7 +25,7 @@ struct Type0Command {
u32 command_id;
u32 finished;
u32 flags;
u8 parameters[20];
u8 parameters[20];
};
void Initialize(Service::Interface* self);

View File

@ -2,11 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/service.h"
#include "core/hle/service/dlp/dlp.h"
#include "core/hle/service/dlp/dlp_clnt.h"
#include "core/hle/service/dlp/dlp_fkcl.h"
#include "core/hle/service/dlp/dlp_srvr.h"
#include "core/hle/service/service.h"
namespace Service {
namespace DLP {

View File

@ -8,8 +8,7 @@ namespace Service {
namespace DLP {
const Interface::FunctionInfo FunctionTable[] = {
{0x000100C3, nullptr, "Initialize"},
{0x00110000, nullptr, "GetWirelessRebootPassphrase"},
{0x000100C3, nullptr, "Initialize"}, {0x00110000, nullptr, "GetWirelessRebootPassphrase"},
};
DLP_CLNT_Interface::DLP_CLNT_Interface() {

View File

@ -8,8 +8,7 @@ namespace Service {
namespace DLP {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010083, nullptr, "Initialize"},
{0x000F0000, nullptr, "GetWirelessRebootPassphrase"},
{0x00010083, nullptr, "Initialize"}, {0x000F0000, nullptr, "GetWirelessRebootPassphrase"},
};
DLP_FKCL_Interface::DLP_FKCL_Interface() {

View File

@ -2,10 +2,10 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/dlp/dlp_srvr.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "core/hle/result.h"
#include "core/hle/service/dlp/dlp_srvr.h"
namespace Service {
namespace DLP {
@ -20,10 +20,10 @@ static void unk_0x000E0040(Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010183, nullptr, "Initialize"},
{0x00020000, nullptr, "Finalize"},
{0x000800C0, nullptr, "SendWirelessRebootPassphrase"},
{0x000E0040, unk_0x000E0040, "unk_0x000E0040"},
{0x00010183, nullptr, "Initialize"},
{0x00020000, nullptr, "Finalize"},
{0x000800C0, nullptr, "SendWirelessRebootPassphrase"},
{0x000E0040, unk_0x000E0040, "unk_0x000E0040"},
};
DLP_SRVR_Interface::DLP_SRVR_Interface() {

View File

@ -23,9 +23,7 @@ namespace DSP_DSP {
static Kernel::SharedPtr<Kernel::Event> semaphore_event;
/// There are three types of interrupts
enum class InterruptType {
Zero, One, Pipe
};
enum class InterruptType { Zero, One, Pipe };
constexpr size_t NUM_INTERRUPT_TYPE = 3;
class InterruptEvents final {
@ -57,9 +55,8 @@ public:
// Actual service implementation only has 6 'slots' for interrupts.
constexpr size_t max_number_of_interrupt_events = 6;
size_t number = std::count_if(pipe.begin(), pipe.end(), [](const auto& evt) {
return evt != nullptr;
});
size_t number =
std::count_if(pipe.begin(), pipe.end(), [](const auto& evt) { return evt != nullptr; });
if (zero != nullptr)
number++;
@ -105,7 +102,8 @@ static void ConvertProcessAddressFromDspDram(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0xC, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
// TODO(merry): There is a per-region offset missing in this calculation (that seems to be always zero).
// TODO(merry): There is a per-region offset missing in this calculation (that seems to be
// always zero).
cmd_buff[2] = (addr << 1) + (Memory::DSP_RAM_VADDR + 0x40000);
LOG_DEBUG(Service_DSP, "addr=0x%08X", addr);
@ -126,15 +124,15 @@ static void ConvertProcessAddressFromDspDram(Service::Interface* self) {
static void LoadComponent(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 size = cmd_buff[1];
u32 prog_mask = cmd_buff[2];
u32 data_mask = cmd_buff[3];
u32 desc = cmd_buff[4];
u32 buffer = cmd_buff[5];
u32 size = cmd_buff[1];
u32 prog_mask = cmd_buff[2];
u32 data_mask = cmd_buff[3];
u32 desc = cmd_buff[4];
u32 buffer = cmd_buff[5];
cmd_buff[0] = IPC::MakeHeader(0x11, 2, 2);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = 1; // Pretend that we actually loaded the DSP firmware
cmd_buff[2] = 1; // Pretend that we actually loaded the DSP firmware
cmd_buff[3] = desc;
cmd_buff[4] = buffer;
@ -145,12 +143,15 @@ static void LoadComponent(Service::Interface* self) {
std::vector<u8> component_data(size);
Memory::ReadBlock(buffer, component_data.data(), component_data.size());
LOG_INFO(Service_DSP, "Firmware hash: %#" PRIx64, Common::ComputeHash64(component_data.data(), component_data.size()));
LOG_INFO(Service_DSP, "Firmware hash: %#" PRIx64,
Common::ComputeHash64(component_data.data(), component_data.size()));
// Some versions of the firmware have the location of DSP structures listed here.
ASSERT(size > 0x37C);
LOG_INFO(Service_DSP, "Structures hash: %#" PRIx64, Common::ComputeHash64(component_data.data() + 0x340, 60));
LOG_INFO(Service_DSP, "Structures hash: %#" PRIx64,
Common::ComputeHash64(component_data.data() + 0x340, 60));
LOG_WARNING(Service_DSP, "(STUBBED) called size=0x%X, prog_mask=0x%08X, data_mask=0x%08X, buffer=0x%08X",
LOG_WARNING(Service_DSP,
"(STUBBED) called size=0x%X, prog_mask=0x%08X, data_mask=0x%08X, buffer=0x%08X",
size, prog_mask, data_mask, buffer);
}
@ -187,13 +188,14 @@ static void GetSemaphoreEventHandle(Service::Interface* self) {
static void FlushDataCache(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 address = cmd_buff[1];
u32 size = cmd_buff[2];
u32 size = cmd_buff[2];
u32 process = cmd_buff[4];
cmd_buff[0] = IPC::MakeHeader(0x13, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_TRACE(Service_DSP, "called address=0x%08X, size=0x%X, process=0x%08X", address, size, process);
LOG_TRACE(Service_DSP, "called address=0x%08X, size=0x%X, process=0x%08X", address, size,
process);
}
/**
@ -224,23 +226,29 @@ static void RegisterInterruptEvents(Service::Interface* self) {
auto evt = Kernel::g_handle_table.Get<Kernel::Event>(cmd_buff[4]);
if (!evt) {
LOG_INFO(Service_DSP, "Invalid event handle! type=%u, pipe=%u, event_handle=0x%08X", type_index, pipe_index, event_handle);
LOG_INFO(Service_DSP, "Invalid event handle! type=%u, pipe=%u, event_handle=0x%08X",
type_index, pipe_index, event_handle);
ASSERT(false); // TODO: This should really be handled at an IPC translation layer.
}
if (interrupt_events.HasTooManyEventsRegistered()) {
LOG_INFO(Service_DSP, "Ran out of space to register interrupts (Attempted to register type=%u, pipe=%u, event_handle=0x%08X)",
LOG_INFO(Service_DSP, "Ran out of space to register interrupts (Attempted to register "
"type=%u, pipe=%u, event_handle=0x%08X)",
type_index, pipe_index, event_handle);
cmd_buff[1] = ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::DSP, ErrorSummary::OutOfResource, ErrorLevel::Status).raw;
cmd_buff[1] = ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::DSP,
ErrorSummary::OutOfResource, ErrorLevel::Status)
.raw;
return;
}
interrupt_events.Get(type, pipe) = evt;
LOG_INFO(Service_DSP, "Registered type=%u, pipe=%u, event_handle=0x%08X", type_index, pipe_index, event_handle);
LOG_INFO(Service_DSP, "Registered type=%u, pipe=%u, event_handle=0x%08X", type_index,
pipe_index, event_handle);
cmd_buff[1] = RESULT_SUCCESS.raw;
} else {
interrupt_events.Get(type, pipe) = nullptr;
LOG_INFO(Service_DSP, "Unregistered interrupt=%u, channel=%u, event_handle=0x%08X", type_index, pipe_index, event_handle);
LOG_INFO(Service_DSP, "Unregistered interrupt=%u, channel=%u, event_handle=0x%08X",
type_index, pipe_index, event_handle);
cmd_buff[1] = RESULT_SUCCESS.raw;
}
}
@ -282,13 +290,18 @@ static void WriteProcessPipe(Service::Interface* self) {
DSP::HLE::DspPipe pipe = static_cast<DSP::HLE::DspPipe>(pipe_index);
if (IPC::StaticBufferDesc(size, 1) != cmd_buff[3]) {
LOG_ERROR(Service_DSP, "IPC static buffer descriptor failed validation (0x%X). pipe=%u, size=0x%X, buffer=0x%08X", cmd_buff[3], pipe_index, size, buffer);
LOG_ERROR(Service_DSP, "IPC static buffer descriptor failed validation (0x%X). pipe=%u, "
"size=0x%X, buffer=0x%08X",
cmd_buff[3], pipe_index, size, buffer);
cmd_buff[0] = IPC::MakeHeader(0, 1, 0);
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
.raw;
return;
}
ASSERT_MSG(Memory::IsValidVirtualAddress(buffer), "Invalid Buffer: pipe=%u, size=0x%X, buffer=0x%08X", pipe, size, buffer);
ASSERT_MSG(Memory::IsValidVirtualAddress(buffer),
"Invalid Buffer: pipe=%u, size=0x%X, buffer=0x%08X", pipe, size, buffer);
std::vector<u8> message(size);
for (u32 i = 0; i < size; i++) {
@ -327,7 +340,9 @@ static void ReadPipeIfPossible(Service::Interface* self) {
DSP::HLE::DspPipe pipe = static_cast<DSP::HLE::DspPipe>(pipe_index);
ASSERT_MSG(Memory::IsValidVirtualAddress(addr), "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown, size, addr);
ASSERT_MSG(Memory::IsValidVirtualAddress(addr),
"Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown,
size, addr);
cmd_buff[0] = IPC::MakeHeader(0x10, 1, 2);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
@ -343,7 +358,9 @@ static void ReadPipeIfPossible(Service::Interface* self) {
cmd_buff[3] = IPC::StaticBufferDesc(size, 0);
cmd_buff[4] = addr;
LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X", pipe_index, unknown, size, addr, cmd_buff[2]);
LOG_DEBUG(Service_DSP,
"pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X",
pipe_index, unknown, size, addr, cmd_buff[2]);
}
/**
@ -367,7 +384,9 @@ static void ReadPipe(Service::Interface* self) {
DSP::HLE::DspPipe pipe = static_cast<DSP::HLE::DspPipe>(pipe_index);
ASSERT_MSG(Memory::IsValidVirtualAddress(addr), "Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown, size, addr);
ASSERT_MSG(Memory::IsValidVirtualAddress(addr),
"Invalid addr: pipe=0x%08X, unknown=0x%08X, size=0x%X, buffer=0x%08X", pipe, unknown,
size, addr);
if (DSP::HLE::GetPipeReadableSize(pipe) >= size) {
std::vector<u8> response = DSP::HLE::PipeRead(pipe, size);
@ -384,7 +403,9 @@ static void ReadPipe(Service::Interface* self) {
UNREACHABLE();
}
LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X", pipe_index, unknown, size, addr, cmd_buff[2]);
LOG_DEBUG(Service_DSP,
"pipe=%u, unknown=0x%08X, size=0x%X, buffer=0x%08X, return cmd_buff[2]=0x%08X",
pipe_index, unknown, size, addr, cmd_buff[2]);
}
/**
@ -408,7 +429,8 @@ static void GetPipeReadableSize(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = static_cast<u32>(DSP::HLE::GetPipeReadableSize(pipe));
LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, return cmd_buff[2]=0x%08X", pipe_index, unknown, cmd_buff[2]);
LOG_DEBUG(Service_DSP, "pipe=%u, unknown=0x%08X, return cmd_buff[2]=0x%08X", pipe_index,
unknown, cmd_buff[2]);
}
/**
@ -443,7 +465,7 @@ static void GetHeadphoneStatus(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x1F, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = 0; // Not using headphones
cmd_buff[2] = 0; // Not using headphones
LOG_DEBUG(Service_DSP, "called");
}
@ -466,7 +488,8 @@ static void RecvData(Service::Interface* self) {
ASSERT_MSG(register_number == 0, "Unknown register_number %u", register_number);
// Application reads this after requesting DSP shutdown, to verify the DSP has indeed shutdown or slept.
// Application reads this after requesting DSP shutdown, to verify the DSP has indeed shutdown
// or slept.
cmd_buff[0] = IPC::MakeHeader(0x1, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
@ -512,39 +535,39 @@ static void RecvDataIsReady(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, RecvData, "RecvData"},
{0x00020040, RecvDataIsReady, "RecvDataIsReady"},
{0x00030080, nullptr, "SendData"},
{0x00040040, nullptr, "SendDataIsEmpty"},
{0x000500C2, nullptr, "SendFifoEx"},
{0x000600C0, nullptr, "RecvFifoEx"},
{0x00070040, SetSemaphore, "SetSemaphore"},
{0x00080000, nullptr, "GetSemaphore"},
{0x00090040, nullptr, "ClearSemaphore"},
{0x000A0040, nullptr, "MaskSemaphore"},
{0x000B0000, nullptr, "CheckSemaphoreRequest"},
{0x00010040, RecvData, "RecvData"},
{0x00020040, RecvDataIsReady, "RecvDataIsReady"},
{0x00030080, nullptr, "SendData"},
{0x00040040, nullptr, "SendDataIsEmpty"},
{0x000500C2, nullptr, "SendFifoEx"},
{0x000600C0, nullptr, "RecvFifoEx"},
{0x00070040, SetSemaphore, "SetSemaphore"},
{0x00080000, nullptr, "GetSemaphore"},
{0x00090040, nullptr, "ClearSemaphore"},
{0x000A0040, nullptr, "MaskSemaphore"},
{0x000B0000, nullptr, "CheckSemaphoreRequest"},
{0x000C0040, ConvertProcessAddressFromDspDram, "ConvertProcessAddressFromDspDram"},
{0x000D0082, WriteProcessPipe, "WriteProcessPipe"},
{0x000E00C0, ReadPipe, "ReadPipe"},
{0x000F0080, GetPipeReadableSize, "GetPipeReadableSize"},
{0x001000C0, ReadPipeIfPossible, "ReadPipeIfPossible"},
{0x001100C2, LoadComponent, "LoadComponent"},
{0x00120000, nullptr, "UnloadComponent"},
{0x00130082, FlushDataCache, "FlushDataCache"},
{0x00140082, nullptr, "InvalidateDCache"},
{0x00150082, RegisterInterruptEvents, "RegisterInterruptEvents"},
{0x00160000, GetSemaphoreEventHandle, "GetSemaphoreEventHandle"},
{0x00170040, SetSemaphoreMask, "SetSemaphoreMask"},
{0x00180040, nullptr, "GetPhysicalAddress"},
{0x00190040, nullptr, "GetVirtualAddress"},
{0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"},
{0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"},
{0x001C0082, nullptr, "SetIirFilterEQ"},
{0x001D00C0, nullptr, "ReadMultiEx_SPI2"},
{0x001E00C2, nullptr, "WriteMultiEx_SPI2"},
{0x001F0000, GetHeadphoneStatus, "GetHeadphoneStatus"},
{0x00200040, nullptr, "ForceHeadphoneOut"},
{0x00210000, nullptr, "GetIsDspOccupied"},
{0x000D0082, WriteProcessPipe, "WriteProcessPipe"},
{0x000E00C0, ReadPipe, "ReadPipe"},
{0x000F0080, GetPipeReadableSize, "GetPipeReadableSize"},
{0x001000C0, ReadPipeIfPossible, "ReadPipeIfPossible"},
{0x001100C2, LoadComponent, "LoadComponent"},
{0x00120000, nullptr, "UnloadComponent"},
{0x00130082, FlushDataCache, "FlushDataCache"},
{0x00140082, nullptr, "InvalidateDCache"},
{0x00150082, RegisterInterruptEvents, "RegisterInterruptEvents"},
{0x00160000, GetSemaphoreEventHandle, "GetSemaphoreEventHandle"},
{0x00170040, SetSemaphoreMask, "SetSemaphoreMask"},
{0x00180040, nullptr, "GetPhysicalAddress"},
{0x00190040, nullptr, "GetVirtualAddress"},
{0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"},
{0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"},
{0x001C0082, nullptr, "SetIirFilterEQ"},
{0x001D00C0, nullptr, "ReadMultiEx_SPI2"},
{0x001E00C2, nullptr, "WriteMultiEx_SPI2"},
{0x001F0000, GetHeadphoneStatus, "GetHeadphoneStatus"},
{0x00200040, nullptr, "ForceHeadphoneOut"},
{0x00210000, nullptr, "GetIsDspOccupied"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -35,70 +35,70 @@ union ErrInfo {
u8 specifier;
struct {
u8 specifier; // 0x0
u8 rev_high; // 0x1
u16 rev_low; // 0x2
RSL result_code; // 0x4
u32 address; // 0x8
INSERT_PADDING_BYTES(4); // 0xC
u32 pid_low; // 0x10
u32 pid_high; // 0x14
u32 aid_low; // 0x18
u32 aid_high; // 0x1C
u8 specifier; // 0x0
u8 rev_high; // 0x1
u16 rev_low; // 0x2
RSL result_code; // 0x4
u32 address; // 0x8
INSERT_PADDING_BYTES(4); // 0xC
u32 pid_low; // 0x10
u32 pid_high; // 0x14
u32 aid_low; // 0x18
u32 aid_high; // 0x1C
} errtype1;
struct {
u8 specifier; // 0x0
u8 rev_high; // 0x1
u16 rev_low; // 0x2
INSERT_PADDING_BYTES(0xC); // 0x4
u32 pid_low; // 0x10
u32 pid_high; // 0x14
u32 aid_low; // 0x18
u32 aid_high; // 0x1C
u8 error_type; // 0x20
INSERT_PADDING_BYTES(3); // 0x21
u32 fault_status_reg; // 0x24
u32 fault_addr; // 0x28
u32 fpexc; // 0x2C
u32 finst; // 0x30
u32 finst2; // 0x34
INSERT_PADDING_BYTES(0x34); // 0x38
u32 sp; // 0x6C
u32 pc; // 0x70
u32 lr; // 0x74
u32 cpsr; // 0x78
u8 specifier; // 0x0
u8 rev_high; // 0x1
u16 rev_low; // 0x2
INSERT_PADDING_BYTES(0xC); // 0x4
u32 pid_low; // 0x10
u32 pid_high; // 0x14
u32 aid_low; // 0x18
u32 aid_high; // 0x1C
u8 error_type; // 0x20
INSERT_PADDING_BYTES(3); // 0x21
u32 fault_status_reg; // 0x24
u32 fault_addr; // 0x28
u32 fpexc; // 0x2C
u32 finst; // 0x30
u32 finst2; // 0x34
INSERT_PADDING_BYTES(0x34); // 0x38
u32 sp; // 0x6C
u32 pc; // 0x70
u32 lr; // 0x74
u32 cpsr; // 0x78
} errtype3;
struct {
u8 specifier; // 0x0
u8 rev_high; // 0x1
u16 rev_low; // 0x2
RSL result_code; // 0x4
INSERT_PADDING_BYTES(8); // 0x8
u32 pid_low; // 0x10
u32 pid_high; // 0x14
u32 aid_low; // 0x18
u32 aid_high; // 0x1C
char debug_string1[0x2E]; // 0x20
char debug_string2[0x2E]; // 0x4E
u8 specifier; // 0x0
u8 rev_high; // 0x1
u16 rev_low; // 0x2
RSL result_code; // 0x4
INSERT_PADDING_BYTES(8); // 0x8
u32 pid_low; // 0x10
u32 pid_high; // 0x14
u32 aid_low; // 0x18
u32 aid_high; // 0x1C
char debug_string1[0x2E]; // 0x20
char debug_string2[0x2E]; // 0x4E
} errtype4;
};
enum {
PrefetchAbort = 0,
DataAbort = 1,
UndefInstr = 2,
VectorFP = 3
};
enum { PrefetchAbort = 0, DataAbort = 1, UndefInstr = 2, VectorFP = 3 };
static std::string GetErrInfo3Type(u8 type_code) {
switch (type_code) {
case PrefetchAbort: return "Prefetch Abort";
case DataAbort: return "Data Abort";
case UndefInstr: return "Undefined Instruction";
case VectorFP: return "Vector Floating Point";
default: return "unknown";
case PrefetchAbort:
return "Prefetch Abort";
case DataAbort:
return "Data Abort";
case UndefInstr:
return "Undefined Instruction";
case VectorFP:
return "Vector Floating Point";
default:
return "unknown";
}
}
@ -110,8 +110,7 @@ static void ThrowFatalError(Service::Interface* self) {
switch (errinfo->specifier) {
case ErrSpecifier0:
case ErrSpecifier1:
{
case ErrSpecifier1: {
const auto& errtype = errinfo->errtype1;
LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high);
LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16));
@ -119,15 +118,14 @@ static void ThrowFatalError(Service::Interface* self) {
LOG_CRITICAL(Service_ERR, "ADR: 0x%08X", errtype.address);
LOG_CRITICAL(Service_ERR, "RSL: 0x%08X", errtype.result_code.raw);
LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
LOG_CRITICAL(Service_ERR, " Summary: %u", errtype.result_code.summary.Value());
LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
break;
}
case ErrSpecifier3:
{
case ErrSpecifier3: {
const auto& errtype = errinfo->errtype3;
LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high);
LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16));
@ -154,18 +152,17 @@ static void ThrowFatalError(Service::Interface* self) {
break;
}
case ErrSpecifier4:
{
case ErrSpecifier4: {
const auto& errtype = errinfo->errtype4;
LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high);
LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16));
LOG_CRITICAL(Service_ERR, "AID: 0x%08X_0x%08X", errtype.aid_low, errtype.aid_high);
LOG_CRITICAL(Service_ERR, "RSL: 0x%08X", errtype.result_code.raw);
LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value());
LOG_CRITICAL(Service_ERR, " Summary: %u", errtype.result_code.summary.Value());
LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value());
LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value());
LOG_CRITICAL(Service_ERR, "%s", errtype.debug_string1);
LOG_CRITICAL(Service_ERR, "%s", errtype.debug_string2);
@ -176,9 +173,7 @@ static void ThrowFatalError(Service::Interface* self) {
cmd_buff[1] = 0; // No error
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010800, ThrowFatalError, "ThrowFatalError"}
};
const Interface::FunctionInfo FunctionTable[] = {{0x00010800, ThrowFatalError, "ThrowFatalError"}};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class

View File

@ -4,10 +4,10 @@
#include "common/string_util.h"
#include "core/hle/service/service.h"
#include "core/hle/service/frd/frd.h"
#include "core/hle/service/frd/frd_a.h"
#include "core/hle/service/frd/frd_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace FRD {
@ -43,7 +43,7 @@ void GetFriendKeyList(Service::Interface* self) {
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = 0; // 0 friends
cmd_buff[2] = 0; // 0 friends
LOG_WARNING(Service_FRD, "(STUBBED) called, unknown=%d, frd_count=%d, frd_key_addr=0x%08X",
unknown, frd_count, frd_key_addr);
}
@ -61,25 +61,27 @@ void GetFriendProfile(Service::Interface* self) {
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_FRD, "(STUBBED) called, count=%d, frd_key_addr=0x%08X, profiles_addr=0x%08X",
count, frd_key_addr, profiles_addr);
LOG_WARNING(Service_FRD,
"(STUBBED) called, count=%d, frd_key_addr=0x%08X, profiles_addr=0x%08X", count,
frd_key_addr, profiles_addr);
}
void GetFriendAttributeFlags(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 count = cmd_buff[1];
u32 frd_key_addr = cmd_buff[3];
u32 count = cmd_buff[1];
u32 frd_key_addr = cmd_buff[3];
u32 attr_flags_addr = cmd_buff[65];
for (u32 i = 0; i < count; ++i) {
//TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
// TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
Memory::Write8(attr_flags_addr + i, 0);
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_FRD, "(STUBBED) called, count=%d, frd_key_addr=0x%08X, attr_flags_addr=0x%08X",
count, frd_key_addr, attr_flags_addr);
LOG_WARNING(Service_FRD,
"(STUBBED) called, count=%d, frd_key_addr=0x%08X, attr_flags_addr=0x%08X", count,
frd_key_addr, attr_flags_addr);
}
void GetMyFriendKey(Service::Interface* self) {

View File

@ -11,7 +11,7 @@ namespace FRD {
// const Interface::FunctionInfo FunctionTable[] = { };
FRD_A_Interface::FRD_A_Interface() {
//Register(FunctionTable);
// Register(FunctionTable);
}
} // namespace FRD

View File

@ -9,59 +9,59 @@ namespace Service {
namespace FRD {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010000, nullptr, "HasLoggedIn"},
{0x00020000, nullptr, "IsOnline"},
{0x00030000, nullptr, "Login"},
{0x00040000, nullptr, "Logout"},
{0x00050000, GetMyFriendKey, "GetMyFriendKey"},
{0x00060000, nullptr, "GetMyPreference"},
{0x00070000, nullptr, "GetMyProfile"},
{0x00080000, GetMyPresence, "GetMyPresence"},
{0x00090000, GetMyScreenName, "GetMyScreenName"},
{0x000A0000, nullptr, "GetMyMii"},
{0x000B0000, nullptr, "GetMyLocalAccountId"},
{0x000C0000, nullptr, "GetMyPlayingGame"},
{0x000D0000, nullptr, "GetMyFavoriteGame"},
{0x000E0000, nullptr, "GetMyNcPrincipalId"},
{0x000F0000, nullptr, "GetMyComment"},
{0x00100040, nullptr, "GetMyPassword"},
{0x00110080, GetFriendKeyList, "GetFriendKeyList"},
{0x00120042, nullptr, "GetFriendPresence"},
{0x00130142, nullptr, "GetFriendScreenName"},
{0x00140044, nullptr, "GetFriendMii"},
{0x00150042, GetFriendProfile, "GetFriendProfile"},
{0x00160042, nullptr, "GetFriendRelationship"},
{0x00010000, nullptr, "HasLoggedIn"},
{0x00020000, nullptr, "IsOnline"},
{0x00030000, nullptr, "Login"},
{0x00040000, nullptr, "Logout"},
{0x00050000, GetMyFriendKey, "GetMyFriendKey"},
{0x00060000, nullptr, "GetMyPreference"},
{0x00070000, nullptr, "GetMyProfile"},
{0x00080000, GetMyPresence, "GetMyPresence"},
{0x00090000, GetMyScreenName, "GetMyScreenName"},
{0x000A0000, nullptr, "GetMyMii"},
{0x000B0000, nullptr, "GetMyLocalAccountId"},
{0x000C0000, nullptr, "GetMyPlayingGame"},
{0x000D0000, nullptr, "GetMyFavoriteGame"},
{0x000E0000, nullptr, "GetMyNcPrincipalId"},
{0x000F0000, nullptr, "GetMyComment"},
{0x00100040, nullptr, "GetMyPassword"},
{0x00110080, GetFriendKeyList, "GetFriendKeyList"},
{0x00120042, nullptr, "GetFriendPresence"},
{0x00130142, nullptr, "GetFriendScreenName"},
{0x00140044, nullptr, "GetFriendMii"},
{0x00150042, GetFriendProfile, "GetFriendProfile"},
{0x00160042, nullptr, "GetFriendRelationship"},
{0x00170042, GetFriendAttributeFlags, "GetFriendAttributeFlags"},
{0x00180044, nullptr, "GetFriendPlayingGame"},
{0x00190042, nullptr, "GetFriendFavoriteGame"},
{0x001A00C4, nullptr, "GetFriendInfo"},
{0x001B0080, nullptr, "IsIncludedInFriendList"},
{0x001C0042, nullptr, "UnscrambleLocalFriendCode"},
{0x001D0002, nullptr, "UpdateGameModeDescription"},
{0x001E02C2, nullptr, "UpdateGameMode"},
{0x001F0042, nullptr, "SendInvitation"},
{0x00200002, nullptr, "AttachToEventNotification"},
{0x00210040, nullptr, "SetNotificationMask"},
{0x00220040, nullptr, "GetEventNotification"},
{0x00230000, nullptr, "GetLastResponseResult"},
{0x00240040, nullptr, "PrincipalIdToFriendCode"},
{0x00250080, nullptr, "FriendCodeToPrincipalId"},
{0x00260080, nullptr, "IsValidFriendCode"},
{0x00270040, nullptr, "ResultToErrorCode"},
{0x00280244, nullptr, "RequestGameAuthentication"},
{0x00290000, nullptr, "GetGameAuthenticationData"},
{0x002A0204, nullptr, "RequestServiceLocator"},
{0x002B0000, nullptr, "GetServiceLocatorData"},
{0x002C0002, nullptr, "DetectNatProperties"},
{0x002D0000, nullptr, "GetNatProperties"},
{0x002E0000, nullptr, "GetServerTimeInterval"},
{0x002F0040, nullptr, "AllowHalfAwake"},
{0x00300000, nullptr, "GetServerTypes"},
{0x00310082, nullptr, "GetFriendComment"},
{0x00320042, nullptr, "SetClientSdkVersion"},
{0x00330000, nullptr, "GetMyApproachContext"},
{0x00340046, nullptr, "AddFriendWithApproach"},
{0x00350082, nullptr, "DecryptApproachContext"},
{0x00180044, nullptr, "GetFriendPlayingGame"},
{0x00190042, nullptr, "GetFriendFavoriteGame"},
{0x001A00C4, nullptr, "GetFriendInfo"},
{0x001B0080, nullptr, "IsIncludedInFriendList"},
{0x001C0042, nullptr, "UnscrambleLocalFriendCode"},
{0x001D0002, nullptr, "UpdateGameModeDescription"},
{0x001E02C2, nullptr, "UpdateGameMode"},
{0x001F0042, nullptr, "SendInvitation"},
{0x00200002, nullptr, "AttachToEventNotification"},
{0x00210040, nullptr, "SetNotificationMask"},
{0x00220040, nullptr, "GetEventNotification"},
{0x00230000, nullptr, "GetLastResponseResult"},
{0x00240040, nullptr, "PrincipalIdToFriendCode"},
{0x00250080, nullptr, "FriendCodeToPrincipalId"},
{0x00260080, nullptr, "IsValidFriendCode"},
{0x00270040, nullptr, "ResultToErrorCode"},
{0x00280244, nullptr, "RequestGameAuthentication"},
{0x00290000, nullptr, "GetGameAuthenticationData"},
{0x002A0204, nullptr, "RequestServiceLocator"},
{0x002B0000, nullptr, "GetServiceLocatorData"},
{0x002C0002, nullptr, "DetectNatProperties"},
{0x002D0000, nullptr, "GetNatProperties"},
{0x002E0000, nullptr, "GetServerTimeInterval"},
{0x002F0040, nullptr, "AllowHalfAwake"},
{0x00300000, nullptr, "GetServerTypes"},
{0x00310082, nullptr, "GetFriendComment"},
{0x00320042, nullptr, "SetClientSdkVersion"},
{0x00330000, nullptr, "GetMyApproachContext"},
{0x00340046, nullptr, "AddFriendWithApproach"},
{0x00350082, nullptr, "DecryptApproachContext"},
};
FRD_U_Interface::FRD_U_Interface() {

View File

@ -3,9 +3,9 @@
// Refer to the license.txt file included.
#include <cstddef>
#include <memory>
#include <system_error>
#include <type_traits>
#include <memory>
#include <unordered_map>
#include <utility>
@ -25,25 +25,25 @@
#include "core/file_sys/directory_backend.h"
#include "core/file_sys/file_backend.h"
#include "core/hle/hle.h"
#include "core/hle/service/service.h"
#include "core/hle/result.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/fs/fs_user.h"
#include "core/hle/result.h"
#include "core/hle/service/service.h"
#include "core/memory.h"
// Specializes std::hash for ArchiveIdCode, so that we can use it in std::unordered_map.
// Workaroung for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970
namespace std {
template <>
struct hash<Service::FS::ArchiveIdCode> {
typedef Service::FS::ArchiveIdCode argument_type;
typedef std::size_t result_type;
template <>
struct hash<Service::FS::ArchiveIdCode> {
typedef Service::FS::ArchiveIdCode argument_type;
typedef std::size_t result_type;
result_type operator()(const argument_type& id_code) const {
typedef std::underlying_type<argument_type>::type Type;
return std::hash<Type>()(static_cast<Type>(id_code));
}
};
result_type operator()(const argument_type& id_code) const {
typedef std::underlying_type<argument_type>::type Type;
return std::hash<Type>()(static_cast<Type>(id_code));
}
};
}
/// TODO(Subv): Confirm length of these strings
@ -56,197 +56,193 @@ namespace FS {
// TODO: Verify code
/// Returned when a function is passed an invalid handle.
const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
/// Returned when a function is passed an invalid archive handle.
const ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrorDescription::FS_ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status); // 0xC8804465
ErrorSummary::NotFound,
ErrorLevel::Status); // 0xC8804465
// Command to access archive file
enum class FileCommand : u32 {
Dummy1 = 0x000100C6,
Control = 0x040100C4,
OpenSubFile = 0x08010100,
Read = 0x080200C2,
Write = 0x08030102,
GetSize = 0x08040000,
SetSize = 0x08050080,
GetAttributes = 0x08060000,
SetAttributes = 0x08070040,
Close = 0x08080000,
Flush = 0x08090000,
SetPriority = 0x080A0040,
GetPriority = 0x080B0000,
OpenLinkFile = 0x080C0000,
Dummy1 = 0x000100C6,
Control = 0x040100C4,
OpenSubFile = 0x08010100,
Read = 0x080200C2,
Write = 0x08030102,
GetSize = 0x08040000,
SetSize = 0x08050080,
GetAttributes = 0x08060000,
SetAttributes = 0x08070040,
Close = 0x08080000,
Flush = 0x08090000,
SetPriority = 0x080A0040,
GetPriority = 0x080B0000,
OpenLinkFile = 0x080C0000,
};
// Command to access directory
enum class DirectoryCommand : u32 {
Dummy1 = 0x000100C6,
Control = 0x040100C4,
Read = 0x08010042,
Close = 0x08020000,
Dummy1 = 0x000100C6,
Control = 0x040100C4,
Read = 0x08010042,
Close = 0x08020000,
};
File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path & path)
: path(path), priority(0), backend(std::move(backend)) {}
File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path)
: path(path), priority(0), backend(std::move(backend)) {
}
File::~File() {}
File::~File() {
}
ResultVal<bool> File::SyncRequest() {
u32* cmd_buff = Kernel::GetCommandBuffer();
FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
switch (cmd) {
// Read from file...
case FileCommand::Read:
{
u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
u32 length = cmd_buff[3];
u32 address = cmd_buff[5];
LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
GetTypeName().c_str(), GetName().c_str(), offset, length, address);
// Read from file...
case FileCommand::Read: {
u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
u32 length = cmd_buff[3];
u32 address = cmd_buff[5];
LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
GetTypeName().c_str(), GetName().c_str(), offset, length, address);
if (offset + length > backend->GetSize()) {
LOG_ERROR(Service_FS, "Reading from out of bounds offset=0x%llX length=0x%08X file_size=0x%llX",
offset, length, backend->GetSize());
}
std::vector<u8> data(length);
ResultVal<size_t> read = backend->Read(offset, data.size(), data.data());
if (read.Failed()) {
cmd_buff[1] = read.Code().raw;
return read.Code();
}
Memory::WriteBlock(address, data.data(), *read);
cmd_buff[2] = static_cast<u32>(*read);
break;
if (offset + length > backend->GetSize()) {
LOG_ERROR(Service_FS,
"Reading from out of bounds offset=0x%llX length=0x%08X file_size=0x%llX",
offset, length, backend->GetSize());
}
// Write to file...
case FileCommand::Write:
{
u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
u32 length = cmd_buff[3];
u32 flush = cmd_buff[4];
u32 address = cmd_buff[6];
LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
std::vector<u8> data(length);
Memory::ReadBlock(address, data.data(), data.size());
ResultVal<size_t> written = backend->Write(offset, data.size(), flush != 0, data.data());
if (written.Failed()) {
cmd_buff[1] = written.Code().raw;
return written.Code();
}
cmd_buff[2] = static_cast<u32>(*written);
break;
std::vector<u8> data(length);
ResultVal<size_t> read = backend->Read(offset, data.size(), data.data());
if (read.Failed()) {
cmd_buff[1] = read.Code().raw;
return read.Code();
}
Memory::WriteBlock(address, data.data(), *read);
cmd_buff[2] = static_cast<u32>(*read);
break;
}
case FileCommand::GetSize:
{
LOG_TRACE(Service_FS, "GetSize %s %s", GetTypeName().c_str(), GetName().c_str());
u64 size = backend->GetSize();
cmd_buff[2] = (u32)size;
cmd_buff[3] = size >> 32;
break;
// Write to file...
case FileCommand::Write: {
u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
u32 length = cmd_buff[3];
u32 flush = cmd_buff[4];
u32 address = cmd_buff[6];
LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
std::vector<u8> data(length);
Memory::ReadBlock(address, data.data(), data.size());
ResultVal<size_t> written = backend->Write(offset, data.size(), flush != 0, data.data());
if (written.Failed()) {
cmd_buff[1] = written.Code().raw;
return written.Code();
}
cmd_buff[2] = static_cast<u32>(*written);
break;
}
case FileCommand::SetSize:
{
u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32);
LOG_TRACE(Service_FS, "SetSize %s %s size=%llu",
GetTypeName().c_str(), GetName().c_str(), size);
backend->SetSize(size);
break;
}
case FileCommand::GetSize: {
LOG_TRACE(Service_FS, "GetSize %s %s", GetTypeName().c_str(), GetName().c_str());
u64 size = backend->GetSize();
cmd_buff[2] = (u32)size;
cmd_buff[3] = size >> 32;
break;
}
case FileCommand::Close:
{
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
backend->Close();
break;
}
case FileCommand::SetSize: {
u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32);
LOG_TRACE(Service_FS, "SetSize %s %s size=%llu", GetTypeName().c_str(), GetName().c_str(),
size);
backend->SetSize(size);
break;
}
case FileCommand::Flush:
{
LOG_TRACE(Service_FS, "Flush");
backend->Flush();
break;
}
case FileCommand::Close: {
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
backend->Close();
break;
}
case FileCommand::OpenLinkFile:
{
LOG_WARNING(Service_FS, "(STUBBED) File command OpenLinkFile %s", GetName().c_str());
cmd_buff[3] = Kernel::g_handle_table.Create(this).ValueOr(INVALID_HANDLE);
break;
}
case FileCommand::Flush: {
LOG_TRACE(Service_FS, "Flush");
backend->Flush();
break;
}
case FileCommand::SetPriority:
{
priority = cmd_buff[1];
LOG_TRACE(Service_FS, "SetPriority %u", priority);
break;
}
case FileCommand::OpenLinkFile: {
LOG_WARNING(Service_FS, "(STUBBED) File command OpenLinkFile %s", GetName().c_str());
cmd_buff[3] = Kernel::g_handle_table.Create(this).ValueOr(INVALID_HANDLE);
break;
}
case FileCommand::GetPriority:
{
cmd_buff[2] = priority;
LOG_TRACE(Service_FS, "GetPriority");
break;
}
case FileCommand::SetPriority: {
priority = cmd_buff[1];
LOG_TRACE(Service_FS, "SetPriority %u", priority);
break;
}
// Unknown command...
default:
LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
ResultCode error = UnimplementedFunction(ErrorModule::FS);
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
return error;
case FileCommand::GetPriority: {
cmd_buff[2] = priority;
LOG_TRACE(Service_FS, "GetPriority");
break;
}
// Unknown command...
default:
LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
ResultCode error = UnimplementedFunction(ErrorModule::FS);
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
return error;
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
return MakeResult<bool>(false);
}
Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path & path)
: path(path), backend(std::move(backend)) {}
Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend,
const FileSys::Path& path)
: path(path), backend(std::move(backend)) {
}
Directory::~Directory() {}
Directory::~Directory() {
}
ResultVal<bool> Directory::SyncRequest() {
u32* cmd_buff = Kernel::GetCommandBuffer();
DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
switch (cmd) {
// Read from directory...
case DirectoryCommand::Read:
{
u32 count = cmd_buff[1];
u32 address = cmd_buff[3];
std::vector<FileSys::Entry> entries(count);
LOG_TRACE(Service_FS, "Read %s %s: count=%d",
GetTypeName().c_str(), GetName().c_str(), count);
// Read from directory...
case DirectoryCommand::Read: {
u32 count = cmd_buff[1];
u32 address = cmd_buff[3];
std::vector<FileSys::Entry> entries(count);
LOG_TRACE(Service_FS, "Read %s %s: count=%d", GetTypeName().c_str(), GetName().c_str(),
count);
// Number of entries actually read
u32 read = backend->Read(entries.size(), entries.data());
cmd_buff[2] = read;
Memory::WriteBlock(address, entries.data(), read * sizeof(FileSys::Entry));
break;
}
// Number of entries actually read
u32 read = backend->Read(entries.size(), entries.data());
cmd_buff[2] = read;
Memory::WriteBlock(address, entries.data(), read * sizeof(FileSys::Entry));
break;
}
case DirectoryCommand::Close:
{
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
backend->Close();
break;
}
case DirectoryCommand::Close: {
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
backend->Close();
break;
}
// Unknown command...
default:
LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
ResultCode error = UnimplementedFunction(ErrorModule::FS);
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
return MakeResult<bool>(false);
// Unknown command...
default:
LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
ResultCode error = UnimplementedFunction(ErrorModule::FS);
cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
return MakeResult<bool>(false);
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
return MakeResult<bool>(false);
@ -280,8 +276,8 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
auto itr = id_code_map.find(id_code);
if (itr == id_code_map.end()) {
// TODO: Verify error against hardware
return ResultCode(ErrorDescription::NotFound, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Permanent);
return ResultCode(ErrorDescription::NotFound, ErrorModule::FS, ErrorSummary::NotFound,
ErrorLevel::Permanent);
}
CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, itr->second->Open(archive_path));
@ -303,19 +299,22 @@ ResultCode CloseArchive(ArchiveHandle handle) {
// TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in
// http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22
ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, ArchiveIdCode id_code) {
ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code) {
auto result = id_code_map.emplace(id_code, std::move(factory));
bool inserted = result.second;
ASSERT_MSG(inserted, "Tried to register more than one archive with same id code");
auto& archive = result.first->second;
LOG_DEBUG(Service_FS, "Registered archive %s with id code 0x%08X", archive->GetName().c_str(), id_code);
LOG_DEBUG(Service_FS, "Registered archive %s with id code 0x%08X", archive->GetName().c_str(),
id_code);
return RESULT_SUCCESS;
}
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path, const FileSys::Mode mode) {
const FileSys::Path& path,
const FileSys::Mode mode) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return ERR_INVALID_ARCHIVE_HANDLE;
@ -336,8 +335,10 @@ ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Pa
return archive->DeleteFile(path);
}
ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) {
ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr)
@ -368,7 +369,8 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
ErrorSummary::Canceled, ErrorLevel::Status);
}
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u64 file_size) {
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
u64 file_size) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return ERR_INVALID_ARCHIVE_HANDLE;
@ -387,8 +389,10 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
ErrorSummary::Canceled, ErrorLevel::Status);
}
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) {
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr)
@ -409,15 +413,15 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
}
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return ERR_INVALID_ARCHIVE_HANDLE;
std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path);
if (backend == nullptr) {
return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Permanent);
return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound,
ErrorLevel::Permanent);
}
auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path));
@ -431,7 +435,8 @@ ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) {
return MakeResult<u64>(archive->GetFreeBytes());
}
ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info, const FileSys::Path& path) {
ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path) {
auto archive_itr = id_code_map.find(id_code);
if (archive_itr == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@ -440,7 +445,8 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo
return archive_itr->second->Format(path, format_info);
}
ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code, FileSys::Path& archive_path) {
ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code,
FileSys::Path& archive_path) {
auto archive = id_code_map.find(id_code);
if (archive == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@ -449,11 +455,14 @@ ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code
return archive->second->GetFormatInfo(archive_path);
}
ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size, const FileSys::ArchiveFormatInfo& format_info) {
ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer,
u32 icon_size, const FileSys::ArchiveFormatInfo& format_info) {
// Construct the binary path to the archive first
FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
FileSys::Path path =
FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
auto archive = id_code_map.find(media_type == MediaType::NAND ? ArchiveIdCode::SharedExtSaveData : ArchiveIdCode::ExtSaveData);
auto archive = id_code_map.find(media_type == MediaType::NAND ? ArchiveIdCode::SharedExtSaveData
: ArchiveIdCode::ExtSaveData);
if (archive == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@ -476,7 +485,8 @@ ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon
ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
// Construct the binary path to the archive first
FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
FileSys::Path path =
FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
std::string media_type_directory;
if (media_type == MediaType::NAND) {
@ -489,7 +499,8 @@ ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
}
// Delete all directories (/user, /boss) and the icon file.
std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
std::string base_path =
FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path);
if (FileUtil::Exists(extsavedata_path) && !FileUtil::DeleteDirRecursively(extsavedata_path))
return ResultCode(-1); // TODO(Subv): Find the right error code
@ -530,30 +541,36 @@ void RegisterArchiveTypes() {
if (sdmc_factory->Initialize())
RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC);
else
LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s",
sdmc_directory.c_str());
// Create the SaveData archive
auto savedata_factory = std::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory);
RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData);
auto extsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false);
auto extsavedata_factory =
std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false);
if (extsavedata_factory->Initialize())
RegisterArchiveType(std::move(extsavedata_factory), ArchiveIdCode::ExtSaveData);
else
LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_factory->GetMountPoint().c_str());
LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s",
extsavedata_factory->GetMountPoint().c_str());
auto sharedextsavedata_factory = std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true);
auto sharedextsavedata_factory =
std::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true);
if (sharedextsavedata_factory->Initialize())
RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData);
else
LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s",
sharedextsavedata_factory->GetMountPoint().c_str());
sharedextsavedata_factory->GetMountPoint().c_str());
// Create the SaveDataCheck archive, basically a small variation of the RomFS archive
auto savedatacheck_factory = std::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory);
auto savedatacheck_factory =
std::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory);
RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck);
auto systemsavedata_factory = std::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory);
auto systemsavedata_factory =
std::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory);
RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData);
}

View File

@ -28,21 +28,18 @@ namespace FS {
/// Supported archive types
enum class ArchiveIdCode : u32 {
RomFS = 0x00000003,
SaveData = 0x00000004,
ExtSaveData = 0x00000006,
SharedExtSaveData = 0x00000007,
SystemSaveData = 0x00000008,
SDMC = 0x00000009,
SDMCWriteOnly = 0x0000000A,
SaveDataCheck = 0x2345678A,
RomFS = 0x00000003,
SaveData = 0x00000004,
ExtSaveData = 0x00000006,
SharedExtSaveData = 0x00000007,
SystemSaveData = 0x00000008,
SDMC = 0x00000009,
SDMCWriteOnly = 0x0000000A,
SaveDataCheck = 0x2345678A,
};
/// Media types for the archives
enum class MediaType : u32 {
NAND = 0,
SDMC = 1
};
enum class MediaType : u32 { NAND = 0, SDMC = 1 };
typedef u64 ArchiveHandle;
@ -51,11 +48,13 @@ public:
File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path);
~File();
std::string GetName() const override { return "Path: " + path.DebugStr(); }
std::string GetName() const override {
return "Path: " + path.DebugStr();
}
ResultVal<bool> SyncRequest() override;
FileSys::Path path; ///< Path of the file
u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
};
@ -64,10 +63,12 @@ public:
Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path);
~Directory();
std::string GetName() const override { return "Directory: " + path.DebugStr(); }
std::string GetName() const override {
return "Directory: " + path.DebugStr();
}
ResultVal<bool> SyncRequest() override;
FileSys::Path path; ///< Path of the directory
FileSys::Path path; ///< Path of the directory
std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
};
@ -90,7 +91,8 @@ ResultCode CloseArchive(ArchiveHandle handle);
* @param factory File system backend interface to the archive
* @param id_code Id code used to access this type of archive
*/
ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, ArchiveIdCode id_code);
ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code);
/**
* Open a File from an Archive
@ -100,7 +102,8 @@ ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factor
* @return The opened File object as a Session
*/
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path, const FileSys::Mode mode);
const FileSys::Path& path,
const FileSys::Mode mode);
/**
* Delete a File from an Archive
@ -118,8 +121,10 @@ ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Pa
* @param dest_path Path to the File inside of the destination Archive
* @return Whether rename succeeded
*/
ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path);
ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path);
/**
* Delete a Directory from an Archive
@ -136,7 +141,8 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
* @param file_size The size of the new file, filled with zeroes
* @return File creation result code
*/
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u64 file_size);
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
u64 file_size);
/**
* Create a Directory from an Archive
@ -154,8 +160,10 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
* @param dest_path Path to the Directory inside of the destination Archive
* @return Whether rename succeeded
*/
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path);
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path);
/**
* Open a Directory from an Archive
@ -164,7 +172,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
* @return The opened Directory object as a Session
*/
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path);
const FileSys::Path& path);
/**
* Get the free space in an Archive
@ -181,7 +189,8 @@ ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle);
* @param path The path to the archive, if relevant.
* @return ResultCode 0 on success or the corresponding code on error
*/
ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info, const FileSys::Path& path = FileSys::Path());
ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path = FileSys::Path());
/**
* Retrieves the format info about the archive of the specified type and path.
@ -190,7 +199,8 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo
* @param archive_path The path of the archive, if relevant
* @return The format info of the archive, or the corresponding error code if failed.
*/
ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code, FileSys::Path& archive_path);
ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code,
FileSys::Path& archive_path);
/**
* Creates a blank SharedExtSaveData archive for the specified extdata ID
@ -202,7 +212,8 @@ ResultVal<FileSys::ArchiveFormatInfo> GetArchiveFormatInfo(ArchiveIdCode id_code
* @param format_info Format information about the new archive
* @return ResultCode 0 on success or the corresponding code on error
*/
ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size, const FileSys::ArchiveFormatInfo& format_info);
ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer,
u32 icon_size, const FileSys::ArchiveFormatInfo& format_info);
/**
* Deletes the SharedExtSaveData archive for the specified extdata ID

View File

@ -57,14 +57,16 @@ static void OpenFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
FileSys::Mode mode; mode.hex = cmd_buff[6];
u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes.
u32 filename_ptr = cmd_buff[9];
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
FileSys::Mode mode;
mode.hex = cmd_buff[6];
u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes.
u32 filename_ptr = cmd_buff[9];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes);
LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex,
attributes);
ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(archive_handle, file_path, mode);
cmd_buff[1] = file_res.Code().raw;
@ -98,24 +100,27 @@ static void OpenFile(Service::Interface* self) {
static void OpenFileDirectly(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
u32 archivename_size = cmd_buff[4];
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
u32 filename_size = cmd_buff[6];
FileSys::Mode mode; mode.hex = cmd_buff[7];
u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
u32 archivename_ptr = cmd_buff[10];
u32 filename_ptr = cmd_buff[12];
u32 archivename_size = cmd_buff[4];
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
u32 filename_size = cmd_buff[6];
FileSys::Mode mode;
mode.hex = cmd_buff[7];
u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
u32 archivename_ptr = cmd_buff[10];
u32 filename_ptr = cmd_buff[12];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s file_path=%s, mode=%u attributes=%d",
archive_id, archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex, attributes);
archive_id, archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex,
attributes);
ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
if (archive_handle.Failed()) {
LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
LOG_ERROR(Service_FS,
"failed to get a handle for archive archive_id=0x%08X archive_path=%s",
archive_id, archive_path.DebugStr().c_str());
cmd_buff[1] = archive_handle.Code().raw;
cmd_buff[3] = 0;
@ -149,14 +154,14 @@ static void DeleteFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
u32 filename_ptr = cmd_buff[7];
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
u32 filename_ptr = cmd_buff[7];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
filename_type, filename_size, file_path.DebugStr().c_str());
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", filename_type, filename_size,
file_path.DebugStr().c_str());
cmd_buff[1] = DeleteFileFromArchive(archive_handle, file_path).raw;
}
@ -181,22 +186,26 @@ static void RenameFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto src_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 src_filename_size = cmd_buff[5];
ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);;
auto dest_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
u32 dest_filename_size = cmd_buff[9];
u32 src_filename_ptr = cmd_buff[11];
u32 dest_filename_ptr = cmd_buff[13];
auto src_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 src_filename_size = cmd_buff[5];
ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);
;
auto dest_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
u32 dest_filename_size = cmd_buff[9];
u32 src_filename_ptr = cmd_buff[11];
u32 dest_filename_ptr = cmd_buff[13];
FileSys::Path src_file_path(src_filename_type, src_filename_size, src_filename_ptr);
FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr);
LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
LOG_DEBUG(Service_FS,
"src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(),
dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str());
cmd_buff[1] = RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path).raw;
cmd_buff[1] = RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle,
dest_file_path)
.raw;
}
/*
@ -214,14 +223,14 @@ static void DeleteDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 dirname_size = cmd_buff[5];
u32 dirname_ptr = cmd_buff[7];
auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 dirname_size = cmd_buff[5];
u32 dirname_ptr = cmd_buff[7];
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
dirname_type, dirname_size, dir_path.DebugStr().c_str());
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
dir_path.DebugStr().c_str());
cmd_buff[1] = DeleteDirectoryFromArchive(archive_handle, dir_path).raw;
}
@ -243,14 +252,15 @@ static void CreateFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
u64 file_size = ((u64)cmd_buff[8] << 32) | cmd_buff[7];
u32 filename_ptr = cmd_buff[10];
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
u64 file_size = ((u64)cmd_buff[8] << 32) | cmd_buff[7];
u32 filename_ptr = cmd_buff[10];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%llu data=%s", filename_type, file_size, file_path.DebugStr().c_str());
LOG_DEBUG(Service_FS, "type=%d size=%llu data=%s", filename_type, file_size,
file_path.DebugStr().c_str());
cmd_buff[1] = CreateFileInArchive(archive_handle, file_path, file_size).raw;
}
@ -276,7 +286,8 @@ static void CreateDirectory(Service::Interface* self) {
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
dir_path.DebugStr().c_str());
cmd_buff[1] = CreateDirectoryFromArchive(archive_handle, dir_path).raw;
}
@ -301,22 +312,25 @@ static void RenameDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto src_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 src_dirname_size = cmd_buff[5];
auto src_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 src_dirname_size = cmd_buff[5];
ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);
auto dest_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
u32 dest_dirname_size = cmd_buff[9];
u32 src_dirname_ptr = cmd_buff[11];
u32 dest_dirname_ptr = cmd_buff[13];
auto dest_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
u32 dest_dirname_size = cmd_buff[9];
u32 src_dirname_ptr = cmd_buff[11];
u32 dest_dirname_ptr = cmd_buff[13];
FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr);
FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr);
LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
LOG_DEBUG(Service_FS,
"src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(),
dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str());
cmd_buff[1] = RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path).raw;
cmd_buff[1] = RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path,
dest_archive_handle, dest_dir_path)
.raw;
}
/**
@ -342,7 +356,8 @@ static void OpenDirectory(Service::Interface* self) {
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
dir_path.DebugStr().c_str());
ResultVal<SharedPtr<Directory>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path);
cmd_buff[1] = dir_res.Code().raw;
@ -370,13 +385,14 @@ static void OpenDirectory(Service::Interface* self) {
static void OpenArchive(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
u32 archivename_size = cmd_buff[3];
u32 archivename_ptr = cmd_buff[5];
u32 archivename_size = cmd_buff[3];
u32 archivename_ptr = cmd_buff[5];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", archive_id, archive_path.DebugStr().c_str());
LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", archive_id,
archive_path.DebugStr().c_str());
ResultVal<ArchiveHandle> handle = OpenArchive(archive_id, archive_path);
cmd_buff[1] = handle.Code().raw;
@ -385,7 +401,8 @@ static void OpenArchive(Service::Interface* self) {
cmd_buff[3] = (*handle >> 32) & 0xFFFFFFFF;
} else {
cmd_buff[2] = cmd_buff[3] = 0;
LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
LOG_ERROR(Service_FS,
"failed to get a handle for archive archive_id=0x%08X archive_path=%s",
archive_id, archive_path.DebugStr().c_str());
}
}
@ -471,7 +488,8 @@ static void FormatSaveData(Service::Interface* self) {
if (archive_id != FS::ArchiveIdCode::SaveData) {
LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u", archive_id);
cmd_buff[1] = ResultCode(ErrorDescription::FS_InvalidPath, ErrorModule::FS,
ErrorSummary::InvalidArgument, ErrorLevel::Usage).raw;
ErrorSummary::InvalidArgument, ErrorLevel::Usage)
.raw;
return;
}
@ -571,18 +589,21 @@ static void CreateExtSaveData(Service::Interface* self) {
u32 icon_size = cmd_buff[9];
VAddr icon_buffer = cmd_buff[11];
LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"icon_size=%08X icon_descriptor=%08X icon_buffer=%08X", save_high, save_low,
cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8], icon_size,
cmd_buff[10], icon_buffer);
LOG_WARNING(
Service_FS,
"(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"icon_size=%08X icon_descriptor=%08X icon_buffer=%08X",
save_high, save_low, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7],
cmd_buff[8], icon_size, cmd_buff[10], icon_buffer);
FileSys::ArchiveFormatInfo format_info;
format_info.number_directories = cmd_buff[5];
format_info.number_files = cmd_buff[6];
format_info.duplicate_data = false;
format_info.total_size = 0;
cmd_buff[1] = CreateExtSaveData(media_type, save_high, save_low, icon_buffer, icon_size, format_info).raw;
cmd_buff[1] =
CreateExtSaveData(media_type, save_high, save_low, icon_buffer, icon_size, format_info).raw;
}
/**
@ -604,7 +625,7 @@ static void DeleteExtSaveData(Service::Interface* self) {
u32 unknown = cmd_buff[4]; // TODO(Subv): Figure out what this is
LOG_WARNING(Service_FS, "(STUBBED) save_low=%08X save_high=%08X media_type=%08X unknown=%08X",
save_low, save_high, cmd_buff[1] & 0xFF, unknown);
save_low, save_high, cmd_buff[1] & 0xFF, unknown);
cmd_buff[1] = DeleteExtSaveData(media_type, save_high, save_low).raw;
}
@ -662,10 +683,13 @@ static void CreateSystemSaveData(Service::Interface* self) {
u32 savedata_high = cmd_buff[1];
u32 savedata_low = cmd_buff[2];
LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"cmd_buff[9]=%08X", savedata_high, savedata_low, cmd_buff[3], cmd_buff[4], cmd_buff[5],
cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9]);
LOG_WARNING(
Service_FS,
"(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"cmd_buff[9]=%08X",
savedata_high, savedata_low, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6],
cmd_buff[7], cmd_buff[8], cmd_buff[9]);
cmd_buff[1] = CreateSystemSaveData(savedata_high, savedata_low).raw;
}
@ -692,10 +716,13 @@ static void CreateLegacySystemSaveData(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 savedata_id = cmd_buff[1];
LOG_WARNING(Service_FS, "(STUBBED) savedata_id=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"cmd_buff[9]=%08X", savedata_id, cmd_buff[3], cmd_buff[4], cmd_buff[5],
cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9]);
LOG_WARNING(
Service_FS,
"(STUBBED) savedata_id=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"cmd_buff[9]=%08X",
savedata_id, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8],
cmd_buff[9]);
cmd_buff[0] = IPC::MakeHeader(0x810, 0x1, 0);
// With this command, the SystemSaveData always has save_high = 0 (Always created in the NAND)
@ -721,8 +748,8 @@ static void InitializeWithSdkVersion(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_FS, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, unk3=0x%08X",
unk1, unk2, unk3);
LOG_WARNING(Service_FS, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, unk3=0x%08X", unk1, unk2,
unk3);
}
/**
@ -834,115 +861,114 @@ static void GetFormatInfo(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x000100C6, nullptr, "Dummy1"},
{0x040100C4, nullptr, "Control"},
{0x08010002, Initialize, "Initialize"},
{0x080201C2, OpenFile, "OpenFile"},
{0x08030204, OpenFileDirectly, "OpenFileDirectly"},
{0x08040142, DeleteFile, "DeleteFile"},
{0x08050244, RenameFile, "RenameFile"},
{0x08060142, DeleteDirectory, "DeleteDirectory"},
{0x08070142, nullptr, "DeleteDirectoryRecursively"},
{0x08080202, CreateFile, "CreateFile"},
{0x08090182, CreateDirectory, "CreateDirectory"},
{0x080A0244, RenameDirectory, "RenameDirectory"},
{0x080B0102, OpenDirectory, "OpenDirectory"},
{0x080C00C2, OpenArchive, "OpenArchive"},
{0x080D0144, nullptr, "ControlArchive"},
{0x080E0080, CloseArchive, "CloseArchive"},
{0x080F0180, FormatThisUserSaveData, "FormatThisUserSaveData"},
{0x000100C6, nullptr, "Dummy1"},
{0x040100C4, nullptr, "Control"},
{0x08010002, Initialize, "Initialize"},
{0x080201C2, OpenFile, "OpenFile"},
{0x08030204, OpenFileDirectly, "OpenFileDirectly"},
{0x08040142, DeleteFile, "DeleteFile"},
{0x08050244, RenameFile, "RenameFile"},
{0x08060142, DeleteDirectory, "DeleteDirectory"},
{0x08070142, nullptr, "DeleteDirectoryRecursively"},
{0x08080202, CreateFile, "CreateFile"},
{0x08090182, CreateDirectory, "CreateDirectory"},
{0x080A0244, RenameDirectory, "RenameDirectory"},
{0x080B0102, OpenDirectory, "OpenDirectory"},
{0x080C00C2, OpenArchive, "OpenArchive"},
{0x080D0144, nullptr, "ControlArchive"},
{0x080E0080, CloseArchive, "CloseArchive"},
{0x080F0180, FormatThisUserSaveData, "FormatThisUserSaveData"},
{0x08100200, CreateLegacySystemSaveData, "CreateLegacySystemSaveData"},
{0x08110040, nullptr, "DeleteSystemSaveData"},
{0x08120080, GetFreeBytes, "GetFreeBytes"},
{0x08130000, nullptr, "GetCardType"},
{0x08140000, nullptr, "GetSdmcArchiveResource"},
{0x08150000, nullptr, "GetNandArchiveResource"},
{0x08160000, nullptr, "GetSdmcFatfsError"},
{0x08170000, IsSdmcDetected, "IsSdmcDetected"},
{0x08180000, IsSdmcWriteable, "IsSdmcWritable"},
{0x08190042, nullptr, "GetSdmcCid"},
{0x081A0042, nullptr, "GetNandCid"},
{0x081B0000, nullptr, "GetSdmcSpeedInfo"},
{0x081C0000, nullptr, "GetNandSpeedInfo"},
{0x081D0042, nullptr, "GetSdmcLog"},
{0x081E0042, nullptr, "GetNandLog"},
{0x081F0000, nullptr, "ClearSdmcLog"},
{0x08200000, nullptr, "ClearNandLog"},
{0x08210000, CardSlotIsInserted, "CardSlotIsInserted"},
{0x08220000, nullptr, "CardSlotPowerOn"},
{0x08230000, nullptr, "CardSlotPowerOff"},
{0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"},
{0x08250040, nullptr, "CardNorDirectCommand"},
{0x08260080, nullptr, "CardNorDirectCommandWithAddress"},
{0x08270082, nullptr, "CardNorDirectRead"},
{0x082800C2, nullptr, "CardNorDirectReadWithAddress"},
{0x08290082, nullptr, "CardNorDirectWrite"},
{0x082A00C2, nullptr, "CardNorDirectWriteWithAddress"},
{0x082B00C2, nullptr, "CardNorDirectRead_4xIO"},
{0x082C0082, nullptr, "CardNorDirectCpuWriteWithoutVerify"},
{0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"},
{0x082E0040, nullptr, "GetProductInfo"},
{0x082F0040, nullptr, "GetProgramLaunchInfo"},
{0x08300182, nullptr, "CreateExtSaveData"},
{0x08310180, nullptr, "CreateSharedExtSaveData"},
{0x08320102, nullptr, "ReadExtSaveDataIcon"},
{0x08330082, nullptr, "EnumerateExtSaveData"},
{0x08340082, nullptr, "EnumerateSharedExtSaveData"},
{0x08350080, nullptr, "DeleteExtSaveData"},
{0x08360080, nullptr, "DeleteSharedExtSaveData"},
{0x08370040, nullptr, "SetCardSpiBaudRate"},
{0x08380040, nullptr, "SetCardSpiBusMode"},
{0x08390000, nullptr, "SendInitializeInfoTo9"},
{0x083A0100, nullptr, "GetSpecialContentIndex"},
{0x083B00C2, nullptr, "GetLegacyRomHeader"},
{0x083C00C2, nullptr, "GetLegacyBannerData"},
{0x083D0100, nullptr, "CheckAuthorityToAccessExtSaveData"},
{0x083E00C2, nullptr, "QueryTotalQuotaSize"},
{0x083F00C0, nullptr, "GetExtDataBlockSize"},
{0x08400040, nullptr, "AbnegateAccessRight"},
{0x08410000, nullptr, "DeleteSdmcRoot"},
{0x08420040, nullptr, "DeleteAllExtSaveDataOnNand"},
{0x08430000, nullptr, "InitializeCtrFileSystem"},
{0x08440000, nullptr, "CreateSeed"},
{0x084500C2, GetFormatInfo, "GetFormatInfo"},
{0x08460102, nullptr, "GetLegacyRomHeader2"},
{0x08470180, nullptr, "FormatCtrCardUserSaveData"},
{0x08480042, nullptr, "GetSdmcCtrRootPath"},
{0x08490040, GetArchiveResource, "GetArchiveResource"},
{0x084A0002, nullptr, "ExportIntegrityVerificationSeed"},
{0x084B0002, nullptr, "ImportIntegrityVerificationSeed"},
{0x084C0242, FormatSaveData, "FormatSaveData"},
{0x084D0102, nullptr, "GetLegacySubBannerData"},
{0x084E0342, nullptr, "UpdateSha256Context"},
{0x084F0102, nullptr, "ReadSpecialFile"},
{0x08500040, nullptr, "GetSpecialFileSize"},
{0x08510242, CreateExtSaveData, "CreateExtSaveData"},
{0x08520100, DeleteExtSaveData, "DeleteExtSaveData"},
{0x08530142, nullptr, "ReadExtSaveDataIcon"},
{0x085400C0, nullptr, "GetExtDataBlockSize"},
{0x08550102, nullptr, "EnumerateExtSaveData"},
{0x08560240, CreateSystemSaveData, "CreateSystemSaveData"},
{0x08570080, DeleteSystemSaveData, "DeleteSystemSaveData"},
{0x08580000, nullptr, "StartDeviceMoveAsSource"},
{0x08590200, nullptr, "StartDeviceMoveAsDestination"},
{0x085A00C0, nullptr, "SetArchivePriority"},
{0x085B0080, nullptr, "GetArchivePriority"},
{0x085C00C0, nullptr, "SetCtrCardLatencyParameter"},
{0x085D01C0, nullptr, "SetFsCompatibilityInfo"},
{0x085E0040, nullptr, "ResetCardCompatibilityParameter"},
{0x085F0040, nullptr, "SwitchCleanupInvalidSaveData"},
{0x08600042, nullptr, "EnumerateSystemSaveData"},
{0x08110040, nullptr, "DeleteSystemSaveData"},
{0x08120080, GetFreeBytes, "GetFreeBytes"},
{0x08130000, nullptr, "GetCardType"},
{0x08140000, nullptr, "GetSdmcArchiveResource"},
{0x08150000, nullptr, "GetNandArchiveResource"},
{0x08160000, nullptr, "GetSdmcFatfsError"},
{0x08170000, IsSdmcDetected, "IsSdmcDetected"},
{0x08180000, IsSdmcWriteable, "IsSdmcWritable"},
{0x08190042, nullptr, "GetSdmcCid"},
{0x081A0042, nullptr, "GetNandCid"},
{0x081B0000, nullptr, "GetSdmcSpeedInfo"},
{0x081C0000, nullptr, "GetNandSpeedInfo"},
{0x081D0042, nullptr, "GetSdmcLog"},
{0x081E0042, nullptr, "GetNandLog"},
{0x081F0000, nullptr, "ClearSdmcLog"},
{0x08200000, nullptr, "ClearNandLog"},
{0x08210000, CardSlotIsInserted, "CardSlotIsInserted"},
{0x08220000, nullptr, "CardSlotPowerOn"},
{0x08230000, nullptr, "CardSlotPowerOff"},
{0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"},
{0x08250040, nullptr, "CardNorDirectCommand"},
{0x08260080, nullptr, "CardNorDirectCommandWithAddress"},
{0x08270082, nullptr, "CardNorDirectRead"},
{0x082800C2, nullptr, "CardNorDirectReadWithAddress"},
{0x08290082, nullptr, "CardNorDirectWrite"},
{0x082A00C2, nullptr, "CardNorDirectWriteWithAddress"},
{0x082B00C2, nullptr, "CardNorDirectRead_4xIO"},
{0x082C0082, nullptr, "CardNorDirectCpuWriteWithoutVerify"},
{0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"},
{0x082E0040, nullptr, "GetProductInfo"},
{0x082F0040, nullptr, "GetProgramLaunchInfo"},
{0x08300182, nullptr, "CreateExtSaveData"},
{0x08310180, nullptr, "CreateSharedExtSaveData"},
{0x08320102, nullptr, "ReadExtSaveDataIcon"},
{0x08330082, nullptr, "EnumerateExtSaveData"},
{0x08340082, nullptr, "EnumerateSharedExtSaveData"},
{0x08350080, nullptr, "DeleteExtSaveData"},
{0x08360080, nullptr, "DeleteSharedExtSaveData"},
{0x08370040, nullptr, "SetCardSpiBaudRate"},
{0x08380040, nullptr, "SetCardSpiBusMode"},
{0x08390000, nullptr, "SendInitializeInfoTo9"},
{0x083A0100, nullptr, "GetSpecialContentIndex"},
{0x083B00C2, nullptr, "GetLegacyRomHeader"},
{0x083C00C2, nullptr, "GetLegacyBannerData"},
{0x083D0100, nullptr, "CheckAuthorityToAccessExtSaveData"},
{0x083E00C2, nullptr, "QueryTotalQuotaSize"},
{0x083F00C0, nullptr, "GetExtDataBlockSize"},
{0x08400040, nullptr, "AbnegateAccessRight"},
{0x08410000, nullptr, "DeleteSdmcRoot"},
{0x08420040, nullptr, "DeleteAllExtSaveDataOnNand"},
{0x08430000, nullptr, "InitializeCtrFileSystem"},
{0x08440000, nullptr, "CreateSeed"},
{0x084500C2, GetFormatInfo, "GetFormatInfo"},
{0x08460102, nullptr, "GetLegacyRomHeader2"},
{0x08470180, nullptr, "FormatCtrCardUserSaveData"},
{0x08480042, nullptr, "GetSdmcCtrRootPath"},
{0x08490040, GetArchiveResource, "GetArchiveResource"},
{0x084A0002, nullptr, "ExportIntegrityVerificationSeed"},
{0x084B0002, nullptr, "ImportIntegrityVerificationSeed"},
{0x084C0242, FormatSaveData, "FormatSaveData"},
{0x084D0102, nullptr, "GetLegacySubBannerData"},
{0x084E0342, nullptr, "UpdateSha256Context"},
{0x084F0102, nullptr, "ReadSpecialFile"},
{0x08500040, nullptr, "GetSpecialFileSize"},
{0x08510242, CreateExtSaveData, "CreateExtSaveData"},
{0x08520100, DeleteExtSaveData, "DeleteExtSaveData"},
{0x08530142, nullptr, "ReadExtSaveDataIcon"},
{0x085400C0, nullptr, "GetExtDataBlockSize"},
{0x08550102, nullptr, "EnumerateExtSaveData"},
{0x08560240, CreateSystemSaveData, "CreateSystemSaveData"},
{0x08570080, DeleteSystemSaveData, "DeleteSystemSaveData"},
{0x08580000, nullptr, "StartDeviceMoveAsSource"},
{0x08590200, nullptr, "StartDeviceMoveAsDestination"},
{0x085A00C0, nullptr, "SetArchivePriority"},
{0x085B0080, nullptr, "GetArchivePriority"},
{0x085C00C0, nullptr, "SetCtrCardLatencyParameter"},
{0x085D01C0, nullptr, "SetFsCompatibilityInfo"},
{0x085E0040, nullptr, "ResetCardCompatibilityParameter"},
{0x085F0040, nullptr, "SwitchCleanupInvalidSaveData"},
{0x08600042, nullptr, "EnumerateSystemSaveData"},
{0x08610042, InitializeWithSdkVersion, "InitializeWithSdkVersion"},
{0x08620040, SetPriority, "SetPriority"},
{0x08630000, GetPriority, "GetPriority"},
{0x08640000, nullptr, "GetNandInfo"},
{0x08650140, nullptr, "SetSaveDataSecureValue"},
{0x086600C0, nullptr, "GetSaveDataSecureValue"},
{0x086700C4, nullptr, "ControlSecureSave"},
{0x08680000, nullptr, "GetMediaType"},
{0x08690000, nullptr, "GetNandEraseCount"},
{0x086A0082, nullptr, "ReadNandReport"}
};
{0x08620040, SetPriority, "SetPriority"},
{0x08630000, GetPriority, "GetPriority"},
{0x08640000, nullptr, "GetNandInfo"},
{0x08650140, nullptr, "SetSaveDataSecureValue"},
{0x086600C0, nullptr, "GetSaveDataSecureValue"},
{0x086700C4, nullptr, "ControlSecureSave"},
{0x08680000, nullptr, "GetMediaType"},
{0x08690000, nullptr, "GetNandEraseCount"},
{0x086A0082, nullptr, "ReadNandReport"}};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class

View File

@ -5,16 +5,16 @@
#include "common/bit_field.h"
#include "common/microprofile.h"
#include "core/memory.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/result.h"
#include "core/hw/hw.h"
#include "core/hw/gpu.h"
#include "core/hw/hw.h"
#include "core/hw/lcd.h"
#include "core/memory.h"
#include "video_core/gpu_debugger.h"
#include "video_core/debug_utils/debug_utils.h"
#include "video_core/gpu_debugger.h"
#include "gsp_gpu.h"
@ -29,12 +29,16 @@ const static u32 REGS_BEGIN = 0x1EB00000;
namespace GSP_GPU {
const ResultCode ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED(ErrorDescription::OutofRangeOrMisalignedAddress, ErrorModule::GX,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02A01
const ResultCode
ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED(ErrorDescription::OutofRangeOrMisalignedAddress,
ErrorModule::GX, ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02A01
const ResultCode ERR_GSP_REGS_MISALIGNED(ErrorDescription::MisalignedSize, ErrorModule::GX,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02BF2
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02BF2
const ResultCode ERR_GSP_REGS_INVALID_SIZE(ErrorDescription::InvalidSize, ErrorModule::GX,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E02BEC
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02BEC
/// Event triggered when GSP interrupt has been signalled
Kernel::SharedPtr<Kernel::Event> g_interrupt_event;
@ -73,7 +77,8 @@ static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) {
* @param data Data to be written
*/
static void WriteSingleHWReg(u32 base_address, u32 data) {
DEBUG_ASSERT_MSG((base_address & 3) == 0 && base_address < 0x420000, "Write address out of range or misaligned");
DEBUG_ASSERT_MSG((base_address & 3) == 0 && base_address < 0x420000,
"Write address out of range or misaligned");
HW::Write<u32>(base_address + REGS_BEGIN, data);
}
@ -90,7 +95,8 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, VAddr data_va
const u32 max_size_in_bytes = 0x80;
if (base_address & 3 || base_address >= 0x420000) {
LOG_ERROR(Service_GSP, "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
LOG_ERROR(Service_GSP,
"Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
base_address, size_in_bytes);
return ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED;
} else if (size_in_bytes <= max_size_in_bytes) {
@ -124,12 +130,14 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, VAddr data_va
* @param masks A pointer to the masks
* @return RESULT_SUCCESS if the parameters are valid, error code otherwise
*/
static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, VAddr data_vaddr, VAddr masks_vaddr) {
static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, VAddr data_vaddr,
VAddr masks_vaddr) {
// This magic number is verified to be done by the gsp module
const u32 max_size_in_bytes = 0x80;
if (base_address & 3 || base_address >= 0x420000) {
LOG_ERROR(Service_GSP, "Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
LOG_ERROR(Service_GSP,
"Write address was out of range or misaligned! (address=0x%08x, size=0x%08x)",
base_address, size_in_bytes);
return ERR_GSP_REGS_OUTOFRANGE_OR_MISALIGNED;
} else if (size_in_bytes <= max_size_in_bytes) {
@ -214,7 +222,8 @@ static void ReadHWRegs(Service::Interface* self) {
// TODO: Return proper error codes
if (reg_addr + size >= 0x420000) {
LOG_ERROR(Service_GSP, "Read address out of range! (address=0x%08x, size=0x%08x)", reg_addr, size);
LOG_ERROR(Service_GSP, "Read address out of range! (address=0x%08x, size=0x%08x)", reg_addr,
size);
return;
}
@ -243,22 +252,34 @@ ResultCode SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left);
PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right);
if (info.active_fb == 0) {
WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)),
phys_address_left);
WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)),
phys_address_right);
WriteSingleHWReg(
base_address +
4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)),
phys_address_left);
WriteSingleHWReg(
base_address +
4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)),
phys_address_right);
} else {
WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)),
phys_address_left);
WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)),
phys_address_right);
WriteSingleHWReg(
base_address +
4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)),
phys_address_left);
WriteSingleHWReg(
base_address +
4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)),
phys_address_right);
}
WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)),
WriteSingleHWReg(base_address +
4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)),
info.stride);
WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)),
info.format);
WriteSingleHWReg(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)),
info.shown_fb);
WriteSingleHWReg(
base_address +
4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)),
info.format);
WriteSingleHWReg(
base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)),
info.shown_fb);
if (Pica::g_debug_context)
Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr);
@ -305,15 +326,15 @@ static void SetBufferSwap(Service::Interface* self) {
static void FlushDataCache(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 address = cmd_buff[1];
u32 size = cmd_buff[2];
u32 size = cmd_buff[2];
u32 process = cmd_buff[4];
// TODO(purpasmart96): Verify return header on HW
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_DEBUG(Service_GSP, "(STUBBED) called address=0x%08X, size=0x%08X, process=0x%08X",
address, size, process);
LOG_DEBUG(Service_GSP, "(STUBBED) called address=0x%08X, size=0x%08X, process=0x%08X", address,
size, process);
}
/**
@ -356,11 +377,12 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) {
// This specific code is required for a successful initialization, rather than 0
first_initialization = false;
cmd_buff[1] = ResultCode(ErrorDescription::GPU_FirstInitialization, ErrorModule::GX,
ErrorSummary::Success, ErrorLevel::Success).raw;
ErrorSummary::Success, ErrorLevel::Success)
.raw;
} else {
cmd_buff[1] = RESULT_SUCCESS.raw;
}
cmd_buff[2] = g_thread_id++; // Thread ID
cmd_buff[2] = g_thread_id++; // Thread ID
cmd_buff[4] = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom(); // GSP shared memory
g_interrupt_event->Signal(); // TODO(bunnei): Is this correct?
@ -416,7 +438,8 @@ void SignalInterrupt(InterruptId interrupt_id) {
// Update framebuffer information if requested
// TODO(yuriks): Confirm where this code should be called. It is definitely updated without
// executing any GSP commands, only waiting on the event.
int screen_id = (interrupt_id == InterruptId::PDC0) ? 0 : (interrupt_id == InterruptId::PDC1) ? 1 : -1;
int screen_id =
(interrupt_id == InterruptId::PDC0) ? 0 : (interrupt_id == InterruptId::PDC1) ? 1 : -1;
if (screen_id != -1) {
FrameBufferUpdate* info = GetFrameBufferInfo(thread_id, screen_id);
if (info->is_dirty) {
@ -440,25 +463,27 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
switch (command.id) {
// GX request DMA - typically used for copying memory from GSP heap to VRAM
case CommandId::REQUEST_DMA:
{
case CommandId::REQUEST_DMA: {
MICROPROFILE_SCOPE(GPU_GSP_DMA);
// TODO: Consider attempting rasterizer-accelerated surface blit if that usage is ever possible/likely
Memory::RasterizerFlushRegion(Memory::VirtualToPhysicalAddress(command.dma_request.source_address),
command.dma_request.size);
Memory::RasterizerFlushAndInvalidateRegion(Memory::VirtualToPhysicalAddress(command.dma_request.dest_address),
command.dma_request.size);
// TODO: Consider attempting rasterizer-accelerated surface blit if that usage is ever
// possible/likely
Memory::RasterizerFlushRegion(
Memory::VirtualToPhysicalAddress(command.dma_request.source_address),
command.dma_request.size);
Memory::RasterizerFlushAndInvalidateRegion(
Memory::VirtualToPhysicalAddress(command.dma_request.dest_address),
command.dma_request.size);
// TODO(Subv): These memory accesses should not go through the application's memory mapping.
// They should go through the GSP module's memory mapping.
Memory::CopyBlock(command.dma_request.dest_address, command.dma_request.source_address, command.dma_request.size);
Memory::CopyBlock(command.dma_request.dest_address, command.dma_request.source_address,
command.dma_request.size);
SignalInterrupt(InterruptId::DMA);
break;
}
// TODO: This will need some rework in the future. (why?)
case CommandId::SUBMIT_GPU_CMDLIST:
{
case CommandId::SUBMIT_GPU_CMDLIST: {
auto& params = command.submit_gpu_cmdlist;
if (params.do_flush) {
@ -468,10 +493,12 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
}
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.address)),
Memory::VirtualToPhysicalAddress(params.address) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.size)), params.size);
Memory::VirtualToPhysicalAddress(params.address) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.size)),
params.size);
// TODO: Not sure if we are supposed to always write this .. seems to trigger processing though
// TODO: Not sure if we are supposed to always write this .. seems to trigger processing
// though
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.trigger)), 1);
// TODO(yuriks): Figure out the meaning of the `flags` field.
@ -481,67 +508,70 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
// It's assumed that the two "blocks" behave equivalently.
// Presumably this is done simply to allow two memory fills to run in parallel.
case CommandId::SET_MEMORY_FILL:
{
case CommandId::SET_MEMORY_FILL: {
auto& params = command.memory_fill;
if (params.start1 != 0) {
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_start)),
Memory::VirtualToPhysicalAddress(params.start1) >> 3);
Memory::VirtualToPhysicalAddress(params.start1) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_end)),
Memory::VirtualToPhysicalAddress(params.end1) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].value_32bit)), params.value1);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].control)), params.control1);
Memory::VirtualToPhysicalAddress(params.end1) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].value_32bit)),
params.value1);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].control)),
params.control1);
}
if (params.start2 != 0) {
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_start)),
Memory::VirtualToPhysicalAddress(params.start2) >> 3);
Memory::VirtualToPhysicalAddress(params.start2) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_end)),
Memory::VirtualToPhysicalAddress(params.end2) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].value_32bit)), params.value2);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].control)), params.control2);
Memory::VirtualToPhysicalAddress(params.end2) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].value_32bit)),
params.value2);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].control)),
params.control2);
}
break;
}
case CommandId::SET_DISPLAY_TRANSFER:
{
case CommandId::SET_DISPLAY_TRANSFER: {
auto& params = command.display_transfer;
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_address)),
Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_address)),
Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_size)), params.in_buffer_size);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_size)), params.out_buffer_size);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.flags)), params.flags);
Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_size)),
params.in_buffer_size);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_size)),
params.out_buffer_size);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.flags)),
params.flags);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.trigger)), 1);
break;
}
case CommandId::SET_TEXTURE_COPY:
{
case CommandId::SET_TEXTURE_COPY: {
auto& params = command.texture_copy;
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.input_address),
Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.output_address),
Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.texture_copy.size),
params.size);
params.size);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.texture_copy.input_size),
params.in_width_gap);
params.in_width_gap);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.texture_copy.output_size),
params.out_width_gap);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.flags),
params.flags);
params.out_width_gap);
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.flags), params.flags);
// NOTE: Actual GSP ORs 1 with current register instead of overwriting. Doesn't seem to matter.
// NOTE: Actual GSP ORs 1 with current register instead of overwriting. Doesn't seem to
// matter.
WriteGPURegister((u32)GPU_REG_INDEX(display_transfer_config.trigger), 1);
break;
}
case CommandId::CACHE_FLUSH:
{
case CommandId::CACHE_FLUSH: {
// NOTE: Rasterizer flushing handled elsewhere in CPU read/write and other GPU handlers
// Use command.cache_flush.regions to implement this handler
break;
@ -552,7 +582,8 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
}
if (Pica::g_debug_context)
Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::GSPCommandProcessed, (void*)&command);
Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::GSPCommandProcessed,
(void*)&command);
}
/**
@ -575,7 +606,7 @@ static void SetLcdForceBlack(Service::Interface* self) {
// the color to black (all zero).
data.is_enabled.Assign(enable_black);
LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_top), data.raw); // Top LCD
LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_top), data.raw); // Top LCD
LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_bottom), data.raw); // Bottom LCD
cmd_buff[1] = RESULT_SUCCESS.raw;
@ -679,37 +710,37 @@ static void ReleaseRight(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010082, WriteHWRegs, "WriteHWRegs"},
{0x00020084, WriteHWRegsWithMask, "WriteHWRegsWithMask"},
{0x00030082, nullptr, "WriteHWRegRepeat"},
{0x00040080, ReadHWRegs, "ReadHWRegs"},
{0x00050200, SetBufferSwap, "SetBufferSwap"},
{0x00060082, nullptr, "SetCommandList"},
{0x000700C2, nullptr, "RequestDma"},
{0x00080082, FlushDataCache, "FlushDataCache"},
{0x00090082, nullptr, "InvalidateDataCache"},
{0x000A0044, nullptr, "RegisterInterruptEvents"},
{0x000B0040, SetLcdForceBlack, "SetLcdForceBlack"},
{0x000C0000, TriggerCmdReqQueue, "TriggerCmdReqQueue"},
{0x000D0140, nullptr, "SetDisplayTransfer"},
{0x000E0180, nullptr, "SetTextureCopy"},
{0x000F0200, nullptr, "SetMemoryFill"},
{0x00100040, SetAxiConfigQoSMode, "SetAxiConfigQoSMode"},
{0x00110040, nullptr, "SetPerfLogMode"},
{0x00120000, nullptr, "GetPerfLog"},
{0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"},
{0x00010082, WriteHWRegs, "WriteHWRegs"},
{0x00020084, WriteHWRegsWithMask, "WriteHWRegsWithMask"},
{0x00030082, nullptr, "WriteHWRegRepeat"},
{0x00040080, ReadHWRegs, "ReadHWRegs"},
{0x00050200, SetBufferSwap, "SetBufferSwap"},
{0x00060082, nullptr, "SetCommandList"},
{0x000700C2, nullptr, "RequestDma"},
{0x00080082, FlushDataCache, "FlushDataCache"},
{0x00090082, nullptr, "InvalidateDataCache"},
{0x000A0044, nullptr, "RegisterInterruptEvents"},
{0x000B0040, SetLcdForceBlack, "SetLcdForceBlack"},
{0x000C0000, TriggerCmdReqQueue, "TriggerCmdReqQueue"},
{0x000D0140, nullptr, "SetDisplayTransfer"},
{0x000E0180, nullptr, "SetTextureCopy"},
{0x000F0200, nullptr, "SetMemoryFill"},
{0x00100040, SetAxiConfigQoSMode, "SetAxiConfigQoSMode"},
{0x00110040, nullptr, "SetPerfLogMode"},
{0x00120000, nullptr, "GetPerfLog"},
{0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"},
{0x00140000, UnregisterInterruptRelayQueue, "UnregisterInterruptRelayQueue"},
{0x00150002, nullptr, "TryAcquireRight"},
{0x00160042, AcquireRight, "AcquireRight"},
{0x00170000, ReleaseRight, "ReleaseRight"},
{0x00180000, ImportDisplayCaptureInfo, "ImportDisplayCaptureInfo"},
{0x00190000, nullptr, "SaveVramSysArea"},
{0x001A0000, nullptr, "RestoreVramSysArea"},
{0x001B0000, nullptr, "ResetGpuCore"},
{0x001C0040, nullptr, "SetLedForceOff"},
{0x001D0040, nullptr, "SetTestCommand"},
{0x001E0080, nullptr, "SetInternalPriorities"},
{0x001F0082, nullptr, "StoreDataCache"},
{0x00150002, nullptr, "TryAcquireRight"},
{0x00160042, AcquireRight, "AcquireRight"},
{0x00170000, ReleaseRight, "ReleaseRight"},
{0x00180000, ImportDisplayCaptureInfo, "ImportDisplayCaptureInfo"},
{0x00190000, nullptr, "SaveVramSysArea"},
{0x001A0000, nullptr, "RestoreVramSysArea"},
{0x001B0000, nullptr, "ResetGpuCore"},
{0x001C0040, nullptr, "SetLedForceOff"},
{0x001D0040, nullptr, "SetTestCommand"},
{0x001E0080, nullptr, "SetInternalPriorities"},
{0x001F0082, nullptr, "StoreDataCache"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -721,9 +752,9 @@ Interface::Interface() {
g_interrupt_event = nullptr;
using Kernel::MemoryPermission;
g_shared_memory = Kernel::SharedMemory::Create(nullptr, 0x1000,
MemoryPermission::ReadWrite, MemoryPermission::ReadWrite,
0, Kernel::MemoryRegion::BASE, "GSP:SharedMemory");
g_shared_memory = Kernel::SharedMemory::Create(nullptr, 0x1000, MemoryPermission::ReadWrite,
MemoryPermission::ReadWrite, 0,
Kernel::MemoryRegion::BASE, "GSP:SharedMemory");
g_thread_id = 0;
gpu_right_acquired = false;

View File

@ -20,30 +20,30 @@ namespace GSP_GPU {
/// GSP interrupt ID
enum class InterruptId : u8 {
PSC0 = 0x00,
PSC1 = 0x01,
PDC0 = 0x02, // Seems called every vertical screen line
PDC1 = 0x03, // Seems called every frame
PPF = 0x04,
P3D = 0x05,
DMA = 0x06,
PSC0 = 0x00,
PSC1 = 0x01,
PDC0 = 0x02, // Seems called every vertical screen line
PDC1 = 0x03, // Seems called every frame
PPF = 0x04,
P3D = 0x05,
DMA = 0x06,
};
/// GSP command ID
enum class CommandId : u32 {
REQUEST_DMA = 0x00,
REQUEST_DMA = 0x00,
/// Submits a commandlist for execution by the GPU.
SUBMIT_GPU_CMDLIST = 0x01,
// Fills a given memory range with a particular value
SET_MEMORY_FILL = 0x02,
SET_MEMORY_FILL = 0x02,
// Copies an image and optionally performs color-conversion or scaling.
// This is highly similar to the GameCube's EFB copy feature
SET_DISPLAY_TRANSFER = 0x03,
SET_DISPLAY_TRANSFER = 0x03,
// Conceptionally similar to SET_DISPLAY_TRANSFER and presumable uses the same hardware path
SET_TEXTURE_COPY = 0x04,
SET_TEXTURE_COPY = 0x04,
/// Flushes up to 3 cache regions in a single command.
CACHE_FLUSH = 0x05,
};
@ -61,19 +61,18 @@ struct InterruptRelayQueue {
u32 missed_PDC0;
u32 missed_PDC1;
InterruptId slot[0x34]; ///< Interrupt ID slots
InterruptId slot[0x34]; ///< Interrupt ID slots
};
static_assert(sizeof(InterruptRelayQueue) == 0x40,
"InterruptRelayQueue struct has incorrect size");
static_assert(sizeof(InterruptRelayQueue) == 0x40, "InterruptRelayQueue struct has incorrect size");
struct FrameBufferInfo {
BitField<0, 1, u32> active_fb; // 0 = first, 1 = second
u32 address_left;
u32 address_right;
u32 stride; // maps to 0x1EF00X90 ?
u32 format; // maps to 0x1EF00X70 ?
u32 shown_fb; // maps to 0x1EF00X78 ?
u32 stride; // maps to 0x1EF00X90 ?
u32 format; // maps to 0x1EF00X70 ?
u32 shown_fb; // maps to 0x1EF00X78 ?
u32 unknown;
};
static_assert(sizeof(FrameBufferInfo) == 0x1c, "Struct has incorrect size");
@ -91,7 +90,8 @@ static_assert(sizeof(FrameBufferUpdate) == 0x40, "Struct has incorrect size");
// TODO: Not sure if this padding is correct.
// Chances are the second block is stored at offset 0x24 rather than 0x20.
#ifndef _MSC_VER
static_assert(offsetof(FrameBufferUpdate, framebuffer_info[1]) == 0x20, "FrameBufferInfo element has incorrect alignment");
static_assert(offsetof(FrameBufferUpdate, framebuffer_info[1]) == 0x20,
"FrameBufferInfo element has incorrect alignment");
#endif
/// GSP command
@ -163,13 +163,13 @@ struct CommandBuffer {
// Current command index. This index is updated by GSP module after loading the command
// data, right before the command is processed. When this index is updated by GSP module,
// the total commands field is decreased by one as well.
BitField<0,8,u32> index;
BitField<0, 8, u32> index;
// Total commands to process, must not be value 0 when GSP module handles commands. This
// must be <=15 when writing a command to shared memory. This is incremented by the
// application when writing a command to shared memory, after increasing this value
// TriggerCmdReqQueue is only used if this field is value 1.
BitField<8,8,u32> number_commands;
BitField<8, 8, u32> number_commands;
};
u32 unk[7];

View File

@ -9,13 +9,11 @@
namespace GSP_LCD {
const Interface::FunctionInfo FunctionTable[] = {
{0x000F0000, nullptr, "PowerOnAllBacklights"},
{0x00100000, nullptr, "PowerOffAllBacklights"},
{0x00110040, nullptr, "PowerOnBacklight"},
{0x00120040, nullptr, "PowerOffBacklight"},
{0x00130040, nullptr, "SetLedForceOff"}
};
const Interface::FunctionInfo FunctionTable[] = {{0x000F0000, nullptr, "PowerOnAllBacklights"},
{0x00100000, nullptr, "PowerOffAllBacklights"},
{0x00110040, nullptr, "PowerOnBacklight"},
{0x00120040, nullptr, "PowerOffBacklight"},
{0x00130040, nullptr, "SetLedForceOff"}};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class

View File

@ -4,13 +4,13 @@
#include <cmath>
#include "common/logging/log.h"
#include "common/emu_window.h"
#include "common/logging/log.h"
#include "core/hle/service/service.h"
#include "core/hle/service/hid/hid.h"
#include "core/hle/service/hid/hid_spvr.h"
#include "core/hle/service/hid/hid_user.h"
#include "core/hle/service/service.h"
#include "core/core_timing.h"
#include "core/hle/kernel/event.h"
@ -37,11 +37,14 @@ static u32 next_accelerometer_index;
static u32 next_gyroscope_index;
static int enable_accelerometer_count = 0; // positive means enabled
static int enable_gyroscope_count = 0; // positive means enabled
static int enable_gyroscope_count = 0; // positive means enabled
static PadState GetCirclePadDirectionState(s16 circle_pad_x, s16 circle_pad_y) {
constexpr float TAN30 = 0.577350269, TAN60 = 1 / TAN30; // 30 degree and 60 degree are angular thresholds for directions
constexpr int CIRCLE_PAD_THRESHOLD_SQUARE = 40 * 40; // a circle pad radius greater than 40 will trigger circle pad direction
constexpr float TAN30 = 0.577350269,
TAN60 =
1 / TAN30; // 30 degree and 60 degree are angular thresholds for directions
constexpr int CIRCLE_PAD_THRESHOLD_SQUARE =
40 * 40; // a circle pad radius greater than 40 will trigger circle pad direction
PadState state;
state.hex = 0;
@ -90,7 +93,7 @@ void Update() {
PadState old_state = mem->pad.entries[last_entry_index].current_state;
// Compute bitmask with 1s for bits different from the old state
PadState changed = { { (state.hex ^ old_state.hex) } };
PadState changed = {{(state.hex ^ old_state.hex)}};
// Get the current Pad entry
PadDataEntry& pad_entry = mem->pad.entries[mem->pad.index];
@ -135,11 +138,13 @@ void Update() {
// Update accelerometer
if (enable_accelerometer_count > 0) {
mem->accelerometer.index = next_accelerometer_index;
next_accelerometer_index = (next_accelerometer_index + 1) % mem->accelerometer.entries.size();
next_accelerometer_index =
(next_accelerometer_index + 1) % mem->accelerometer.entries.size();
AccelerometerDataEntry& accelerometer_entry = mem->accelerometer.entries[mem->accelerometer.index];
std::tie(accelerometer_entry.x, accelerometer_entry.y, accelerometer_entry.z)
= VideoCore::g_emu_window->GetAccelerometerState();
AccelerometerDataEntry& accelerometer_entry =
mem->accelerometer.entries[mem->accelerometer.index];
std::tie(accelerometer_entry.x, accelerometer_entry.y, accelerometer_entry.z) =
VideoCore::g_emu_window->GetAccelerometerState();
// Make up "raw" entry
// TODO(wwylele):
@ -167,8 +172,8 @@ void Update() {
next_gyroscope_index = (next_gyroscope_index + 1) % mem->gyroscope.entries.size();
GyroscopeDataEntry& gyroscope_entry = mem->gyroscope.entries[mem->gyroscope.index];
std::tie(gyroscope_entry.x, gyroscope_entry.y, gyroscope_entry.z)
= VideoCore::g_emu_window->GetGyroscopeState();
std::tie(gyroscope_entry.x, gyroscope_entry.y, gyroscope_entry.z) =
VideoCore::g_emu_window->GetGyroscopeState();
// Make up "raw" entry
mem->gyroscope.raw_entry.x = gyroscope_entry.x;
@ -188,7 +193,7 @@ void Update() {
void GetIPCHandles(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = 0; // No error
cmd_buff[1] = 0; // No error
cmd_buff[2] = 0x14000000; // IPC Command Structure translate-header
// TODO(yuriks): Return error from SendSyncRequest is this fails (part of IPC marshalling)
cmd_buff[3] = Kernel::g_handle_table.Create(Service::HID::shared_mem).MoveFrom();
@ -259,9 +264,7 @@ void GetGyroscopeLowCalibrateParam(Service::Interface* self) {
const s16 param_unit = 6700; // an approximate value taken from hw
GyroscopeCalibrateParam param = {
{ 0, param_unit, -param_unit },
{ 0, param_unit, -param_unit },
{ 0, param_unit, -param_unit },
{0, param_unit, -param_unit}, {0, param_unit, -param_unit}, {0, param_unit, -param_unit},
};
memcpy(&cmd_buff[2], &param, sizeof(param));
@ -286,9 +289,9 @@ void Init() {
AddService(new HID_SPVR_Interface);
using Kernel::MemoryPermission;
shared_mem = SharedMemory::Create(nullptr, 0x1000,
MemoryPermission::ReadWrite, MemoryPermission::Read,
0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
shared_mem =
SharedMemory::Create(nullptr, 0x1000, MemoryPermission::ReadWrite, MemoryPermission::Read,
0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
next_pad_index = 0;
next_touch_index = 0;
@ -296,9 +299,9 @@ void Init() {
// Create event handles
event_pad_or_touch_1 = Event::Create(ResetType::OneShot, "HID:EventPadOrTouch1");
event_pad_or_touch_2 = Event::Create(ResetType::OneShot, "HID:EventPadOrTouch2");
event_accelerometer = Event::Create(ResetType::OneShot, "HID:EventAccelerometer");
event_gyroscope = Event::Create(ResetType::OneShot, "HID:EventGyroscope");
event_debug_pad = Event::Create(ResetType::OneShot, "HID:EventDebugPad");
event_accelerometer = Event::Create(ResetType::OneShot, "HID:EventAccelerometer");
event_gyroscope = Event::Create(ResetType::OneShot, "HID:EventGyroscope");
event_debug_pad = Event::Create(ResetType::OneShot, "HID:EventDebugPad");
}
void Shutdown() {

View File

@ -9,10 +9,10 @@
#ifndef _MSC_VER
#include <cstddef>
#endif
#include "core/settings.h"
#include "common/bit_field.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "core/settings.h"
namespace Service {
@ -103,7 +103,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
u32 index; ///< Index of the last updated pad state entry
u32 index; ///< Index of the last updated pad state entry
INSERT_PADDING_WORDS(0x2);
@ -121,7 +121,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
u32 index; ///< Index of the last updated touch entry
u32 index; ///< Index of the last updated touch entry
INSERT_PADDING_WORDS(0x1);
@ -135,7 +135,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
u32 index; ///< Index of the last updated accelerometer entry
u32 index; ///< Index of the last updated accelerometer entry
INSERT_PADDING_WORDS(0x1);
@ -149,7 +149,7 @@ struct SharedMem {
struct {
s64 index_reset_ticks; ///< CPU tick count for when HID module updated entry index 0
s64 index_reset_ticks_previous; ///< Previous `index_reset_ticks`
u32 index; ///< Index of the last updated accelerometer entry
u32 index; ///< Index of the last updated accelerometer entry
INSERT_PADDING_WORDS(0x1);
@ -176,9 +176,9 @@ struct GyroscopeCalibrateParam {
// is technically allowed since C++11. This macro should be enabled once MSVC adds
// support for that.
#ifndef _MSC_VER
#define ASSERT_REG_POSITION(field_name, position) \
static_assert(offsetof(SharedMem, field_name) == position * 4, \
"Field "#field_name" has invalid position")
#define ASSERT_REG_POSITION(field_name, position) \
static_assert(offsetof(SharedMem, field_name) == position * 4, \
"Field " #field_name " has invalid position")
ASSERT_REG_POSITION(pad.index_reset_ticks, 0x0);
ASSERT_REG_POSITION(touch.index_reset_ticks, 0x2A);
@ -187,33 +187,33 @@ ASSERT_REG_POSITION(touch.index_reset_ticks, 0x2A);
#endif // !defined(_MSC_VER)
// Pre-defined PadStates for single button presses
const PadState PAD_NONE = {{0}};
const PadState PAD_A = {{1u << 0}};
const PadState PAD_B = {{1u << 1}};
const PadState PAD_SELECT = {{1u << 2}};
const PadState PAD_START = {{1u << 3}};
const PadState PAD_RIGHT = {{1u << 4}};
const PadState PAD_LEFT = {{1u << 5}};
const PadState PAD_UP = {{1u << 6}};
const PadState PAD_DOWN = {{1u << 7}};
const PadState PAD_R = {{1u << 8}};
const PadState PAD_L = {{1u << 9}};
const PadState PAD_X = {{1u << 10}};
const PadState PAD_Y = {{1u << 11}};
const PadState PAD_NONE = {{0}};
const PadState PAD_A = {{1u << 0}};
const PadState PAD_B = {{1u << 1}};
const PadState PAD_SELECT = {{1u << 2}};
const PadState PAD_START = {{1u << 3}};
const PadState PAD_RIGHT = {{1u << 4}};
const PadState PAD_LEFT = {{1u << 5}};
const PadState PAD_UP = {{1u << 6}};
const PadState PAD_DOWN = {{1u << 7}};
const PadState PAD_R = {{1u << 8}};
const PadState PAD_L = {{1u << 9}};
const PadState PAD_X = {{1u << 10}};
const PadState PAD_Y = {{1u << 11}};
const PadState PAD_ZL = {{1u << 14}};
const PadState PAD_ZR = {{1u << 15}};
const PadState PAD_ZL = {{1u << 14}};
const PadState PAD_ZR = {{1u << 15}};
const PadState PAD_TOUCH = {{1u << 20}};
const PadState PAD_TOUCH = {{1u << 20}};
const PadState PAD_C_RIGHT = {{1u << 24}};
const PadState PAD_C_LEFT = {{1u << 25}};
const PadState PAD_C_UP = {{1u << 26}};
const PadState PAD_C_DOWN = {{1u << 27}};
const PadState PAD_C_RIGHT = {{1u << 24}};
const PadState PAD_C_LEFT = {{1u << 25}};
const PadState PAD_C_UP = {{1u << 26}};
const PadState PAD_C_DOWN = {{1u << 27}};
const PadState PAD_CIRCLE_RIGHT = {{1u << 28}};
const PadState PAD_CIRCLE_LEFT = {{1u << 29}};
const PadState PAD_CIRCLE_UP = {{1u << 30}};
const PadState PAD_CIRCLE_DOWN = {{1u << 31}};
const PadState PAD_CIRCLE_LEFT = {{1u << 29}};
const PadState PAD_CIRCLE_UP = {{1u << 30}};
const PadState PAD_CIRCLE_DOWN = {{1u << 31}};
/**
* HID::GetIPCHandles service function
@ -305,6 +305,5 @@ void Init();
/// Shutdown HID service
void Shutdown();
}
}

View File

@ -9,16 +9,16 @@ namespace Service {
namespace HID {
const Interface::FunctionInfo FunctionTable[] = {
{0x000A0000, GetIPCHandles, "GetIPCHandles"},
{0x000B0000, nullptr, "StartAnalogStickCalibration"},
{0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
{0x00110000, EnableAccelerometer, "EnableAccelerometer"},
{0x00120000, DisableAccelerometer, "DisableAccelerometer"},
{0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
{0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
{0x000A0000, GetIPCHandles, "GetIPCHandles"},
{0x000B0000, nullptr, "StartAnalogStickCalibration"},
{0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
{0x00110000, EnableAccelerometer, "EnableAccelerometer"},
{0x00120000, DisableAccelerometer, "DisableAccelerometer"},
{0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
{0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
{0x00150000, GetGyroscopeLowRawToDpsCoefficient, "GetGyroscopeLowRawToDpsCoefficient"},
{0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
{0x00170000, GetSoundVolume, "GetSoundVolume"},
{0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
{0x00170000, GetSoundVolume, "GetSoundVolume"},
};
HID_SPVR_Interface::HID_SPVR_Interface() {

View File

@ -9,16 +9,16 @@ namespace Service {
namespace HID {
const Interface::FunctionInfo FunctionTable[] = {
{0x000A0000, GetIPCHandles, "GetIPCHandles"},
{0x000B0000, nullptr, "StartAnalogStickCalibration"},
{0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
{0x00110000, EnableAccelerometer, "EnableAccelerometer"},
{0x00120000, DisableAccelerometer, "DisableAccelerometer"},
{0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
{0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
{0x000A0000, GetIPCHandles, "GetIPCHandles"},
{0x000B0000, nullptr, "StartAnalogStickCalibration"},
{0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
{0x00110000, EnableAccelerometer, "EnableAccelerometer"},
{0x00120000, DisableAccelerometer, "DisableAccelerometer"},
{0x00130000, EnableGyroscopeLow, "EnableGyroscopeLow"},
{0x00140000, DisableGyroscopeLow, "DisableGyroscopeLow"},
{0x00150000, GetGyroscopeLowRawToDpsCoefficient, "GetGyroscopeLowRawToDpsCoefficient"},
{0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
{0x00170000, GetSoundVolume, "GetSoundVolume"},
{0x00160000, GetGyroscopeLowCalibrateParam, "GetGyroscopeLowCalibrateParam"},
{0x00170000, GetSoundVolume, "GetSoundVolume"},
};
HID_U_Interface::HID_U_Interface() {

View File

@ -10,56 +10,56 @@
namespace HTTP_C {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010044, nullptr, "Initialize"},
{0x00020082, nullptr, "CreateContext"},
{0x00030040, nullptr, "CloseContext"},
{0x00040040, nullptr, "CancelConnection"},
{0x00050040, nullptr, "GetRequestState"},
{0x00060040, nullptr, "GetDownloadSizeState"},
{0x00070040, nullptr, "GetRequestError"},
{0x00080042, nullptr, "InitializeConnectionSession"},
{0x00090040, nullptr, "BeginRequest"},
{0x000A0040, nullptr, "BeginRequestAsync"},
{0x000B0082, nullptr, "ReceiveData"},
{0x000C0102, nullptr, "ReceiveDataTimeout"},
{0x000D0146, nullptr, "SetProxy"},
{0x000E0040, nullptr, "SetProxyDefault"},
{0x000F00C4, nullptr, "SetBasicAuthorization"},
{0x00100080, nullptr, "SetSocketBufferSize"},
{0x001100C4, nullptr, "AddRequestHeader"},
{0x001200C4, nullptr, "AddPostDataAscii"},
{0x001300C4, nullptr, "AddPostDataBinary"},
{0x00140082, nullptr, "AddPostDataRaw"},
{0x00150080, nullptr, "SetPostDataType"},
{0x001600C4, nullptr, "SendPostDataAscii"},
{0x00170144, nullptr, "SendPostDataAsciiTimeout"},
{0x001800C4, nullptr, "SendPostDataBinary"},
{0x00190144, nullptr, "SendPostDataBinaryTimeout"},
{0x001A0082, nullptr, "SendPostDataRaw"},
{0x001B0102, nullptr, "SendPOSTDataRawTimeout"},
{0x001C0080, nullptr, "SetPostDataEncoding"},
{0x001D0040, nullptr, "NotifyFinishSendPostData"},
{0x001E00C4, nullptr, "GetResponseHeader"},
{0x001F0144, nullptr, "GetResponseHeaderTimeout"},
{0x00200082, nullptr, "GetResponseData"},
{0x00210102, nullptr, "GetResponseDataTimeout"},
{0x00220040, nullptr, "GetResponseStatusCode"},
{0x002300C0, nullptr, "GetResponseStatusCodeTimeout"},
{0x00240082, nullptr, "AddTrustedRootCA"},
{0x00250080, nullptr, "AddDefaultCert"},
{0x00260080, nullptr, "SelectRootCertChain"},
{0x002700C4, nullptr, "SetClientCert"},
{0x002B0080, nullptr, "SetSSLOpt"},
{0x002C0080, nullptr, "SetSSLClearOpt"},
{0x002D0000, nullptr, "CreateRootCertChain"},
{0x002E0040, nullptr, "DestroyRootCertChain"},
{0x002F0082, nullptr, "RootCertChainAddCert"},
{0x00300080, nullptr, "RootCertChainAddDefaultCert"},
{0x00350186, nullptr, "SetDefaultProxy"},
{0x00360000, nullptr, "ClearDNSCache"},
{0x00370080, nullptr, "SetKeepAlive"},
{0x003800C0, nullptr, "SetPostDataTypeSize"},
{0x00390000, nullptr, "Finalize"},
{0x00010044, nullptr, "Initialize"},
{0x00020082, nullptr, "CreateContext"},
{0x00030040, nullptr, "CloseContext"},
{0x00040040, nullptr, "CancelConnection"},
{0x00050040, nullptr, "GetRequestState"},
{0x00060040, nullptr, "GetDownloadSizeState"},
{0x00070040, nullptr, "GetRequestError"},
{0x00080042, nullptr, "InitializeConnectionSession"},
{0x00090040, nullptr, "BeginRequest"},
{0x000A0040, nullptr, "BeginRequestAsync"},
{0x000B0082, nullptr, "ReceiveData"},
{0x000C0102, nullptr, "ReceiveDataTimeout"},
{0x000D0146, nullptr, "SetProxy"},
{0x000E0040, nullptr, "SetProxyDefault"},
{0x000F00C4, nullptr, "SetBasicAuthorization"},
{0x00100080, nullptr, "SetSocketBufferSize"},
{0x001100C4, nullptr, "AddRequestHeader"},
{0x001200C4, nullptr, "AddPostDataAscii"},
{0x001300C4, nullptr, "AddPostDataBinary"},
{0x00140082, nullptr, "AddPostDataRaw"},
{0x00150080, nullptr, "SetPostDataType"},
{0x001600C4, nullptr, "SendPostDataAscii"},
{0x00170144, nullptr, "SendPostDataAsciiTimeout"},
{0x001800C4, nullptr, "SendPostDataBinary"},
{0x00190144, nullptr, "SendPostDataBinaryTimeout"},
{0x001A0082, nullptr, "SendPostDataRaw"},
{0x001B0102, nullptr, "SendPOSTDataRawTimeout"},
{0x001C0080, nullptr, "SetPostDataEncoding"},
{0x001D0040, nullptr, "NotifyFinishSendPostData"},
{0x001E00C4, nullptr, "GetResponseHeader"},
{0x001F0144, nullptr, "GetResponseHeaderTimeout"},
{0x00200082, nullptr, "GetResponseData"},
{0x00210102, nullptr, "GetResponseDataTimeout"},
{0x00220040, nullptr, "GetResponseStatusCode"},
{0x002300C0, nullptr, "GetResponseStatusCodeTimeout"},
{0x00240082, nullptr, "AddTrustedRootCA"},
{0x00250080, nullptr, "AddDefaultCert"},
{0x00260080, nullptr, "SelectRootCertChain"},
{0x002700C4, nullptr, "SetClientCert"},
{0x002B0080, nullptr, "SetSSLOpt"},
{0x002C0080, nullptr, "SetSSLClearOpt"},
{0x002D0000, nullptr, "CreateRootCertChain"},
{0x002E0040, nullptr, "DestroyRootCertChain"},
{0x002F0082, nullptr, "RootCertChainAddCert"},
{0x00300080, nullptr, "RootCertChainAddDefaultCert"},
{0x00350186, nullptr, "SetDefaultProxy"},
{0x00360000, nullptr, "ClearDNSCache"},
{0x00370080, nullptr, "SetKeepAlive"},
{0x003800C0, nullptr, "SetPostDataTypeSize"},
{0x00390000, nullptr, "Finalize"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -5,11 +5,11 @@
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/service.h"
#include "core/hle/service/ir/ir.h"
#include "core/hle/service/ir/ir_rst.h"
#include "core/hle/service/ir/ir_u.h"
#include "core/hle/service/ir/ir_user.h"
#include "core/hle/service/service.h"
namespace Service {
namespace IR {
@ -32,14 +32,14 @@ void InitializeIrNopShared(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 transfer_buff_size = cmd_buff[1];
u32 recv_buff_size = cmd_buff[2];
u32 unk1 = cmd_buff[3];
u32 send_buff_size = cmd_buff[4];
u32 unk2 = cmd_buff[5];
u8 baud_rate = cmd_buff[6] & 0xFF;
Handle handle = cmd_buff[8];
u32 recv_buff_size = cmd_buff[2];
u32 unk1 = cmd_buff[3];
u32 send_buff_size = cmd_buff[4];
u32 unk2 = cmd_buff[5];
u8 baud_rate = cmd_buff[6] & 0xFF;
Handle handle = cmd_buff[8];
if(Kernel::g_handle_table.IsValid(handle)) {
if (Kernel::g_handle_table.IsValid(handle)) {
transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);
transfer_shared_memory->name = "IR:TransferSharedMemory";
}
@ -47,7 +47,7 @@ void InitializeIrNopShared(Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_IR, "(STUBBED) called, transfer_buff_size=%d, recv_buff_size=%d, "
"unk1=%d, send_buff_size=%d, unk2=%d, baud_rate=%u, handle=0x%08X",
"unk1=%d, send_buff_size=%d, unk2=%d, baud_rate=%u, handle=0x%08X",
transfer_buff_size, recv_buff_size, unk1, send_buff_size, unk2, baud_rate, handle);
}
@ -94,13 +94,13 @@ void Init() {
AddService(new IR_User_Interface);
using Kernel::MemoryPermission;
shared_memory = SharedMemory::Create(nullptr, 0x1000,
Kernel::MemoryPermission::ReadWrite, Kernel::MemoryPermission::ReadWrite,
0, Kernel::MemoryRegion::BASE, "IR:SharedMemory");
shared_memory = SharedMemory::Create(nullptr, 0x1000, Kernel::MemoryPermission::ReadWrite,
Kernel::MemoryPermission::ReadWrite, 0,
Kernel::MemoryRegion::BASE, "IR:SharedMemory");
transfer_shared_memory = nullptr;
// Create event handle(s)
handle_event = Event::Create(ResetType::OneShot, "IR:HandleEvent");
handle_event = Event::Create(ResetType::OneShot, "IR:HandleEvent");
conn_status_event = Event::Create(ResetType::OneShot, "IR:ConnectionStatusEvent");
}

View File

@ -9,10 +9,10 @@ namespace Service {
namespace IR {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010000, GetHandles, "GetHandles"},
{0x00020080, nullptr, "Initialize"},
{0x00030000, nullptr, "Shutdown"},
{0x00090000, nullptr, "WriteToTwoFields"},
{0x00010000, GetHandles, "GetHandles"},
{0x00020080, nullptr, "Initialize"},
{0x00030000, nullptr, "Shutdown"},
{0x00090000, nullptr, "WriteToTwoFields"},
};
IR_RST_Interface::IR_RST_Interface() {

View File

@ -8,24 +8,15 @@ namespace Service {
namespace IR {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010000, nullptr, "Initialize"},
{0x00020000, nullptr, "Shutdown"},
{0x00030042, nullptr, "StartSendTransfer"},
{0x00040000, nullptr, "WaitSendTransfer"},
{0x000500C2, nullptr, "StartRecvTransfer"},
{0x00060000, nullptr, "WaitRecvTransfer"},
{0x00070080, nullptr, "GetRecvTransferCount"},
{0x00080000, nullptr, "GetSendState"},
{0x00090040, nullptr, "SetBitRate"},
{0x000A0000, nullptr, "GetBitRate"},
{0x000B0040, nullptr, "SetIRLEDState"},
{0x000C0000, nullptr, "GetIRLEDRecvState"},
{0x000D0000, nullptr, "GetSendFinishedEvent"},
{0x000E0000, nullptr, "GetRecvFinishedEvent"},
{0x000F0000, nullptr, "GetTransferState"},
{0x00100000, nullptr, "GetErrorStatus"},
{0x00110040, nullptr, "SetSleepModeActive"},
{0x00120040, nullptr, "SetSleepModeState"},
{0x00010000, nullptr, "Initialize"}, {0x00020000, nullptr, "Shutdown"},
{0x00030042, nullptr, "StartSendTransfer"}, {0x00040000, nullptr, "WaitSendTransfer"},
{0x000500C2, nullptr, "StartRecvTransfer"}, {0x00060000, nullptr, "WaitRecvTransfer"},
{0x00070080, nullptr, "GetRecvTransferCount"}, {0x00080000, nullptr, "GetSendState"},
{0x00090040, nullptr, "SetBitRate"}, {0x000A0000, nullptr, "GetBitRate"},
{0x000B0040, nullptr, "SetIRLEDState"}, {0x000C0000, nullptr, "GetIRLEDRecvState"},
{0x000D0000, nullptr, "GetSendFinishedEvent"}, {0x000E0000, nullptr, "GetRecvFinishedEvent"},
{0x000F0000, nullptr, "GetTransferState"}, {0x00100000, nullptr, "GetErrorStatus"},
{0x00110040, nullptr, "SetSleepModeActive"}, {0x00120040, nullptr, "SetSleepModeState"},
};
IR_U_Interface::IR_U_Interface() {

View File

@ -9,32 +9,32 @@ namespace Service {
namespace IR {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010182, nullptr, "InitializeIrNop"},
{0x00020000, FinalizeIrNop, "FinalizeIrNop"},
{0x00030000, nullptr, "ClearReceiveBuffer"},
{0x00040000, nullptr, "ClearSendBuffer"},
{0x000500C0, nullptr, "WaitConnection"},
{0x00060040, RequireConnection, "RequireConnection"},
{0x000702C0, nullptr, "AutoConnection"},
{0x00080000, nullptr, "AnyConnection"},
{0x00090000, Disconnect, "Disconnect"},
{0x000A0000, nullptr, "GetReceiveEvent"},
{0x000B0000, nullptr, "GetSendEvent"},
{0x00010182, nullptr, "InitializeIrNop"},
{0x00020000, FinalizeIrNop, "FinalizeIrNop"},
{0x00030000, nullptr, "ClearReceiveBuffer"},
{0x00040000, nullptr, "ClearSendBuffer"},
{0x000500C0, nullptr, "WaitConnection"},
{0x00060040, RequireConnection, "RequireConnection"},
{0x000702C0, nullptr, "AutoConnection"},
{0x00080000, nullptr, "AnyConnection"},
{0x00090000, Disconnect, "Disconnect"},
{0x000A0000, nullptr, "GetReceiveEvent"},
{0x000B0000, nullptr, "GetSendEvent"},
{0x000C0000, GetConnectionStatusEvent, "GetConnectionStatusEvent"},
{0x000D0042, nullptr, "SendIrNop"},
{0x000E0042, nullptr, "SendIrNopLarge"},
{0x000F0040, nullptr, "ReceiveIrnop"},
{0x00100042, nullptr, "ReceiveIrnopLarge"},
{0x00110040, nullptr, "GetLatestReceiveErrorResult"},
{0x00120040, nullptr, "GetLatestSendErrorResult"},
{0x00130000, nullptr, "GetConnectionStatus"},
{0x00140000, nullptr, "GetTryingToConnectStatus"},
{0x00150000, nullptr, "GetReceiveSizeFreeAndUsed"},
{0x00160000, nullptr, "GetSendSizeFreeAndUsed"},
{0x00170000, nullptr, "GetConnectionRole"},
{0x00180182, InitializeIrNopShared, "InitializeIrNopShared"},
{0x00190040, nullptr, "ReleaseReceivedData"},
{0x001A0040, nullptr, "SetOwnMachineId"},
{0x000D0042, nullptr, "SendIrNop"},
{0x000E0042, nullptr, "SendIrNopLarge"},
{0x000F0040, nullptr, "ReceiveIrnop"},
{0x00100042, nullptr, "ReceiveIrnopLarge"},
{0x00110040, nullptr, "GetLatestReceiveErrorResult"},
{0x00120040, nullptr, "GetLatestSendErrorResult"},
{0x00130000, nullptr, "GetConnectionStatus"},
{0x00140000, nullptr, "GetTryingToConnectStatus"},
{0x00150000, nullptr, "GetReceiveSizeFreeAndUsed"},
{0x00160000, nullptr, "GetSendSizeFreeAndUsed"},
{0x00170000, nullptr, "GetConnectionRole"},
{0x00180182, InitializeIrNopShared, "InitializeIrNopShared"},
{0x00190040, nullptr, "ReleaseReceivedData"},
{0x001A0040, nullptr, "SetOwnMachineId"},
};
IR_User_Interface::IR_User_Interface() {

View File

@ -14,38 +14,29 @@
namespace LDR_RO {
static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
ErrorLevel::Usage);
static ResultCode CROFormatError(u32 description) {
return ResultCode(static_cast<ErrorDescription>(description), ErrorModule::RO, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
return ResultCode(static_cast<ErrorDescription>(description), ErrorModule::RO,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
const std::array<int, 17> CROHelper::ENTRY_SIZE {{
1, // code
1, // data
1, // module name
sizeof(SegmentEntry),
sizeof(ExportNamedSymbolEntry),
sizeof(ExportIndexedSymbolEntry),
1, // export strings
sizeof(ExportTreeEntry),
sizeof(ImportModuleEntry),
sizeof(ExternalRelocationEntry),
sizeof(ImportNamedSymbolEntry),
sizeof(ImportIndexedSymbolEntry),
sizeof(ImportAnonymousSymbolEntry),
1, // import strings
sizeof(StaticAnonymousSymbolEntry),
sizeof(InternalRelocationEntry),
sizeof(StaticRelocationEntry)
}};
const std::array<int, 17> CROHelper::ENTRY_SIZE{
{1, // code
1, // data
1, // module name
sizeof(SegmentEntry), sizeof(ExportNamedSymbolEntry), sizeof(ExportIndexedSymbolEntry),
1, // export strings
sizeof(ExportTreeEntry), sizeof(ImportModuleEntry), sizeof(ExternalRelocationEntry),
sizeof(ImportNamedSymbolEntry), sizeof(ImportIndexedSymbolEntry),
sizeof(ImportAnonymousSymbolEntry),
1, // import strings
sizeof(StaticAnonymousSymbolEntry), sizeof(InternalRelocationEntry),
sizeof(StaticRelocationEntry)}};
const std::array<CROHelper::HeaderField, 4> CROHelper::FIX_BARRIERS {{
Fix0Barrier,
Fix1Barrier,
Fix2Barrier,
Fix3Barrier
}};
const std::array<CROHelper::HeaderField, 4> CROHelper::FIX_BARRIERS{
{Fix0Barrier, Fix1Barrier, Fix2Barrier, Fix3Barrier}};
VAddr CROHelper::SegmentTagToAddress(SegmentTag segment_tag) const {
u32 segment_num = GetField(SegmentNum);
@ -63,7 +54,7 @@ VAddr CROHelper::SegmentTagToAddress(SegmentTag segment_tag) const {
}
ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType relocation_type,
u32 addend, u32 symbol_address, u32 target_future_address) {
u32 addend, u32 symbol_address, u32 target_future_address) {
switch (relocation_type) {
case RelocationType::Nothing:
@ -124,7 +115,8 @@ ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool
return CROFormatError(0x12);
}
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, symbol_address, relocation_target);
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
symbol_address, relocation_target);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
return result;
@ -167,7 +159,7 @@ VAddr CROHelper::FindExportNamedSymbol(const std::string& name) const {
if (test_byte >= len) {
next.raw = entry.left.raw;
} else if((name[test_byte] >> test_bit_in_byte) & 1) {
} else if ((name[test_byte] >> test_bit_in_byte) & 1) {
next.raw = entry.right.raw;
} else {
next.raw = entry.left.raw;
@ -212,26 +204,13 @@ ResultCode CROHelper::RebaseHeader(u32 cro_size) {
return error;
// verifies that all offsets are in the correct order
constexpr std::array<HeaderField, 18> OFFSET_ORDER = {{
CodeOffset,
ModuleNameOffset,
SegmentTableOffset,
ExportNamedSymbolTableOffset,
ExportTreeTableOffset,
ExportIndexedSymbolTableOffset,
ExportStringsOffset,
ImportModuleTableOffset,
ExternalRelocationTableOffset,
ImportNamedSymbolTableOffset,
ImportIndexedSymbolTableOffset,
ImportAnonymousSymbolTableOffset,
ImportStringsOffset,
StaticAnonymousSymbolTableOffset,
InternalRelocationTableOffset,
StaticRelocationTableOffset,
DataOffset,
FileSize
}};
constexpr std::array<HeaderField, 18> OFFSET_ORDER = {
{CodeOffset, ModuleNameOffset, SegmentTableOffset, ExportNamedSymbolTableOffset,
ExportTreeTableOffset, ExportIndexedSymbolTableOffset, ExportStringsOffset,
ImportModuleTableOffset, ExternalRelocationTableOffset, ImportNamedSymbolTableOffset,
ImportIndexedSymbolTableOffset, ImportAnonymousSymbolTableOffset, ImportStringsOffset,
StaticAnonymousSymbolTableOffset, InternalRelocationTableOffset,
StaticRelocationTableOffset, DataOffset, FileSize}};
u32 prev_offset = GetField(OFFSET_ORDER[0]);
u32 cur_offset;
@ -266,9 +245,9 @@ ResultCode CROHelper::RebaseHeader(u32 cro_size) {
return RESULT_SUCCESS;
}
ResultVal<VAddr> CROHelper::RebaseSegmentTable(u32 cro_size,
VAddr data_segment_address, u32 data_segment_size,
VAddr bss_segment_address, u32 bss_segment_size) {
ResultVal<VAddr> CROHelper::RebaseSegmentTable(u32 cro_size, VAddr data_segment_address,
u32 data_segment_size, VAddr bss_segment_address,
u32 bss_segment_size) {
u32 prev_data_segment = 0;
u32 segment_num = GetField(SegmentNum);
@ -309,8 +288,8 @@ ResultCode CROHelper::RebaseExportNamedSymbolTable() {
if (entry.name_offset != 0) {
entry.name_offset += module_address;
if (entry.name_offset < export_strings_offset
|| entry.name_offset >= export_strings_end) {
if (entry.name_offset < export_strings_offset ||
entry.name_offset >= export_strings_end) {
return CROFormatError(0x11);
}
}
@ -337,9 +316,13 @@ ResultCode CROHelper::RebaseImportModuleTable() {
VAddr import_strings_offset = GetField(ImportStringsOffset);
VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize);
VAddr import_indexed_symbol_table_offset = GetField(ImportIndexedSymbolTableOffset);
VAddr index_import_table_end = import_indexed_symbol_table_offset + GetField(ImportIndexedSymbolNum) * sizeof(ImportIndexedSymbolEntry);
VAddr index_import_table_end =
import_indexed_symbol_table_offset +
GetField(ImportIndexedSymbolNum) * sizeof(ImportIndexedSymbolEntry);
VAddr import_anonymous_symbol_table_offset = GetField(ImportAnonymousSymbolTableOffset);
VAddr offset_import_table_end = import_anonymous_symbol_table_offset + GetField(ImportAnonymousSymbolNum) * sizeof(ImportAnonymousSymbolEntry);
VAddr offset_import_table_end =
import_anonymous_symbol_table_offset +
GetField(ImportAnonymousSymbolNum) * sizeof(ImportAnonymousSymbolEntry);
u32 module_num = GetField(ImportModuleNum);
for (u32 i = 0; i < module_num; ++i) {
@ -348,24 +331,24 @@ ResultCode CROHelper::RebaseImportModuleTable() {
if (entry.name_offset != 0) {
entry.name_offset += module_address;
if (entry.name_offset < import_strings_offset
|| entry.name_offset >= import_strings_end) {
if (entry.name_offset < import_strings_offset ||
entry.name_offset >= import_strings_end) {
return CROFormatError(0x18);
}
}
if (entry.import_indexed_symbol_table_offset != 0) {
entry.import_indexed_symbol_table_offset += module_address;
if (entry.import_indexed_symbol_table_offset < import_indexed_symbol_table_offset
|| entry.import_indexed_symbol_table_offset > index_import_table_end) {
if (entry.import_indexed_symbol_table_offset < import_indexed_symbol_table_offset ||
entry.import_indexed_symbol_table_offset > index_import_table_end) {
return CROFormatError(0x18);
}
}
if (entry.import_anonymous_symbol_table_offset != 0) {
entry.import_anonymous_symbol_table_offset += module_address;
if (entry.import_anonymous_symbol_table_offset < import_anonymous_symbol_table_offset
|| entry.import_anonymous_symbol_table_offset > offset_import_table_end) {
if (entry.import_anonymous_symbol_table_offset < import_anonymous_symbol_table_offset ||
entry.import_anonymous_symbol_table_offset > offset_import_table_end) {
return CROFormatError(0x18);
}
}
@ -379,25 +362,27 @@ ResultCode CROHelper::RebaseImportNamedSymbolTable() {
VAddr import_strings_offset = GetField(ImportStringsOffset);
VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize);
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
VAddr external_relocation_table_end = external_relocation_table_offset + GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
VAddr external_relocation_table_end =
external_relocation_table_offset +
GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
u32 num = GetField(ImportNamedSymbolNum);
for (u32 i = 0; i < num ; ++i) {
for (u32 i = 0; i < num; ++i) {
ImportNamedSymbolEntry entry;
GetEntry(i, entry);
if (entry.name_offset != 0) {
entry.name_offset += module_address;
if (entry.name_offset < import_strings_offset
|| entry.name_offset >= import_strings_end) {
if (entry.name_offset < import_strings_offset ||
entry.name_offset >= import_strings_end) {
return CROFormatError(0x1B);
}
}
if (entry.relocation_batch_offset != 0) {
entry.relocation_batch_offset += module_address;
if (entry.relocation_batch_offset < external_relocation_table_offset
|| entry.relocation_batch_offset > external_relocation_table_end) {
if (entry.relocation_batch_offset < external_relocation_table_offset ||
entry.relocation_batch_offset > external_relocation_table_end) {
return CROFormatError(0x1B);
}
}
@ -409,17 +394,19 @@ ResultCode CROHelper::RebaseImportNamedSymbolTable() {
ResultCode CROHelper::RebaseImportIndexedSymbolTable() {
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
VAddr external_relocation_table_end = external_relocation_table_offset + GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
VAddr external_relocation_table_end =
external_relocation_table_offset +
GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
u32 num = GetField(ImportIndexedSymbolNum);
for (u32 i = 0; i < num ; ++i) {
for (u32 i = 0; i < num; ++i) {
ImportIndexedSymbolEntry entry;
GetEntry(i, entry);
if (entry.relocation_batch_offset != 0) {
entry.relocation_batch_offset += module_address;
if (entry.relocation_batch_offset < external_relocation_table_offset
|| entry.relocation_batch_offset > external_relocation_table_end) {
if (entry.relocation_batch_offset < external_relocation_table_offset ||
entry.relocation_batch_offset > external_relocation_table_end) {
return CROFormatError(0x14);
}
}
@ -431,17 +418,19 @@ ResultCode CROHelper::RebaseImportIndexedSymbolTable() {
ResultCode CROHelper::RebaseImportAnonymousSymbolTable() {
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
VAddr external_relocation_table_end = external_relocation_table_offset + GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
VAddr external_relocation_table_end =
external_relocation_table_offset +
GetField(ExternalRelocationNum) * sizeof(ExternalRelocationEntry);
u32 num = GetField(ImportAnonymousSymbolNum);
for (u32 i = 0; i < num ; ++i) {
for (u32 i = 0; i < num; ++i) {
ImportAnonymousSymbolEntry entry;
GetEntry(i, entry);
if (entry.relocation_batch_offset != 0) {
entry.relocation_batch_offset += module_address;
if (entry.relocation_batch_offset < external_relocation_table_offset
|| entry.relocation_batch_offset > external_relocation_table_end) {
if (entry.relocation_batch_offset < external_relocation_table_offset ||
entry.relocation_batch_offset > external_relocation_table_end) {
return CROFormatError(0x17);
}
}
@ -475,7 +464,8 @@ ResultCode CROHelper::ResetExternalRelocations() {
return CROFormatError(0x12);
}
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, unresolved_symbol, relocation_target);
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
unresolved_symbol, relocation_target);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
return result;
@ -528,23 +518,27 @@ ResultCode CROHelper::ClearExternalRelocations() {
ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) {
VAddr static_relocation_table_offset = GetField(StaticRelocationTableOffset);
VAddr static_relocation_table_end = static_relocation_table_offset + GetField(StaticRelocationNum) * sizeof(StaticRelocationEntry);
VAddr static_relocation_table_end =
static_relocation_table_offset +
GetField(StaticRelocationNum) * sizeof(StaticRelocationEntry);
CROHelper crs(crs_address);
u32 offset_export_num = GetField(StaticAnonymousSymbolNum);
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d static anonymous symbols", ModuleName().data(), offset_export_num);
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d static anonymous symbols", ModuleName().data(),
offset_export_num);
for (u32 i = 0; i < offset_export_num; ++i) {
StaticAnonymousSymbolEntry entry;
GetEntry(i, entry);
u32 batch_address = entry.relocation_batch_offset + module_address;
if (batch_address < static_relocation_table_offset
|| batch_address > static_relocation_table_end) {
if (batch_address < static_relocation_table_offset ||
batch_address > static_relocation_table_end) {
return CROFormatError(0x16);
}
u32 symbol_address = SegmentTagToAddress(entry.symbol_position);
LOG_TRACE(Service_LDR, "CRO \"%s\" exports 0x%08X to the static module", ModuleName().data(), symbol_address);
LOG_TRACE(Service_LDR, "CRO \"%s\" exports 0x%08X to the static module",
ModuleName().data(), symbol_address);
ResultCode result = crs.ApplyRelocationBatch(batch_address, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
@ -571,7 +565,8 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
if (target_segment.type == SegmentType::Data) {
// If the relocation is to the .data segment, we need to relocate it in the old buffer
target_address = old_data_segment_address + relocation.target_position.offset_into_segment;
target_address =
old_data_segment_address + relocation.target_position.offset_into_segment;
} else {
target_address = target_addressB;
}
@ -582,8 +577,10 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
SegmentEntry symbol_segment;
GetEntry(relocation.symbol_segment, symbol_segment);
LOG_TRACE(Service_LDR, "Internally relocates 0x%08X with 0x%08X", target_address, symbol_segment.offset);
ResultCode result = ApplyRelocation(target_address, relocation.type, relocation.addend, symbol_segment.offset, target_addressB);
LOG_TRACE(Service_LDR, "Internally relocates 0x%08X with 0x%08X", target_address,
symbol_segment.offset);
ResultCode result = ApplyRelocation(target_address, relocation.type, relocation.addend,
symbol_segment.offset, target_addressB);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation %08X", result.raw);
return result;
@ -734,25 +731,29 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
if (!relocation_entry.is_batch_resolved) {
ResultCode result = ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
std::string symbol_name = Memory::ReadCString(entry.name_offset, import_strings_size);
u32 symbol_address = source.FindExportNamedSymbol(symbol_name);
ResultCode result =
ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
std::string symbol_name =
Memory::ReadCString(entry.name_offset, import_strings_size);
u32 symbol_address = source.FindExportNamedSymbol(symbol_name);
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, "CRO \"%s\" imports \"%s\" from \"%s\"",
ModuleName().data(), symbol_name.data(), source.ModuleName().data());
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, "CRO \"%s\" imports \"%s\" from \"%s\"",
ModuleName().data(), symbol_name.data(),
source.ModuleName().data());
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
result.raw);
return result;
}
return MakeResult<bool>(false);
}
return MakeResult<bool>(false);
}
return MakeResult<bool>(true);
});
return MakeResult<bool>(true);
});
if (result.IsError()) {
return result;
}
@ -777,7 +778,6 @@ ResultCode CROHelper::ResetImportNamedSymbol() {
LOG_ERROR(Service_LDR, "Error reseting relocation batch %08X", result.raw);
return result;
}
}
return RESULT_SUCCESS;
}
@ -831,40 +831,47 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
GetEntry(i, entry);
std::string want_cro_name = Memory::ReadCString(entry.name_offset, import_strings_size);
ResultCode result = ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
if (want_cro_name == source.ModuleName()) {
LOG_INFO(Service_LDR, "CRO \"%s\" imports %d indexed symbols from \"%s\"",
ModuleName().data(), entry.import_indexed_symbol_num, source.ModuleName().data());
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
ImportIndexedSymbolEntry im;
entry.GetImportIndexedSymbolEntry(j, im);
ExportIndexedSymbolEntry ex;
source.GetEntry(im.index, ex);
u32 symbol_address = source.SegmentTagToAddress(ex.symbol_position);
LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
ResultCode result = ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
ResultCode result =
ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
if (want_cro_name == source.ModuleName()) {
LOG_INFO(Service_LDR, "CRO \"%s\" imports %d indexed symbols from \"%s\"",
ModuleName().data(), entry.import_indexed_symbol_num,
source.ModuleName().data());
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
ImportIndexedSymbolEntry im;
entry.GetImportIndexedSymbolEntry(j, im);
ExportIndexedSymbolEntry ex;
source.GetEntry(im.index, ex);
u32 symbol_address = source.SegmentTagToAddress(ex.symbol_position);
LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
ResultCode result =
ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
result.raw);
return result;
}
}
}
LOG_INFO(Service_LDR, "CRO \"%s\" imports %d anonymous symbols from \"%s\"",
ModuleName().data(), entry.import_anonymous_symbol_num, source.ModuleName().data());
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
ImportAnonymousSymbolEntry im;
entry.GetImportAnonymousSymbolEntry(j, im);
u32 symbol_address = source.SegmentTagToAddress(im.symbol_position);
LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
ResultCode result = ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
LOG_INFO(Service_LDR, "CRO \"%s\" imports %d anonymous symbols from \"%s\"",
ModuleName().data(), entry.import_anonymous_symbol_num,
source.ModuleName().data());
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
ImportAnonymousSymbolEntry im;
entry.GetImportAnonymousSymbolEntry(j, im);
u32 symbol_address = source.SegmentTagToAddress(im.symbol_position);
LOG_TRACE(Service_LDR, " Imports 0x%08X", symbol_address);
ResultCode result =
ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
result.raw);
return result;
}
}
return MakeResult<bool>(false);
}
return MakeResult<bool>(false);
}
return MakeResult<bool>(true);
});
return MakeResult<bool>(true);
});
if (result.IsError()) {
return result;
}
@ -873,8 +880,8 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
}
ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
LOG_DEBUG(Service_LDR, "CRO \"%s\" exports named symbols to \"%s\"",
ModuleName().data(), target.ModuleName().data());
LOG_DEBUG(Service_LDR, "CRO \"%s\" exports named symbols to \"%s\"", ModuleName().data(),
target.ModuleName().data());
u32 target_import_strings_size = target.GetField(ImportStringsSize);
u32 target_symbol_import_num = target.GetField(ImportNamedSymbolNum);
for (u32 i = 0; i < target_symbol_import_num; ++i) {
@ -885,7 +892,8 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
if (!relocation_entry.is_batch_resolved) {
std::string symbol_name = Memory::ReadCString(entry.name_offset, target_import_strings_size);
std::string symbol_name =
Memory::ReadCString(entry.name_offset, target_import_strings_size);
u32 symbol_address = FindExportNamedSymbol(symbol_name);
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, " exports symbol \"%s\"", symbol_name.data());
@ -901,8 +909,8 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
}
ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports named symbols to \"%s\"",
ModuleName().data(), target.ModuleName().data());
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports named symbols to \"%s\"", ModuleName().data(),
target.ModuleName().data());
u32 unresolved_symbol = target.GetOnUnresolvedAddress();
u32 target_import_strings_size = target.GetField(ImportStringsSize);
u32 target_symbol_import_num = target.GetField(ImportNamedSymbolNum);
@ -914,11 +922,13 @@ ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
if (relocation_entry.is_batch_resolved) {
std::string symbol_name = Memory::ReadCString(entry.name_offset, target_import_strings_size);
std::string symbol_name =
Memory::ReadCString(entry.name_offset, target_import_strings_size);
u32 symbol_address = FindExportNamedSymbol(symbol_name);
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, " unexports symbol \"%s\"", symbol_name.data());
ResultCode result = target.ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
ResultCode result =
target.ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@ -940,8 +950,8 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
if (Memory::ReadCString(entry.name_offset, target_import_string_size) != module_name)
continue;
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d indexed symbols to \"%s\"",
module_name.data(), entry.import_indexed_symbol_num, target.ModuleName().data());
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d indexed symbols to \"%s\"", module_name.data(),
entry.import_indexed_symbol_num, target.ModuleName().data());
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
ImportIndexedSymbolEntry im;
entry.GetImportIndexedSymbolEntry(j, im);
@ -949,7 +959,8 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
GetEntry(im.index, ex);
u32 symbol_address = SegmentTagToAddress(ex.symbol_position);
LOG_TRACE(Service_LDR, " exports symbol 0x%08X", symbol_address);
ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
ResultCode result =
target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@ -957,13 +968,14 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
}
LOG_INFO(Service_LDR, "CRO \"%s\" exports %d anonymous symbols to \"%s\"",
module_name.data(), entry.import_anonymous_symbol_num, target.ModuleName().data());
module_name.data(), entry.import_anonymous_symbol_num, target.ModuleName().data());
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
ImportAnonymousSymbolEntry im;
entry.GetImportAnonymousSymbolEntry(j, im);
u32 symbol_address = SegmentTagToAddress(im.symbol_position);
LOG_TRACE(Service_LDR, " exports symbol 0x%08X", symbol_address);
ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
ResultCode result =
target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@ -987,12 +999,13 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
if (Memory::ReadCString(entry.name_offset, target_import_string_size) != module_name)
continue;
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports indexed symbols to \"%s\"",
module_name.data(), target.ModuleName().data());
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports indexed symbols to \"%s\"", module_name.data(),
target.ModuleName().data());
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
ImportIndexedSymbolEntry im;
entry.GetImportIndexedSymbolEntry(j, im);
ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
ResultCode result =
target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@ -1000,11 +1013,12 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
}
LOG_DEBUG(Service_LDR, "CRO \"%s\" unexports anonymous symbols to \"%s\"",
module_name.data(), target.ModuleName().data());
module_name.data(), target.ModuleName().data());
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
ImportAnonymousSymbolEntry im;
entry.GetImportAnonymousSymbolEntry(j, im);
ResultCode result = target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
ResultCode result =
target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
@ -1025,25 +1039,27 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
ExternalRelocationEntry relocation_entry;
Memory::ReadBlock(relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry));
if (Memory::ReadCString(entry.name_offset, import_strings_size) == "__aeabi_atexit"){
ResultCode result = ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
u32 symbol_address = source.FindExportNamedSymbol("nnroAeabiAtexit_");
if (Memory::ReadCString(entry.name_offset, import_strings_size) == "__aeabi_atexit") {
ResultCode result =
ForEachAutoLinkCRO(crs_address, [&](CROHelper source) -> ResultVal<bool> {
u32 symbol_address = source.FindExportNamedSymbol("nnroAeabiAtexit_");
if (symbol_address != 0) {
LOG_DEBUG(Service_LDR, "CRO \"%s\" import exit function from \"%s\"",
ModuleName().data(), source.ModuleName().data());
if (symbol_address != 0) {
LOG_DEBUG(Service_LDR, "CRO \"%s\" import exit function from \"%s\"",
ModuleName().data(), source.ModuleName().data());
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X", result.raw);
return result;
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch %08X",
result.raw);
return result;
}
return MakeResult<bool>(false);
}
return MakeResult<bool>(false);
}
return MakeResult<bool>(true);
});
return MakeResult<bool>(true);
});
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying exit relocation %08X", result.raw);
return result;
@ -1070,9 +1086,9 @@ static ResultCode VerifyStringTableLength(VAddr address, u32 size) {
return RESULT_SUCCESS;
}
ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size,
VAddr data_segment_addresss, u32 data_segment_size,
VAddr bss_segment_address, u32 bss_segment_size, bool is_crs) {
ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss,
u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
bool is_crs) {
ResultCode result = RebaseHeader(cro_size);
if (result.IsError()) {
@ -1088,9 +1104,8 @@ ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size,
u32 prev_data_segment_address = 0;
if (!is_crs) {
auto result_val = RebaseSegmentTable(cro_size,
data_segment_addresss, data_segment_size,
bss_segment_address, bss_segment_size);
auto result_val = RebaseSegmentTable(cro_size, data_segment_addresss, data_segment_size,
bss_segment_address, bss_segment_size);
if (result_val.Failed()) {
LOG_ERROR(Service_LDR, "Error rebasing segment table %08X", result_val.Code().raw);
return result_val.Code();
@ -1374,7 +1389,8 @@ void CROHelper::Unregister(VAddr crs_address) {
CROHelper next_head(crs.NextModule()), previous_head(crs.PreviousModule());
CROHelper next(NextModule()), previous(PreviousModule());
if (module_address == next_head.module_address || module_address == previous_head.module_address) {
if (module_address == next_head.module_address ||
module_address == previous_head.module_address) {
// removing head
if (next.module_address) {
// the next is new head
@ -1400,7 +1416,8 @@ void CROHelper::Unregister(VAddr crs_address) {
// let head's previous point to the new tail
if (next_head.module_address && next_head.PreviousModule() == module_address) {
next_head.SetPreviousModule(previous.module_address);
} else if (previous_head.module_address && previous_head.PreviousModule() == module_address) {
} else if (previous_head.module_address &&
previous_head.PreviousModule() == module_address) {
previous_head.SetPreviousModule(previous.module_address);
} else {
UNREACHABLE();
@ -1419,9 +1436,9 @@ u32 CROHelper::GetFixEnd(u32 fix_level) const {
u32 entry_size_i = 2;
int field = ModuleNameOffset;
while (true) {
end = std::max<u32>(end,
GetField(static_cast<HeaderField>(field)) +
GetField(static_cast<HeaderField>(field + 1)) * ENTRY_SIZE[entry_size_i]);
end = std::max<u32>(end, GetField(static_cast<HeaderField>(field)) +
GetField(static_cast<HeaderField>(field + 1)) *
ENTRY_SIZE[entry_size_i]);
++entry_size_i;
field += 2;

View File

@ -10,8 +10,8 @@
#include "common/common_types.h"
#include "common/swap.h"
#include "core/memory.h"
#include "core/hle/result.h"
#include "core/memory.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace LDR_RO
@ -21,14 +21,17 @@ namespace LDR_RO {
// GCC versions < 5.0 do not implement std::is_trivially_copyable.
// Excluding MSVC because it has weird behaviour for std::is_trivially_copyable.
#if (__GNUC__ >= 5) || defined(__clang__)
#define ASSERT_CRO_STRUCT(name, size) \
static_assert(std::is_standard_layout<name>::value, "CRO structure " #name " doesn't use standard layout"); \
static_assert(std::is_trivially_copyable<name>::value, "CRO structure " #name " isn't trivially copyable"); \
static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
#define ASSERT_CRO_STRUCT(name, size) \
static_assert(std::is_standard_layout<name>::value, \
"CRO structure " #name " doesn't use standard layout"); \
static_assert(std::is_trivially_copyable<name>::value, \
"CRO structure " #name " isn't trivially copyable"); \
static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
#else
#define ASSERT_CRO_STRUCT(name, size) \
static_assert(std::is_standard_layout<name>::value, "CRO structure " #name " doesn't use standard layout"); \
static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
#define ASSERT_CRO_STRUCT(name, size) \
static_assert(std::is_standard_layout<name>::value, \
"CRO structure " #name " doesn't use standard layout"); \
static_assert(sizeof(name) == (size), "Unexpected struct size for CRO structure " #name)
#endif
static constexpr u32 CRO_HEADER_SIZE = 0x138;
@ -59,9 +62,9 @@ public:
* @param is_crs true if the module itself is the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
ResultCode Rebase(VAddr crs_address, u32 cro_size,
VAddr data_segment_addresss, u32 data_segment_size,
VAddr bss_segment_address, u32 bss_segment_size, bool is_crs);
ResultCode Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss,
u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
bool is_crs);
/**
* Unrebases the module.
@ -148,8 +151,10 @@ private:
const VAddr module_address; ///< the virtual address of this module
/**
* Each item in this enum represents a u32 field in the header begin from address+0x80, successively.
* We don't directly use a struct here, to avoid GetPointer, reinterpret_cast, or Read/WriteBlock repeatedly.
* Each item in this enum represents a u32 field in the header begin from address+0x80,
* successively.
* We don't directly use a struct here, to avoid GetPointer, reinterpret_cast, or
* Read/WriteBlock repeatedly.
*/
enum HeaderField {
Magic = 0,
@ -208,18 +213,20 @@ private:
Fix2Barrier = ImportModuleTableOffset,
Fix1Barrier = StaticAnonymousSymbolTableOffset,
};
static_assert(Fix0Barrier == (CRO_HEADER_SIZE - CRO_HASH_SIZE) / 4, "CRO Header fields are wrong!");
static_assert(Fix0Barrier == (CRO_HEADER_SIZE - CRO_HASH_SIZE) / 4,
"CRO Header fields are wrong!");
enum class SegmentType : u32 {
Code = 0,
Code = 0,
ROData = 1,
Data = 2,
BSS = 3,
Data = 2,
BSS = 3,
};
/**
* Identifies a program location inside of a segment.
* Required to refer to program locations because individual segments may be relocated independently of each other.
* Required to refer to program locations because individual segments may be relocated
* independently of each other.
*/
union SegmentTag {
u32_le raw;
@ -227,7 +234,8 @@ private:
BitField<4, 28, u32_le> offset_into_segment;
SegmentTag() = default;
explicit SegmentTag(u32 raw_) : raw(raw_) {}
explicit SegmentTag(u32 raw_) : raw(raw_) {
}
};
/// Information of a segment in this module.
@ -282,7 +290,7 @@ private:
/// Identifies an indexed symbol imported from another module.
struct ImportIndexedSymbolEntry {
u32_le index; // index of an ExportIndexedSymbolEntry in the exporting module
u32_le index; // index of an ExportIndexedSymbolEntry in the exporting module
u32_le relocation_batch_offset; // pointing to a relocation batch in ExternalRelocationTable
static constexpr HeaderField TABLE_OFFSET_FIELD = ImportIndexedSymbolTableOffset;
@ -291,8 +299,8 @@ private:
/// Identifies an anonymous symbol imported from another module.
struct ImportAnonymousSymbolEntry {
SegmentTag symbol_position; // in the exporting segment
u32_le relocation_batch_offset; // pointing to a relocation batch in ExternalRelocationTable
SegmentTag symbol_position; // in the exporting segment
u32_le relocation_batch_offset; // pointing to a relocation batch in ExternalRelocationTable
static constexpr HeaderField TABLE_OFFSET_FIELD = ImportAnonymousSymbolTableOffset;
};
@ -300,42 +308,47 @@ private:
/// Information of a imported module and symbols imported from it.
struct ImportModuleEntry {
u32_le name_offset; // pointing to a substring in ImportStrings
u32_le import_indexed_symbol_table_offset; // pointing to a subtable in ImportIndexedSymbolTable
u32_le name_offset; // pointing to a substring in ImportStrings
u32_le import_indexed_symbol_table_offset; // pointing to a subtable in
// ImportIndexedSymbolTable
u32_le import_indexed_symbol_num;
u32_le import_anonymous_symbol_table_offset; // pointing to a subtable in ImportAnonymousSymbolTable
u32_le import_anonymous_symbol_table_offset; // pointing to a subtable in
// ImportAnonymousSymbolTable
u32_le import_anonymous_symbol_num;
static constexpr HeaderField TABLE_OFFSET_FIELD = ImportModuleTableOffset;
void GetImportIndexedSymbolEntry(u32 index, ImportIndexedSymbolEntry& entry) {
Memory::ReadBlock(import_indexed_symbol_table_offset + index * sizeof(ImportIndexedSymbolEntry),
&entry, sizeof(ImportIndexedSymbolEntry));
Memory::ReadBlock(import_indexed_symbol_table_offset +
index * sizeof(ImportIndexedSymbolEntry),
&entry, sizeof(ImportIndexedSymbolEntry));
}
void GetImportAnonymousSymbolEntry(u32 index, ImportAnonymousSymbolEntry& entry) {
Memory::ReadBlock(import_anonymous_symbol_table_offset + index * sizeof(ImportAnonymousSymbolEntry),
&entry, sizeof(ImportAnonymousSymbolEntry));
Memory::ReadBlock(import_anonymous_symbol_table_offset +
index * sizeof(ImportAnonymousSymbolEntry),
&entry, sizeof(ImportAnonymousSymbolEntry));
}
};
ASSERT_CRO_STRUCT(ImportModuleEntry, 20);
enum class RelocationType : u8 {
Nothing = 0,
AbsoluteAddress = 2,
RelativeAddress = 3,
ThumbBranch = 10,
ArmBranch = 28,
ModifyArmBranch = 29,
AbsoluteAddress2 = 38,
Nothing = 0,
AbsoluteAddress = 2,
RelativeAddress = 3,
ThumbBranch = 10,
ArmBranch = 28,
ModifyArmBranch = 29,
AbsoluteAddress2 = 38,
AlignedRelativeAddress = 42,
};
struct RelocationEntry {
SegmentTag target_position; // to self's segment as an ExternalRelocationEntry; to static module segment as a StaticRelocationEntry
SegmentTag target_position; // to self's segment as an ExternalRelocationEntry; to static
// module segment as a StaticRelocationEntry
RelocationType type;
u8 is_batch_end;
u8 is_batch_resolved; // set at a batch beginning if the batch is resolved
u8 is_batch_resolved; // set at a batch beginning if the batch is resolved
INSERT_PADDING_BYTES(1);
u32_le addend;
};
@ -366,8 +379,8 @@ private:
/// Identifies a special static anonymous symbol (no game is known using this).
struct StaticAnonymousSymbolEntry {
SegmentTag symbol_position; // to self's segment
u32_le relocation_batch_offset; // pointing to a relocation batch in StaticRelocationTable
SegmentTag symbol_position; // to self's segment
u32_le relocation_batch_offset; // pointing to a relocation batch in StaticRelocationTable
static constexpr HeaderField TABLE_OFFSET_FIELD = StaticAnonymousSymbolTableOffset;
};
@ -446,12 +459,15 @@ private:
}
/**
* A helper function iterating over all registered auto-link modules, including the static module.
* A helper function iterating over all registered auto-link modules, including the static
* module.
* @param crs_address the virtual address of the static module
* @param func a function object to operate on a module. It accepts one parameter
* CROHelper and returns ResultVal<bool>. It should return true to continue the iteration,
* CROHelper and returns ResultVal<bool>. It should return true to continue the
* iteration,
* false to stop the iteration, or an error code (which will also stop the iteration).
* @returns ResultCode indicating the result of the operation, RESULT_SUCCESS if all iteration success,
* @returns ResultCode indicating the result of the operation, RESULT_SUCCESS if all iteration
* success,
* otherwise error code of the last iteration.
*/
template <typename FunctionObject>
@ -477,8 +493,8 @@ private:
* Usually equals to target_address, but will be different for a target in .data segment
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
ResultCode ApplyRelocation(VAddr target_address, RelocationType relocation_type,
u32 addend, u32 symbol_address, u32 target_future_address);
ResultCode ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend,
u32 symbol_address, u32 target_future_address);
/**
* Clears a relocation to zero
@ -492,7 +508,8 @@ private:
* Applies or resets a batch of relocations
* @param batch the virtual address of the first relocation in the batch
* @param symbol_address the symbol address to be relocated with
* @param reset false to set the batch to resolved state, true to reset the batch to unresolved state
* @param reset false to set the batch to resolved state, true to reset the batch to unresolved
* state
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
ResultCode ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset = false);
@ -507,7 +524,8 @@ private:
/**
* Rebases offsets in module header according to module address.
* @param cro_size the size of the CRO file
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseHeader(u32 cro_size);
@ -520,43 +538,49 @@ private:
* @param bss_segment_size the buffer size for .bss segment
* @returns ResultVal<VAddr> with the virtual address of .data segment in CRO.
*/
ResultVal<VAddr> RebaseSegmentTable(u32 cro_size,
VAddr data_segment_address, u32 data_segment_size,
VAddr bss_segment_address, u32 bss_segment_size);
ResultVal<VAddr> RebaseSegmentTable(u32 cro_size, VAddr data_segment_address,
u32 data_segment_size, VAddr bss_segment_address,
u32 bss_segment_size);
/**
* Rebases offsets in exported named symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseExportNamedSymbolTable();
/**
* Verifies indices in export tree table.
* @returns ResultCode RESULT_SUCCESS if all indices are verified as valid, otherwise error code.
* @returns ResultCode RESULT_SUCCESS if all indices are verified as valid, otherwise error
* code.
*/
ResultCode VerifyExportTreeTable() const;
/**
* Rebases offsets in exported module table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportModuleTable();
/**
* Rebases offsets in imported named symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportNamedSymbolTable();
/**
* Rebases offsets in imported indexed symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportIndexedSymbolTable();
/**
* Rebases offsets in imported anonymous symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error code.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportAnonymousSymbolTable();
@ -621,7 +645,8 @@ private:
void UnrebaseHeader();
/**
* Looks up all imported named symbols of this module in all registered auto-link modules, and resolves them if found.
* Looks up all imported named symbols of this module in all registered auto-link modules, and
* resolves them if found.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
@ -646,7 +671,8 @@ private:
ResultCode ResetImportAnonymousSymbol();
/**
* Finds registered auto-link modules that this module imports, and resolves indexed and anonymous symbols exported by them.
* Finds registered auto-link modules that this module imports, and resolves indexed and
* anonymous symbols exported by them.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/
@ -667,7 +693,8 @@ private:
ResultCode ResetExportNamedSymbol(CROHelper target);
/**
* Resolves imported indexed and anonymous symbols in the target module which imports this module.
* Resolves imported indexed and anonymous symbols in the target module which imports this
* module.
* @param target the module to resolve.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
*/

View File

@ -18,24 +18,33 @@
namespace LDR_RO {
static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9
ResultCode(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Permanent);
static const ResultCode ERROR_NOT_INITIALIZED = // 0xD9612FF8
ResultCode(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Permanent);
static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
static const ResultCode ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1
ResultCode(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
static const ResultCode ERROR_MISALIGNED_SIZE = // 0xD9012FF2
ResultCode(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
static const ResultCode ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F
ResultCode(static_cast<ErrorDescription>(15), ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Usage);
static const ResultCode ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08
ResultCode(static_cast<ErrorDescription>(8), ErrorModule::RO, ErrorSummary::InvalidState, ErrorLevel::Permanent);
static const ResultCode ERROR_NOT_LOADED = // 0xD8A12C0D
ResultCode(static_cast<ErrorDescription>(13), ErrorModule::RO, ErrorSummary::InvalidState, ErrorLevel::Permanent);
static const ResultCode ERROR_INVALID_DESCRIPTOR = // 0xD9001830
ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9
ResultCode(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Permanent);
static const ResultCode ERROR_NOT_INITIALIZED = // 0xD9612FF8
ResultCode(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Permanent);
static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
ErrorLevel::Usage);
static const ResultCode ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1
ResultCode(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument,
ErrorLevel::Permanent);
static const ResultCode ERROR_MISALIGNED_SIZE = // 0xD9012FF2
ResultCode(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument,
ErrorLevel::Permanent);
static const ResultCode ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F
ResultCode(static_cast<ErrorDescription>(15), ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Usage);
static const ResultCode ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08
ResultCode(static_cast<ErrorDescription>(8), ErrorModule::RO, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
static const ResultCode ERROR_NOT_LOADED = // 0xD8A12C0D
ResultCode(static_cast<ErrorDescription>(13), ErrorModule::RO, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
static const ResultCode ERROR_INVALID_DESCRIPTOR = // 0xD9001830
ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
static MemorySynchronizer memory_synchronizer;
@ -44,10 +53,10 @@ static VAddr loaded_crs; ///< the virtual address of the static module
static bool VerifyBufferState(VAddr buffer_ptr, u32 size) {
auto vma = Kernel::g_current_process->vm_manager.FindVMA(buffer_ptr);
return vma != Kernel::g_current_process->vm_manager.vma_map.end()
&& vma->second.base + vma->second.size >= buffer_ptr + size
&& vma->second.permissions == Kernel::VMAPermission::ReadWrite
&& vma->second.meminfo_state == Kernel::MemoryState::Private;
return vma != Kernel::g_current_process->vm_manager.vma_map.end() &&
vma->second.base + vma->second.size >= buffer_ptr + size &&
vma->second.permissions == Kernel::VMAPermission::ReadWrite &&
vma->second.meminfo_state == Kernel::MemoryState::Private;
}
/**
@ -66,13 +75,14 @@ static bool VerifyBufferState(VAddr buffer_ptr, u32 size) {
static void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr crs_buffer_ptr = cmd_buff[1];
u32 crs_size = cmd_buff[2];
VAddr crs_address = cmd_buff[3];
u32 descriptor = cmd_buff[4];
u32 process = cmd_buff[5];
u32 crs_size = cmd_buff[2];
VAddr crs_address = cmd_buff[3];
u32 descriptor = cmd_buff[4];
u32 process = cmd_buff[5];
LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X, crs_address=0x%08X, crs_size=0x%X, descriptor=0x%08X, process=0x%08X",
crs_buffer_ptr, crs_address, crs_size, descriptor, process);
LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X, crs_address=0x%08X, crs_size=0x%X, "
"descriptor=0x%08X, process=0x%08X",
crs_buffer_ptr, crs_address, crs_size, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -119,7 +129,8 @@ static void Initialize(Service::Interface* self) {
return;
}
if (crs_address < Memory::PROCESS_IMAGE_VADDR || crs_address + crs_size > Memory::PROCESS_IMAGE_VADDR_END) {
if (crs_address < Memory::PROCESS_IMAGE_VADDR ||
crs_address + crs_size > Memory::PROCESS_IMAGE_VADDR_END) {
LOG_ERROR(Service_LDR, "CRS mapping address is not in the process image region");
cmd_buff[1] = ERROR_ILLEGAL_ADDRESS.raw;
return;
@ -131,14 +142,17 @@ static void Initialize(Service::Interface* self) {
// TODO(wwylele): should be memory aliasing
std::shared_ptr<std::vector<u8>> crs_mem = std::make_shared<std::vector<u8>>(crs_size);
Memory::ReadBlock(crs_buffer_ptr, crs_mem->data(), crs_size);
result = Kernel::g_current_process->vm_manager.MapMemoryBlock(crs_address, crs_mem, 0, crs_size, Kernel::MemoryState::Code).Code();
result = Kernel::g_current_process->vm_manager
.MapMemoryBlock(crs_address, crs_mem, 0, crs_size, Kernel::MemoryState::Code)
.Code();
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error mapping memory block %08X", result.raw);
cmd_buff[1] = result.raw;
return;
}
result = Kernel::g_current_process->vm_manager.ReprotectRange(crs_address, crs_size, Kernel::VMAPermission::Read);
result = Kernel::g_current_process->vm_manager.ReprotectRange(crs_address, crs_size,
Kernel::VMAPermission::Read);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
cmd_buff[1] = result.raw;
@ -186,9 +200,9 @@ static void Initialize(Service::Interface* self) {
static void LoadCRR(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 crr_buffer_ptr = cmd_buff[1];
u32 crr_size = cmd_buff[2];
u32 descriptor = cmd_buff[3];
u32 process = cmd_buff[4];
u32 crr_size = cmd_buff[2];
u32 descriptor = cmd_buff[3];
u32 process = cmd_buff[4];
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -200,7 +214,8 @@ static void LoadCRR(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(2, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X, crr_size=0x%08X, descriptor=0x%08X, process=0x%08X",
LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X, crr_size=0x%08X, "
"descriptor=0x%08X, process=0x%08X",
crr_buffer_ptr, crr_size, descriptor, process);
}
@ -218,8 +233,8 @@ static void LoadCRR(Service::Interface* self) {
static void UnloadCRR(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 crr_buffer_ptr = cmd_buff[1];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -231,7 +246,8 @@ static void UnloadCRR(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(3, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
LOG_WARNING(Service_LDR,
"(STUBBED) called, crr_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
crr_buffer_ptr, descriptor, process);
}
@ -263,27 +279,28 @@ static void UnloadCRR(Service::Interface* self) {
*/
static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr cro_buffer_ptr = cmd_buff[1];
VAddr cro_address = cmd_buff[2];
u32 cro_size = cmd_buff[3];
VAddr cro_buffer_ptr = cmd_buff[1];
VAddr cro_address = cmd_buff[2];
u32 cro_size = cmd_buff[3];
VAddr data_segment_address = cmd_buff[4];
u32 zero = cmd_buff[5];
u32 data_segment_size = cmd_buff[6];
u32 bss_segment_address = cmd_buff[7];
u32 bss_segment_size = cmd_buff[8];
bool auto_link = (cmd_buff[9] & 0xFF) != 0;
u32 fix_level = cmd_buff[10];
VAddr crr_address = cmd_buff[11];
u32 descriptor = cmd_buff[12];
u32 process = cmd_buff[13];
u32 zero = cmd_buff[5];
u32 data_segment_size = cmd_buff[6];
u32 bss_segment_address = cmd_buff[7];
u32 bss_segment_size = cmd_buff[8];
bool auto_link = (cmd_buff[9] & 0xFF) != 0;
u32 fix_level = cmd_buff[10];
VAddr crr_address = cmd_buff[11];
u32 descriptor = cmd_buff[12];
u32 process = cmd_buff[13];
LOG_DEBUG(Service_LDR, "called (%s), cro_buffer_ptr=0x%08X, cro_address=0x%08X, cro_size=0x%X, "
"data_segment_address=0x%08X, zero=%d, data_segment_size=0x%X, bss_segment_address=0x%08X, bss_segment_size=0x%X, "
"auto_link=%s, fix_level=%d, crr_address=0x%08X, descriptor=0x%08X, process=0x%08X",
link_on_load_bug_fix ? "new" : "old", cro_buffer_ptr, cro_address, cro_size,
data_segment_address, zero, data_segment_size, bss_segment_address, bss_segment_size,
auto_link ? "true" : "false", fix_level, crr_address, descriptor, process
);
LOG_DEBUG(Service_LDR,
"called (%s), cro_buffer_ptr=0x%08X, cro_address=0x%08X, cro_size=0x%X, "
"data_segment_address=0x%08X, zero=%d, data_segment_size=0x%X, "
"bss_segment_address=0x%08X, bss_segment_size=0x%X, "
"auto_link=%s, fix_level=%d, crr_address=0x%08X, descriptor=0x%08X, process=0x%08X",
link_on_load_bug_fix ? "new" : "old", cro_buffer_ptr, cro_address, cro_size,
data_segment_address, zero, data_segment_size, bss_segment_address, bss_segment_size,
auto_link ? "true" : "false", fix_level, crr_address, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -330,8 +347,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
return;
}
if (cro_address < Memory::PROCESS_IMAGE_VADDR
|| cro_address + cro_size > Memory::PROCESS_IMAGE_VADDR_END) {
if (cro_address < Memory::PROCESS_IMAGE_VADDR ||
cro_address + cro_size > Memory::PROCESS_IMAGE_VADDR_END) {
LOG_ERROR(Service_LDR, "CRO mapping address is not in the process image region");
cmd_buff[1] = ERROR_ILLEGAL_ADDRESS.raw;
return;
@ -339,7 +356,9 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
if (zero) {
LOG_ERROR(Service_LDR, "Zero is not zero %d", zero);
cmd_buff[1] = ResultCode(static_cast<ErrorDescription>(29), ErrorModule::RO, ErrorSummary::Internal, ErrorLevel::Usage).raw;
cmd_buff[1] = ResultCode(static_cast<ErrorDescription>(29), ErrorModule::RO,
ErrorSummary::Internal, ErrorLevel::Usage)
.raw;
return;
}
@ -349,14 +368,17 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
// TODO(wwylele): should be memory aliasing
std::shared_ptr<std::vector<u8>> cro_mem = std::make_shared<std::vector<u8>>(cro_size);
Memory::ReadBlock(cro_buffer_ptr, cro_mem->data(), cro_size);
result = Kernel::g_current_process->vm_manager.MapMemoryBlock(cro_address, cro_mem, 0, cro_size, Kernel::MemoryState::Code).Code();
result = Kernel::g_current_process->vm_manager
.MapMemoryBlock(cro_address, cro_mem, 0, cro_size, Kernel::MemoryState::Code)
.Code();
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error mapping memory block %08X", result.raw);
cmd_buff[1] = result.raw;
return;
}
result = Kernel::g_current_process->vm_manager.ReprotectRange(cro_address, cro_size, Kernel::VMAPermission::Read);
result = Kernel::g_current_process->vm_manager.ReprotectRange(cro_address, cro_size,
Kernel::VMAPermission::Read);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, cro_size);
@ -384,7 +406,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
return;
}
result = cro.Rebase(loaded_crs, cro_size, data_segment_address, data_segment_size, bss_segment_address, bss_segment_size, false);
result = cro.Rebase(loaded_crs, cro_size, data_segment_address, data_segment_size,
bss_segment_address, bss_segment_size, false);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error rebasing CRO %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, cro_size);
@ -409,7 +432,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
// TODO(wwylele): verify the behaviour when buffer_ptr == address
if (cro_buffer_ptr != cro_address) {
if (fix_size != cro_size) {
result = Kernel::g_current_process->vm_manager.UnmapRange(cro_address + fix_size, cro_size - fix_size);
result = Kernel::g_current_process->vm_manager.UnmapRange(cro_address + fix_size,
cro_size - fix_size);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error unmapping memory block %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, cro_size);
@ -426,7 +450,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
u32 exe_size;
std::tie(exe_begin, exe_size) = cro.GetExecutablePages();
if (exe_begin) {
result = Kernel::g_current_process->vm_manager.ReprotectRange(exe_begin, exe_size, Kernel::VMAPermission::ReadExecute);
result = Kernel::g_current_process->vm_manager.ReprotectRange(
exe_begin, exe_size, Kernel::VMAPermission::ReadExecute);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reprotecting memory block %08X", result.raw);
Kernel::g_current_process->vm_manager.UnmapRange(cro_address, fix_size);
@ -437,8 +462,8 @@ static void LoadCRO(Service::Interface* self, bool link_on_load_bug_fix) {
Core::g_app_core->ClearInstructionCache();
LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X",
cro.ModuleName().data(), cro_address, cro_address+fix_size);
LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(),
cro_address, cro_address + fix_size);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = fix_size;
@ -464,14 +489,15 @@ static void LoadCRO(Service::Interface* self) {
*/
static void UnloadCRO(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr cro_address = cmd_buff[1];
u32 zero = cmd_buff[2];
VAddr cro_buffer_ptr = cmd_buff[3];
u32 descriptor = cmd_buff[4];
u32 process = cmd_buff[5];
VAddr cro_address = cmd_buff[1];
u32 zero = cmd_buff[2];
VAddr cro_buffer_ptr = cmd_buff[3];
u32 descriptor = cmd_buff[4];
u32 process = cmd_buff[5];
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, zero=%d, cro_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
cro_address, zero, cro_buffer_ptr, descriptor, process);
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, zero=%d, cro_buffer_ptr=0x%08X, "
"descriptor=0x%08X, process=0x%08X",
cro_address, zero, cro_buffer_ptr, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -558,11 +584,11 @@ static void UnloadCRO(Service::Interface* self) {
static void LinkCRO(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr cro_address = cmd_buff[1];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, descriptor=0x%08X, process=0x%08X",
cro_address, descriptor, process);
cro_address, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -620,11 +646,11 @@ static void LinkCRO(Service::Interface* self) {
static void UnlinkCRO(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr cro_address = cmd_buff[1];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
LOG_DEBUG(Service_LDR, "called, cro_address=0x%08X, descriptor=0x%08X, process=0x%08X",
cro_address, descriptor, process);
cro_address, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -682,11 +708,11 @@ static void UnlinkCRO(Service::Interface* self) {
static void Shutdown(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
VAddr crs_buffer_ptr = cmd_buff[1];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
u32 descriptor = cmd_buff[2];
u32 process = cmd_buff[3];
LOG_DEBUG(Service_LDR, "called, crs_buffer_ptr=0x%08X, descriptor=0x%08X, process=0x%08X",
crs_buffer_ptr, descriptor, process);
crs_buffer_ptr, descriptor, process);
if (descriptor != 0) {
LOG_ERROR(Service_LDR, "IPC handle descriptor failed validation (0x%X)", descriptor);
@ -724,15 +750,11 @@ static void Shutdown(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x000100C2, Initialize, "Initialize"},
{0x00020082, LoadCRR, "LoadCRR"},
{0x00030042, UnloadCRR, "UnloadCRR"},
{0x000402C2, LoadCRO<false>, "LoadCRO"},
{0x000500C2, UnloadCRO, "UnloadCRO"},
{0x00060042, LinkCRO, "LinkCRO"},
{0x00070042, UnlinkCRO, "UnlinkCRO"},
{0x00080042, Shutdown, "Shutdown"},
{0x000902C2, LoadCRO<true>, "LoadCRO_New"},
{0x000100C2, Initialize, "Initialize"}, {0x00020082, LoadCRR, "LoadCRR"},
{0x00030042, UnloadCRR, "UnloadCRR"}, {0x000402C2, LoadCRO<false>, "LoadCRO"},
{0x000500C2, UnloadCRO, "UnloadCRO"}, {0x00060042, LinkCRO, "LinkCRO"},
{0x00070042, UnlinkCRO, "UnlinkCRO"}, {0x00080042, Shutdown, "Shutdown"},
{0x000902C2, LoadCRO<true>, "LoadCRO_New"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -14,9 +14,8 @@
namespace LDR_RO {
auto MemorySynchronizer::FindMemoryBlock(VAddr mapping, VAddr original) {
auto block = std::find_if(memory_blocks.begin(), memory_blocks.end(), [=](MemoryBlock& b){
return b.original == original;
});
auto block = std::find_if(memory_blocks.begin(), memory_blocks.end(),
[=](MemoryBlock& b) { return b.original == original; });
ASSERT(block->mapping == mapping);
return block;
}

View File

@ -10,22 +10,22 @@
namespace MIC_U {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010042, nullptr, "MapSharedMem"},
{0x00020000, nullptr, "UnmapSharedMem"},
{0x00030140, nullptr, "Initialize"},
{0x00040040, nullptr, "AdjustSampling"},
{0x00050000, nullptr, "StopSampling"},
{0x00060000, nullptr, "IsSampling"},
{0x00070000, nullptr, "GetEventHandle"},
{0x00080040, nullptr, "SetGain"},
{0x00090000, nullptr, "GetGain"},
{0x000A0040, nullptr, "SetPower"},
{0x000B0000, nullptr, "GetPower"},
{0x000C0042, nullptr, "size"},
{0x000D0040, nullptr, "SetClamp"},
{0x000E0000, nullptr, "GetClamp"},
{0x000F0040, nullptr, "SetAllowShellClosed"},
{0x00100040, nullptr, "unknown_input2"},
{0x00010042, nullptr, "MapSharedMem"},
{0x00020000, nullptr, "UnmapSharedMem"},
{0x00030140, nullptr, "Initialize"},
{0x00040040, nullptr, "AdjustSampling"},
{0x00050000, nullptr, "StopSampling"},
{0x00060000, nullptr, "IsSampling"},
{0x00070000, nullptr, "GetEventHandle"},
{0x00080040, nullptr, "SetGain"},
{0x00090000, nullptr, "GetGain"},
{0x000A0040, nullptr, "SetPower"},
{0x000B0000, nullptr, "GetPower"},
{0x000C0042, nullptr, "size"},
{0x000D0040, nullptr, "SetClamp"},
{0x000E0000, nullptr, "GetClamp"},
{0x000F0040, nullptr, "SetAllowShellClosed"},
{0x00100040, nullptr, "unknown_input2"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -2,23 +2,21 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/ndm/ndm.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "core/hle/service/service.h"
#include "core/hle/service/ndm/ndm.h"
#include "core/hle/service/ndm/ndm_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace NDM {
enum : u32 {
DEFAULT_RETRY_INTERVAL = 10,
DEFAULT_SCAN_INTERVAL = 30
};
enum : u32 { DEFAULT_RETRY_INTERVAL = 10, DEFAULT_SCAN_INTERVAL = 30 };
static DaemonMask daemon_bit_mask = DaemonMask::Default;
static DaemonMask default_daemon_bit_mask = DaemonMask::Default;
static std::array<DaemonStatus, 4> daemon_status = { DaemonStatus::Idle, DaemonStatus::Idle, DaemonStatus::Idle, DaemonStatus::Idle };
static std::array<DaemonStatus, 4> daemon_status = {DaemonStatus::Idle, DaemonStatus::Idle,
DaemonStatus::Idle, DaemonStatus::Idle};
static ExclusiveState exclusive_state = ExclusiveState::None;
static u32 scan_interval = DEFAULT_SCAN_INTERVAL;
static u32 retry_interval = DEFAULT_RETRY_INTERVAL;
@ -72,7 +70,8 @@ void UnlockState(Service::Interface* self) {
void SuspendDaemons(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 bit_mask = cmd_buff[1] & 0xF;
daemon_bit_mask = static_cast<DaemonMask>(static_cast<u32>(default_daemon_bit_mask) & ~bit_mask);
daemon_bit_mask =
static_cast<DaemonMask>(static_cast<u32>(default_daemon_bit_mask) & ~bit_mask);
for (size_t index = 0; index < daemon_status.size(); ++index) {
if (bit_mask & (1 << index)) {
daemon_status[index] = DaemonStatus::Suspended;
@ -229,8 +228,7 @@ void Init() {
}
void Shutdown() {
}
}// namespace NDM
}// namespace Service
} // namespace NDM
} // namespace Service

View File

@ -12,36 +12,26 @@ class Interface;
namespace NDM {
enum class Daemon : u32 {
Cec = 0,
Boss = 1,
Nim = 2,
Friend = 3
};
enum class Daemon : u32 { Cec = 0, Boss = 1, Nim = 2, Friend = 3 };
enum class DaemonMask : u32 {
None = 0,
Cec = (1 << static_cast<u32>(Daemon::Cec)),
Boss = (1 << static_cast<u32>(Daemon::Boss)),
Nim = (1 << static_cast<u32>(Daemon::Nim)),
Friend = (1 << static_cast<u32>(Daemon::Friend)),
None = 0,
Cec = (1 << static_cast<u32>(Daemon::Cec)),
Boss = (1 << static_cast<u32>(Daemon::Boss)),
Nim = (1 << static_cast<u32>(Daemon::Nim)),
Friend = (1 << static_cast<u32>(Daemon::Friend)),
Default = Cec | Friend,
All = Cec | Boss | Nim | Friend
All = Cec | Boss | Nim | Friend
};
enum class DaemonStatus : u32 {
Busy = 0,
Idle = 1,
Suspending = 2,
Suspended = 3
};
enum class DaemonStatus : u32 { Busy = 0, Idle = 1, Suspending = 2, Suspended = 3 };
enum class ExclusiveState : u32 {
None = 0,
Infrastructure = 1,
None = 0,
Infrastructure = 1,
LocalCommunications = 2,
Streetpass = 3,
StreetpassData = 4,
Streetpass = 3,
StreetpassData = 4,
};
/**
@ -205,7 +195,6 @@ void SetRetryInterval(Service::Interface* self);
*/
void GetRetryInterval(Service::Interface* self);
/**
* NDM::OverrideDefaultDaemons service function
* Inputs:
@ -233,7 +222,8 @@ void ResetDefaultDaemons(Service::Interface* self);
* 1 : Result, 0 on success, otherwise error code
* 2 : Daemon bit mask
* Note:
* Gets the current default daemon bit mask. The default value is (DAEMONMASK_CEC | DAEMONMASK_FRIENDS)
* Gets the current default daemon bit mask. The default value is (DAEMONMASK_CEC |
* DAEMONMASK_FRIENDS)
*/
void GetDefaultDaemons(Service::Interface* self);
@ -252,5 +242,5 @@ void Init();
/// Shutdown NDM service
void Shutdown();
}// namespace NDM
}// namespace Service
} // namespace NDM
} // namespace Service

View File

@ -9,28 +9,28 @@ namespace Service {
namespace NDM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010042, EnterExclusiveState, "EnterExclusiveState"},
{0x00020002, LeaveExclusiveState, "LeaveExclusiveState"},
{0x00030000, QueryExclusiveMode, "QueryExclusiveMode"},
{0x00040002, LockState, "LockState"},
{0x00050002, UnlockState, "UnlockState"},
{0x00060040, SuspendDaemons, "SuspendDaemons"},
{0x00070040, ResumeDaemons, "ResumeDaemons"},
{0x00080040, SuspendScheduler, "SuspendScheduler"},
{0x00090000, ResumeScheduler, "ResumeScheduler"},
{0x000A0000, nullptr, "GetCurrentState"},
{0x000B0000, nullptr, "GetTargetState"},
{0x000C0000, nullptr, "<Stubbed>"},
{0x000D0040, QueryStatus, "QueryStatus"},
{0x000E0040, GetDaemonDisableCount, "GetDaemonDisableCount"},
{0x000F0000, GetSchedulerDisableCount,"GetSchedulerDisableCount"},
{0x00100040, SetScanInterval, "SetScanInterval"},
{0x00110000, GetScanInterval, "GetScanInterval"},
{0x00120040, SetRetryInterval, "SetRetryInterval"},
{0x00130000, GetRetryInterval, "GetRetryInterval"},
{0x00140040, OverrideDefaultDaemons, "OverrideDefaultDaemons"},
{0x00150000, ResetDefaultDaemons, "ResetDefaultDaemons"},
{0x00160000, GetDefaultDaemons, "GetDefaultDaemons"},
{0x00010042, EnterExclusiveState, "EnterExclusiveState"},
{0x00020002, LeaveExclusiveState, "LeaveExclusiveState"},
{0x00030000, QueryExclusiveMode, "QueryExclusiveMode"},
{0x00040002, LockState, "LockState"},
{0x00050002, UnlockState, "UnlockState"},
{0x00060040, SuspendDaemons, "SuspendDaemons"},
{0x00070040, ResumeDaemons, "ResumeDaemons"},
{0x00080040, SuspendScheduler, "SuspendScheduler"},
{0x00090000, ResumeScheduler, "ResumeScheduler"},
{0x000A0000, nullptr, "GetCurrentState"},
{0x000B0000, nullptr, "GetTargetState"},
{0x000C0000, nullptr, "<Stubbed>"},
{0x000D0040, QueryStatus, "QueryStatus"},
{0x000E0040, GetDaemonDisableCount, "GetDaemonDisableCount"},
{0x000F0000, GetSchedulerDisableCount, "GetSchedulerDisableCount"},
{0x00100040, SetScanInterval, "SetScanInterval"},
{0x00110000, GetScanInterval, "GetScanInterval"},
{0x00120040, SetRetryInterval, "SetRetryInterval"},
{0x00130000, GetRetryInterval, "GetRetryInterval"},
{0x00140040, OverrideDefaultDaemons, "OverrideDefaultDaemons"},
{0x00150000, ResetDefaultDaemons, "ResetDefaultDaemons"},
{0x00160000, GetDefaultDaemons, "GetDefaultDaemons"},
{0x00170000, ClearHalfAwakeMacFilter, "ClearHalfAwakeMacFilter"},
};

View File

@ -4,10 +4,10 @@
#include "common/logging/log.h"
#include "core/hle/service/service.h"
#include "core/hle/service/news/news.h"
#include "core/hle/service/news/news_s.h"
#include "core/hle/service/news/news_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace NEWS {

View File

@ -9,19 +9,19 @@ namespace Service {
namespace NEWS {
const Interface::FunctionInfo FunctionTable[] = {
{0x000100C6, nullptr, "AddNotification"},
{0x00050000, nullptr, "GetTotalNotifications"},
{0x00060042, nullptr, "SetNewsDBHeader"},
{0x00070082, nullptr, "SetNotificationHeader"},
{0x00080082, nullptr, "SetNotificationMessage"},
{0x00090082, nullptr, "SetNotificationImage"},
{0x000A0042, nullptr, "GetNewsDBHeader"},
{0x000B0082, nullptr, "GetNotificationHeader"},
{0x000C0082, nullptr, "GetNotificationMessage"},
{0x000D0082, nullptr, "GetNotificationImage"},
{0x000E0040, nullptr, "SetInfoLEDPattern"},
{0x00120082, nullptr, "GetNotificationHeaderOther"},
{0x00130000, nullptr, "WriteNewsDBSavedata"},
{0x000100C6, nullptr, "AddNotification"},
{0x00050000, nullptr, "GetTotalNotifications"},
{0x00060042, nullptr, "SetNewsDBHeader"},
{0x00070082, nullptr, "SetNotificationHeader"},
{0x00080082, nullptr, "SetNotificationMessage"},
{0x00090082, nullptr, "SetNotificationImage"},
{0x000A0042, nullptr, "GetNewsDBHeader"},
{0x000B0082, nullptr, "GetNotificationHeader"},
{0x000C0082, nullptr, "GetNotificationMessage"},
{0x000D0082, nullptr, "GetNotificationImage"},
{0x000E0040, nullptr, "SetInfoLEDPattern"},
{0x00120082, nullptr, "GetNotificationHeaderOther"},
{0x00130000, nullptr, "WriteNewsDBSavedata"},
};
NEWS_S_Interface::NEWS_S_Interface() {

View File

@ -8,7 +8,7 @@ namespace Service {
namespace NEWS {
const Interface::FunctionInfo FunctionTable[] = {
{0x000100C6, nullptr, "AddNotification"},
{0x000100C6, nullptr, "AddNotification"},
};
NEWS_U_Interface::NEWS_U_Interface() {

View File

@ -5,11 +5,11 @@
#include "common/common_types.h"
#include "common/logging/log.h"
#include "core/hle/service/service.h"
#include "core/hle/service/nim/nim.h"
#include "core/hle/service/nim/nim_aoc.h"
#include "core/hle/service/nim/nim_s.h"
#include "core/hle/service/nim/nim_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace NIM {

View File

@ -8,14 +8,14 @@ namespace Service {
namespace NIM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00030042, nullptr, "SetApplicationId"},
{0x00040042, nullptr, "SetTin"},
{0x000902D0, nullptr, "ListContentSetsEx"},
{0x00180000, nullptr, "GetBalance"},
{0x001D0000, nullptr, "GetCustomerSupportCode"},
{0x00210000, nullptr, "Initialize"},
{0x00240282, nullptr, "CalculateContentsRequiredSize"},
{0x00250000, nullptr, "RefreshServerTime"},
{0x00030042, nullptr, "SetApplicationId"},
{0x00040042, nullptr, "SetTin"},
{0x000902D0, nullptr, "ListContentSetsEx"},
{0x00180000, nullptr, "GetBalance"},
{0x001D0000, nullptr, "GetCustomerSupportCode"},
{0x00210000, nullptr, "Initialize"},
{0x00240282, nullptr, "CalculateContentsRequiredSize"},
{0x00250000, nullptr, "RefreshServerTime"},
};
NIM_AOC_Interface::NIM_AOC_Interface() {

View File

@ -8,10 +8,10 @@ namespace Service {
namespace NIM {
const Interface::FunctionInfo FunctionTable[] = {
{0x000A0000, nullptr, "CheckSysupdateAvailableSOAP"},
{0x0016020A, nullptr, "ListTitles"},
{0x002D0042, nullptr, "DownloadTickets"},
{0x00420240, nullptr, "StartDownload"},
{0x000A0000, nullptr, "CheckSysupdateAvailableSOAP"},
{0x0016020A, nullptr, "ListTitles"},
{0x002D0042, nullptr, "DownloadTickets"},
{0x00420240, nullptr, "StartDownload"},
};
NIM_S_Interface::NIM_S_Interface() {
@ -20,4 +20,3 @@ NIM_S_Interface::NIM_S_Interface() {
} // namespace NIM
} // namespace Service

View File

@ -9,12 +9,12 @@ namespace Service {
namespace NIM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010000, nullptr, "StartSysUpdate"},
{0x00020000, nullptr, "GetUpdateDownloadProgress"},
{0x00040000, nullptr, "FinishTitlesInstall"},
{0x00050000, nullptr, "CheckForSysUpdateEvent"},
{0x00090000, CheckSysUpdateAvailable, "CheckSysUpdateAvailable"},
{0x000A0000, nullptr, "GetState"},
{0x00010000, nullptr, "StartSysUpdate"},
{0x00020000, nullptr, "GetUpdateDownloadProgress"},
{0x00040000, nullptr, "FinishTitlesInstall"},
{0x00050000, nullptr, "CheckForSysUpdateEvent"},
{0x00090000, CheckSysUpdateAvailable, "CheckSysUpdateAvailable"},
{0x000A0000, nullptr, "GetState"},
};
NIM_U_Interface::NIM_U_Interface() {
@ -23,4 +23,3 @@ NIM_U_Interface::NIM_U_Interface() {
} // namespace NIM
} // namespace Service

View File

@ -10,21 +10,21 @@
namespace NS_S {
const Interface::FunctionInfo FunctionTable[] = {
{0x000100C0, nullptr, "LaunchFIRM"},
{0x000200C0, nullptr, "LaunchTitle"},
{0x00030000, nullptr, "TerminateApplication"},
{0x00040040, nullptr, "TerminateProcess"},
{0x000500C0, nullptr, "LaunchApplicationFIRM"},
{0x00060042, nullptr, "SetFIRMParams4A0"},
{0x00070042, nullptr, "CardUpdateInitialize"},
{0x00080000, nullptr, "CardUpdateShutdown"},
{0x000D0140, nullptr, "SetTWLBannerHMAC"},
{0x000E0000, nullptr, "ShutdownAsync"},
{0x00100180, nullptr, "RebootSystem"},
{0x00110100, nullptr, "TerminateTitle"},
{0x001200C0, nullptr, "SetApplicationCpuTimeLimit"},
{0x00150140, nullptr, "LaunchApplication"},
{0x00160000, nullptr, "RebootSystemClean"},
{0x000100C0, nullptr, "LaunchFIRM"},
{0x000200C0, nullptr, "LaunchTitle"},
{0x00030000, nullptr, "TerminateApplication"},
{0x00040040, nullptr, "TerminateProcess"},
{0x000500C0, nullptr, "LaunchApplicationFIRM"},
{0x00060042, nullptr, "SetFIRMParams4A0"},
{0x00070042, nullptr, "CardUpdateInitialize"},
{0x00080000, nullptr, "CardUpdateShutdown"},
{0x000D0140, nullptr, "SetTWLBannerHMAC"},
{0x000E0000, nullptr, "ShutdownAsync"},
{0x00100180, nullptr, "RebootSystem"},
{0x00110100, nullptr, "TerminateTitle"},
{0x001200C0, nullptr, "SetApplicationCpuTimeLimit"},
{0x00150140, nullptr, "LaunchApplication"},
{0x00160000, nullptr, "RebootSystemClean"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -54,22 +54,23 @@ static void Shutdown(Service::Interface* self) {
static void RecvBeaconBroadcastData(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 out_buffer_size = cmd_buff[1];
u32 unk1 = cmd_buff[2];
u32 unk2 = cmd_buff[3];
u32 mac_address = cmd_buff[4];
u32 unk1 = cmd_buff[2];
u32 unk2 = cmd_buff[3];
u32 mac_address = cmd_buff[4];
u32 unk3 = cmd_buff[6];
u32 unk3 = cmd_buff[6];
u32 wlan_comm_id = cmd_buff[15];
u32 ctr_gen_id = cmd_buff[16];
u32 value = cmd_buff[17];
u32 input_handle = cmd_buff[18];
u32 wlan_comm_id = cmd_buff[15];
u32 ctr_gen_id = cmd_buff[16];
u32 value = cmd_buff[17];
u32 input_handle = cmd_buff[18];
u32 new_buffer_size = cmd_buff[19];
u32 out_buffer_ptr = cmd_buff[20];
u32 out_buffer_ptr = cmd_buff[20];
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_NWM, "(STUBBED) called out_buffer_size=0x%08X, unk1=0x%08X, unk2=0x%08X,"
LOG_WARNING(Service_NWM,
"(STUBBED) called out_buffer_size=0x%08X, unk1=0x%08X, unk2=0x%08X,"
"mac_address=0x%08X, unk3=0x%08X, wlan_comm_id=0x%08X, ctr_gen_id=0x%08X,"
"value=%u, input_handle=0x%08X, new_buffer_size=0x%08X, out_buffer_ptr=0x%08X",
out_buffer_size, unk1, unk2, mac_address, unk3, wlan_comm_id, ctr_gen_id, value,
@ -92,46 +93,47 @@ static void RecvBeaconBroadcastData(Service::Interface* self) {
*/
static void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 unk1 = cmd_buff[1];
u32 unk2 = cmd_buff[12];
u32 value = cmd_buff[13];
u32 unk1 = cmd_buff[1];
u32 unk2 = cmd_buff[12];
u32 value = cmd_buff[13];
u32 handle = cmd_buff[14];
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = 0;
cmd_buff[3] = Kernel::g_handle_table.Create(handle_event).MoveFrom(); //TODO(purpasmart): Verify if this is a event handle
cmd_buff[3] = Kernel::g_handle_table.Create(handle_event)
.MoveFrom(); // TODO(purpasmart): Verify if this is a event handle
LOG_WARNING(Service_NWM, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, value=%u, handle=0x%08X",
unk1, unk2, value, handle);
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00020000, nullptr, "Scrap"},
{0x00030000, Shutdown, "Shutdown"},
{0x00040402, nullptr, "CreateNetwork"},
{0x00050040, nullptr, "EjectClient"},
{0x00060000, nullptr, "EjectSpectator"},
{0x00070080, nullptr, "UpdateNetworkAttribute"},
{0x00080000, nullptr, "DestroyNetwork"},
{0x000A0000, nullptr, "DisconnectNetwork"},
{0x000B0000, nullptr, "GetConnectionStatus"},
{0x000D0040, nullptr, "GetNodeInformation"},
{0x000F0404, RecvBeaconBroadcastData, "RecvBeaconBroadcastData"},
{0x00100042, nullptr, "SetBeaconAdditionalData"},
{0x00110040, nullptr, "GetApplicationData"},
{0x00120100, nullptr, "Bind"},
{0x00130040, nullptr, "Unbind"},
{0x001400C0, nullptr, "RecvBroadcastDataFrame"},
{0x00150080, nullptr, "SetMaxSendDelay"},
{0x00170182, nullptr, "SendTo"},
{0x001A0000, nullptr, "GetChannel"},
{0x001B0302, Initialize, "Initialize"},
{0x001D0044, nullptr, "BeginHostingNetwork"},
{0x001E0084, nullptr, "ConnectToNetwork"},
{0x001F0006, nullptr, "DecryptBeaconData"},
{0x00200040, nullptr, "Flush"},
{0x00210080, nullptr, "SetProbeResponseParam"},
{0x00220402, nullptr, "ScanOnConnection"},
{0x00020000, nullptr, "Scrap"},
{0x00030000, Shutdown, "Shutdown"},
{0x00040402, nullptr, "CreateNetwork"},
{0x00050040, nullptr, "EjectClient"},
{0x00060000, nullptr, "EjectSpectator"},
{0x00070080, nullptr, "UpdateNetworkAttribute"},
{0x00080000, nullptr, "DestroyNetwork"},
{0x000A0000, nullptr, "DisconnectNetwork"},
{0x000B0000, nullptr, "GetConnectionStatus"},
{0x000D0040, nullptr, "GetNodeInformation"},
{0x000F0404, RecvBeaconBroadcastData, "RecvBeaconBroadcastData"},
{0x00100042, nullptr, "SetBeaconAdditionalData"},
{0x00110040, nullptr, "GetApplicationData"},
{0x00120100, nullptr, "Bind"},
{0x00130040, nullptr, "Unbind"},
{0x001400C0, nullptr, "RecvBroadcastDataFrame"},
{0x00150080, nullptr, "SetMaxSendDelay"},
{0x00170182, nullptr, "SendTo"},
{0x001A0000, nullptr, "GetChannel"},
{0x001B0302, Initialize, "Initialize"},
{0x001D0044, nullptr, "BeginHostingNetwork"},
{0x001E0084, nullptr, "ConnectToNetwork"},
{0x001F0006, nullptr, "DecryptBeaconData"},
{0x00200040, nullptr, "Flush"},
{0x00210080, nullptr, "SetProbeResponseParam"},
{0x00220402, nullptr, "ScanOnConnection"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -10,18 +10,18 @@
namespace PM_APP {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010140, nullptr, "LaunchTitle"},
{0x00020082, nullptr, "LaunchFIRMSetParams"},
{0x00030080, nullptr, "TerminateProcesse"},
{0x00040100, nullptr, "TerminateProcessTID"},
{0x000500C0, nullptr, "TerminateProcessTID_unknown"},
{0x00070042, nullptr, "GetFIRMLaunchParams"},
{0x00080100, nullptr, "GetTitleExheaderFlags"},
{0x00090042, nullptr, "SetFIRMLaunchParams"},
{0x000A0140, nullptr, "SetResourceLimit"},
{0x000B0140, nullptr, "GetResourceLimitMax"},
{0x000C0080, nullptr, "UnregisterProcess"},
{0x000D0240, nullptr, "LaunchTitleUpdate"},
{0x00010140, nullptr, "LaunchTitle"},
{0x00020082, nullptr, "LaunchFIRMSetParams"},
{0x00030080, nullptr, "TerminateProcesse"},
{0x00040100, nullptr, "TerminateProcessTID"},
{0x000500C0, nullptr, "TerminateProcessTID_unknown"},
{0x00070042, nullptr, "GetFIRMLaunchParams"},
{0x00080100, nullptr, "GetTitleExheaderFlags"},
{0x00090042, nullptr, "SetFIRMLaunchParams"},
{0x000A0140, nullptr, "SetResourceLimit"},
{0x000B0140, nullptr, "GetResourceLimitMax"},
{0x000C0080, nullptr, "UnregisterProcess"},
{0x000D0240, nullptr, "LaunchTitleUpdate"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -2,21 +2,21 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/ptm/ptm.h"
#include "common/logging/log.h"
#include "core/settings.h"
#include "core/file_sys/file_backend.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/ptm/ptm.h"
#include "core/hle/service/ptm/ptm_play.h"
#include "core/hle/service/ptm/ptm_sysm.h"
#include "core/hle/service/ptm/ptm_u.h"
#include "core/hle/service/service.h"
#include "core/settings.h"
namespace Service {
namespace PTM {
/// Values for the default gamecoin.dat file
static const GameCoin default_game_coin = { 0x4F00, 42, 0, 0, 0, 2014, 12, 29 };
static const GameCoin default_game_coin = {0x4F00, 42, 0, 0, 0, 2014, 12, 29};
/// Id of the SharedExtData archive used by the PTM process
static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0};
@ -51,7 +51,8 @@ void GetBatteryLevel(Service::Interface* self) {
// it returns a valid result without implementing full functionality.
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery
cmd_buff[2] =
static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
@ -94,7 +95,8 @@ void CheckNew3DS(Service::Interface* self) {
const bool is_new_3ds = Settings::values.is_new_3ds;
if (is_new_3ds) {
LOG_CRITICAL(Service_PTM, "The option 'is_new_3ds' is enabled as part of the 'System' settings. Citra does not fully support New 3DS emulation yet!");
LOG_CRITICAL(Service_PTM, "The option 'is_new_3ds' is enabled as part of the 'System' "
"settings. Citra does not fully support New 3DS emulation yet!");
}
cmd_buff[1] = RESULT_SUCCESS.raw;
@ -111,15 +113,19 @@ void Init() {
shell_open = true;
battery_is_charging = true;
// Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't exist
// Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't
// exist
FileSys::Path archive_path(ptm_shared_extdata_id);
auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
auto archive_result =
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
// If the archive didn't exist, create the files inside
if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
// Format the archive to create the directories
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, FileSys::ArchiveFormatInfo(), archive_path);
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
FileSys::ArchiveFormatInfo(), archive_path);
// Open it again to get a valid archive now that the folder exists
archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
archive_result =
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");
FileSys::Path gamecoin_path("gamecoin.dat");
@ -127,17 +133,18 @@ void Init() {
open_mode.write_flag.Assign(1);
open_mode.create_flag.Assign(1);
// Open the file and write the default gamecoin information
auto gamecoin_result = Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
auto gamecoin_result =
Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
if (gamecoin_result.Succeeded()) {
auto gamecoin = gamecoin_result.MoveFrom();
gamecoin->backend->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin));
gamecoin->backend->Write(0, sizeof(GameCoin), 1,
reinterpret_cast<const u8*>(&default_game_coin));
gamecoin->backend->Close();
}
}
}
void Shutdown() {
}
} // namespace PTM

View File

@ -14,23 +14,24 @@ namespace PTM {
/// Charge levels used by PTM functions
enum class ChargeLevels : u32 {
CriticalBattery = 1,
LowBattery = 2,
HalfFull = 3,
MostlyFull = 4,
CompletelyFull = 5,
CriticalBattery = 1,
LowBattery = 2,
HalfFull = 3,
MostlyFull = 4,
CompletelyFull = 5,
};
/**
* Represents the gamecoin file structure in the SharedExtData archive
* More information in 3dbrew (http://www.3dbrew.org/wiki/Extdata#Shared_Extdata_0xf000000b_gamecoin.dat)
* More information in 3dbrew
* (http://www.3dbrew.org/wiki/Extdata#Shared_Extdata_0xf000000b_gamecoin.dat)
*/
struct GameCoin {
u32 magic; ///< Magic number: 0x4F00
u16 total_coins; ///< Total Play Coins
u32 magic; ///< Magic number: 0x4F00
u16 total_coins; ///< Total Play Coins
u16 total_coins_on_date; ///< Total Play Coins obtained on the date stored below.
u32 step_count; ///< Total step count at the time a new Play Coin was obtained.
u32 last_step_count; ///< Step count for the day the last Play Coin was obtained
u32 step_count; ///< Total step count at the time a new Play Coin was obtained.
u32 last_step_count; ///< Step count for the day the last Play Coin was obtained
u16 year;
u8 month;
u8 day;

View File

@ -8,10 +8,10 @@ namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
};
PTM_Play_Interface::PTM_Play_Interface() {

View File

@ -13,9 +13,9 @@ class PTM_Play_Interface : public Service::Interface {
public:
PTM_Play_Interface();
std::string GetPortName() const override {
return "ptm:play";
}
std::string GetPortName() const override {
return "ptm:play";
}
};
} // namespace PTM

View File

@ -9,37 +9,37 @@ namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
{0x040100C0, nullptr, "SetRtcAlarmEx"},
{0x04020042, nullptr, "ReplySleepQuery"},
{0x04030042, nullptr, "NotifySleepPreparationComplete"},
{0x04040102, nullptr, "SetWakeupTrigger"},
{0x04050000, nullptr, "GetAwakeReason"},
{0x04060000, nullptr, "RequestSleep"},
{0x040700C0, nullptr, "ShutdownAsync"},
{0x04080000, nullptr, "Awake"},
{0x04090080, nullptr, "RebootAsync"},
{0x040A0000, CheckNew3DS, "CheckNew3DS"},
{0x08010640, nullptr, "SetInfoLEDPattern"},
{0x08020040, nullptr, "SetInfoLEDPatternHeader"},
{0x08030000, nullptr, "GetInfoLEDStatus"},
{0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
{0x08050000, nullptr, "ClearStepHistory"},
{0x080600C2, nullptr, "SetStepHistory"},
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080A0000, nullptr, "ClearPlayHistory"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
{0x080C0080, nullptr, "SetUserTime"},
{0x080D0000, nullptr, "InvalidateSystemTime"},
{0x080E0140, nullptr, "NotifyPlayEvent"},
{0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"},
{0x08100000, nullptr, "ClearLegacyPowerOff"},
{0x08110000, GetShellState, "GetShellState"},
{0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
{0x08130000, nullptr, "FormatSavedata"},
{0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"},
{0x08180040, nullptr, "ConfigureNew3DSCPU"},
{0x040100C0, nullptr, "SetRtcAlarmEx"},
{0x04020042, nullptr, "ReplySleepQuery"},
{0x04030042, nullptr, "NotifySleepPreparationComplete"},
{0x04040102, nullptr, "SetWakeupTrigger"},
{0x04050000, nullptr, "GetAwakeReason"},
{0x04060000, nullptr, "RequestSleep"},
{0x040700C0, nullptr, "ShutdownAsync"},
{0x04080000, nullptr, "Awake"},
{0x04090080, nullptr, "RebootAsync"},
{0x040A0000, CheckNew3DS, "CheckNew3DS"},
{0x08010640, nullptr, "SetInfoLEDPattern"},
{0x08020040, nullptr, "SetInfoLEDPatternHeader"},
{0x08030000, nullptr, "GetInfoLEDStatus"},
{0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
{0x08050000, nullptr, "ClearStepHistory"},
{0x080600C2, nullptr, "SetStepHistory"},
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080A0000, nullptr, "ClearPlayHistory"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
{0x080C0080, nullptr, "SetUserTime"},
{0x080D0000, nullptr, "InvalidateSystemTime"},
{0x080E0140, nullptr, "NotifyPlayEvent"},
{0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"},
{0x08100000, nullptr, "ClearLegacyPowerOff"},
{0x08110000, GetShellState, "GetShellState"},
{0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
{0x08130000, nullptr, "FormatSavedata"},
{0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"},
{0x08180040, nullptr, "ConfigureNew3DSCPU"},
};
PTM_Sysm_Interface::PTM_Sysm_Interface() {

View File

@ -9,21 +9,21 @@ namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, GetAdapterState, "GetAdapterState"},
{0x00060000, GetShellState, "GetShellState"},
{0x00070000, GetBatteryLevel, "GetBatteryLevel"},
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, GetAdapterState, "GetAdapterState"},
{0x00060000, GetShellState, "GetShellState"},
{0x00070000, GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, nullptr, "GetStepHistory"},
{0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, nullptr, "GetStepHistory"},
{0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
};
PTM_U_Interface::PTM_U_Interface() {

View File

@ -5,7 +5,6 @@
#include "common/logging/log.h"
#include "common/string_util.h"
#include "core/hle/service/service.h"
#include "core/hle/service/ac_u.h"
#include "core/hle/service/act_a.h"
#include "core/hle/service/act_u.h"
@ -19,6 +18,7 @@
#include "core/hle/service/ns_s.h"
#include "core/hle/service/nwm_uds.h"
#include "core/hle/service/pm_app.h"
#include "core/hle/service/service.h"
#include "core/hle/service/soc_u.h"
#include "core/hle/service/srv.h"
#include "core/hle/service/ssl_c.h"
@ -29,10 +29,10 @@
#include "core/hle/service/boss/boss.h"
#include "core/hle/service/cam/cam.h"
#include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/dlp/dlp.h"
#include "core/hle/service/frd/frd.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/hid/hid.h"
#include "core/hle/service/ir/ir.h"
#include "core/hle/service/ldr_ro/ldr_ro.h"
@ -50,11 +50,13 @@ std::unordered_map<std::string, Kernel::SharedPtr<Interface>> g_srv_services;
* Creates a function string for logging, complete with the name (or header code, depending
* on what's passed in) the port name, and all the cmd_buff arguments.
*/
static std::string MakeFunctionString(const char* name, const char* port_name, const u32* cmd_buff) {
static std::string MakeFunctionString(const char* name, const char* port_name,
const u32* cmd_buff) {
// Number of params == bits 0-5 + bits 6-11
int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F);
std::string function_string = Common::StringFromFormat("function '%s': port=%s", name, port_name);
std::string function_string =
Common::StringFromFormat("function '%s': port=%s", name, port_name);
for (int i = 1; i <= num_params; ++i) {
function_string += Common::StringFromFormat(", cmd_buff[%i]=0x%X", i, cmd_buff[i]);
}
@ -66,14 +68,19 @@ ResultVal<bool> Interface::SyncRequest() {
auto itr = m_functions.find(cmd_buff[0]);
if (itr == m_functions.end() || itr->second.func == nullptr) {
std::string function_name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name;
LOG_ERROR(Service, "unknown / unimplemented %s", MakeFunctionString(function_name.c_str(), GetPortName().c_str(), cmd_buff).c_str());
std::string function_name = (itr == m_functions.end())
? Common::StringFromFormat("0x%08X", cmd_buff[0])
: itr->second.name;
LOG_ERROR(
Service, "unknown / unimplemented %s",
MakeFunctionString(function_name.c_str(), GetPortName().c_str(), cmd_buff).c_str());
// TODO(bunnei): Hack - ignore error
cmd_buff[1] = 0;
return MakeResult<bool>(false);
}
LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str());
LOG_TRACE(Service, "%s",
MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str());
itr->second.func(this);
@ -163,6 +170,4 @@ void Shutdown() {
g_kernel_named_ports.clear();
LOG_DEBUG(Service, "shutdown OK");
}
}

View File

@ -28,13 +28,15 @@ class Interface : public Kernel::Session {
// just something that encapsulates a session and acts as a helper to implement service
// processes.
public:
std::string GetName() const override { return GetPortName(); }
std::string GetName() const override {
return GetPortName();
}
typedef void (*Function)(Interface*);
struct FunctionInfo {
u32 id;
Function func;
u32 id;
Function func;
const char* name;
};
@ -49,7 +51,6 @@ public:
ResultVal<bool> SyncRequest() override;
protected:
/**
* Registers the functions in the service
*/
@ -62,7 +63,6 @@ protected:
private:
boost::container::flat_map<u32, FunctionInfo> m_functions;
};
/// Initialize ServiceManager

View File

@ -19,40 +19,40 @@
#include "core/memory.h"
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <winsock2.h>
#include <ws2tcpip.h>
// MinGW does not define several errno constants
#ifndef _MSC_VER
#define EBADMSG 104
#define ENODATA 120
#define ENOMSG 122
#define ENOSR 124
#define ENOSTR 125
#define ETIME 137
#define EIDRM 2001
#define ENOLINK 2002
#endif // _MSC_VER
// MinGW does not define several errno constants
#ifndef _MSC_VER
#define EBADMSG 104
#define ENODATA 120
#define ENOMSG 122
#define ENOSR 124
#define ENOSTR 125
#define ETIME 137
#define EIDRM 2001
#define ENOLINK 2002
#endif // _MSC_VER
#else
#include <cerrno>
#include <fcntl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <poll.h>
#include <sys/socket.h>
#include <unistd.h>
#include <cerrno>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <poll.h>
#include <sys/socket.h>
#include <unistd.h>
#endif
#ifdef _WIN32
# define WSAEAGAIN WSAEWOULDBLOCK
# define WSAEMULTIHOP -1 // Invalid dummy value
# define ERRNO(x) WSA##x
# define GET_ERRNO WSAGetLastError()
# define poll(x, y, z) WSAPoll(x, y, z);
#define WSAEAGAIN WSAEWOULDBLOCK
#define WSAEMULTIHOP -1 // Invalid dummy value
#define ERRNO(x) WSA##x
#define GET_ERRNO WSAGetLastError()
#define poll(x, y, z) WSAPoll(x, y, z);
#else
# define ERRNO(x) x
# define GET_ERRNO errno
# define closesocket(x) close(x)
#define ERRNO(x) x
#define GET_ERRNO errno
#define closesocket(x) close(x)
#endif
static const s32 SOCKET_ERROR_VALUE = -1;
@ -63,84 +63,82 @@ static const s32 SOCKET_ERROR_VALUE = -1;
namespace SOC_U {
/// Holds the translation from system network errors to 3DS network errors
static const std::unordered_map<int, int> error_map = { {
{ E2BIG, 1 },
{ ERRNO(EACCES), 2 },
{ ERRNO(EADDRINUSE), 3 },
{ ERRNO(EADDRNOTAVAIL), 4 },
{ ERRNO(EAFNOSUPPORT), 5 },
{ ERRNO(EAGAIN), 6 },
{ ERRNO(EALREADY), 7 },
{ ERRNO(EBADF), 8 },
{ EBADMSG, 9 },
{ EBUSY, 10 },
{ ECANCELED, 11 },
{ ECHILD, 12 },
{ ERRNO(ECONNABORTED), 13 },
{ ERRNO(ECONNREFUSED), 14 },
{ ERRNO(ECONNRESET), 15 },
{ EDEADLK, 16 },
{ ERRNO(EDESTADDRREQ), 17 },
{ EDOM, 18 },
{ ERRNO(EDQUOT), 19 },
{ EEXIST, 20 },
{ ERRNO(EFAULT), 21 },
{ EFBIG, 22 },
{ ERRNO(EHOSTUNREACH), 23 },
{ EIDRM, 24 },
{ EILSEQ, 25 },
{ ERRNO(EINPROGRESS), 26 },
{ ERRNO(EINTR), 27 },
{ ERRNO(EINVAL), 28 },
{ EIO, 29 },
{ ERRNO(EISCONN), 30 },
{ EISDIR, 31 },
{ ERRNO(ELOOP), 32 },
{ ERRNO(EMFILE), 33 },
{ EMLINK, 34 },
{ ERRNO(EMSGSIZE), 35 },
{ ERRNO(EMULTIHOP), 36 },
{ ERRNO(ENAMETOOLONG), 37 },
{ ERRNO(ENETDOWN), 38 },
{ ERRNO(ENETRESET), 39 },
{ ERRNO(ENETUNREACH), 40 },
{ ENFILE, 41 },
{ ERRNO(ENOBUFS), 42 },
{ ENODATA, 43 },
{ ENODEV, 44 },
{ ENOENT, 45 },
{ ENOEXEC, 46 },
{ ENOLCK, 47 },
{ ENOLINK, 48 },
{ ENOMEM, 49 },
{ ENOMSG, 50 },
{ ERRNO(ENOPROTOOPT), 51 },
{ ENOSPC, 52 },
{ ENOSR, 53 },
{ ENOSTR, 54 },
{ ENOSYS, 55 },
{ ERRNO(ENOTCONN), 56 },
{ ENOTDIR, 57 },
{ ERRNO(ENOTEMPTY), 58 },
{ ERRNO(ENOTSOCK), 59 },
{ ENOTSUP, 60 },
{ ENOTTY, 61 },
{ ENXIO, 62 },
{ ERRNO(EOPNOTSUPP), 63 },
{ EOVERFLOW, 64 },
{ EPERM, 65 },
{ EPIPE, 66 },
{ EPROTO, 67 },
{ ERRNO(EPROTONOSUPPORT), 68 },
{ ERRNO(EPROTOTYPE), 69 },
{ ERANGE, 70 },
{ EROFS, 71 },
{ ESPIPE, 72 },
{ ESRCH, 73 },
{ ERRNO(ESTALE), 74 },
{ ETIME, 75 },
{ ERRNO(ETIMEDOUT), 76 }
}};
static const std::unordered_map<int, int> error_map = {{{E2BIG, 1},
{ERRNO(EACCES), 2},
{ERRNO(EADDRINUSE), 3},
{ERRNO(EADDRNOTAVAIL), 4},
{ERRNO(EAFNOSUPPORT), 5},
{ERRNO(EAGAIN), 6},
{ERRNO(EALREADY), 7},
{ERRNO(EBADF), 8},
{EBADMSG, 9},
{EBUSY, 10},
{ECANCELED, 11},
{ECHILD, 12},
{ERRNO(ECONNABORTED), 13},
{ERRNO(ECONNREFUSED), 14},
{ERRNO(ECONNRESET), 15},
{EDEADLK, 16},
{ERRNO(EDESTADDRREQ), 17},
{EDOM, 18},
{ERRNO(EDQUOT), 19},
{EEXIST, 20},
{ERRNO(EFAULT), 21},
{EFBIG, 22},
{ERRNO(EHOSTUNREACH), 23},
{EIDRM, 24},
{EILSEQ, 25},
{ERRNO(EINPROGRESS), 26},
{ERRNO(EINTR), 27},
{ERRNO(EINVAL), 28},
{EIO, 29},
{ERRNO(EISCONN), 30},
{EISDIR, 31},
{ERRNO(ELOOP), 32},
{ERRNO(EMFILE), 33},
{EMLINK, 34},
{ERRNO(EMSGSIZE), 35},
{ERRNO(EMULTIHOP), 36},
{ERRNO(ENAMETOOLONG), 37},
{ERRNO(ENETDOWN), 38},
{ERRNO(ENETRESET), 39},
{ERRNO(ENETUNREACH), 40},
{ENFILE, 41},
{ERRNO(ENOBUFS), 42},
{ENODATA, 43},
{ENODEV, 44},
{ENOENT, 45},
{ENOEXEC, 46},
{ENOLCK, 47},
{ENOLINK, 48},
{ENOMEM, 49},
{ENOMSG, 50},
{ERRNO(ENOPROTOOPT), 51},
{ENOSPC, 52},
{ENOSR, 53},
{ENOSTR, 54},
{ENOSYS, 55},
{ERRNO(ENOTCONN), 56},
{ENOTDIR, 57},
{ERRNO(ENOTEMPTY), 58},
{ERRNO(ENOTSOCK), 59},
{ENOTSUP, 60},
{ENOTTY, 61},
{ENXIO, 62},
{ERRNO(EOPNOTSUPP), 63},
{EOVERFLOW, 64},
{EPERM, 65},
{EPIPE, 66},
{EPROTO, 67},
{ERRNO(EPROTONOSUPPORT), 68},
{ERRNO(EPROTOTYPE), 69},
{ERANGE, 70},
{EROFS, 71},
{ESPIPE, 72},
{ESRCH, 73},
{ERRNO(ESTALE), 74},
{ETIME, 75},
{ERRNO(ETIMEDOUT), 76}}};
/// Converts a network error from platform-specific to 3ds-specific
static int TranslateError(int error) {
@ -153,21 +151,21 @@ static int TranslateError(int error) {
/// Holds the translation from system network socket options to 3DS network socket options
/// Note: -1 = No effect/unavailable
static const std::unordered_map<int, int> sockopt_map = { {
{ 0x0004, SO_REUSEADDR },
{ 0x0080, -1 },
{ 0x0100, -1 },
{ 0x1001, SO_SNDBUF },
{ 0x1002, SO_RCVBUF },
{ 0x1003, -1 },
static const std::unordered_map<int, int> sockopt_map = {{
{0x0004, SO_REUSEADDR},
{0x0080, -1},
{0x0100, -1},
{0x1001, SO_SNDBUF},
{0x1002, SO_RCVBUF},
{0x1003, -1},
#ifdef _WIN32
/// Unsupported in WinSock2
{ 0x1004, -1 },
{0x1004, -1},
#else
{ 0x1004, SO_RCVLOWAT },
{0x1004, SO_RCVLOWAT},
#endif
{ 0x1008, SO_TYPE },
{ 0x1009, SO_ERROR },
{0x1008, SO_TYPE},
{0x1009, SO_ERROR},
}};
/// Converts a socket option from 3ds-specific to platform-specific
@ -203,7 +201,8 @@ struct CTRPollFD {
return *this;
}
/// Translates the resulting events of a Poll operation from platform-specific to 3ds specific
/// Translates the resulting events of a Poll operation from platform-specific to 3ds
/// specific
static Events TranslateTo3DS(u32 input_event) {
Events ev = {};
if (input_event & POLLIN)
@ -221,7 +220,8 @@ struct CTRPollFD {
return ev;
}
/// Translates the resulting events of a Poll operation from 3ds specific to platform specific
/// Translates the resulting events of a Poll operation from 3ds specific to platform
/// specific
static u32 TranslateToPlatform(Events input_event) {
u32 ret = 0;
if (input_event.pollin)
@ -239,7 +239,7 @@ struct CTRPollFD {
return ret;
}
};
Events events; ///< Events to poll for (input)
Events events; ///< Events to poll for (input)
Events revents; ///< Events received (output)
/// Converts a platform-specific pollfd to a 3ds specific structure
@ -265,17 +265,17 @@ struct CTRPollFD {
union CTRSockAddr {
/// Structure to represent a raw sockaddr
struct {
u8 len; ///< The length of the entire structure, only the set fields count
u8 sa_family; ///< The address family of the sockaddr
u8 len; ///< The length of the entire structure, only the set fields count
u8 sa_family; ///< The address family of the sockaddr
u8 sa_data[0x1A]; ///< The extra data, this varies, depending on the address family
} raw;
/// Structure to represent the 3ds' sockaddr_in structure
struct CTRSockAddrIn {
u8 len; ///< The length of the entire structure
u8 len; ///< The length of the entire structure
u8 sin_family; ///< The address family of the sockaddr_in
u16 sin_port; ///< The port associated with this sockaddr_in
u32 sin_addr; ///< The actual address of the sockaddr_in
u16 sin_port; ///< The port associated with this sockaddr_in
u32 sin_addr; ///< The actual address of the sockaddr_in
} in;
/// Convert a 3DS CTRSockAddr to a platform-specific sockaddr
@ -286,8 +286,7 @@ union CTRSockAddr {
// We can not guarantee ABI compatibility between platforms so we copy the fields manually
switch (result.sa_family) {
case AF_INET:
{
case AF_INET: {
sockaddr_in* result_in = reinterpret_cast<sockaddr_in*>(&result);
result_in->sin_port = ctr_addr.in.sin_port;
result_in->sin_addr.s_addr = ctr_addr.in.sin_addr;
@ -307,8 +306,7 @@ union CTRSockAddr {
result.raw.sa_family = static_cast<u8>(addr.sa_family);
// We can not guarantee ABI compatibility between platforms so we copy the fields manually
switch (result.raw.sa_family) {
case AF_INET:
{
case AF_INET: {
sockaddr_in const* addr_in = reinterpret_cast<sockaddr_in const*>(&addr);
result.raw.len = sizeof(CTRSockAddrIn);
result.in.sin_port = addr_in->sin_port;
@ -341,24 +339,27 @@ static void Socket(Service::Interface* self) {
// Only 0 is allowed according to 3dbrew, using 0 will let the OS decide which protocol to use
if (protocol != 0) {
cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
cmd_buffer[1] =
UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
return;
}
if (domain != AF_INET) {
cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
cmd_buffer[1] =
UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
return;
}
if (type != SOCK_DGRAM && type != SOCK_STREAM) {
cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
cmd_buffer[1] =
UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
return;
}
u32 socket_handle = static_cast<u32>(::socket(domain, type, protocol));
if ((s32)socket_handle != SOCKET_ERROR_VALUE)
open_sockets[socket_handle] = { socket_handle, true };
open_sockets[socket_handle] = {socket_handle, true};
int result = 0;
if ((s32)socket_handle == SOCKET_ERROR_VALUE)
@ -406,8 +407,8 @@ static void Fcntl(Service::Interface* self) {
int result = 0;
u32 posix_ret = 0; // TODO: Check what hardware returns for F_SETFL (unspecified by POSIX)
SCOPE_EXIT({
cmd_buffer[1] = result;
cmd_buffer[2] = posix_ret;
cmd_buffer[1] = result;
cmd_buffer[2] = posix_ret;
});
if (ctr_cmd == 3) { // F_GETFL
@ -493,7 +494,7 @@ static void Accept(Service::Interface* self) {
u32 ret = static_cast<u32>(::accept(socket_handle, &addr, &addr_len));
if ((s32)ret != SOCKET_ERROR_VALUE)
open_sockets[ret] = { ret, true };
open_sockets[ret] = {ret, true};
int result = 0;
if ((s32)ret == SOCKET_ERROR_VALUE) {
@ -573,9 +574,11 @@ static void SendTo(Service::Interface* self) {
int ret = -1;
if (addr_len > 0) {
sockaddr dest_addr = CTRSockAddr::ToPlatform(ctr_dest_addr);
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags, &dest_addr, sizeof(dest_addr));
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
&dest_addr, sizeof(dest_addr));
} else {
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags, nullptr, 0);
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
nullptr, 0);
}
int result = 0;
@ -596,8 +599,7 @@ static void RecvFrom(Service::Interface* self) {
u32 flags = cmd_buffer[3];
socklen_t addr_len = static_cast<socklen_t>(cmd_buffer[4]);
struct
{
struct {
u32 output_buffer_descriptor;
u32 output_buffer_addr;
u32 address_buffer_descriptor;
@ -619,11 +621,13 @@ static void RecvFrom(Service::Interface* self) {
std::vector<u8> output_buff(len);
sockaddr src_addr;
socklen_t src_addr_len = sizeof(src_addr);
int ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags, &src_addr, &src_addr_len);
int ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
&src_addr, &src_addr_len);
if (ret >= 0 && buffer_parameters.output_src_address_buffer != 0 && src_addr_len > 0) {
CTRSockAddr ctr_src_addr = CTRSockAddr::FromPlatform(src_addr);
Memory::WriteBlock(buffer_parameters.output_src_address_buffer, &ctr_src_addr, sizeof(ctr_src_addr));
Memory::WriteBlock(buffer_parameters.output_src_address_buffer, &ctr_src_addr,
sizeof(ctr_src_addr));
}
int result = 0;
@ -633,7 +637,8 @@ static void RecvFrom(Service::Interface* self) {
total_received = 0;
} else {
// Write only the data we received to avoid overwriting parts of the buffer with zeros
Memory::WriteBlock(buffer_parameters.output_buffer_addr, output_buff.data(), total_received);
Memory::WriteBlock(buffer_parameters.output_buffer_addr, output_buff.data(),
total_received);
}
cmd_buffer[1] = result;
@ -648,7 +653,8 @@ static void Poll(Service::Interface* self) {
VAddr input_fds_addr = cmd_buffer[6];
VAddr output_fds_addr = cmd_buffer[0x104 >> 2];
if (!Memory::IsValidVirtualAddress(input_fds_addr) || !Memory::IsValidVirtualAddress(output_fds_addr)) {
if (!Memory::IsValidVirtualAddress(input_fds_addr) ||
!Memory::IsValidVirtualAddress(output_fds_addr)) {
cmd_buffer[1] = -1; // TODO(Subv): Find correct error code.
return;
}
@ -656,7 +662,8 @@ static void Poll(Service::Interface* self) {
std::vector<CTRPollFD> ctr_fds(nfds);
Memory::ReadBlock(input_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
// The 3ds_pollfd and the pollfd structures may be different (Windows/Linux have different sizes)
// The 3ds_pollfd and the pollfd structures may be different (Windows/Linux have different
// sizes)
// so we have to copy the data
std::vector<pollfd> platform_pollfd(nfds);
std::transform(ctr_fds.begin(), ctr_fds.end(), platform_pollfd.begin(), CTRPollFD::ToPlatform);
@ -664,7 +671,8 @@ static void Poll(Service::Interface* self) {
const int ret = ::poll(platform_pollfd.data(), nfds, timeout);
// Now update the output pollfd structure
std::transform(platform_pollfd.begin(), platform_pollfd.end(), ctr_fds.begin(), CTRPollFD::FromPlatform);
std::transform(platform_pollfd.begin(), platform_pollfd.end(), ctr_fds.begin(),
CTRPollFD::FromPlatform);
Memory::WriteBlock(output_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
@ -775,7 +783,7 @@ static void Connect(Service::Interface* self) {
}
static void InitializeSockets(Service::Interface* self) {
// TODO(Subv): Implement
// TODO(Subv): Implement
#ifdef _WIN32
WSADATA data;
WSAStartup(MAKEWORD(2, 2), &data);
@ -808,7 +816,7 @@ static void GetSockOpt(Service::Interface* self) {
int ret = -1;
int err = 0;
if(optname < 0) {
if (optname < 0) {
#ifdef _WIN32
err = WSAEINVAL;
#else
@ -818,7 +826,7 @@ static void GetSockOpt(Service::Interface* self) {
// 0x100 = static buffer offset (bytes)
// + 0x4 = 2nd pointer (u32) position
// >> 2 = convert to u32 offset instead of byte offset (cmd_buffer = u32*)
char* optval = reinterpret_cast<char *>(Memory::GetPointer(cmd_buffer[0x104 >> 2]));
char* optval = reinterpret_cast<char*>(Memory::GetPointer(cmd_buffer[0x104 >> 2]));
ret = ::getsockopt(socket_handle, level, optname, optval, &optlen);
err = 0;
@ -842,7 +850,7 @@ static void SetSockOpt(Service::Interface* self) {
int ret = -1;
int err = 0;
if(optname < 0) {
if (optname < 0) {
#ifdef _WIN32
err = WSAEINVAL;
#else
@ -850,7 +858,7 @@ static void SetSockOpt(Service::Interface* self) {
#endif
} else {
socklen_t optlen = static_cast<socklen_t>(cmd_buffer[4]);
const char* optval = reinterpret_cast<const char *>(Memory::GetPointer(cmd_buffer[8]));
const char* optval = reinterpret_cast<const char*>(Memory::GetPointer(cmd_buffer[8]));
ret = static_cast<u32>(::setsockopt(socket_handle, level, optname, optval, optlen));
err = 0;
@ -865,39 +873,39 @@ static void SetSockOpt(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010044, InitializeSockets, "InitializeSockets"},
{0x000200C2, Socket, "Socket"},
{0x00030082, Listen, "Listen"},
{0x00040082, Accept, "Accept"},
{0x00050084, Bind, "Bind"},
{0x00060084, Connect, "Connect"},
{0x00070104, nullptr, "recvfrom_other"},
{0x00080102, RecvFrom, "RecvFrom"},
{0x00090106, nullptr, "sendto_other"},
{0x000A0106, SendTo, "SendTo"},
{0x000B0042, Close, "Close"},
{0x000C0082, Shutdown, "Shutdown"},
{0x000D0082, nullptr, "GetHostByName"},
{0x000E00C2, nullptr, "GetHostByAddr"},
{0x000F0106, nullptr, "GetAddrInfo"},
{0x00100102, nullptr, "GetNameInfo"},
{0x00110102, GetSockOpt, "GetSockOpt"},
{0x00120104, SetSockOpt, "SetSockOpt"},
{0x001300C2, Fcntl, "Fcntl"},
{0x00140084, Poll, "Poll"},
{0x00150042, nullptr, "SockAtMark"},
{0x00160000, GetHostId, "GetHostId"},
{0x00170082, GetSockName, "GetSockName"},
{0x00180082, GetPeerName, "GetPeerName"},
{0x00190000, ShutdownSockets, "ShutdownSockets"},
{0x001A00C0, nullptr, "GetNetworkOpt"},
{0x001B0040, nullptr, "ICMPSocket"},
{0x001C0104, nullptr, "ICMPPing"},
{0x001D0040, nullptr, "ICMPCancel"},
{0x001E0040, nullptr, "ICMPClose"},
{0x001F0040, nullptr, "GetResolverInfo"},
{0x00210002, nullptr, "CloseSockets"},
{0x00230040, nullptr, "AddGlobalSocket"},
{0x00010044, InitializeSockets, "InitializeSockets"},
{0x000200C2, Socket, "Socket"},
{0x00030082, Listen, "Listen"},
{0x00040082, Accept, "Accept"},
{0x00050084, Bind, "Bind"},
{0x00060084, Connect, "Connect"},
{0x00070104, nullptr, "recvfrom_other"},
{0x00080102, RecvFrom, "RecvFrom"},
{0x00090106, nullptr, "sendto_other"},
{0x000A0106, SendTo, "SendTo"},
{0x000B0042, Close, "Close"},
{0x000C0082, Shutdown, "Shutdown"},
{0x000D0082, nullptr, "GetHostByName"},
{0x000E00C2, nullptr, "GetHostByAddr"},
{0x000F0106, nullptr, "GetAddrInfo"},
{0x00100102, nullptr, "GetNameInfo"},
{0x00110102, GetSockOpt, "GetSockOpt"},
{0x00120104, SetSockOpt, "SetSockOpt"},
{0x001300C2, Fcntl, "Fcntl"},
{0x00140084, Poll, "Poll"},
{0x00150042, nullptr, "SockAtMark"},
{0x00160000, GetHostId, "GetHostId"},
{0x00170082, GetSockName, "GetSockName"},
{0x00180082, GetPeerName, "GetPeerName"},
{0x00190000, ShutdownSockets, "ShutdownSockets"},
{0x001A00C0, nullptr, "GetNetworkOpt"},
{0x001B0040, nullptr, "ICMPSocket"},
{0x001C0104, nullptr, "ICMPPing"},
{0x001D0040, nullptr, "ICMPCancel"},
{0x001E0040, nullptr, "ICMPClose"},
{0x001F0040, nullptr, "GetResolverInfo"},
{0x00210002, nullptr, "CloseSockets"},
{0x00230040, nullptr, "AddGlobalSocket"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -5,8 +5,8 @@
#include "common/common_types.h"
#include "common/logging/log.h"
#include "core/hle/service/srv.h"
#include "core/hle/kernel/event.h"
#include "core/hle/service/srv.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace SRV
@ -28,13 +28,14 @@ static void RegisterClient(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
if (cmd_buff[1] != IPC::CallingPidDesc()) {
cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); //0x40
cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); // 0x40
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
.raw;
return;
}
cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); //0x10040
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); // 0x10040
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called");
}
@ -56,7 +57,7 @@ static void EnableNotification(Service::Interface* self) {
event_handle->Clear();
cmd_buff[0] = IPC::MakeHeader(0x2, 0x1, 0x2); // 0x20042
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = IPC::CopyHandleDesc(1);
cmd_buff[3] = Kernel::g_handle_table.Create(event_handle).MoveFrom();
LOG_WARNING(Service_SRV, "(STUBBED) called");
@ -105,7 +106,7 @@ static void Subscribe(Service::Interface* self) {
u32 notification_id = cmd_buff[1];
cmd_buff[0] = IPC::MakeHeader(0x9, 0x1, 0); // 0x90040
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X", notification_id);
}
@ -124,7 +125,7 @@ static void Unsubscribe(Service::Interface* self) {
u32 notification_id = cmd_buff[1];
cmd_buff[0] = IPC::MakeHeader(0xA, 0x1, 0); // 0xA0040
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X", notification_id);
}
@ -145,25 +146,26 @@ static void PublishToSubscriber(Service::Interface* self) {
u8 flags = cmd_buff[2] & 0xFF;
cmd_buff[0] = IPC::MakeHeader(0xC, 0x1, 0); // 0xC0040
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X, flags=%u", notification_id, flags);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_SRV, "(STUBBED) called, notification_id=0x%X, flags=%u", notification_id,
flags);
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010002, RegisterClient, "RegisterClient"},
{0x00020000, EnableNotification, "EnableNotification"},
{0x00030100, nullptr, "RegisterService"},
{0x000400C0, nullptr, "UnregisterService"},
{0x00050100, GetServiceHandle, "GetServiceHandle"},
{0x000600C2, nullptr, "RegisterPort"},
{0x000700C0, nullptr, "UnregisterPort"},
{0x00080100, nullptr, "GetPort"},
{0x00090040, Subscribe, "Subscribe"},
{0x000A0040, Unsubscribe, "Unsubscribe"},
{0x000B0000, nullptr, "ReceiveNotification"},
{0x000C0080, PublishToSubscriber, "PublishToSubscriber"},
{0x000D0040, nullptr, "PublishAndGetSubscriber"},
{0x000E00C0, nullptr, "IsServiceRegistered"},
{0x00010002, RegisterClient, "RegisterClient"},
{0x00020000, EnableNotification, "EnableNotification"},
{0x00030100, nullptr, "RegisterService"},
{0x000400C0, nullptr, "UnregisterService"},
{0x00050100, GetServiceHandle, "GetServiceHandle"},
{0x000600C2, nullptr, "RegisterPort"},
{0x000700C0, nullptr, "UnregisterPort"},
{0x00080100, nullptr, "GetPort"},
{0x00090040, Subscribe, "Subscribe"},
{0x000A0040, Unsubscribe, "Unsubscribe"},
{0x000B0000, nullptr, "ReceiveNotification"},
{0x000C0080, PublishToSubscriber, "PublishToSubscriber"},
{0x000D0040, nullptr, "PublishAndGetSubscriber"},
{0x000E00C0, nullptr, "IsServiceRegistered"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -37,7 +37,8 @@ static void GenerateRandomData(Service::Interface* self) {
u32 i = 0;
while (i < size) {
if ((i % 4) == 0) {
// The random number generator returns 4 bytes worth of data, so generate new random data when i == 0 and when i is divisible by 4
// The random number generator returns 4 bytes worth of data, so generate new random
// data when i == 0 and when i is divisible by 4
data = rand_gen();
}
@ -59,27 +60,26 @@ static void GenerateRandomData(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010002, Initialize, "Initialize"},
{0x000200C2, nullptr, "CreateContext"},
{0x00030000, nullptr, "CreateRootCertChain"},
{0x00040040, nullptr, "DestroyRootCertChain"},
{0x00050082, nullptr, "AddTrustedRootCA"},
{0x00060080, nullptr, "RootCertChainAddDefaultCert"},
{0x00070080, nullptr, "RootCertChainRemoveCert"},
{0x000E0040, nullptr, "OpenDefaultClientCertContext"},
{0x000F0040, nullptr, "CloseClientCertContext"},
{0x00110042, GenerateRandomData, "GenerateRandomData"},
{0x00120042, nullptr, "InitializeConnectionSession"},
{0x00130040, nullptr, "StartConnection"},
{0x00140040, nullptr, "StartConnectionGetOut"},
{0x00150082, nullptr, "Read"},
{0x00170082, nullptr, "Write"},
{0x00180080, nullptr, "ContextSetRootCertChain"},
{0x00190080, nullptr, "ContextSetClientCert"},
{0x001B0080, nullptr, "ContextClearOpt"},
{0x001E0040, nullptr, "DestroyContext"},
{0x001F0082, nullptr, "ContextInitSharedmem"}
};
{0x00010002, Initialize, "Initialize"},
{0x000200C2, nullptr, "CreateContext"},
{0x00030000, nullptr, "CreateRootCertChain"},
{0x00040040, nullptr, "DestroyRootCertChain"},
{0x00050082, nullptr, "AddTrustedRootCA"},
{0x00060080, nullptr, "RootCertChainAddDefaultCert"},
{0x00070080, nullptr, "RootCertChainRemoveCert"},
{0x000E0040, nullptr, "OpenDefaultClientCertContext"},
{0x000F0040, nullptr, "CloseClientCertContext"},
{0x00110042, GenerateRandomData, "GenerateRandomData"},
{0x00120042, nullptr, "InitializeConnectionSession"},
{0x00130040, nullptr, "StartConnection"},
{0x00140040, nullptr, "StartConnectionGetOut"},
{0x00150082, nullptr, "Read"},
{0x00170082, nullptr, "Write"},
{0x00180080, nullptr, "ContextSetRootCertChain"},
{0x00190080, nullptr, "ContextSetClientCert"},
{0x001B0080, nullptr, "ContextClearOpt"},
{0x001E0040, nullptr, "DestroyContext"},
{0x001F0082, nullptr, "ContextInitSharedmem"}};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class

View File

@ -39,16 +39,16 @@ static u32 transfer_end_interrupt_enabled = 0;
static u32 spacial_dithering_enabled = 0;
static const CoefficientSet standard_coefficients[4] = {
{{ 0x100, 0x166, 0xB6, 0x58, 0x1C5, -0x166F, 0x10EE, -0x1C5B }}, // ITU_Rec601
{{ 0x100, 0x193, 0x77, 0x2F, 0x1DB, -0x1933, 0xA7C, -0x1D51 }}, // ITU_Rec709
{{ 0x12A, 0x198, 0xD0, 0x64, 0x204, -0x1BDE, 0x10F2, -0x229B }}, // ITU_Rec601_Scaling
{{ 0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421 }}, // ITU_Rec709_Scaling
{{0x100, 0x166, 0xB6, 0x58, 0x1C5, -0x166F, 0x10EE, -0x1C5B}}, // ITU_Rec601
{{0x100, 0x193, 0x77, 0x2F, 0x1DB, -0x1933, 0xA7C, -0x1D51}}, // ITU_Rec709
{{0x12A, 0x198, 0xD0, 0x64, 0x204, -0x1BDE, 0x10F2, -0x229B}}, // ITU_Rec601_Scaling
{{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling
};
ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
if (width == 0 || width > 1024 || width % 8 != 0) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of
@ -61,7 +61,7 @@ ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
if (lines == 0 || lines > 1024) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: In what appears to be a bug, the `camera` module does not set the hardware register at
@ -73,11 +73,12 @@ ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
return RESULT_SUCCESS;
}
ResultCode ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) {
ResultCode
ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) {
size_t index = static_cast<size_t>(standard_coefficient);
if (index >= ARRAY_SIZE(standard_coefficients)) {
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
}
std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients));
@ -294,8 +295,10 @@ static void SetSendingY(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x10, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
conversion.src_Y.image_size, conversion.src_Y.transfer_unit, conversion.src_Y.gap, cmd_buff[6]);
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X",
conversion.src_Y.image_size, conversion.src_Y.transfer_unit, conversion.src_Y.gap,
cmd_buff[6]);
}
static void SetSendingU(Service::Interface* self) {
@ -309,8 +312,10 @@ static void SetSendingU(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x11, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
conversion.src_U.image_size, conversion.src_U.transfer_unit, conversion.src_U.gap, cmd_buff[6]);
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X",
conversion.src_U.image_size, conversion.src_U.transfer_unit, conversion.src_U.gap,
cmd_buff[6]);
}
static void SetSendingV(Service::Interface* self) {
@ -324,8 +329,10 @@ static void SetSendingV(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x12, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
conversion.src_V.image_size, conversion.src_V.transfer_unit, conversion.src_V.gap, cmd_buff[6]);
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X",
conversion.src_V.image_size, conversion.src_V.transfer_unit, conversion.src_V.gap,
cmd_buff[6]);
}
static void SetSendingYUYV(Service::Interface* self) {
@ -339,8 +346,10 @@ static void SetSendingYUYV(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x13, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, src_process_handle=0x%08X",
conversion.src_YUYV.image_size, conversion.src_YUYV.transfer_unit, conversion.src_YUYV.gap, cmd_buff[6]);
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X",
conversion.src_YUYV.image_size, conversion.src_YUYV.transfer_unit,
conversion.src_YUYV.gap, cmd_buff[6]);
}
/**
@ -418,8 +427,10 @@ static void SetReceiving(Service::Interface* self) {
cmd_buff[0] = IPC::MakeHeader(0x18, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, dst_process_handle=0x%08X",
conversion.dst.image_size, conversion.dst.transfer_unit, conversion.dst.gap, cmd_buff[6]);
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"dst_process_handle=0x%08X",
conversion.dst.image_size, conversion.dst.transfer_unit, conversion.dst.gap,
cmd_buff[6]);
}
/**
@ -486,8 +497,8 @@ static void SetCoefficient(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called coefficients=[%hX, %hX, %hX, %hX, %hX, %hX, %hX, %hX]",
coefficients[0], coefficients[1], coefficients[2], coefficients[3],
coefficients[4], coefficients[5], coefficients[6], coefficients[7]);
coefficients[0], coefficients[1], coefficients[2], coefficients[3], coefficients[4],
coefficients[5], coefficients[6], coefficients[7]);
}
static void GetCoefficient(Service::Interface* self) {
@ -575,8 +586,10 @@ static void StartConversion(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
// dst_image_size would seem to be perfect for this, but it doesn't include the gap :(
u32 total_output_size = conversion.input_lines * (conversion.dst.transfer_unit + conversion.dst.gap);
Memory::RasterizerFlushAndInvalidateRegion(Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size);
u32 total_output_size =
conversion.input_lines * (conversion.dst.transfer_unit + conversion.dst.gap);
Memory::RasterizerFlushAndInvalidateRegion(
Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size);
HW::Y2R::PerformConversion(conversion);
@ -648,10 +661,13 @@ cleanup:
cmd_buff[0] = IPC::MakeHeader(0x29, 1, 0);
cmd_buff[1] = result.raw;
LOG_DEBUG(Service_Y2R, "called input_format=%hhu output_format=%hhu rotation=%hhu block_alignment=%hhu "
"input_line_width=%hu input_lines=%hu standard_coefficient=%hhu reserved=%hhu alpha=%hX",
params->input_format, params->output_format, params->rotation, params->block_alignment,
params->input_line_width, params->input_lines, params->standard_coefficient, params->padding, params->alpha);
LOG_DEBUG(
Service_Y2R,
"called input_format=%hhu output_format=%hhu rotation=%hhu block_alignment=%hhu "
"input_line_width=%hu input_lines=%hu standard_coefficient=%hhu reserved=%hhu alpha=%hX",
params->input_format, params->output_format, params->rotation, params->block_alignment,
params->input_line_width, params->input_lines, params->standard_coefficient,
params->padding, params->alpha);
}
static void PingProcess(Service::Interface* self) {
@ -699,7 +715,6 @@ static void DriverFinalize(Service::Interface* self) {
LOG_DEBUG(Service_Y2R, "called");
}
static void GetPackageParameter(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
@ -711,51 +726,51 @@ static void GetPackageParameter(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, SetInputFormat, "SetInputFormat"},
{0x00020000, GetInputFormat, "GetInputFormat"},
{0x00030040, SetOutputFormat, "SetOutputFormat"},
{0x00040000, GetOutputFormat, "GetOutputFormat"},
{0x00050040, SetRotation, "SetRotation"},
{0x00060000, GetRotation, "GetRotation"},
{0x00070040, SetBlockAlignment, "SetBlockAlignment"},
{0x00080000, GetBlockAlignment, "GetBlockAlignment"},
{0x00090040, SetSpacialDithering, "SetSpacialDithering"},
{0x000A0000, GetSpacialDithering, "GetSpacialDithering"},
{0x000B0040, SetTemporalDithering, "SetTemporalDithering"},
{0x000C0000, GetTemporalDithering, "GetTemporalDithering"},
{0x00010040, SetInputFormat, "SetInputFormat"},
{0x00020000, GetInputFormat, "GetInputFormat"},
{0x00030040, SetOutputFormat, "SetOutputFormat"},
{0x00040000, GetOutputFormat, "GetOutputFormat"},
{0x00050040, SetRotation, "SetRotation"},
{0x00060000, GetRotation, "GetRotation"},
{0x00070040, SetBlockAlignment, "SetBlockAlignment"},
{0x00080000, GetBlockAlignment, "GetBlockAlignment"},
{0x00090040, SetSpacialDithering, "SetSpacialDithering"},
{0x000A0000, GetSpacialDithering, "GetSpacialDithering"},
{0x000B0040, SetTemporalDithering, "SetTemporalDithering"},
{0x000C0000, GetTemporalDithering, "GetTemporalDithering"},
{0x000D0040, SetTransferEndInterrupt, "SetTransferEndInterrupt"},
{0x000E0000, GetTransferEndInterrupt, "GetTransferEndInterrupt"},
{0x000F0000, GetTransferEndEvent, "GetTransferEndEvent"},
{0x00100102, SetSendingY, "SetSendingY"},
{0x00110102, SetSendingU, "SetSendingU"},
{0x00120102, SetSendingV, "SetSendingV"},
{0x00130102, SetSendingYUYV, "SetSendingYUYV"},
{0x00140000, IsFinishedSendingYuv, "IsFinishedSendingYuv"},
{0x00150000, IsFinishedSendingY, "IsFinishedSendingY"},
{0x00160000, IsFinishedSendingU, "IsFinishedSendingU"},
{0x00170000, IsFinishedSendingV, "IsFinishedSendingV"},
{0x00180102, SetReceiving, "SetReceiving"},
{0x00190000, IsFinishedReceiving, "IsFinishedReceiving"},
{0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
{0x001B0000, GetInputLineWidth, "GetInputLineWidth"},
{0x001C0040, SetInputLines, "SetInputLines"},
{0x001D0000, GetInputLines, "GetInputLines"},
{0x001E0100, SetCoefficient, "SetCoefficient"},
{0x001F0000, GetCoefficient, "GetCoefficient"},
{0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
{0x00210040, GetStandardCoefficient, "GetStandardCoefficient"},
{0x00220040, SetAlpha, "SetAlpha"},
{0x00230000, GetAlpha, "GetAlpha"},
{0x00240200, SetDitheringWeightParams,"SetDitheringWeightParams"},
{0x00250000, GetDitheringWeightParams,"GetDitheringWeightParams"},
{0x00260000, StartConversion, "StartConversion"},
{0x00270000, StopConversion, "StopConversion"},
{0x00280000, IsBusyConversion, "IsBusyConversion"},
{0x002901C0, SetPackageParameter, "SetPackageParameter"},
{0x002A0000, PingProcess, "PingProcess"},
{0x002B0000, DriverInitialize, "DriverInitialize"},
{0x002C0000, DriverFinalize, "DriverFinalize"},
{0x002D0000, GetPackageParameter, "GetPackageParameter"},
{0x000F0000, GetTransferEndEvent, "GetTransferEndEvent"},
{0x00100102, SetSendingY, "SetSendingY"},
{0x00110102, SetSendingU, "SetSendingU"},
{0x00120102, SetSendingV, "SetSendingV"},
{0x00130102, SetSendingYUYV, "SetSendingYUYV"},
{0x00140000, IsFinishedSendingYuv, "IsFinishedSendingYuv"},
{0x00150000, IsFinishedSendingY, "IsFinishedSendingY"},
{0x00160000, IsFinishedSendingU, "IsFinishedSendingU"},
{0x00170000, IsFinishedSendingV, "IsFinishedSendingV"},
{0x00180102, SetReceiving, "SetReceiving"},
{0x00190000, IsFinishedReceiving, "IsFinishedReceiving"},
{0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
{0x001B0000, GetInputLineWidth, "GetInputLineWidth"},
{0x001C0040, SetInputLines, "SetInputLines"},
{0x001D0000, GetInputLines, "GetInputLines"},
{0x001E0100, SetCoefficient, "SetCoefficient"},
{0x001F0000, GetCoefficient, "GetCoefficient"},
{0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
{0x00210040, GetStandardCoefficient, "GetStandardCoefficient"},
{0x00220040, SetAlpha, "SetAlpha"},
{0x00230000, GetAlpha, "GetAlpha"},
{0x00240200, SetDitheringWeightParams, "SetDitheringWeightParams"},
{0x00250000, GetDitheringWeightParams, "GetDitheringWeightParams"},
{0x00260000, StartConversion, "StartConversion"},
{0x00270000, StopConversion, "StopConversion"},
{0x00280000, IsBusyConversion, "IsBusyConversion"},
{0x002901C0, SetPackageParameter, "SetPackageParameter"},
{0x002A0000, PingProcess, "PingProcess"},
{0x002B0000, DriverInitialize, "DriverInitialize"},
{0x002C0000, DriverFinalize, "DriverFinalize"},
{0x002D0000, GetPackageParameter, "GetPackageParameter"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////