Skip to content

Commit

Permalink
Added (incomplete) stubs to allow for booting the v18.0.0 firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodnorwell committed Apr 12, 2024
1 parent edd7896 commit 0f2a1f3
Show file tree
Hide file tree
Showing 25 changed files with 166 additions and 15 deletions.
10 changes: 10 additions & 0 deletions src/core/hle/kernel/k_page_table_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Result KPageTableBase::InitializeForKernel(bool is_64_bit, KVirtualAddress start
m_kernel_map_region_end = 0;
m_alias_code_region_start = 0;
m_alias_code_region_end = 0;
m_reserved_region_extra_size = 0;
m_code_region_start = 0;
m_code_region_end = 0;
m_max_heap_size = 0;
Expand Down Expand Up @@ -253,6 +254,15 @@ Result KPageTableBase::InitializeForProcess(Svc::CreateProcessFlag as_type, bool
m_alias_code_region_end = m_code_region_end;
process_code_start = Common::AlignDown(GetInteger(code_address), RegionAlignment);
process_code_end = Common::AlignUp(GetInteger(code_address) + code_size, RegionAlignment);

// TODO: (jarrodnorwell)
// [switchbrew.org][0] Address space type must be 39-bit
// [switchbrew.org][1] System resource size must be > 0
// [switchbrew.org][2] KTargetSystem::IsDebugMode() must be true
if (as_type == Svc::CreateProcessFlag::EnableReservedRegionExtraSize) {
m_reserved_region_extra_size = GetAddressSpaceSize() / 8;
alias_region_size += alias_region_size;
}
} else {
stack_region_size = 0;
kernel_map_region_size = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/core/hle/kernel/k_page_table_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class KPageTableBase {
size_t m_mapped_unsafe_physical_memory{};
size_t m_mapped_insecure_memory{};
size_t m_mapped_ipc_server_memory{};
size_t m_reserved_region_extra_size{};
mutable KLightLock m_general_lock;
mutable KLightLock m_map_physical_memory_lock;
KLightLock m_device_map_lock;
Expand Down Expand Up @@ -694,6 +695,9 @@ class KPageTableBase {
size_t GetAliasCodeRegionSize() const {
return m_alias_code_region_end - m_alias_code_region_start;
}
size_t GetReservedRegionExtraSize() const {
return m_reserved_region_extra_size;
}

size_t GetNormalMemorySize() const {
// Lock the table.
Expand Down
3 changes: 3 additions & 0 deletions src/core/hle/kernel/k_process_page_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ class KProcessPageTable {
size_t GetAliasCodeRegionSize() const {
return m_page_table.GetAliasCodeRegionSize();
}
size_t GetReservedRegionExtraSize() const {
return m_page_table.GetReservedRegionExtraSize();
}

size_t GetNormalMemorySize() const {
return m_page_table.GetNormalMemorySize();
Expand Down
7 changes: 6 additions & 1 deletion src/core/hle/kernel/svc/svc_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
case InfoType::TotalNonSystemMemorySize:
case InfoType::UsedNonSystemMemorySize:
case InfoType::IsApplication:
case InfoType::FreeThreadCount: {
case InfoType::FreeThreadCount:
case InfoType::ReservedRegionExtraSize: {
R_UNLESS(info_sub_id == 0, ResultInvalidEnumValue);

const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
Expand Down Expand Up @@ -134,6 +135,10 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
}
R_SUCCEED();

case InfoType::ReservedRegionExtraSize:
*result = process->GetPageTable().GetReservedRegionExtraSize();
R_SUCCEED();

default:
break;
}
Expand Down
7 changes: 6 additions & 1 deletion src/core/hle/kernel/svc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ enum class InfoType : u32 {
ThreadTickCount = 25,
IsSvcPermitted = 26,
IoRegionHint = 27,
ReservedRegionExtraSize = 28,

MesosphereMeta = 65000,
MesosphereCurrentProcess = 65001,
Expand Down Expand Up @@ -642,9 +643,13 @@ enum class CreateProcessFlag : u32 {
// 11.x+ DisableDeviceAddressSpaceMerge.
DisableDeviceAddressSpaceMerge = (1 << 12),

// 18.x+ EnableReservedRegionExtraSize.
EnableReservedRegionExtraSize = (1 << 13),

// Mask of all flags.
All = Is64Bit | AddressSpaceMask | EnableDebug | EnableAslr | IsApplication |
PoolPartitionMask | OptimizeMemoryAllocation | DisableDeviceAddressSpaceMerge,
PoolPartitionMask | OptimizeMemoryAllocation | DisableDeviceAddressSpaceMerge |
EnableReservedRegionExtraSize,
};
DECLARE_ENUM_FLAG_OPERATORS(CreateProcessFlag);

Expand Down
11 changes: 10 additions & 1 deletion src/core/hle/service/acc/acc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class IManagerForSystemService final : public ServiceFramework<IManagerForSystem
{140, nullptr, "GetNetworkServiceLicenseCache"}, // 5.0.0+
{141, nullptr, "RefreshNetworkServiceLicenseCacheAsync"}, // 5.0.0+
{142, nullptr, "RefreshNetworkServiceLicenseCacheAsyncIfSecondsElapsed"}, // 5.0.0+
{143, nullptr, "GetNetworkServiceLicenseCacheEx"}, // 15.0.0+
{150, nullptr, "CreateAuthorizationRequest"},
{160, nullptr, "RequiresUpdateNetworkServiceAccountIdTokenCache"},
{161, nullptr, "RequireReauthenticationOfNetworkServiceAccount"},
Expand Down Expand Up @@ -326,7 +327,7 @@ class IProfileCommon : public ServiceFramework<IProfileCommon> {
{11, &IProfileCommon::LoadImage, "LoadImage"},
{20, nullptr, "GetLargeImageSize"}, // 18.0.0+
{21, nullptr, "LoadLargeImage"}, // 18.0.0+
{30, nullptr, "GetImageId"} // 18.0.0+
{30, &IProfileCommon::GetImageId, "GetImageId"} // 18.0.0+
};
// clang-format on

Expand Down Expand Up @@ -405,6 +406,14 @@ class IProfileCommon : public ServiceFramework<IProfileCommon> {
rb.Push(static_cast<u32>(buffer.size()));
}

void GetImageId(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "(STUBBED) called");

IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(0);
}

void GetImageSize(HLERequestContext& ctx) {
LOG_DEBUG(Service_ACC, "called");
IPC::ResponseBuilder rb{ctx, 3};
Expand Down
9 changes: 8 additions & 1 deletion src/core/hle/service/am/common_state_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{30, nullptr, "GetHomeButtonReaderLockAccessor"},
{31, &ICommonStateGetter::GetReaderLockAccessorEx, "GetReaderLockAccessorEx"},
{32, nullptr, "GetWriterLockAccessorEx"},
{40, nullptr, "GetCradleFwVersion"},
{40, &ICommonStateGetter::GetCradleFwVersion, "GetCradleFwVersion"},
{50, &ICommonStateGetter::IsVrModeEnabled, "IsVrModeEnabled"},
{51, &ICommonStateGetter::SetVrModeEnabled, "SetVrModeEnabled"},
{52, &ICommonStateGetter::SetLcdBacklighOffEnabled, "SetLcdBacklighOffEnabled"},
Expand Down Expand Up @@ -170,6 +170,13 @@ void ICommonStateGetter::GetAcquiredSleepLockEvent(HLERequestContext& ctx) {
rb.PushCopyObjects(applet->sleep_lock_event.GetHandle());
}

void ICommonStateGetter::GetCradleFwVersion(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");

IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}

void ICommonStateGetter::IsVrModeEnabled(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");

Expand Down
1 change: 1 addition & 0 deletions src/core/hle/service/am/common_state_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
void GetOperationMode(HLERequestContext& ctx);
void GetPerformanceMode(HLERequestContext& ctx);
void GetBootMode(HLERequestContext& ctx);
void GetCradleFwVersion(HLERequestContext& ctx);
void IsVrModeEnabled(HLERequestContext& ctx);
void SetVrModeEnabled(HLERequestContext& ctx);
void SetLcdBacklighOffEnabled(HLERequestContext& ctx);
Expand Down
7 changes: 6 additions & 1 deletion src/core/hle/service/am/service/common_state_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{30, nullptr, "GetHomeButtonReaderLockAccessor"},
{31, D<&ICommonStateGetter::GetReaderLockAccessorEx>, "GetReaderLockAccessorEx"},
{32, D<&ICommonStateGetter::GetWriterLockAccessorEx>, "GetWriterLockAccessorEx"},
{40, nullptr, "GetCradleFwVersion"},
{40, D<&ICommonStateGetter::GetCradleFwVersion>, "GetCradleFwVersion"},
{50, D<&ICommonStateGetter::IsVrModeEnabled>, "IsVrModeEnabled"},
{51, D<&ICommonStateGetter::SetVrModeEnabled>, "SetVrModeEnabled"},
{52, D<&ICommonStateGetter::SetLcdBacklighOffEnabled>, "SetLcdBacklighOffEnabled"},
Expand Down Expand Up @@ -161,6 +161,11 @@ Result ICommonStateGetter::GetBootMode(Out<PM::SystemBootMode> out_boot_mode) {
R_SUCCEED();
}

Result ICommonStateGetter::GetCradleFwVersion() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}

Result ICommonStateGetter::IsVrModeEnabled(Out<bool> out_is_vr_mode_enabled) {
LOG_DEBUG(Service_AM, "called");

Expand Down
1 change: 1 addition & 0 deletions src/core/hle/service/am/service/common_state_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
Result GetOperationMode(Out<OperationMode> out_operation_mode);
Result GetPerformanceMode(Out<APM::PerformanceMode> out_performance_mode);
Result GetBootMode(Out<PM::SystemBootMode> out_boot_mode);
Result GetCradleFwVersion();
Result IsVrModeEnabled(Out<bool> out_is_vr_mode_enabled);
Result SetVrModeEnabled(bool is_vr_mode_enabled);
Result SetLcdBacklighOffEnabled(bool is_lcd_backlight_off_enabled);
Expand Down
7 changes: 6 additions & 1 deletion src/core/hle/service/bcat/news/news_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Service::News {
INewsService::INewsService(Core::System& system_) : ServiceFramework{system_, "INewsService"} {
// clang-format off
static const FunctionInfo functions[] = {
{10100, nullptr, "PostLocalNews"},
{10100, D<&INewsService::PostLocalNews>, "PostLocalNews"},
{20100, nullptr, "SetPassphrase"},
{30100, D<&INewsService::GetSubscriptionStatus>, "GetSubscriptionStatus"},
{30101, nullptr, "GetTopicList"},
Expand All @@ -36,6 +36,11 @@ INewsService::INewsService(Core::System& system_) : ServiceFramework{system_, "I

INewsService::~INewsService() = default;

Result INewsService::PostLocalNews() {
LOG_WARNING(Service_BCAT, "(STUBBED) called");
R_SUCCEED();
}

Result INewsService::GetSubscriptionStatus(Out<u32> out_status,
InBuffer<BufferAttr_HipcPointer> buffer_data) {
LOG_WARNING(Service_BCAT, "(STUBBED) called, buffer_size={}", buffer_data.size());
Expand Down
2 changes: 2 additions & 0 deletions src/core/hle/service/bcat/news/news_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class INewsService final : public ServiceFramework<INewsService> {
~INewsService() override;

private:
Result PostLocalNews();

Result GetSubscriptionStatus(Out<u32> out_status, InBuffer<BufferAttr_HipcPointer> buffer_data);

Result IsSystemUpdateRequired(Out<bool> out_is_system_update_required);
Expand Down
7 changes: 6 additions & 1 deletion src/core/hle/service/filesystem/fsp/fsp_srv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ FSP_SRV::FSP_SRV(Core::System& system_)
{24, nullptr, "RegisterSaveDataFileSystemAtomicDeletion"},
{25, nullptr, "DeleteSaveDataFileSystemBySaveDataSpaceId"},
{26, nullptr, "FormatSdCardDryRun"},
{27, nullptr, "IsExFatSupported"},
{27, D<&FSP_SRV::IsExFatSupported>, "IsExFatSupported"},
{28, nullptr, "DeleteSaveDataFileSystemBySaveDataAttribute"},
{30, nullptr, "OpenGameCardStorage"},
{31, nullptr, "OpenGameCardFileSystem"},
Expand Down Expand Up @@ -247,6 +247,11 @@ Result FSP_SRV::CreateSaveDataFileSystemBySystemSaveDataId(
save_struct));
}

Result FSP_SRV::IsExFatSupported(bool is_exfat_supported) {
LOG_INFO(Service_FS, "(STUBBED) called.");
R_SUCCEED();
}

Result FSP_SRV::OpenSaveDataFileSystem(OutInterface<IFileSystem> out_interface,
FileSys::SaveDataSpaceId space_id,
FileSys::SaveDataAttribute attribute) {
Expand Down
1 change: 1 addition & 0 deletions src/core/hle/service/filesystem/fsp/fsp_srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class FSP_SRV final : public ServiceFramework<FSP_SRV> {
FileSys::SaveDataAttribute save_struct, u128 uid);
Result CreateSaveDataFileSystemBySystemSaveDataId(
FileSys::SaveDataAttribute save_struct, FileSys::SaveDataCreationInfo save_create_struct);
Result IsExFatSupported(bool is_exfat_supported);
Result OpenSaveDataFileSystem(OutInterface<IFileSystem> out_interface,
FileSys::SaveDataSpaceId space_id,
FileSys::SaveDataAttribute attribute);
Expand Down
10 changes: 9 additions & 1 deletion src/core/hle/service/filesystem/fsp_srv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ FSP_SRV::FSP_SRV(Core::System& system_)
{24, nullptr, "RegisterSaveDataFileSystemAtomicDeletion"},
{25, nullptr, "DeleteSaveDataFileSystemBySaveDataSpaceId"},
{26, nullptr, "FormatSdCardDryRun"},
{27, nullptr, "IsExFatSupported"},
{27, &FSP_SRV::IsExFatSupported, "IsExFatSupported"},
{28, nullptr, "DeleteSaveDataFileSystemBySaveDataAttribute"},
{30, nullptr, "OpenGameCardStorage"},
{31, nullptr, "OpenGameCardFileSystem"},
Expand Down Expand Up @@ -946,6 +946,14 @@ void FSP_SRV::CreateSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx)
rb.Push(ResultSuccess);
}

void FSP_SRV::IsExFatSupported(HLERequestContext& ctx) {
LOG_INFO(Service_FS, "(STUBBED) called.");

IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(0);
}

void FSP_SRV::OpenSaveDataFileSystem(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};

Expand Down
1 change: 1 addition & 0 deletions src/core/hle/service/filesystem/fsp_srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class FSP_SRV final : public ServiceFramework<FSP_SRV> {
void OpenSdCardFileSystem(HLERequestContext& ctx);
void CreateSaveDataFileSystem(HLERequestContext& ctx);
void CreateSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx);
void IsExFatSupported(HLERequestContext& ctx);
void OpenSaveDataFileSystem(HLERequestContext& ctx);
void OpenSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx);
void OpenReadOnlySaveDataFileSystem(HLERequestContext& ctx);
Expand Down
21 changes: 19 additions & 2 deletions src/core/hle/service/nifm/nifm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ void IGeneralService::GetCurrentNetworkProfile(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}

void IGeneralService::EnumerateNetworkInterfaces(HLERequestContext& ctx) {
for (const auto& interface : Network::GetAvailableNetworkInterfaces())
LOG_WARNING(Service_NIFM, "(STUBBED) called, interface={}", interface.name);

IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}

void IGeneralService::RemoveNetworkProfile(HLERequestContext& ctx) {
LOG_WARNING(Service_NIFM, "(STUBBED) called");

Expand Down Expand Up @@ -565,6 +573,15 @@ void IGeneralService::IsAnyForegroundRequestAccepted(HLERequestContext& ctx) {
rb.Push<u8>(is_accepted);
}

void IGeneralService::GetSsidListVersion(HLERequestContext& ctx) {
const u32 ssid = 1;
LOG_WARNING(Service_NIFM, "(STUBBED) called");

IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u64>(ssid);
}

IGeneralService::IGeneralService(Core::System& system_)
: ServiceFramework{system_, "IGeneralService"}, network{system_.GetRoomNetwork()} {
// clang-format off
Expand All @@ -573,7 +590,7 @@ IGeneralService::IGeneralService(Core::System& system_)
{2, &IGeneralService::CreateScanRequest, "CreateScanRequest"},
{4, &IGeneralService::CreateRequest, "CreateRequest"},
{5, &IGeneralService::GetCurrentNetworkProfile, "GetCurrentNetworkProfile"},
{6, nullptr, "EnumerateNetworkInterfaces"},
{6, &IGeneralService::EnumerateNetworkInterfaces, "EnumerateNetworkInterfaces"},
{7, nullptr, "EnumerateNetworkProfiles"},
{8, nullptr, "GetNetworkProfile"},
{9, nullptr, "SetNetworkProfile"},
Expand All @@ -592,7 +609,7 @@ IGeneralService::IGeneralService(Core::System& system_)
{22, &IGeneralService::IsAnyForegroundRequestAccepted, "IsAnyForegroundRequestAccepted"},
{23, nullptr, "PutToSleep"},
{24, nullptr, "WakeUp"},
{25, nullptr, "GetSsidListVersion"},
{25, &IGeneralService::GetSsidListVersion, "GetSsidListVersion"},
{26, nullptr, "SetExclusiveClient"},
{27, nullptr, "GetDefaultIpSetting"},
{28, nullptr, "SetDefaultIpSetting"},
Expand Down
2 changes: 2 additions & 0 deletions src/core/hle/service/nifm/nifm.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class IGeneralService final : public ServiceFramework<IGeneralService> {
void CreateScanRequest(HLERequestContext& ctx);
void CreateRequest(HLERequestContext& ctx);
void GetCurrentNetworkProfile(HLERequestContext& ctx);
void EnumerateNetworkInterfaces(HLERequestContext& ctx);
void RemoveNetworkProfile(HLERequestContext& ctx);
void GetCurrentIpAddress(HLERequestContext& ctx);
void CreateTemporaryNetworkProfile(HLERequestContext& ctx);
Expand All @@ -36,6 +37,7 @@ class IGeneralService final : public ServiceFramework<IGeneralService> {
void IsEthernetCommunicationEnabled(HLERequestContext& ctx);
void IsAnyInternetRequestAccepted(HLERequestContext& ctx);
void IsAnyForegroundRequestAccepted(HLERequestContext& ctx);
void GetSsidListVersion(HLERequestContext& ctx);

Network::RoomNetwork& network;
};
Expand Down
21 changes: 18 additions & 3 deletions src/core/hle/service/npns/npns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class INpnsSystem final : public ServiceFramework<INpnsSystem> {
{5, C<&INpnsSystem::GetReceiveEvent>, "GetReceiveEvent"},
{6, nullptr, "ListenUndelivered"},
{7, nullptr, "GetStateChangeEvent"},
{8, nullptr, "ListenToByName"}, // 18.0.0+
{8, C<&INpnsSystem::ListenToByName>, "ListenToByName"}, // 18.0.0+
{11, nullptr, "SubscribeTopic"},
{12, nullptr, "UnsubscribeTopic"},
{13, nullptr, "QueryIsTopicExist"},
Expand Down Expand Up @@ -57,10 +57,10 @@ class INpnsSystem final : public ServiceFramework<INpnsSystem> {
{51, nullptr, "DeleteDigitalTwinKeyValue"}, // 18.0.0+
{101, nullptr, "Suspend"},
{102, nullptr, "Resume"},
{103, nullptr, "GetState"},
{103, C<&INpnsSystem::GetState>, "GetState"},
{104, nullptr, "GetStatistics"},
{105, nullptr, "GetPlayReportRequestEvent"},
{106, nullptr, "GetLastNotifiedTime"}, // 18.0.0+
{106, C<&INpnsSystem::GetLastNotifiedTime>, "GetLastNotifiedTime"}, // 18.0.0+
{107, nullptr, "SetLastNotifiedTime"}, // 18.0.0+
{111, nullptr, "GetJid"},
{112, nullptr, "CreateJid"},
Expand Down Expand Up @@ -109,6 +109,21 @@ class INpnsSystem final : public ServiceFramework<INpnsSystem> {
R_SUCCEED();
}

Result ListenToByName() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}

Result GetState() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}

Result GetLastNotifiedTime() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}

KernelHelpers::ServiceContext service_context;
Kernel::KEvent* get_receive_event;
};
Expand Down

0 comments on commit 0f2a1f3

Please sign in to comment.