Compare commits
1 Commits
android-11
...
android-10
Author | SHA1 | Date | |
---|---|---|---|
078e14cc40 |
@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
[codespell]
|
[codespell]
|
||||||
skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES,./src/android/app/src/main/res
|
skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES,./src/android/app/src/main/res
|
||||||
ignore-words-list = aci,allright,ba,canonicalizations,deques,froms,hda,inout,lod,masia,nam,nax,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,vas,zink
|
ignore-words-list = aci,allright,ba,canonicalizations,deques,froms,hda,inout,lod,masia,nam,nax,nd,optin,pullrequests,pullrequest,te,transfered,unstall,uscaled,zink
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
| Pull Request | Commit | Title | Author | Merged? |
|
| Pull Request | Commit | Title | Author | Merged? |
|
||||||
|----|----|----|----|----|
|
|----|----|----|----|----|
|
||||||
| [11827](https://github.com/yuzu-emu/yuzu//pull/11827) | [`689f346e9`](https://github.com/yuzu-emu/yuzu//pull/11827/files) | nvnflinger: fix reporting and freeing of preallocated buffers | [liamwhite](https://github.com/liamwhite/) | Yes |
|
|
||||||
| [11876](https://github.com/yuzu-emu/yuzu//pull/11876) | [`e0834ee50`](https://github.com/yuzu-emu/yuzu//pull/11876/files) | vulkan_common: use highest API version | [liamwhite](https://github.com/liamwhite/) | Yes |
|
|
||||||
|
|
||||||
|
|
||||||
End of merge log. You can find the original README.md below the break.
|
End of merge log. You can find the original README.md below the break.
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "common/string_util.h"
|
|
||||||
#else
|
#else
|
||||||
#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
#include <pthread_np.h>
|
#include <pthread_np.h>
|
||||||
@ -83,8 +82,29 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
// Sets the debugger-visible name of the current thread.
|
// Sets the debugger-visible name of the current thread.
|
||||||
|
// Uses trick documented in:
|
||||||
|
// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code
|
||||||
void SetCurrentThreadName(const char* name) {
|
void SetCurrentThreadName(const char* name) {
|
||||||
SetThreadDescription(GetCurrentThread(), UTF8ToUTF16W(name).data());
|
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
||||||
|
|
||||||
|
#pragma pack(push, 8)
|
||||||
|
struct THREADNAME_INFO {
|
||||||
|
DWORD dwType; // must be 0x1000
|
||||||
|
LPCSTR szName; // pointer to name (in user addr space)
|
||||||
|
DWORD dwThreadID; // thread ID (-1=caller thread)
|
||||||
|
DWORD dwFlags; // reserved for future use, must be zero
|
||||||
|
} info;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
info.dwType = 0x1000;
|
||||||
|
info.szName = name;
|
||||||
|
info.dwThreadID = std::numeric_limits<DWORD>::max();
|
||||||
|
info.dwFlags = 0;
|
||||||
|
|
||||||
|
__try {
|
||||||
|
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
||||||
|
} __except (EXCEPTION_CONTINUE_EXECUTION) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // !MSVC_VER, so must be POSIX threads
|
#else // !MSVC_VER, so must be POSIX threads
|
||||||
|
@ -822,13 +822,11 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
|
|||||||
const char i = True(mem_info.attribute & MemoryAttribute::IpcLocked) ? 'I' : '-';
|
const char i = True(mem_info.attribute & MemoryAttribute::IpcLocked) ? 'I' : '-';
|
||||||
const char d = True(mem_info.attribute & MemoryAttribute::DeviceShared) ? 'D' : '-';
|
const char d = True(mem_info.attribute & MemoryAttribute::DeviceShared) ? 'D' : '-';
|
||||||
const char u = True(mem_info.attribute & MemoryAttribute::Uncached) ? 'U' : '-';
|
const char u = True(mem_info.attribute & MemoryAttribute::Uncached) ? 'U' : '-';
|
||||||
const char p =
|
|
||||||
True(mem_info.attribute & MemoryAttribute::PermissionLocked) ? 'P' : '-';
|
|
||||||
|
|
||||||
reply += fmt::format(" {:#012x} - {:#012x} {} {} {}{}{}{}{} [{}, {}]\n",
|
reply +=
|
||||||
mem_info.base_address,
|
fmt::format(" {:#012x} - {:#012x} {} {} {}{}{}{} [{}, {}]\n",
|
||||||
mem_info.base_address + mem_info.size - 1, perm, state, l, i,
|
mem_info.base_address, mem_info.base_address + mem_info.size - 1,
|
||||||
d, u, p, mem_info.ipc_count, mem_info.device_count);
|
perm, state, l, i, d, u, mem_info.ipc_count, mem_info.device_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uintptr_t next_address = mem_info.base_address + mem_info.size;
|
const uintptr_t next_address = mem_info.base_address + mem_info.size;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
|
||||||
#include "core/file_sys/system_archive/system_version.h"
|
#include "core/file_sys/system_archive/system_version.h"
|
||||||
#include "core/file_sys/vfs_vector.h"
|
#include "core/file_sys/vfs_vector.h"
|
||||||
#include "core/hle/api_version.h"
|
#include "core/hle/api_version.h"
|
||||||
@ -13,9 +12,6 @@ std::string GetLongDisplayVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VirtualDir SystemVersion() {
|
VirtualDir SystemVersion() {
|
||||||
LOG_WARNING(Common_Filesystem, "called - Using hardcoded firmware version '{}'",
|
|
||||||
GetLongDisplayVersion());
|
|
||||||
|
|
||||||
VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file");
|
VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file");
|
||||||
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0);
|
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0);
|
||||||
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1);
|
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1);
|
||||||
|
@ -106,7 +106,7 @@ static_assert(KernelPageBufferAdditionalSize ==
|
|||||||
/// memory.
|
/// memory.
|
||||||
static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout,
|
static KPhysicalAddress TranslateSlabAddrToPhysical(KMemoryLayout& memory_layout,
|
||||||
KVirtualAddress slab_addr) {
|
KVirtualAddress slab_addr) {
|
||||||
slab_addr -= memory_layout.GetSlabRegion().GetAddress();
|
slab_addr -= GetInteger(memory_layout.GetSlabRegionAddress());
|
||||||
return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase;
|
return GetInteger(slab_addr) + Core::DramMemoryMap::SlabHeapBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,12 +196,7 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) {
|
|||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
|
|
||||||
// Get the start of the slab region, since that's where we'll be working.
|
// Get the start of the slab region, since that's where we'll be working.
|
||||||
const KMemoryRegion& slab_region = memory_layout.GetSlabRegion();
|
KVirtualAddress address = memory_layout.GetSlabRegionAddress();
|
||||||
KVirtualAddress address = slab_region.GetAddress();
|
|
||||||
|
|
||||||
// Clear the slab region.
|
|
||||||
// TODO: implement access to kernel VAs.
|
|
||||||
// std::memset(device_ptr, 0, slab_region.GetSize());
|
|
||||||
|
|
||||||
// Initialize slab type array to be in sorted order.
|
// Initialize slab type array to be in sorted order.
|
||||||
std::array<KSlabType, KSlabType_Count> slab_types;
|
std::array<KSlabType, KSlabType_Count> slab_types;
|
||||||
|
@ -19,8 +19,4 @@ static inline KPhysicalAddress GetInitialProcessBinaryPhysicalAddress() {
|
|||||||
MainMemoryAddress);
|
MainMemoryAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t GetInitialProcessBinarySize() {
|
|
||||||
return InitialProcessBinarySizeMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
@ -36,7 +36,6 @@ enum class KMemoryState : u32 {
|
|||||||
FlagCanChangeAttribute = (1 << 24),
|
FlagCanChangeAttribute = (1 << 24),
|
||||||
FlagCanCodeMemory = (1 << 25),
|
FlagCanCodeMemory = (1 << 25),
|
||||||
FlagLinearMapped = (1 << 26),
|
FlagLinearMapped = (1 << 26),
|
||||||
FlagCanPermissionLock = (1 << 27),
|
|
||||||
|
|
||||||
FlagsData = FlagCanReprotect | FlagCanUseIpc | FlagCanUseNonDeviceIpc | FlagCanUseNonSecureIpc |
|
FlagsData = FlagCanReprotect | FlagCanUseIpc | FlagCanUseNonDeviceIpc | FlagCanUseNonSecureIpc |
|
||||||
FlagMapped | FlagCanAlias | FlagCanTransfer | FlagCanQueryPhysical |
|
FlagMapped | FlagCanAlias | FlagCanTransfer | FlagCanQueryPhysical |
|
||||||
@ -51,16 +50,12 @@ enum class KMemoryState : u32 {
|
|||||||
FlagLinearMapped,
|
FlagLinearMapped,
|
||||||
|
|
||||||
Free = static_cast<u32>(Svc::MemoryState::Free),
|
Free = static_cast<u32>(Svc::MemoryState::Free),
|
||||||
|
Io = static_cast<u32>(Svc::MemoryState::Io) | FlagMapped | FlagCanDeviceMap |
|
||||||
IoMemory = static_cast<u32>(Svc::MemoryState::Io) | FlagMapped | FlagCanDeviceMap |
|
FlagCanAlignedDeviceMap,
|
||||||
FlagCanAlignedDeviceMap,
|
|
||||||
IoRegister =
|
|
||||||
static_cast<u32>(Svc::MemoryState::Io) | FlagCanDeviceMap | FlagCanAlignedDeviceMap,
|
|
||||||
|
|
||||||
Static = static_cast<u32>(Svc::MemoryState::Static) | FlagMapped | FlagCanQueryPhysical,
|
Static = static_cast<u32>(Svc::MemoryState::Static) | FlagMapped | FlagCanQueryPhysical,
|
||||||
Code = static_cast<u32>(Svc::MemoryState::Code) | FlagsCode | FlagCanMapProcess,
|
Code = static_cast<u32>(Svc::MemoryState::Code) | FlagsCode | FlagCanMapProcess,
|
||||||
CodeData = static_cast<u32>(Svc::MemoryState::CodeData) | FlagsData | FlagCanMapProcess |
|
CodeData = static_cast<u32>(Svc::MemoryState::CodeData) | FlagsData | FlagCanMapProcess |
|
||||||
FlagCanCodeMemory | FlagCanPermissionLock,
|
FlagCanCodeMemory,
|
||||||
Normal = static_cast<u32>(Svc::MemoryState::Normal) | FlagsData | FlagCanCodeMemory,
|
Normal = static_cast<u32>(Svc::MemoryState::Normal) | FlagsData | FlagCanCodeMemory,
|
||||||
Shared = static_cast<u32>(Svc::MemoryState::Shared) | FlagMapped | FlagReferenceCounted |
|
Shared = static_cast<u32>(Svc::MemoryState::Shared) | FlagMapped | FlagReferenceCounted |
|
||||||
FlagLinearMapped,
|
FlagLinearMapped,
|
||||||
@ -70,8 +65,7 @@ enum class KMemoryState : u32 {
|
|||||||
AliasCode = static_cast<u32>(Svc::MemoryState::AliasCode) | FlagsCode | FlagCanMapProcess |
|
AliasCode = static_cast<u32>(Svc::MemoryState::AliasCode) | FlagsCode | FlagCanMapProcess |
|
||||||
FlagCanCodeAlias,
|
FlagCanCodeAlias,
|
||||||
AliasCodeData = static_cast<u32>(Svc::MemoryState::AliasCodeData) | FlagsData |
|
AliasCodeData = static_cast<u32>(Svc::MemoryState::AliasCodeData) | FlagsData |
|
||||||
FlagCanMapProcess | FlagCanCodeAlias | FlagCanCodeMemory |
|
FlagCanMapProcess | FlagCanCodeAlias | FlagCanCodeMemory,
|
||||||
FlagCanPermissionLock,
|
|
||||||
|
|
||||||
Ipc = static_cast<u32>(Svc::MemoryState::Ipc) | FlagsMisc | FlagCanAlignedDeviceMap |
|
Ipc = static_cast<u32>(Svc::MemoryState::Ipc) | FlagsMisc | FlagCanAlignedDeviceMap |
|
||||||
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||||
@ -79,7 +73,7 @@ enum class KMemoryState : u32 {
|
|||||||
Stack = static_cast<u32>(Svc::MemoryState::Stack) | FlagsMisc | FlagCanAlignedDeviceMap |
|
Stack = static_cast<u32>(Svc::MemoryState::Stack) | FlagsMisc | FlagCanAlignedDeviceMap |
|
||||||
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
FlagCanUseIpc | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||||
|
|
||||||
ThreadLocal = static_cast<u32>(Svc::MemoryState::ThreadLocal) | FlagLinearMapped,
|
ThreadLocal = static_cast<u32>(Svc::MemoryState::ThreadLocal) | FlagMapped | FlagLinearMapped,
|
||||||
|
|
||||||
Transfered = static_cast<u32>(Svc::MemoryState::Transfered) | FlagsMisc |
|
Transfered = static_cast<u32>(Svc::MemoryState::Transfered) | FlagsMisc |
|
||||||
FlagCanAlignedDeviceMap | FlagCanChangeAttribute | FlagCanUseIpc |
|
FlagCanAlignedDeviceMap | FlagCanChangeAttribute | FlagCanUseIpc |
|
||||||
@ -100,7 +94,7 @@ enum class KMemoryState : u32 {
|
|||||||
NonDeviceIpc =
|
NonDeviceIpc =
|
||||||
static_cast<u32>(Svc::MemoryState::NonDeviceIpc) | FlagsMisc | FlagCanUseNonDeviceIpc,
|
static_cast<u32>(Svc::MemoryState::NonDeviceIpc) | FlagsMisc | FlagCanUseNonDeviceIpc,
|
||||||
|
|
||||||
Kernel = static_cast<u32>(Svc::MemoryState::Kernel),
|
Kernel = static_cast<u32>(Svc::MemoryState::Kernel) | FlagMapped,
|
||||||
|
|
||||||
GeneratedCode = static_cast<u32>(Svc::MemoryState::GeneratedCode) | FlagMapped |
|
GeneratedCode = static_cast<u32>(Svc::MemoryState::GeneratedCode) | FlagMapped |
|
||||||
FlagReferenceCounted | FlagCanDebug | FlagLinearMapped,
|
FlagReferenceCounted | FlagCanDebug | FlagLinearMapped,
|
||||||
@ -111,36 +105,34 @@ enum class KMemoryState : u32 {
|
|||||||
|
|
||||||
Insecure = static_cast<u32>(Svc::MemoryState::Insecure) | FlagMapped | FlagReferenceCounted |
|
Insecure = static_cast<u32>(Svc::MemoryState::Insecure) | FlagMapped | FlagReferenceCounted |
|
||||||
FlagLinearMapped | FlagCanChangeAttribute | FlagCanDeviceMap |
|
FlagLinearMapped | FlagCanChangeAttribute | FlagCanDeviceMap |
|
||||||
FlagCanAlignedDeviceMap | FlagCanQueryPhysical | FlagCanUseNonSecureIpc |
|
FlagCanAlignedDeviceMap | FlagCanUseNonSecureIpc | FlagCanUseNonDeviceIpc,
|
||||||
FlagCanUseNonDeviceIpc,
|
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(KMemoryState);
|
DECLARE_ENUM_FLAG_OPERATORS(KMemoryState);
|
||||||
|
|
||||||
static_assert(static_cast<u32>(KMemoryState::Free) == 0x00000000);
|
static_assert(static_cast<u32>(KMemoryState::Free) == 0x00000000);
|
||||||
static_assert(static_cast<u32>(KMemoryState::IoMemory) == 0x00182001);
|
static_assert(static_cast<u32>(KMemoryState::Io) == 0x00182001);
|
||||||
static_assert(static_cast<u32>(KMemoryState::IoRegister) == 0x00180001);
|
|
||||||
static_assert(static_cast<u32>(KMemoryState::Static) == 0x00042002);
|
static_assert(static_cast<u32>(KMemoryState::Static) == 0x00042002);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Code) == 0x04DC7E03);
|
static_assert(static_cast<u32>(KMemoryState::Code) == 0x04DC7E03);
|
||||||
static_assert(static_cast<u32>(KMemoryState::CodeData) == 0x0FFEBD04);
|
static_assert(static_cast<u32>(KMemoryState::CodeData) == 0x07FEBD04);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Normal) == 0x077EBD05);
|
static_assert(static_cast<u32>(KMemoryState::Normal) == 0x077EBD05);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Shared) == 0x04402006);
|
static_assert(static_cast<u32>(KMemoryState::Shared) == 0x04402006);
|
||||||
|
|
||||||
static_assert(static_cast<u32>(KMemoryState::AliasCode) == 0x04DD7E08);
|
static_assert(static_cast<u32>(KMemoryState::AliasCode) == 0x04DD7E08);
|
||||||
static_assert(static_cast<u32>(KMemoryState::AliasCodeData) == 0x0FFFBD09);
|
static_assert(static_cast<u32>(KMemoryState::AliasCodeData) == 0x07FFBD09);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Ipc) == 0x045C3C0A);
|
static_assert(static_cast<u32>(KMemoryState::Ipc) == 0x045C3C0A);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Stack) == 0x045C3C0B);
|
static_assert(static_cast<u32>(KMemoryState::Stack) == 0x045C3C0B);
|
||||||
static_assert(static_cast<u32>(KMemoryState::ThreadLocal) == 0x0400000C);
|
static_assert(static_cast<u32>(KMemoryState::ThreadLocal) == 0x0400200C);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Transfered) == 0x055C3C0D);
|
static_assert(static_cast<u32>(KMemoryState::Transfered) == 0x055C3C0D);
|
||||||
static_assert(static_cast<u32>(KMemoryState::SharedTransfered) == 0x045C380E);
|
static_assert(static_cast<u32>(KMemoryState::SharedTransfered) == 0x045C380E);
|
||||||
static_assert(static_cast<u32>(KMemoryState::SharedCode) == 0x0440380F);
|
static_assert(static_cast<u32>(KMemoryState::SharedCode) == 0x0440380F);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Inaccessible) == 0x00000010);
|
static_assert(static_cast<u32>(KMemoryState::Inaccessible) == 0x00000010);
|
||||||
static_assert(static_cast<u32>(KMemoryState::NonSecureIpc) == 0x045C3811);
|
static_assert(static_cast<u32>(KMemoryState::NonSecureIpc) == 0x045C3811);
|
||||||
static_assert(static_cast<u32>(KMemoryState::NonDeviceIpc) == 0x044C2812);
|
static_assert(static_cast<u32>(KMemoryState::NonDeviceIpc) == 0x044C2812);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Kernel) == 0x00000013);
|
static_assert(static_cast<u32>(KMemoryState::Kernel) == 0x00002013);
|
||||||
static_assert(static_cast<u32>(KMemoryState::GeneratedCode) == 0x04402214);
|
static_assert(static_cast<u32>(KMemoryState::GeneratedCode) == 0x04402214);
|
||||||
static_assert(static_cast<u32>(KMemoryState::CodeOut) == 0x04402015);
|
static_assert(static_cast<u32>(KMemoryState::CodeOut) == 0x04402015);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Coverage) == 0x00002016);
|
static_assert(static_cast<u32>(KMemoryState::Coverage) == 0x00002016);
|
||||||
static_assert(static_cast<u32>(KMemoryState::Insecure) == 0x055C3817);
|
static_assert(static_cast<u32>(KMemoryState::Insecure) == 0x05583817);
|
||||||
|
|
||||||
enum class KMemoryPermission : u8 {
|
enum class KMemoryPermission : u8 {
|
||||||
None = 0,
|
None = 0,
|
||||||
@ -190,9 +182,8 @@ enum class KMemoryAttribute : u8 {
|
|||||||
IpcLocked = static_cast<u8>(Svc::MemoryAttribute::IpcLocked),
|
IpcLocked = static_cast<u8>(Svc::MemoryAttribute::IpcLocked),
|
||||||
DeviceShared = static_cast<u8>(Svc::MemoryAttribute::DeviceShared),
|
DeviceShared = static_cast<u8>(Svc::MemoryAttribute::DeviceShared),
|
||||||
Uncached = static_cast<u8>(Svc::MemoryAttribute::Uncached),
|
Uncached = static_cast<u8>(Svc::MemoryAttribute::Uncached),
|
||||||
PermissionLocked = static_cast<u8>(Svc::MemoryAttribute::PermissionLocked),
|
|
||||||
|
|
||||||
SetMask = Uncached | PermissionLocked,
|
SetMask = Uncached,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(KMemoryAttribute);
|
DECLARE_ENUM_FLAG_OPERATORS(KMemoryAttribute);
|
||||||
|
|
||||||
@ -270,10 +261,6 @@ struct KMemoryInfo {
|
|||||||
return m_state;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Svc::MemoryState GetSvcState() const {
|
|
||||||
return static_cast<Svc::MemoryState>(m_state & KMemoryState::Mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr KMemoryPermission GetPermission() const {
|
constexpr KMemoryPermission GetPermission() const {
|
||||||
return m_permission;
|
return m_permission;
|
||||||
}
|
}
|
||||||
@ -339,10 +326,6 @@ public:
|
|||||||
return this->GetEndAddress() - 1;
|
return this->GetEndAddress() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr KMemoryState GetState() const {
|
|
||||||
return m_memory_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr u16 GetIpcLockCount() const {
|
constexpr u16 GetIpcLockCount() const {
|
||||||
return m_ipc_lock_count;
|
return m_ipc_lock_count;
|
||||||
}
|
}
|
||||||
@ -460,13 +443,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void UpdateAttribute(KMemoryAttribute mask, KMemoryAttribute attr) {
|
|
||||||
ASSERT(False(mask & KMemoryAttribute::IpcLocked));
|
|
||||||
ASSERT(False(mask & KMemoryAttribute::DeviceShared));
|
|
||||||
|
|
||||||
m_attribute = (m_attribute & ~mask) | attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void Split(KMemoryBlock* block, KProcessAddress addr) {
|
constexpr void Split(KMemoryBlock* block, KProcessAddress addr) {
|
||||||
ASSERT(this->GetAddress() < addr);
|
ASSERT(this->GetAddress() < addr);
|
||||||
ASSERT(this->Contains(addr));
|
ASSERT(this->Contains(addr));
|
||||||
|
@ -160,8 +160,8 @@ void KMemoryBlockManager::Update(KMemoryBlockManagerUpdateAllocator* allocator,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update block state.
|
// Update block state.
|
||||||
it->Update(state, perm, attr, it->GetAddress() == address,
|
it->Update(state, perm, attr, cur_address == address, static_cast<u8>(set_disable_attr),
|
||||||
static_cast<u8>(set_disable_attr), static_cast<u8>(clear_disable_attr));
|
static_cast<u8>(clear_disable_attr));
|
||||||
cur_address += cur_info.GetSize();
|
cur_address += cur_info.GetSize();
|
||||||
remaining_pages -= cur_info.GetNumPages();
|
remaining_pages -= cur_info.GetNumPages();
|
||||||
}
|
}
|
||||||
@ -175,9 +175,7 @@ void KMemoryBlockManager::UpdateIfMatch(KMemoryBlockManagerUpdateAllocator* allo
|
|||||||
KProcessAddress address, size_t num_pages,
|
KProcessAddress address, size_t num_pages,
|
||||||
KMemoryState test_state, KMemoryPermission test_perm,
|
KMemoryState test_state, KMemoryPermission test_perm,
|
||||||
KMemoryAttribute test_attr, KMemoryState state,
|
KMemoryAttribute test_attr, KMemoryState state,
|
||||||
KMemoryPermission perm, KMemoryAttribute attr,
|
KMemoryPermission perm, KMemoryAttribute attr) {
|
||||||
KMemoryBlockDisableMergeAttribute set_disable_attr,
|
|
||||||
KMemoryBlockDisableMergeAttribute clear_disable_attr) {
|
|
||||||
// Ensure for auditing that we never end up with an invalid tree.
|
// Ensure for auditing that we never end up with an invalid tree.
|
||||||
KScopedMemoryBlockManagerAuditor auditor(this);
|
KScopedMemoryBlockManagerAuditor auditor(this);
|
||||||
ASSERT(Common::IsAligned(GetInteger(address), PageSize));
|
ASSERT(Common::IsAligned(GetInteger(address), PageSize));
|
||||||
@ -216,8 +214,7 @@ void KMemoryBlockManager::UpdateIfMatch(KMemoryBlockManagerUpdateAllocator* allo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update block state.
|
// Update block state.
|
||||||
it->Update(state, perm, attr, false, static_cast<u8>(set_disable_attr),
|
it->Update(state, perm, attr, false, 0, 0);
|
||||||
static_cast<u8>(clear_disable_attr));
|
|
||||||
cur_address += cur_info.GetSize();
|
cur_address += cur_info.GetSize();
|
||||||
remaining_pages -= cur_info.GetNumPages();
|
remaining_pages -= cur_info.GetNumPages();
|
||||||
} else {
|
} else {
|
||||||
@ -287,65 +284,6 @@ void KMemoryBlockManager::UpdateLock(KMemoryBlockManagerUpdateAllocator* allocat
|
|||||||
this->CoalesceForUpdate(allocator, address, num_pages);
|
this->CoalesceForUpdate(allocator, address, num_pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMemoryBlockManager::UpdateAttribute(KMemoryBlockManagerUpdateAllocator* allocator,
|
|
||||||
KProcessAddress address, size_t num_pages,
|
|
||||||
KMemoryAttribute mask, KMemoryAttribute attr) {
|
|
||||||
// Ensure for auditing that we never end up with an invalid tree.
|
|
||||||
KScopedMemoryBlockManagerAuditor auditor(this);
|
|
||||||
ASSERT(Common::IsAligned(GetInteger(address), PageSize));
|
|
||||||
|
|
||||||
KProcessAddress cur_address = address;
|
|
||||||
size_t remaining_pages = num_pages;
|
|
||||||
iterator it = this->FindIterator(address);
|
|
||||||
|
|
||||||
while (remaining_pages > 0) {
|
|
||||||
const size_t remaining_size = remaining_pages * PageSize;
|
|
||||||
KMemoryInfo cur_info = it->GetMemoryInfo();
|
|
||||||
|
|
||||||
if ((it->GetAttribute() & mask) != attr) {
|
|
||||||
// If we need to, create a new block before and insert it.
|
|
||||||
if (cur_info.GetAddress() != GetInteger(cur_address)) {
|
|
||||||
KMemoryBlock* new_block = allocator->Allocate();
|
|
||||||
|
|
||||||
it->Split(new_block, cur_address);
|
|
||||||
it = m_memory_block_tree.insert(*new_block);
|
|
||||||
it++;
|
|
||||||
|
|
||||||
cur_info = it->GetMemoryInfo();
|
|
||||||
cur_address = cur_info.GetAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we need to, create a new block after and insert it.
|
|
||||||
if (cur_info.GetSize() > remaining_size) {
|
|
||||||
KMemoryBlock* new_block = allocator->Allocate();
|
|
||||||
|
|
||||||
it->Split(new_block, cur_address + remaining_size);
|
|
||||||
it = m_memory_block_tree.insert(*new_block);
|
|
||||||
|
|
||||||
cur_info = it->GetMemoryInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update block state.
|
|
||||||
it->UpdateAttribute(mask, attr);
|
|
||||||
cur_address += cur_info.GetSize();
|
|
||||||
remaining_pages -= cur_info.GetNumPages();
|
|
||||||
} else {
|
|
||||||
// If we already have the right attributes, just advance.
|
|
||||||
if (cur_address + remaining_size < cur_info.GetEndAddress()) {
|
|
||||||
remaining_pages = 0;
|
|
||||||
cur_address += remaining_size;
|
|
||||||
} else {
|
|
||||||
remaining_pages =
|
|
||||||
(cur_address + remaining_size - cur_info.GetEndAddress()) / PageSize;
|
|
||||||
cur_address = cur_info.GetEndAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it++;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->CoalesceForUpdate(allocator, address, num_pages);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug.
|
// Debug.
|
||||||
bool KMemoryBlockManager::CheckState() const {
|
bool KMemoryBlockManager::CheckState() const {
|
||||||
// Loop over every block, ensuring that we are sorted and coalesced.
|
// Loop over every block, ensuring that we are sorted and coalesced.
|
||||||
|
@ -115,11 +115,7 @@ public:
|
|||||||
void UpdateIfMatch(KMemoryBlockManagerUpdateAllocator* allocator, KProcessAddress address,
|
void UpdateIfMatch(KMemoryBlockManagerUpdateAllocator* allocator, KProcessAddress address,
|
||||||
size_t num_pages, KMemoryState test_state, KMemoryPermission test_perm,
|
size_t num_pages, KMemoryState test_state, KMemoryPermission test_perm,
|
||||||
KMemoryAttribute test_attr, KMemoryState state, KMemoryPermission perm,
|
KMemoryAttribute test_attr, KMemoryState state, KMemoryPermission perm,
|
||||||
KMemoryAttribute attr, KMemoryBlockDisableMergeAttribute set_disable_attr,
|
KMemoryAttribute attr);
|
||||||
KMemoryBlockDisableMergeAttribute clear_disable_attr);
|
|
||||||
|
|
||||||
void UpdateAttribute(KMemoryBlockManagerUpdateAllocator* allocator, KProcessAddress address,
|
|
||||||
size_t num_pages, KMemoryAttribute mask, KMemoryAttribute attr);
|
|
||||||
|
|
||||||
iterator FindIterator(KProcessAddress address) const {
|
iterator FindIterator(KProcessAddress address) const {
|
||||||
return m_memory_block_tree.find(KMemoryBlock(
|
return m_memory_block_tree.find(KMemoryBlock(
|
||||||
|
@ -137,9 +137,11 @@ public:
|
|||||||
return GetStackTopAddress(core_id, KMemoryRegionType_KernelMiscExceptionStack);
|
return GetStackTopAddress(core_id, KMemoryRegionType_KernelMiscExceptionStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
const KMemoryRegion& GetSlabRegion() const {
|
KVirtualAddress GetSlabRegionAddress() const {
|
||||||
return Dereference(GetVirtualMemoryRegionTree().FindByType(KMemoryRegionType_KernelSlab));
|
return Dereference(GetVirtualMemoryRegionTree().FindByType(KMemoryRegionType_KernelSlab))
|
||||||
|
.GetAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
const KMemoryRegion& GetDeviceRegion(KMemoryRegionType type) const {
|
const KMemoryRegion& GetDeviceRegion(KMemoryRegionType type) const {
|
||||||
return Dereference(GetPhysicalMemoryRegionTree().FindFirstDerived(type));
|
return Dereference(GetPhysicalMemoryRegionTree().FindFirstDerived(type));
|
||||||
}
|
}
|
||||||
|
@ -119,8 +119,7 @@ void KMemoryManager::Initialize(KVirtualAddress management_region, size_t manage
|
|||||||
// Free each region to its corresponding heap.
|
// Free each region to its corresponding heap.
|
||||||
size_t reserved_sizes[MaxManagerCount] = {};
|
size_t reserved_sizes[MaxManagerCount] = {};
|
||||||
const KPhysicalAddress ini_start = GetInitialProcessBinaryPhysicalAddress();
|
const KPhysicalAddress ini_start = GetInitialProcessBinaryPhysicalAddress();
|
||||||
const size_t ini_size = GetInitialProcessBinarySize();
|
const KPhysicalAddress ini_end = ini_start + InitialProcessBinarySizeMax;
|
||||||
const KPhysicalAddress ini_end = ini_start + ini_size;
|
|
||||||
const KPhysicalAddress ini_last = ini_end - 1;
|
const KPhysicalAddress ini_last = ini_end - 1;
|
||||||
for (const auto& it : m_system.Kernel().MemoryLayout().GetPhysicalMemoryRegionTree()) {
|
for (const auto& it : m_system.Kernel().MemoryLayout().GetPhysicalMemoryRegionTree()) {
|
||||||
if (it.IsDerivedFrom(KMemoryRegionType_DramUserPool)) {
|
if (it.IsDerivedFrom(KMemoryRegionType_DramUserPool)) {
|
||||||
@ -138,13 +137,13 @@ void KMemoryManager::Initialize(KVirtualAddress management_region, size_t manage
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open/reserve the ini memory.
|
// Open/reserve the ini memory.
|
||||||
manager.OpenFirst(ini_start, ini_size / PageSize);
|
manager.OpenFirst(ini_start, InitialProcessBinarySizeMax / PageSize);
|
||||||
reserved_sizes[it.GetAttributes()] += ini_size;
|
reserved_sizes[it.GetAttributes()] += InitialProcessBinarySizeMax;
|
||||||
|
|
||||||
// Free memory after the ini to the heap.
|
// Free memory after the ini to the heap.
|
||||||
if (ini_last != cur_last) {
|
if (ini_last != cur_last) {
|
||||||
ASSERT(cur_end != 0);
|
ASSERT(cur_end != 0);
|
||||||
manager.Free(ini_end, (cur_end - ini_end) / PageSize);
|
manager.Free(ini_end, cur_end - ini_end);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Ensure there's no partial overlap with the ini image.
|
// Ensure there's no partial overlap with the ini image.
|
||||||
|
@ -190,15 +190,9 @@ static_assert(KMemoryRegionType_DramKernelInitPt.GetValue() ==
|
|||||||
constexpr inline auto KMemoryRegionType_DramKernelSecureAppletMemory =
|
constexpr inline auto KMemoryRegionType_DramKernelSecureAppletMemory =
|
||||||
KMemoryRegionType_DramKernelBase.DeriveSparse(1, 3, 0).SetAttribute(
|
KMemoryRegionType_DramKernelBase.DeriveSparse(1, 3, 0).SetAttribute(
|
||||||
KMemoryRegionAttr_LinearMapped);
|
KMemoryRegionAttr_LinearMapped);
|
||||||
constexpr inline const auto KMemoryRegionType_DramKernelSecureUnknown =
|
|
||||||
KMemoryRegionType_DramKernelBase.DeriveSparse(1, 3, 1).SetAttribute(
|
|
||||||
KMemoryRegionAttr_LinearMapped);
|
|
||||||
static_assert(KMemoryRegionType_DramKernelSecureAppletMemory.GetValue() ==
|
static_assert(KMemoryRegionType_DramKernelSecureAppletMemory.GetValue() ==
|
||||||
(0x18E | KMemoryRegionAttr_CarveoutProtected | KMemoryRegionAttr_NoUserMap |
|
(0x18E | KMemoryRegionAttr_CarveoutProtected | KMemoryRegionAttr_NoUserMap |
|
||||||
KMemoryRegionAttr_LinearMapped));
|
KMemoryRegionAttr_LinearMapped));
|
||||||
static_assert(KMemoryRegionType_DramKernelSecureUnknown.GetValue() ==
|
|
||||||
(0x28E | KMemoryRegionAttr_CarveoutProtected | KMemoryRegionAttr_NoUserMap |
|
|
||||||
KMemoryRegionAttr_LinearMapped));
|
|
||||||
|
|
||||||
constexpr inline auto KMemoryRegionType_DramReservedEarly =
|
constexpr inline auto KMemoryRegionType_DramReservedEarly =
|
||||||
KMemoryRegionType_DramReservedBase.DeriveAttribute(KMemoryRegionAttr_NoUserMap);
|
KMemoryRegionType_DramReservedBase.DeriveAttribute(KMemoryRegionAttr_NoUserMap);
|
||||||
@ -223,18 +217,16 @@ constexpr inline auto KMemoryRegionType_DramPoolPartition =
|
|||||||
static_assert(KMemoryRegionType_DramPoolPartition.GetValue() ==
|
static_assert(KMemoryRegionType_DramPoolPartition.GetValue() ==
|
||||||
(0x26 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
(0x26 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
||||||
|
|
||||||
// UNUSED: .Derive(4, 1);
|
constexpr inline auto KMemoryRegionType_DramPoolManagement =
|
||||||
// UNUSED: .Derive(4, 2);
|
KMemoryRegionType_DramPoolPartition.DeriveTransition(0, 2).DeriveTransition().SetAttribute(
|
||||||
constexpr inline const auto KMemoryRegionType_DramPoolManagement =
|
|
||||||
KMemoryRegionType_DramPoolPartition.Derive(4, 0).SetAttribute(
|
|
||||||
KMemoryRegionAttr_CarveoutProtected);
|
KMemoryRegionAttr_CarveoutProtected);
|
||||||
constexpr inline const auto KMemoryRegionType_DramUserPool =
|
constexpr inline auto KMemoryRegionType_DramUserPool =
|
||||||
KMemoryRegionType_DramPoolPartition.Derive(4, 3);
|
KMemoryRegionType_DramPoolPartition.DeriveTransition(1, 2).DeriveTransition();
|
||||||
static_assert(KMemoryRegionType_DramPoolManagement.GetValue() ==
|
static_assert(KMemoryRegionType_DramPoolManagement.GetValue() ==
|
||||||
(0xE6 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap |
|
(0x166 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap |
|
||||||
KMemoryRegionAttr_CarveoutProtected));
|
KMemoryRegionAttr_CarveoutProtected));
|
||||||
static_assert(KMemoryRegionType_DramUserPool.GetValue() ==
|
static_assert(KMemoryRegionType_DramUserPool.GetValue() ==
|
||||||
(0x266 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
(0x1A6 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
||||||
|
|
||||||
constexpr inline auto KMemoryRegionType_DramApplicationPool =
|
constexpr inline auto KMemoryRegionType_DramApplicationPool =
|
||||||
KMemoryRegionType_DramUserPool.Derive(4, 0);
|
KMemoryRegionType_DramUserPool.Derive(4, 0);
|
||||||
@ -245,63 +237,60 @@ constexpr inline auto KMemoryRegionType_DramSystemNonSecurePool =
|
|||||||
constexpr inline auto KMemoryRegionType_DramSystemPool =
|
constexpr inline auto KMemoryRegionType_DramSystemPool =
|
||||||
KMemoryRegionType_DramUserPool.Derive(4, 3).SetAttribute(KMemoryRegionAttr_CarveoutProtected);
|
KMemoryRegionType_DramUserPool.Derive(4, 3).SetAttribute(KMemoryRegionAttr_CarveoutProtected);
|
||||||
static_assert(KMemoryRegionType_DramApplicationPool.GetValue() ==
|
static_assert(KMemoryRegionType_DramApplicationPool.GetValue() ==
|
||||||
(0xE66 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
(0x7A6 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
||||||
static_assert(KMemoryRegionType_DramAppletPool.GetValue() ==
|
static_assert(KMemoryRegionType_DramAppletPool.GetValue() ==
|
||||||
(0x1666 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
(0xBA6 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
||||||
static_assert(KMemoryRegionType_DramSystemNonSecurePool.GetValue() ==
|
static_assert(KMemoryRegionType_DramSystemNonSecurePool.GetValue() ==
|
||||||
(0x1A66 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
(0xDA6 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap));
|
||||||
static_assert(KMemoryRegionType_DramSystemPool.GetValue() ==
|
static_assert(KMemoryRegionType_DramSystemPool.GetValue() ==
|
||||||
(0x2666 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap |
|
(0x13A6 | KMemoryRegionAttr_LinearMapped | KMemoryRegionAttr_NoUserMap |
|
||||||
KMemoryRegionAttr_CarveoutProtected));
|
KMemoryRegionAttr_CarveoutProtected));
|
||||||
|
|
||||||
constexpr inline auto KMemoryRegionType_VirtualDramHeapBase =
|
constexpr inline auto KMemoryRegionType_VirtualDramHeapBase =
|
||||||
KMemoryRegionType_Dram.DeriveSparse(1, 4, 0);
|
KMemoryRegionType_Dram.DeriveSparse(1, 3, 0);
|
||||||
constexpr inline auto KMemoryRegionType_VirtualDramKernelPtHeap =
|
constexpr inline auto KMemoryRegionType_VirtualDramKernelPtHeap =
|
||||||
KMemoryRegionType_Dram.DeriveSparse(1, 4, 1);
|
KMemoryRegionType_Dram.DeriveSparse(1, 3, 1);
|
||||||
constexpr inline auto KMemoryRegionType_VirtualDramKernelTraceBuffer =
|
constexpr inline auto KMemoryRegionType_VirtualDramKernelTraceBuffer =
|
||||||
KMemoryRegionType_Dram.DeriveSparse(1, 4, 2);
|
KMemoryRegionType_Dram.DeriveSparse(1, 3, 2);
|
||||||
static_assert(KMemoryRegionType_VirtualDramHeapBase.GetValue() == 0x1A);
|
static_assert(KMemoryRegionType_VirtualDramHeapBase.GetValue() == 0x1A);
|
||||||
static_assert(KMemoryRegionType_VirtualDramKernelPtHeap.GetValue() == 0x2A);
|
static_assert(KMemoryRegionType_VirtualDramKernelPtHeap.GetValue() == 0x2A);
|
||||||
static_assert(KMemoryRegionType_VirtualDramKernelTraceBuffer.GetValue() == 0x4A);
|
static_assert(KMemoryRegionType_VirtualDramKernelTraceBuffer.GetValue() == 0x4A);
|
||||||
|
|
||||||
// UNUSED: .Derive(4, 2);
|
// UNUSED: .DeriveSparse(2, 2, 0);
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramUnknownDebug =
|
constexpr inline auto KMemoryRegionType_VirtualDramUnknownDebug =
|
||||||
KMemoryRegionType_Dram.Advance(2).Derive(4, 0);
|
KMemoryRegionType_Dram.DeriveSparse(2, 2, 1);
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramKernelSecureAppletMemory =
|
static_assert(KMemoryRegionType_VirtualDramUnknownDebug.GetValue() == (0x52));
|
||||||
KMemoryRegionType_Dram.Advance(2).Derive(4, 1);
|
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramKernelSecureUnknown =
|
|
||||||
KMemoryRegionType_Dram.Advance(2).Derive(4, 3);
|
|
||||||
static_assert(KMemoryRegionType_VirtualDramUnknownDebug.GetValue() == (0x32));
|
|
||||||
static_assert(KMemoryRegionType_VirtualDramKernelSecureAppletMemory.GetValue() == (0x52));
|
|
||||||
static_assert(KMemoryRegionType_VirtualDramKernelSecureUnknown.GetValue() == (0x92));
|
|
||||||
|
|
||||||
// UNUSED: .Derive(4, 3);
|
constexpr inline auto KMemoryRegionType_VirtualDramKernelSecureAppletMemory =
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramKernelInitPt =
|
KMemoryRegionType_Dram.DeriveSparse(3, 1, 0);
|
||||||
KMemoryRegionType_VirtualDramHeapBase.Derive(4, 0);
|
static_assert(KMemoryRegionType_VirtualDramKernelSecureAppletMemory.GetValue() == (0x62));
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramPoolManagement =
|
|
||||||
KMemoryRegionType_VirtualDramHeapBase.Derive(4, 1);
|
constexpr inline auto KMemoryRegionType_VirtualDramKernelInitPt =
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramUserPool =
|
KMemoryRegionType_VirtualDramHeapBase.Derive(3, 0);
|
||||||
KMemoryRegionType_VirtualDramHeapBase.Derive(4, 2);
|
constexpr inline auto KMemoryRegionType_VirtualDramPoolManagement =
|
||||||
static_assert(KMemoryRegionType_VirtualDramKernelInitPt.GetValue() == 0x31A);
|
KMemoryRegionType_VirtualDramHeapBase.Derive(3, 1);
|
||||||
static_assert(KMemoryRegionType_VirtualDramPoolManagement.GetValue() == 0x51A);
|
constexpr inline auto KMemoryRegionType_VirtualDramUserPool =
|
||||||
static_assert(KMemoryRegionType_VirtualDramUserPool.GetValue() == 0x61A);
|
KMemoryRegionType_VirtualDramHeapBase.Derive(3, 2);
|
||||||
|
static_assert(KMemoryRegionType_VirtualDramKernelInitPt.GetValue() == 0x19A);
|
||||||
|
static_assert(KMemoryRegionType_VirtualDramPoolManagement.GetValue() == 0x29A);
|
||||||
|
static_assert(KMemoryRegionType_VirtualDramUserPool.GetValue() == 0x31A);
|
||||||
|
|
||||||
// NOTE: For unknown reason, the pools are derived out-of-order here.
|
// NOTE: For unknown reason, the pools are derived out-of-order here.
|
||||||
// It's worth eventually trying to understand why Nintendo made this choice.
|
// It's worth eventually trying to understand why Nintendo made this choice.
|
||||||
// UNUSED: .Derive(6, 0);
|
// UNUSED: .Derive(6, 0);
|
||||||
// UNUSED: .Derive(6, 1);
|
// UNUSED: .Derive(6, 1);
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramApplicationPool =
|
constexpr inline auto KMemoryRegionType_VirtualDramAppletPool =
|
||||||
KMemoryRegionType_VirtualDramUserPool.Derive(4, 0);
|
KMemoryRegionType_VirtualDramUserPool.Derive(6, 2);
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramAppletPool =
|
constexpr inline auto KMemoryRegionType_VirtualDramApplicationPool =
|
||||||
KMemoryRegionType_VirtualDramUserPool.Derive(4, 1);
|
KMemoryRegionType_VirtualDramUserPool.Derive(6, 3);
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramSystemNonSecurePool =
|
constexpr inline auto KMemoryRegionType_VirtualDramSystemNonSecurePool =
|
||||||
KMemoryRegionType_VirtualDramUserPool.Derive(4, 2);
|
KMemoryRegionType_VirtualDramUserPool.Derive(6, 4);
|
||||||
constexpr inline const auto KMemoryRegionType_VirtualDramSystemPool =
|
constexpr inline auto KMemoryRegionType_VirtualDramSystemPool =
|
||||||
KMemoryRegionType_VirtualDramUserPool.Derive(4, 3);
|
KMemoryRegionType_VirtualDramUserPool.Derive(6, 5);
|
||||||
static_assert(KMemoryRegionType_VirtualDramApplicationPool.GetValue() == 0x361A);
|
static_assert(KMemoryRegionType_VirtualDramAppletPool.GetValue() == 0x1B1A);
|
||||||
static_assert(KMemoryRegionType_VirtualDramAppletPool.GetValue() == 0x561A);
|
static_assert(KMemoryRegionType_VirtualDramApplicationPool.GetValue() == 0x271A);
|
||||||
static_assert(KMemoryRegionType_VirtualDramSystemNonSecurePool.GetValue() == 0x661A);
|
static_assert(KMemoryRegionType_VirtualDramSystemNonSecurePool.GetValue() == 0x2B1A);
|
||||||
static_assert(KMemoryRegionType_VirtualDramSystemPool.GetValue() == 0x961A);
|
static_assert(KMemoryRegionType_VirtualDramSystemPool.GetValue() == 0x331A);
|
||||||
|
|
||||||
constexpr inline auto KMemoryRegionType_ArchDeviceBase =
|
constexpr inline auto KMemoryRegionType_ArchDeviceBase =
|
||||||
KMemoryRegionType_Kernel.DeriveTransition(0, 1).SetSparseOnly();
|
KMemoryRegionType_Kernel.DeriveTransition(0, 1).SetSparseOnly();
|
||||||
@ -365,14 +354,12 @@ constexpr inline auto KMemoryRegionType_KernelTemp =
|
|||||||
static_assert(KMemoryRegionType_KernelTemp.GetValue() == 0x31);
|
static_assert(KMemoryRegionType_KernelTemp.GetValue() == 0x31);
|
||||||
|
|
||||||
constexpr KMemoryRegionType GetTypeForVirtualLinearMapping(u32 type_id) {
|
constexpr KMemoryRegionType GetTypeForVirtualLinearMapping(u32 type_id) {
|
||||||
if (KMemoryRegionType_DramKernelPtHeap.IsAncestorOf(type_id)) {
|
if (KMemoryRegionType_KernelTraceBuffer.IsAncestorOf(type_id)) {
|
||||||
|
return KMemoryRegionType_VirtualDramKernelTraceBuffer;
|
||||||
|
} else if (KMemoryRegionType_DramKernelPtHeap.IsAncestorOf(type_id)) {
|
||||||
return KMemoryRegionType_VirtualDramKernelPtHeap;
|
return KMemoryRegionType_VirtualDramKernelPtHeap;
|
||||||
} else if (KMemoryRegionType_DramKernelSecureAppletMemory.IsAncestorOf(type_id)) {
|
} else if (KMemoryRegionType_DramKernelSecureAppletMemory.IsAncestorOf(type_id)) {
|
||||||
return KMemoryRegionType_VirtualDramKernelSecureAppletMemory;
|
return KMemoryRegionType_VirtualDramKernelSecureAppletMemory;
|
||||||
} else if (KMemoryRegionType_DramKernelSecureUnknown.IsAncestorOf(type_id)) {
|
|
||||||
return KMemoryRegionType_VirtualDramKernelSecureUnknown;
|
|
||||||
} else if (KMemoryRegionType_KernelTraceBuffer.IsAncestorOf(type_id)) {
|
|
||||||
return KMemoryRegionType_VirtualDramKernelTraceBuffer;
|
|
||||||
} else if ((type_id | KMemoryRegionAttr_ShouldKernelMap) == type_id) {
|
} else if ((type_id | KMemoryRegionAttr_ShouldKernelMap) == type_id) {
|
||||||
return KMemoryRegionType_VirtualDramUnknownDebug;
|
return KMemoryRegionType_VirtualDramUnknownDebug;
|
||||||
} else {
|
} else {
|
||||||
|
@ -183,17 +183,12 @@ private:
|
|||||||
|
|
||||||
class KScopedPageGroup {
|
class KScopedPageGroup {
|
||||||
public:
|
public:
|
||||||
explicit KScopedPageGroup(const KPageGroup* gp, bool not_first = true) : m_pg(gp) {
|
explicit KScopedPageGroup(const KPageGroup* gp) : m_pg(gp) {
|
||||||
if (m_pg) {
|
if (m_pg) {
|
||||||
if (not_first) {
|
m_pg->Open();
|
||||||
m_pg->Open();
|
|
||||||
} else {
|
|
||||||
m_pg->OpenFirst();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
explicit KScopedPageGroup(const KPageGroup& gp, bool not_first = true)
|
explicit KScopedPageGroup(const KPageGroup& gp) : KScopedPageGroup(std::addressof(gp)) {}
|
||||||
: KScopedPageGroup(std::addressof(gp), not_first) {}
|
|
||||||
~KScopedPageGroup() {
|
~KScopedPageGroup() {
|
||||||
if (m_pg) {
|
if (m_pg) {
|
||||||
m_pg->Close();
|
m_pg->Close();
|
||||||
|
@ -505,7 +505,7 @@ Result KPageTable::UnmapCodeMemory(KProcessAddress dst_address, KProcessAddress
|
|||||||
R_TRY(this->CheckMemoryStateContiguous(
|
R_TRY(this->CheckMemoryStateContiguous(
|
||||||
std::addressof(num_dst_allocator_blocks), dst_address, size, KMemoryState::FlagCanCodeAlias,
|
std::addressof(num_dst_allocator_blocks), dst_address, size, KMemoryState::FlagCanCodeAlias,
|
||||||
KMemoryState::FlagCanCodeAlias, KMemoryPermission::None, KMemoryPermission::None,
|
KMemoryState::FlagCanCodeAlias, KMemoryPermission::None, KMemoryPermission::None,
|
||||||
KMemoryAttribute::All & ~KMemoryAttribute::PermissionLocked, KMemoryAttribute::None));
|
KMemoryAttribute::All, KMemoryAttribute::None));
|
||||||
|
|
||||||
// Determine whether any pages being unmapped are code.
|
// Determine whether any pages being unmapped are code.
|
||||||
bool any_code_pages = false;
|
bool any_code_pages = false;
|
||||||
@ -1724,43 +1724,29 @@ Result KPageTable::MapPhysicalMemory(KProcessAddress address, size_t size) {
|
|||||||
PageSize;
|
PageSize;
|
||||||
|
|
||||||
// While we have pages to map, map them.
|
// While we have pages to map, map them.
|
||||||
{
|
while (map_pages > 0) {
|
||||||
// Create a page group for the current mapping range.
|
// Check if we're at the end of the physical block.
|
||||||
KPageGroup cur_pg(m_kernel, m_block_info_manager);
|
if (pg_pages == 0) {
|
||||||
{
|
// Ensure there are more pages to map.
|
||||||
ON_RESULT_FAILURE_2 {
|
ASSERT(pg_it != pg.end());
|
||||||
cur_pg.OpenFirst();
|
|
||||||
cur_pg.Close();
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t remain_pages = map_pages;
|
// Advance our physical block.
|
||||||
while (remain_pages > 0) {
|
++pg_it;
|
||||||
// Check if we're at the end of the physical block.
|
pg_phys_addr = pg_it->GetAddress();
|
||||||
if (pg_pages == 0) {
|
pg_pages = pg_it->GetNumPages();
|
||||||
// Ensure there are more pages to map.
|
|
||||||
ASSERT(pg_it != pg.end());
|
|
||||||
|
|
||||||
// Advance our physical block.
|
|
||||||
++pg_it;
|
|
||||||
pg_phys_addr = pg_it->GetAddress();
|
|
||||||
pg_pages = pg_it->GetNumPages();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add whatever we can to the current block.
|
|
||||||
const size_t cur_pages = std::min(pg_pages, remain_pages);
|
|
||||||
R_TRY(cur_pg.AddBlock(pg_phys_addr +
|
|
||||||
((pg_pages - cur_pages) * PageSize),
|
|
||||||
cur_pages));
|
|
||||||
|
|
||||||
// Advance.
|
|
||||||
remain_pages -= cur_pages;
|
|
||||||
pg_pages -= cur_pages;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map the pages.
|
// Map whatever we can.
|
||||||
R_TRY(this->Operate(cur_address, map_pages, cur_pg,
|
const size_t cur_pages = std::min(pg_pages, map_pages);
|
||||||
OperationType::MapFirstGroup));
|
R_TRY(Operate(cur_address, cur_pages, KMemoryPermission::UserReadWrite,
|
||||||
|
OperationType::MapFirst, pg_phys_addr));
|
||||||
|
|
||||||
|
// Advance.
|
||||||
|
cur_address += cur_pages * PageSize;
|
||||||
|
map_pages -= cur_pages;
|
||||||
|
|
||||||
|
pg_phys_addr += cur_pages * PageSize;
|
||||||
|
pg_pages -= cur_pages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1784,11 +1770,7 @@ Result KPageTable::MapPhysicalMemory(KProcessAddress address, size_t size) {
|
|||||||
m_memory_block_manager.UpdateIfMatch(
|
m_memory_block_manager.UpdateIfMatch(
|
||||||
std::addressof(allocator), address, size / PageSize, KMemoryState::Free,
|
std::addressof(allocator), address, size / PageSize, KMemoryState::Free,
|
||||||
KMemoryPermission::None, KMemoryAttribute::None, KMemoryState::Normal,
|
KMemoryPermission::None, KMemoryAttribute::None, KMemoryState::Normal,
|
||||||
KMemoryPermission::UserReadWrite, KMemoryAttribute::None,
|
KMemoryPermission::UserReadWrite, KMemoryAttribute::None);
|
||||||
address == this->GetAliasRegionStart()
|
|
||||||
? KMemoryBlockDisableMergeAttribute::Normal
|
|
||||||
: KMemoryBlockDisableMergeAttribute::None,
|
|
||||||
KMemoryBlockDisableMergeAttribute::None);
|
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@ -1886,13 +1868,6 @@ Result KPageTable::UnmapPhysicalMemory(KProcessAddress address, size_t size) {
|
|||||||
|
|
||||||
// Iterate over the memory, unmapping as we go.
|
// Iterate over the memory, unmapping as we go.
|
||||||
auto it = m_memory_block_manager.FindIterator(cur_address);
|
auto it = m_memory_block_manager.FindIterator(cur_address);
|
||||||
|
|
||||||
const auto clear_merge_attr =
|
|
||||||
(it->GetState() == KMemoryState::Normal &&
|
|
||||||
it->GetAddress() == this->GetAliasRegionStart() && it->GetAddress() == address)
|
|
||||||
? KMemoryBlockDisableMergeAttribute::Normal
|
|
||||||
: KMemoryBlockDisableMergeAttribute::None;
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Check that the iterator is valid.
|
// Check that the iterator is valid.
|
||||||
ASSERT(it != m_memory_block_manager.end());
|
ASSERT(it != m_memory_block_manager.end());
|
||||||
@ -1930,7 +1905,7 @@ Result KPageTable::UnmapPhysicalMemory(KProcessAddress address, size_t size) {
|
|||||||
m_memory_block_manager.Update(std::addressof(allocator), address, size / PageSize,
|
m_memory_block_manager.Update(std::addressof(allocator), address, size / PageSize,
|
||||||
KMemoryState::Free, KMemoryPermission::None,
|
KMemoryState::Free, KMemoryPermission::None,
|
||||||
KMemoryAttribute::None, KMemoryBlockDisableMergeAttribute::None,
|
KMemoryAttribute::None, KMemoryBlockDisableMergeAttribute::None,
|
||||||
clear_merge_attr);
|
KMemoryBlockDisableMergeAttribute::None);
|
||||||
|
|
||||||
// We succeeded.
|
// We succeeded.
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
@ -2404,7 +2379,8 @@ Result KPageTable::MapPageGroup(KProcessAddress* out_addr, const KPageGroup& pg,
|
|||||||
KScopedPageTableUpdater updater(this);
|
KScopedPageTableUpdater updater(this);
|
||||||
|
|
||||||
// Perform mapping operation.
|
// Perform mapping operation.
|
||||||
const KPageProperties properties = {perm, false, false, DisableMergeAttribute::DisableHead};
|
const KPageProperties properties = {perm, state == KMemoryState::Io, false,
|
||||||
|
DisableMergeAttribute::DisableHead};
|
||||||
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
||||||
|
|
||||||
// Update the blocks.
|
// Update the blocks.
|
||||||
@ -2446,7 +2422,8 @@ Result KPageTable::MapPageGroup(KProcessAddress addr, const KPageGroup& pg, KMem
|
|||||||
KScopedPageTableUpdater updater(this);
|
KScopedPageTableUpdater updater(this);
|
||||||
|
|
||||||
// Perform mapping operation.
|
// Perform mapping operation.
|
||||||
const KPageProperties properties = {perm, false, false, DisableMergeAttribute::DisableHead};
|
const KPageProperties properties = {perm, state == KMemoryState::Io, false,
|
||||||
|
DisableMergeAttribute::DisableHead};
|
||||||
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
||||||
|
|
||||||
// Update the blocks.
|
// Update the blocks.
|
||||||
@ -2675,18 +2652,11 @@ Result KPageTable::SetMemoryAttribute(KProcessAddress addr, size_t size, u32 mas
|
|||||||
size_t num_allocator_blocks;
|
size_t num_allocator_blocks;
|
||||||
constexpr auto AttributeTestMask =
|
constexpr auto AttributeTestMask =
|
||||||
~(KMemoryAttribute::SetMask | KMemoryAttribute::DeviceShared);
|
~(KMemoryAttribute::SetMask | KMemoryAttribute::DeviceShared);
|
||||||
const KMemoryState state_test_mask =
|
R_TRY(this->CheckMemoryState(
|
||||||
static_cast<KMemoryState>(((mask & static_cast<u32>(KMemoryAttribute::Uncached))
|
std::addressof(old_state), std::addressof(old_perm), std::addressof(old_attr),
|
||||||
? static_cast<u32>(KMemoryState::FlagCanChangeAttribute)
|
std::addressof(num_allocator_blocks), addr, size, KMemoryState::FlagCanChangeAttribute,
|
||||||
: 0) |
|
KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None,
|
||||||
((mask & static_cast<u32>(KMemoryAttribute::PermissionLocked))
|
AttributeTestMask, KMemoryAttribute::None, ~AttributeTestMask));
|
||||||
? static_cast<u32>(KMemoryState::FlagCanPermissionLock)
|
|
||||||
: 0));
|
|
||||||
R_TRY(this->CheckMemoryState(std::addressof(old_state), std::addressof(old_perm),
|
|
||||||
std::addressof(old_attr), std::addressof(num_allocator_blocks),
|
|
||||||
addr, size, state_test_mask, state_test_mask,
|
|
||||||
KMemoryPermission::None, KMemoryPermission::None,
|
|
||||||
AttributeTestMask, KMemoryAttribute::None, ~AttributeTestMask));
|
|
||||||
|
|
||||||
// Create an update allocator.
|
// Create an update allocator.
|
||||||
Result allocator_result{ResultSuccess};
|
Result allocator_result{ResultSuccess};
|
||||||
@ -2694,17 +2664,18 @@ Result KPageTable::SetMemoryAttribute(KProcessAddress addr, size_t size, u32 mas
|
|||||||
m_memory_block_slab_manager, num_allocator_blocks);
|
m_memory_block_slab_manager, num_allocator_blocks);
|
||||||
R_TRY(allocator_result);
|
R_TRY(allocator_result);
|
||||||
|
|
||||||
// If we need to, perform a change attribute operation.
|
// Determine the new attribute.
|
||||||
if (True(KMemoryAttribute::Uncached & static_cast<KMemoryAttribute>(mask))) {
|
const KMemoryAttribute new_attr =
|
||||||
// Perform operation.
|
static_cast<KMemoryAttribute>(((old_attr & static_cast<KMemoryAttribute>(~mask)) |
|
||||||
R_TRY(this->Operate(addr, num_pages, old_perm,
|
static_cast<KMemoryAttribute>(attr & mask)));
|
||||||
OperationType::ChangePermissionsAndRefreshAndFlush, 0));
|
|
||||||
}
|
// Perform operation.
|
||||||
|
this->Operate(addr, num_pages, old_perm, OperationType::ChangePermissionsAndRefresh);
|
||||||
|
|
||||||
// Update the blocks.
|
// Update the blocks.
|
||||||
m_memory_block_manager.UpdateAttribute(std::addressof(allocator), addr, num_pages,
|
m_memory_block_manager.Update(std::addressof(allocator), addr, num_pages, old_state, old_perm,
|
||||||
static_cast<KMemoryAttribute>(mask),
|
new_attr, KMemoryBlockDisableMergeAttribute::None,
|
||||||
static_cast<KMemoryAttribute>(attr));
|
KMemoryBlockDisableMergeAttribute::None);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@ -2892,8 +2863,7 @@ Result KPageTable::LockForMapDeviceAddressSpace(bool* out_is_io, KProcessAddress
|
|||||||
&KMemoryBlock::ShareToDevice, KMemoryPermission::None);
|
&KMemoryBlock::ShareToDevice, KMemoryPermission::None);
|
||||||
|
|
||||||
// Set whether the locked memory was io.
|
// Set whether the locked memory was io.
|
||||||
*out_is_io =
|
*out_is_io = old_state == KMemoryState::Io;
|
||||||
static_cast<Svc::MemoryState>(old_state & KMemoryState::Mask) == Svc::MemoryState::Io;
|
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
@ -3051,10 +3021,9 @@ Result KPageTable::Operate(KProcessAddress addr, size_t num_pages, const KPageGr
|
|||||||
ASSERT(num_pages == page_group.GetNumPages());
|
ASSERT(num_pages == page_group.GetNumPages());
|
||||||
|
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case OperationType::MapGroup:
|
case OperationType::MapGroup: {
|
||||||
case OperationType::MapFirstGroup: {
|
|
||||||
// We want to maintain a new reference to every page in the group.
|
// We want to maintain a new reference to every page in the group.
|
||||||
KScopedPageGroup spg(page_group, operation != OperationType::MapFirstGroup);
|
KScopedPageGroup spg(page_group);
|
||||||
|
|
||||||
for (const auto& node : page_group) {
|
for (const auto& node : page_group) {
|
||||||
const size_t size{node.GetNumPages() * PageSize};
|
const size_t size{node.GetNumPages() * PageSize};
|
||||||
@ -3096,6 +3065,7 @@ Result KPageTable::Operate(KProcessAddress addr, size_t num_pages, KMemoryPermis
|
|||||||
m_memory->UnmapRegion(*m_page_table_impl, addr, num_pages * PageSize);
|
m_memory->UnmapRegion(*m_page_table_impl, addr, num_pages * PageSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OperationType::MapFirst:
|
||||||
case OperationType::Map: {
|
case OperationType::Map: {
|
||||||
ASSERT(map_addr);
|
ASSERT(map_addr);
|
||||||
ASSERT(Common::IsAligned(GetInteger(map_addr), PageSize));
|
ASSERT(Common::IsAligned(GetInteger(map_addr), PageSize));
|
||||||
@ -3103,7 +3073,11 @@ Result KPageTable::Operate(KProcessAddress addr, size_t num_pages, KMemoryPermis
|
|||||||
|
|
||||||
// Open references to pages, if we should.
|
// Open references to pages, if we should.
|
||||||
if (IsHeapPhysicalAddress(m_kernel.MemoryLayout(), map_addr)) {
|
if (IsHeapPhysicalAddress(m_kernel.MemoryLayout(), map_addr)) {
|
||||||
m_kernel.MemoryManager().Open(map_addr, num_pages);
|
if (operation == OperationType::MapFirst) {
|
||||||
|
m_kernel.MemoryManager().OpenFirst(map_addr, num_pages);
|
||||||
|
} else {
|
||||||
|
m_kernel.MemoryManager().Open(map_addr, num_pages);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3113,7 +3087,6 @@ Result KPageTable::Operate(KProcessAddress addr, size_t num_pages, KMemoryPermis
|
|||||||
}
|
}
|
||||||
case OperationType::ChangePermissions:
|
case OperationType::ChangePermissions:
|
||||||
case OperationType::ChangePermissionsAndRefresh:
|
case OperationType::ChangePermissionsAndRefresh:
|
||||||
case OperationType::ChangePermissionsAndRefreshAndFlush:
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
@ -3133,79 +3106,79 @@ void KPageTable::FinalizeUpdate(PageLinkedList* page_list) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KProcessAddress KPageTable::GetRegionAddress(Svc::MemoryState state) const {
|
KProcessAddress KPageTable::GetRegionAddress(KMemoryState state) const {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Svc::MemoryState::Free:
|
case KMemoryState::Free:
|
||||||
case Svc::MemoryState::Kernel:
|
case KMemoryState::Kernel:
|
||||||
return m_address_space_start;
|
return m_address_space_start;
|
||||||
case Svc::MemoryState::Normal:
|
case KMemoryState::Normal:
|
||||||
return m_heap_region_start;
|
return m_heap_region_start;
|
||||||
case Svc::MemoryState::Ipc:
|
case KMemoryState::Ipc:
|
||||||
case Svc::MemoryState::NonSecureIpc:
|
case KMemoryState::NonSecureIpc:
|
||||||
case Svc::MemoryState::NonDeviceIpc:
|
case KMemoryState::NonDeviceIpc:
|
||||||
return m_alias_region_start;
|
return m_alias_region_start;
|
||||||
case Svc::MemoryState::Stack:
|
case KMemoryState::Stack:
|
||||||
return m_stack_region_start;
|
return m_stack_region_start;
|
||||||
case Svc::MemoryState::Static:
|
case KMemoryState::Static:
|
||||||
case Svc::MemoryState::ThreadLocal:
|
case KMemoryState::ThreadLocal:
|
||||||
return m_kernel_map_region_start;
|
return m_kernel_map_region_start;
|
||||||
case Svc::MemoryState::Io:
|
case KMemoryState::Io:
|
||||||
case Svc::MemoryState::Shared:
|
case KMemoryState::Shared:
|
||||||
case Svc::MemoryState::AliasCode:
|
case KMemoryState::AliasCode:
|
||||||
case Svc::MemoryState::AliasCodeData:
|
case KMemoryState::AliasCodeData:
|
||||||
case Svc::MemoryState::Transfered:
|
case KMemoryState::Transfered:
|
||||||
case Svc::MemoryState::SharedTransfered:
|
case KMemoryState::SharedTransfered:
|
||||||
case Svc::MemoryState::SharedCode:
|
case KMemoryState::SharedCode:
|
||||||
case Svc::MemoryState::GeneratedCode:
|
case KMemoryState::GeneratedCode:
|
||||||
case Svc::MemoryState::CodeOut:
|
case KMemoryState::CodeOut:
|
||||||
case Svc::MemoryState::Coverage:
|
case KMemoryState::Coverage:
|
||||||
case Svc::MemoryState::Insecure:
|
case KMemoryState::Insecure:
|
||||||
return m_alias_code_region_start;
|
return m_alias_code_region_start;
|
||||||
case Svc::MemoryState::Code:
|
case KMemoryState::Code:
|
||||||
case Svc::MemoryState::CodeData:
|
case KMemoryState::CodeData:
|
||||||
return m_code_region_start;
|
return m_code_region_start;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t KPageTable::GetRegionSize(Svc::MemoryState state) const {
|
size_t KPageTable::GetRegionSize(KMemoryState state) const {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Svc::MemoryState::Free:
|
case KMemoryState::Free:
|
||||||
case Svc::MemoryState::Kernel:
|
case KMemoryState::Kernel:
|
||||||
return m_address_space_end - m_address_space_start;
|
return m_address_space_end - m_address_space_start;
|
||||||
case Svc::MemoryState::Normal:
|
case KMemoryState::Normal:
|
||||||
return m_heap_region_end - m_heap_region_start;
|
return m_heap_region_end - m_heap_region_start;
|
||||||
case Svc::MemoryState::Ipc:
|
case KMemoryState::Ipc:
|
||||||
case Svc::MemoryState::NonSecureIpc:
|
case KMemoryState::NonSecureIpc:
|
||||||
case Svc::MemoryState::NonDeviceIpc:
|
case KMemoryState::NonDeviceIpc:
|
||||||
return m_alias_region_end - m_alias_region_start;
|
return m_alias_region_end - m_alias_region_start;
|
||||||
case Svc::MemoryState::Stack:
|
case KMemoryState::Stack:
|
||||||
return m_stack_region_end - m_stack_region_start;
|
return m_stack_region_end - m_stack_region_start;
|
||||||
case Svc::MemoryState::Static:
|
case KMemoryState::Static:
|
||||||
case Svc::MemoryState::ThreadLocal:
|
case KMemoryState::ThreadLocal:
|
||||||
return m_kernel_map_region_end - m_kernel_map_region_start;
|
return m_kernel_map_region_end - m_kernel_map_region_start;
|
||||||
case Svc::MemoryState::Io:
|
case KMemoryState::Io:
|
||||||
case Svc::MemoryState::Shared:
|
case KMemoryState::Shared:
|
||||||
case Svc::MemoryState::AliasCode:
|
case KMemoryState::AliasCode:
|
||||||
case Svc::MemoryState::AliasCodeData:
|
case KMemoryState::AliasCodeData:
|
||||||
case Svc::MemoryState::Transfered:
|
case KMemoryState::Transfered:
|
||||||
case Svc::MemoryState::SharedTransfered:
|
case KMemoryState::SharedTransfered:
|
||||||
case Svc::MemoryState::SharedCode:
|
case KMemoryState::SharedCode:
|
||||||
case Svc::MemoryState::GeneratedCode:
|
case KMemoryState::GeneratedCode:
|
||||||
case Svc::MemoryState::CodeOut:
|
case KMemoryState::CodeOut:
|
||||||
case Svc::MemoryState::Coverage:
|
case KMemoryState::Coverage:
|
||||||
case Svc::MemoryState::Insecure:
|
case KMemoryState::Insecure:
|
||||||
return m_alias_code_region_end - m_alias_code_region_start;
|
return m_alias_code_region_end - m_alias_code_region_start;
|
||||||
case Svc::MemoryState::Code:
|
case KMemoryState::Code:
|
||||||
case Svc::MemoryState::CodeData:
|
case KMemoryState::CodeData:
|
||||||
return m_code_region_end - m_code_region_start;
|
return m_code_region_end - m_code_region_start;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KPageTable::CanContain(KProcessAddress addr, size_t size, Svc::MemoryState state) const {
|
bool KPageTable::CanContain(KProcessAddress addr, size_t size, KMemoryState state) const {
|
||||||
const KProcessAddress end = addr + size;
|
const KProcessAddress end = addr + size;
|
||||||
const KProcessAddress last = end - 1;
|
const KProcessAddress last = end - 1;
|
||||||
|
|
||||||
@ -3219,32 +3192,32 @@ bool KPageTable::CanContain(KProcessAddress addr, size_t size, Svc::MemoryState
|
|||||||
const bool is_in_alias = !(end <= m_alias_region_start || m_alias_region_end <= addr ||
|
const bool is_in_alias = !(end <= m_alias_region_start || m_alias_region_end <= addr ||
|
||||||
m_alias_region_start == m_alias_region_end);
|
m_alias_region_start == m_alias_region_end);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Svc::MemoryState::Free:
|
case KMemoryState::Free:
|
||||||
case Svc::MemoryState::Kernel:
|
case KMemoryState::Kernel:
|
||||||
return is_in_region;
|
return is_in_region;
|
||||||
case Svc::MemoryState::Io:
|
case KMemoryState::Io:
|
||||||
case Svc::MemoryState::Static:
|
case KMemoryState::Static:
|
||||||
case Svc::MemoryState::Code:
|
case KMemoryState::Code:
|
||||||
case Svc::MemoryState::CodeData:
|
case KMemoryState::CodeData:
|
||||||
case Svc::MemoryState::Shared:
|
case KMemoryState::Shared:
|
||||||
case Svc::MemoryState::AliasCode:
|
case KMemoryState::AliasCode:
|
||||||
case Svc::MemoryState::AliasCodeData:
|
case KMemoryState::AliasCodeData:
|
||||||
case Svc::MemoryState::Stack:
|
case KMemoryState::Stack:
|
||||||
case Svc::MemoryState::ThreadLocal:
|
case KMemoryState::ThreadLocal:
|
||||||
case Svc::MemoryState::Transfered:
|
case KMemoryState::Transfered:
|
||||||
case Svc::MemoryState::SharedTransfered:
|
case KMemoryState::SharedTransfered:
|
||||||
case Svc::MemoryState::SharedCode:
|
case KMemoryState::SharedCode:
|
||||||
case Svc::MemoryState::GeneratedCode:
|
case KMemoryState::GeneratedCode:
|
||||||
case Svc::MemoryState::CodeOut:
|
case KMemoryState::CodeOut:
|
||||||
case Svc::MemoryState::Coverage:
|
case KMemoryState::Coverage:
|
||||||
case Svc::MemoryState::Insecure:
|
case KMemoryState::Insecure:
|
||||||
return is_in_region && !is_in_heap && !is_in_alias;
|
return is_in_region && !is_in_heap && !is_in_alias;
|
||||||
case Svc::MemoryState::Normal:
|
case KMemoryState::Normal:
|
||||||
ASSERT(is_in_heap);
|
ASSERT(is_in_heap);
|
||||||
return is_in_region && !is_in_alias;
|
return is_in_region && !is_in_alias;
|
||||||
case Svc::MemoryState::Ipc:
|
case KMemoryState::Ipc:
|
||||||
case Svc::MemoryState::NonSecureIpc:
|
case KMemoryState::NonSecureIpc:
|
||||||
case Svc::MemoryState::NonDeviceIpc:
|
case KMemoryState::NonDeviceIpc:
|
||||||
ASSERT(is_in_alias);
|
ASSERT(is_in_alias);
|
||||||
return is_in_region && !is_in_heap;
|
return is_in_region && !is_in_heap;
|
||||||
default:
|
default:
|
||||||
@ -3308,16 +3281,21 @@ Result KPageTable::CheckMemoryStateContiguous(size_t* out_blocks_needed, KProces
|
|||||||
|
|
||||||
Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
|
Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
|
||||||
KMemoryAttribute* out_attr, size_t* out_blocks_needed,
|
KMemoryAttribute* out_attr, size_t* out_blocks_needed,
|
||||||
KMemoryBlockManager::const_iterator it,
|
KProcessAddress addr, size_t size, KMemoryState state_mask,
|
||||||
KProcessAddress last_addr, KMemoryState state_mask,
|
|
||||||
KMemoryState state, KMemoryPermission perm_mask,
|
KMemoryState state, KMemoryPermission perm_mask,
|
||||||
KMemoryPermission perm, KMemoryAttribute attr_mask,
|
KMemoryPermission perm, KMemoryAttribute attr_mask,
|
||||||
KMemoryAttribute attr, KMemoryAttribute ignore_attr) const {
|
KMemoryAttribute attr, KMemoryAttribute ignore_attr) const {
|
||||||
ASSERT(this->IsLockedByCurrentThread());
|
ASSERT(this->IsLockedByCurrentThread());
|
||||||
|
|
||||||
// Get information about the first block.
|
// Get information about the first block.
|
||||||
|
const KProcessAddress last_addr = addr + size - 1;
|
||||||
|
KMemoryBlockManager::const_iterator it = m_memory_block_manager.FindIterator(addr);
|
||||||
KMemoryInfo info = it->GetMemoryInfo();
|
KMemoryInfo info = it->GetMemoryInfo();
|
||||||
|
|
||||||
|
// If the start address isn't aligned, we need a block.
|
||||||
|
const size_t blocks_for_start_align =
|
||||||
|
(Common::AlignDown(GetInteger(addr), PageSize) != info.GetAddress()) ? 1 : 0;
|
||||||
|
|
||||||
// Validate all blocks in the range have correct state.
|
// Validate all blocks in the range have correct state.
|
||||||
const KMemoryState first_state = info.m_state;
|
const KMemoryState first_state = info.m_state;
|
||||||
const KMemoryPermission first_perm = info.m_permission;
|
const KMemoryPermission first_perm = info.m_permission;
|
||||||
@ -3343,6 +3321,10 @@ Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission*
|
|||||||
info = it->GetMemoryInfo();
|
info = it->GetMemoryInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the end address isn't aligned, we need a block.
|
||||||
|
const size_t blocks_for_end_align =
|
||||||
|
(Common::AlignUp(GetInteger(addr) + size, PageSize) != info.GetEndAddress()) ? 1 : 0;
|
||||||
|
|
||||||
// Write output state.
|
// Write output state.
|
||||||
if (out_state != nullptr) {
|
if (out_state != nullptr) {
|
||||||
*out_state = first_state;
|
*out_state = first_state;
|
||||||
@ -3353,39 +3335,9 @@ Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission*
|
|||||||
if (out_attr != nullptr) {
|
if (out_attr != nullptr) {
|
||||||
*out_attr = static_cast<KMemoryAttribute>(first_attr & ~ignore_attr);
|
*out_attr = static_cast<KMemoryAttribute>(first_attr & ~ignore_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the end address isn't aligned, we need a block.
|
|
||||||
if (out_blocks_needed != nullptr) {
|
if (out_blocks_needed != nullptr) {
|
||||||
const size_t blocks_for_end_align =
|
*out_blocks_needed = blocks_for_start_align + blocks_for_end_align;
|
||||||
(Common::AlignDown(GetInteger(last_addr), PageSize) + PageSize != info.GetEndAddress())
|
|
||||||
? 1
|
|
||||||
: 0;
|
|
||||||
*out_blocks_needed = blocks_for_end_align;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SUCCEED();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
|
|
||||||
KMemoryAttribute* out_attr, size_t* out_blocks_needed,
|
|
||||||
KProcessAddress addr, size_t size, KMemoryState state_mask,
|
|
||||||
KMemoryState state, KMemoryPermission perm_mask,
|
|
||||||
KMemoryPermission perm, KMemoryAttribute attr_mask,
|
|
||||||
KMemoryAttribute attr, KMemoryAttribute ignore_attr) const {
|
|
||||||
ASSERT(this->IsLockedByCurrentThread());
|
|
||||||
|
|
||||||
// Check memory state.
|
|
||||||
const KProcessAddress last_addr = addr + size - 1;
|
|
||||||
KMemoryBlockManager::const_iterator it = m_memory_block_manager.FindIterator(addr);
|
|
||||||
R_TRY(this->CheckMemoryState(out_state, out_perm, out_attr, out_blocks_needed, it, last_addr,
|
|
||||||
state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr));
|
|
||||||
|
|
||||||
// If the start address isn't aligned, we need a block.
|
|
||||||
if (out_blocks_needed != nullptr &&
|
|
||||||
Common::AlignDown(GetInteger(addr), PageSize) != it->GetAddress()) {
|
|
||||||
++(*out_blocks_needed);
|
|
||||||
}
|
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,8 @@ public:
|
|||||||
return m_block_info_manager;
|
return m_block_info_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CanContain(KProcessAddress addr, size_t size, KMemoryState state) const;
|
||||||
|
|
||||||
Result MapPages(KProcessAddress* out_addr, size_t num_pages, size_t alignment,
|
Result MapPages(KProcessAddress* out_addr, size_t num_pages, size_t alignment,
|
||||||
KPhysicalAddress phys_addr, KProcessAddress region_start,
|
KPhysicalAddress phys_addr, KProcessAddress region_start,
|
||||||
size_t region_num_pages, KMemoryState state, KMemoryPermission perm) {
|
size_t region_num_pages, KMemoryState state, KMemoryPermission perm) {
|
||||||
@ -160,21 +162,6 @@ public:
|
|||||||
void RemapPageGroup(PageLinkedList* page_list, KProcessAddress address, size_t size,
|
void RemapPageGroup(PageLinkedList* page_list, KProcessAddress address, size_t size,
|
||||||
const KPageGroup& pg);
|
const KPageGroup& pg);
|
||||||
|
|
||||||
KProcessAddress GetRegionAddress(Svc::MemoryState state) const;
|
|
||||||
size_t GetRegionSize(Svc::MemoryState state) const;
|
|
||||||
bool CanContain(KProcessAddress addr, size_t size, Svc::MemoryState state) const;
|
|
||||||
|
|
||||||
KProcessAddress GetRegionAddress(KMemoryState state) const {
|
|
||||||
return this->GetRegionAddress(static_cast<Svc::MemoryState>(state & KMemoryState::Mask));
|
|
||||||
}
|
|
||||||
size_t GetRegionSize(KMemoryState state) const {
|
|
||||||
return this->GetRegionSize(static_cast<Svc::MemoryState>(state & KMemoryState::Mask));
|
|
||||||
}
|
|
||||||
bool CanContain(KProcessAddress addr, size_t size, KMemoryState state) const {
|
|
||||||
return this->CanContain(addr, size,
|
|
||||||
static_cast<Svc::MemoryState>(state & KMemoryState::Mask));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct PageLinkedList {
|
struct PageLinkedList {
|
||||||
private:
|
private:
|
||||||
@ -217,13 +204,12 @@ protected:
|
|||||||
private:
|
private:
|
||||||
enum class OperationType : u32 {
|
enum class OperationType : u32 {
|
||||||
Map = 0,
|
Map = 0,
|
||||||
MapGroup = 1,
|
MapFirst = 1,
|
||||||
MapFirstGroup = 2,
|
MapGroup = 2,
|
||||||
Unmap = 3,
|
Unmap = 3,
|
||||||
ChangePermissions = 4,
|
ChangePermissions = 4,
|
||||||
ChangePermissionsAndRefresh = 5,
|
ChangePermissionsAndRefresh = 5,
|
||||||
ChangePermissionsAndRefreshAndFlush = 6,
|
Separate = 6,
|
||||||
Separate = 7,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr KMemoryAttribute DefaultMemoryIgnoreAttr =
|
static constexpr KMemoryAttribute DefaultMemoryIgnoreAttr =
|
||||||
@ -242,6 +228,8 @@ private:
|
|||||||
Result Operate(KProcessAddress addr, size_t num_pages, KMemoryPermission perm,
|
Result Operate(KProcessAddress addr, size_t num_pages, KMemoryPermission perm,
|
||||||
OperationType operation, KPhysicalAddress map_addr = 0);
|
OperationType operation, KPhysicalAddress map_addr = 0);
|
||||||
void FinalizeUpdate(PageLinkedList* page_list);
|
void FinalizeUpdate(PageLinkedList* page_list);
|
||||||
|
KProcessAddress GetRegionAddress(KMemoryState state) const;
|
||||||
|
size_t GetRegionSize(KMemoryState state) const;
|
||||||
|
|
||||||
KProcessAddress FindFreeArea(KProcessAddress region_start, size_t region_num_pages,
|
KProcessAddress FindFreeArea(KProcessAddress region_start, size_t region_num_pages,
|
||||||
size_t num_pages, size_t alignment, size_t offset,
|
size_t num_pages, size_t alignment, size_t offset,
|
||||||
@ -262,13 +250,6 @@ private:
|
|||||||
Result CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, KMemoryState state,
|
Result CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, KMemoryState state,
|
||||||
KMemoryPermission perm_mask, KMemoryPermission perm,
|
KMemoryPermission perm_mask, KMemoryPermission perm,
|
||||||
KMemoryAttribute attr_mask, KMemoryAttribute attr) const;
|
KMemoryAttribute attr_mask, KMemoryAttribute attr) const;
|
||||||
Result CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
|
|
||||||
KMemoryAttribute* out_attr, size_t* out_blocks_needed,
|
|
||||||
KMemoryBlockManager::const_iterator it, KProcessAddress last_addr,
|
|
||||||
KMemoryState state_mask, KMemoryState state,
|
|
||||||
KMemoryPermission perm_mask, KMemoryPermission perm,
|
|
||||||
KMemoryAttribute attr_mask, KMemoryAttribute attr,
|
|
||||||
KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const;
|
|
||||||
Result CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
|
Result CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
|
||||||
KMemoryAttribute* out_attr, size_t* out_blocks_needed,
|
KMemoryAttribute* out_attr, size_t* out_blocks_needed,
|
||||||
KProcessAddress addr, size_t size, KMemoryState state_mask,
|
KProcessAddress addr, size_t size, KMemoryState state_mask,
|
||||||
|
@ -149,7 +149,7 @@ u64 KProcess::GetTotalPhysicalMemoryUsed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u64 KProcess::GetTotalPhysicalMemoryUsedWithoutSystemResource() {
|
u64 KProcess::GetTotalPhysicalMemoryUsedWithoutSystemResource() {
|
||||||
return this->GetTotalPhysicalMemoryUsed() - this->GetSystemResourceSize();
|
return this->GetTotalPhysicalMemoryUsed() - this->GetSystemResourceUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KProcess::ReleaseUserException(KThread* thread) {
|
bool KProcess::ReleaseUserException(KThread* thread) {
|
||||||
|
@ -623,33 +623,14 @@ struct KernelCore::Impl {
|
|||||||
ASSERT(memory_layout->GetPhysicalMemoryRegionTree().Insert(
|
ASSERT(memory_layout->GetPhysicalMemoryRegionTree().Insert(
|
||||||
GetInteger(slab_start_phys_addr), slab_region_size, KMemoryRegionType_DramKernelSlab));
|
GetInteger(slab_start_phys_addr), slab_region_size, KMemoryRegionType_DramKernelSlab));
|
||||||
|
|
||||||
// Insert a physical region for the secure applet memory.
|
|
||||||
const auto secure_applet_end_phys_addr =
|
|
||||||
slab_end_phys_addr + KSystemControl::SecureAppletMemorySize;
|
|
||||||
if constexpr (KSystemControl::SecureAppletMemorySize > 0) {
|
|
||||||
ASSERT(memory_layout->GetPhysicalMemoryRegionTree().Insert(
|
|
||||||
GetInteger(slab_end_phys_addr), KSystemControl::SecureAppletMemorySize,
|
|
||||||
KMemoryRegionType_DramKernelSecureAppletMemory));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert a physical region for the unknown debug2 region.
|
|
||||||
constexpr size_t SecureUnknownRegionSize = 0;
|
|
||||||
const size_t secure_unknown_size = SecureUnknownRegionSize;
|
|
||||||
const auto secure_unknown_end_phys_addr = secure_applet_end_phys_addr + secure_unknown_size;
|
|
||||||
if constexpr (SecureUnknownRegionSize > 0) {
|
|
||||||
ASSERT(memory_layout->GetPhysicalMemoryRegionTree().Insert(
|
|
||||||
GetInteger(secure_applet_end_phys_addr), secure_unknown_size,
|
|
||||||
KMemoryRegionType_DramKernelSecureUnknown));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine size available for kernel page table heaps, requiring > 8 MB.
|
// Determine size available for kernel page table heaps, requiring > 8 MB.
|
||||||
const KPhysicalAddress resource_end_phys_addr = slab_start_phys_addr + resource_region_size;
|
const KPhysicalAddress resource_end_phys_addr = slab_start_phys_addr + resource_region_size;
|
||||||
const size_t page_table_heap_size = resource_end_phys_addr - secure_unknown_end_phys_addr;
|
const size_t page_table_heap_size = resource_end_phys_addr - slab_end_phys_addr;
|
||||||
ASSERT(page_table_heap_size / 4_MiB > 2);
|
ASSERT(page_table_heap_size / 4_MiB > 2);
|
||||||
|
|
||||||
// Insert a physical region for the kernel page table heap region
|
// Insert a physical region for the kernel page table heap region
|
||||||
ASSERT(memory_layout->GetPhysicalMemoryRegionTree().Insert(
|
ASSERT(memory_layout->GetPhysicalMemoryRegionTree().Insert(
|
||||||
GetInteger(secure_unknown_end_phys_addr), page_table_heap_size,
|
GetInteger(slab_end_phys_addr), page_table_heap_size,
|
||||||
KMemoryRegionType_DramKernelPtHeap));
|
KMemoryRegionType_DramKernelPtHeap));
|
||||||
|
|
||||||
// All DRAM regions that we haven't tagged by this point will be mapped under the linear
|
// All DRAM regions that we haven't tagged by this point will be mapped under the linear
|
||||||
|
@ -76,7 +76,7 @@ Result MapUnmapMemorySanityChecks(const KPageTable& manager, u64 dst_addr, u64 s
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Result SetMemoryPermission(Core::System& system, u64 address, u64 size, MemoryPermission perm) {
|
Result SetMemoryPermission(Core::System& system, u64 address, u64 size, MemoryPermission perm) {
|
||||||
LOG_DEBUG(Kernel_SVC, "called, address=0x{:016X}, size=0x{:X}, perm=0x{:08X}", address, size,
|
LOG_DEBUG(Kernel_SVC, "called, address=0x{:016X}, size=0x{:X}, perm=0x{:08X", address, size,
|
||||||
perm);
|
perm);
|
||||||
|
|
||||||
// Validate address / size.
|
// Validate address / size.
|
||||||
@ -108,16 +108,10 @@ Result SetMemoryAttribute(Core::System& system, u64 address, u64 size, u32 mask,
|
|||||||
R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
|
R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
|
||||||
|
|
||||||
// Validate the attribute and mask.
|
// Validate the attribute and mask.
|
||||||
constexpr u32 SupportedMask =
|
constexpr u32 SupportedMask = static_cast<u32>(MemoryAttribute::Uncached);
|
||||||
static_cast<u32>(MemoryAttribute::Uncached | MemoryAttribute::PermissionLocked);
|
|
||||||
R_UNLESS((mask | attr) == mask, ResultInvalidCombination);
|
R_UNLESS((mask | attr) == mask, ResultInvalidCombination);
|
||||||
R_UNLESS((mask | attr | SupportedMask) == SupportedMask, ResultInvalidCombination);
|
R_UNLESS((mask | attr | SupportedMask) == SupportedMask, ResultInvalidCombination);
|
||||||
|
|
||||||
// Check that permission locked is either being set or not masked.
|
|
||||||
R_UNLESS((static_cast<Svc::MemoryAttribute>(mask) & Svc::MemoryAttribute::PermissionLocked) ==
|
|
||||||
(static_cast<Svc::MemoryAttribute>(attr) & Svc::MemoryAttribute::PermissionLocked),
|
|
||||||
ResultInvalidCombination);
|
|
||||||
|
|
||||||
// Validate that the region is in range for the current process.
|
// Validate that the region is in range for the current process.
|
||||||
auto& page_table{GetCurrentProcess(system.Kernel()).GetPageTable()};
|
auto& page_table{GetCurrentProcess(system.Kernel()).GetPageTable()};
|
||||||
R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
|
R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
|
||||||
|
@ -46,7 +46,6 @@ enum class MemoryAttribute : u32 {
|
|||||||
IpcLocked = (1 << 1),
|
IpcLocked = (1 << 1),
|
||||||
DeviceShared = (1 << 2),
|
DeviceShared = (1 << 2),
|
||||||
Uncached = (1 << 3),
|
Uncached = (1 << 3),
|
||||||
PermissionLocked = (1 << 4),
|
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(MemoryAttribute);
|
DECLARE_ENUM_FLAG_OPERATORS(MemoryAttribute);
|
||||||
|
|
||||||
|
@ -27,12 +27,10 @@ namespace {
|
|||||||
static thread_local std::array read_buffer_data_a{
|
static thread_local std::array read_buffer_data_a{
|
||||||
Common::ScratchBuffer<u8>(),
|
Common::ScratchBuffer<u8>(),
|
||||||
Common::ScratchBuffer<u8>(),
|
Common::ScratchBuffer<u8>(),
|
||||||
Common::ScratchBuffer<u8>(),
|
|
||||||
};
|
};
|
||||||
static thread_local std::array read_buffer_data_x{
|
static thread_local std::array read_buffer_data_x{
|
||||||
Common::ScratchBuffer<u8>(),
|
Common::ScratchBuffer<u8>(),
|
||||||
Common::ScratchBuffer<u8>(),
|
Common::ScratchBuffer<u8>(),
|
||||||
Common::ScratchBuffer<u8>(),
|
|
||||||
};
|
};
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
@ -345,7 +343,6 @@ std::span<const u8> HLERequestContext::ReadBufferA(std::size_t buffer_index) con
|
|||||||
static thread_local std::array read_buffer_a{
|
static thread_local std::array read_buffer_a{
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_OR_EXECUTE_MSG(
|
ASSERT_OR_EXECUTE_MSG(
|
||||||
@ -361,7 +358,6 @@ std::span<const u8> HLERequestContext::ReadBufferX(std::size_t buffer_index) con
|
|||||||
static thread_local std::array read_buffer_x{
|
static thread_local std::array read_buffer_x{
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_OR_EXECUTE_MSG(
|
ASSERT_OR_EXECUTE_MSG(
|
||||||
@ -377,12 +373,10 @@ std::span<const u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) cons
|
|||||||
static thread_local std::array read_buffer_a{
|
static thread_local std::array read_buffer_a{
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
|
||||||
};
|
};
|
||||||
static thread_local std::array read_buffer_x{
|
static thread_local std::array read_buffer_x{
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
||||||
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::SafeRead>(memory, 0, 0),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
|
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
|
||||||
|
@ -41,7 +41,6 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDefault();
|
|
||||||
SetGender(gender);
|
SetGender(gender);
|
||||||
SetFavoriteColor(MiiUtil::GetRandomValue(FavoriteColor::Max));
|
SetFavoriteColor(MiiUtil::GetRandomValue(FavoriteColor::Max));
|
||||||
SetRegionMove(0);
|
SetRegionMove(0);
|
||||||
|
@ -41,7 +41,7 @@ bool BufferQueueCore::WaitForDequeueCondition(std::unique_lock<std::mutex>& lk)
|
|||||||
s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
|
s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
|
||||||
// If DequeueBuffer is allowed to error out, we don't have to add an extra buffer.
|
// If DequeueBuffer is allowed to error out, we don't have to add an extra buffer.
|
||||||
if (!use_async_buffer) {
|
if (!use_async_buffer) {
|
||||||
return 0;
|
return max_acquired_buffer_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dequeue_buffer_cannot_block || async) {
|
if (dequeue_buffer_cannot_block || async) {
|
||||||
@ -52,7 +52,7 @@ s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 BufferQueueCore::GetMinMaxBufferCountLocked(bool async) const {
|
s32 BufferQueueCore::GetMinMaxBufferCountLocked(bool async) const {
|
||||||
return GetMinUndequeuedBufferCountLocked(async);
|
return GetMinUndequeuedBufferCountLocked(async) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
|
s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
|
||||||
@ -61,7 +61,7 @@ s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
|
|||||||
|
|
||||||
if (override_max_buffer_count != 0) {
|
if (override_max_buffer_count != 0) {
|
||||||
ASSERT(override_max_buffer_count >= min_buffer_count);
|
ASSERT(override_max_buffer_count >= min_buffer_count);
|
||||||
return override_max_buffer_count;
|
max_buffer_count = override_max_buffer_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any buffers that are dequeued by the producer or sitting in the queue waiting to be consumed
|
// Any buffers that are dequeued by the producer or sitting in the queue waiting to be consumed
|
||||||
|
@ -134,7 +134,7 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St
|
|||||||
const s32 max_buffer_count = core->GetMaxBufferCountLocked(async);
|
const s32 max_buffer_count = core->GetMaxBufferCountLocked(async);
|
||||||
if (async && core->override_max_buffer_count) {
|
if (async && core->override_max_buffer_count) {
|
||||||
if (core->override_max_buffer_count < max_buffer_count) {
|
if (core->override_max_buffer_count < max_buffer_count) {
|
||||||
*found = BufferQueueCore::INVALID_BUFFER_SLOT;
|
LOG_ERROR(Service_Nvnflinger, "async mode is invalid with buffer count override");
|
||||||
return Status::BadValue;
|
return Status::BadValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,8 +142,7 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St
|
|||||||
// Free up any buffers that are in slots beyond the max buffer count
|
// Free up any buffers that are in slots beyond the max buffer count
|
||||||
for (s32 s = max_buffer_count; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
|
for (s32 s = max_buffer_count; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
|
||||||
ASSERT(slots[s].buffer_state == BufferState::Free);
|
ASSERT(slots[s].buffer_state == BufferState::Free);
|
||||||
if (slots[s].graphic_buffer != nullptr && slots[s].buffer_state == BufferState::Free &&
|
if (slots[s].graphic_buffer != nullptr) {
|
||||||
!slots[s].is_preallocated) {
|
|
||||||
core->FreeBufferLocked(s);
|
core->FreeBufferLocked(s);
|
||||||
*return_flags |= Status::ReleaseAllBuffers;
|
*return_flags |= Status::ReleaseAllBuffers;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ Result AllocateIoForProcessAddressSpace(Common::ProcessAddress* out_map_address,
|
|||||||
// Get bounds of where mapping is possible.
|
// Get bounds of where mapping is possible.
|
||||||
const VAddr alias_code_begin = GetInteger(page_table.GetAliasCodeRegionStart());
|
const VAddr alias_code_begin = GetInteger(page_table.GetAliasCodeRegionStart());
|
||||||
const VAddr alias_code_size = page_table.GetAliasCodeRegionSize() / YUZU_PAGESIZE;
|
const VAddr alias_code_size = page_table.GetAliasCodeRegionSize() / YUZU_PAGESIZE;
|
||||||
const auto state = Kernel::KMemoryState::IoMemory;
|
const auto state = Kernel::KMemoryState::Io;
|
||||||
const auto perm = Kernel::KMemoryPermission::UserReadWrite;
|
const auto perm = Kernel::KMemoryPermission::UserReadWrite;
|
||||||
std::mt19937_64 rng{process->GetRandomEntropy(0)};
|
std::mt19937_64 rng{process->GetRandomEntropy(0)};
|
||||||
|
|
||||||
|
@ -9,35 +9,6 @@
|
|||||||
|
|
||||||
namespace Service::PTM {
|
namespace Service::PTM {
|
||||||
|
|
||||||
enum class Location : u8 {
|
|
||||||
Internal,
|
|
||||||
External,
|
|
||||||
};
|
|
||||||
|
|
||||||
class ISession : public ServiceFramework<ISession> {
|
|
||||||
public:
|
|
||||||
explicit ISession(Core::System& system_) : ServiceFramework{system_, "ISession"} {
|
|
||||||
// clang-format off
|
|
||||||
static const FunctionInfo functions[] = {
|
|
||||||
{0, nullptr, "GetTemperatureRange"},
|
|
||||||
{2, nullptr, "SetMeasurementMode"},
|
|
||||||
{4, &ISession::GetTemperature, "GetTemperature"},
|
|
||||||
};
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
RegisterHandlers(functions);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void GetTemperature(HLERequestContext& ctx) {
|
|
||||||
constexpr f32 temperature = 35;
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push(temperature);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} {
|
TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -45,7 +16,7 @@ TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} {
|
|||||||
{1, &TS::GetTemperature, "GetTemperature"},
|
{1, &TS::GetTemperature, "GetTemperature"},
|
||||||
{2, nullptr, "SetMeasurementMode"},
|
{2, nullptr, "SetMeasurementMode"},
|
||||||
{3, &TS::GetTemperatureMilliC, "GetTemperatureMilliC"},
|
{3, &TS::GetTemperatureMilliC, "GetTemperatureMilliC"},
|
||||||
{4, &TS::OpenSession, "OpenSession"},
|
{4, nullptr, "OpenSession"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
@ -76,13 +47,4 @@ void TS::GetTemperatureMilliC(HLERequestContext& ctx) {
|
|||||||
rb.Push(temperature);
|
rb.Push(temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TS::OpenSession(HLERequestContext& ctx) {
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
[[maybe_unused]] const u32 device_code = rp.Pop<u32>();
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushIpcInterface<ISession>(system);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Service::PTM
|
} // namespace Service::PTM
|
||||||
|
@ -14,9 +14,13 @@ public:
|
|||||||
~TS() override;
|
~TS() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum class Location : u8 {
|
||||||
|
Internal,
|
||||||
|
External,
|
||||||
|
};
|
||||||
|
|
||||||
void GetTemperature(HLERequestContext& ctx);
|
void GetTemperature(HLERequestContext& ctx);
|
||||||
void GetTemperatureMilliC(HLERequestContext& ctx);
|
void GetTemperatureMilliC(HLERequestContext& ctx);
|
||||||
void OpenSession(HLERequestContext& ctx);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::PTM
|
} // namespace Service::PTM
|
||||||
|
@ -5,13 +5,8 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/core.h"
|
|
||||||
#include "core/file_sys/content_archive.h"
|
|
||||||
#include "core/file_sys/errors.h"
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/file_sys/nca_metadata.h"
|
#include "core/file_sys/system_archive/system_version.h"
|
||||||
#include "core/file_sys/registered_cache.h"
|
|
||||||
#include "core/file_sys/romfs.h"
|
|
||||||
#include "core/file_sys/system_archive/system_archive.h"
|
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
#include "core/hle/service/set/set.h"
|
#include "core/hle/service/set/set.h"
|
||||||
@ -27,30 +22,18 @@ enum class GetFirmwareVersionType {
|
|||||||
Version2,
|
Version2,
|
||||||
};
|
};
|
||||||
|
|
||||||
void GetFirmwareVersionImpl(Core::System& system, HLERequestContext& ctx,
|
void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type) {
|
||||||
GetFirmwareVersionType type) {
|
LOG_WARNING(Service_SET, "called - Using hardcoded firmware version '{}'",
|
||||||
|
FileSys::SystemArchive::GetLongDisplayVersion());
|
||||||
|
|
||||||
ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100,
|
ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100,
|
||||||
"FirmwareVersion output buffer must be 0x100 bytes in size!");
|
"FirmwareVersion output buffer must be 0x100 bytes in size!");
|
||||||
|
|
||||||
constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809;
|
// Instead of using the normal procedure of checking for the real system archive and if it
|
||||||
auto& fsc = system.GetFileSystemController();
|
// doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a
|
||||||
|
// used is using a really old or really new SystemVersion title. The synthesized one ensures
|
||||||
// Attempt to load version data from disk
|
// consistence (currently reports as 5.1.0-0.0)
|
||||||
const FileSys::RegisteredCache* bis_system{};
|
const auto archive = FileSys::SystemArchive::SystemVersion();
|
||||||
std::unique_ptr<FileSys::NCA> nca{};
|
|
||||||
FileSys::VirtualDir romfs{};
|
|
||||||
|
|
||||||
bis_system = fsc.GetSystemNANDContents();
|
|
||||||
if (bis_system) {
|
|
||||||
nca = bis_system->GetEntry(FirmwareVersionSystemDataId, FileSys::ContentRecordType::Data);
|
|
||||||
}
|
|
||||||
if (nca) {
|
|
||||||
romfs = FileSys::ExtractRomFS(nca->GetRomFS());
|
|
||||||
}
|
|
||||||
if (!romfs) {
|
|
||||||
romfs = FileSys::ExtractRomFS(
|
|
||||||
FileSys::SystemArchive::SynthesizeSystemArchive(FirmwareVersionSystemDataId));
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto early_exit_failure = [&ctx](std::string_view desc, Result code) {
|
const auto early_exit_failure = [&ctx](std::string_view desc, Result code) {
|
||||||
LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).",
|
LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).",
|
||||||
@ -59,7 +42,13 @@ void GetFirmwareVersionImpl(Core::System& system, HLERequestContext& ctx,
|
|||||||
rb.Push(code);
|
rb.Push(code);
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto ver_file = romfs->GetFile("file");
|
if (archive == nullptr) {
|
||||||
|
early_exit_failure("The system version archive couldn't be synthesized.",
|
||||||
|
FileSys::ERROR_FAILED_MOUNT_ARCHIVE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ver_file = archive->GetFile("file");
|
||||||
if (ver_file == nullptr) {
|
if (ver_file == nullptr) {
|
||||||
early_exit_failure("The system version archive didn't contain the file 'file'.",
|
early_exit_failure("The system version archive didn't contain the file 'file'.",
|
||||||
FileSys::ERROR_INVALID_ARGUMENT);
|
FileSys::ERROR_INVALID_ARGUMENT);
|
||||||
@ -98,12 +87,12 @@ void SET_SYS::SetLanguageCode(HLERequestContext& ctx) {
|
|||||||
|
|
||||||
void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) {
|
void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_SET, "called");
|
LOG_DEBUG(Service_SET, "called");
|
||||||
GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version1);
|
GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) {
|
void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_SET, "called");
|
LOG_DEBUG(Service_SET, "called");
|
||||||
GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version2);
|
GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SET_SYS::GetAccountSettings(HLERequestContext& ctx) {
|
void SET_SYS::GetAccountSettings(HLERequestContext& ctx) {
|
||||||
|
@ -19,23 +19,16 @@ namespace Core::Memory {
|
|||||||
namespace {
|
namespace {
|
||||||
constexpr auto CHEAT_ENGINE_NS = std::chrono::nanoseconds{1000000000 / 12};
|
constexpr auto CHEAT_ENGINE_NS = std::chrono::nanoseconds{1000000000 / 12};
|
||||||
|
|
||||||
std::string_view ExtractName(std::size_t& out_name_size, std::string_view data,
|
std::string_view ExtractName(std::string_view data, std::size_t start_index, char match) {
|
||||||
std::size_t start_index, char match) {
|
|
||||||
auto end_index = start_index;
|
auto end_index = start_index;
|
||||||
while (data[end_index] != match) {
|
while (data[end_index] != match) {
|
||||||
++end_index;
|
++end_index;
|
||||||
if (end_index > data.size()) {
|
if (end_index > data.size() ||
|
||||||
|
(end_index - start_index - 1) > sizeof(CheatDefinition::readable_name)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out_name_size = end_index - start_index;
|
|
||||||
|
|
||||||
// Clamp name if it's too big
|
|
||||||
if (out_name_size > sizeof(CheatDefinition::readable_name)) {
|
|
||||||
end_index = start_index + sizeof(CheatDefinition::readable_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data.substr(start_index, end_index - start_index);
|
return data.substr(start_index, end_index - start_index);
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
@ -120,8 +113,7 @@ std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t name_size{};
|
const auto name = ExtractName(data, i + 1, '}');
|
||||||
const auto name = ExtractName(name_size, data, i + 1, '}');
|
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -133,13 +125,12 @@ std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const {
|
|||||||
.definition.readable_name[out[*current_entry].definition.readable_name.size() - 1] =
|
.definition.readable_name[out[*current_entry].definition.readable_name.size() - 1] =
|
||||||
'\0';
|
'\0';
|
||||||
|
|
||||||
i += name_size + 1;
|
i += name.length() + 1;
|
||||||
} else if (data[i] == '[') {
|
} else if (data[i] == '[') {
|
||||||
current_entry = out.size();
|
current_entry = out.size();
|
||||||
out.emplace_back();
|
out.emplace_back();
|
||||||
|
|
||||||
std::size_t name_size{};
|
const auto name = ExtractName(data, i + 1, ']');
|
||||||
const auto name = ExtractName(name_size, data, i + 1, ']');
|
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -151,7 +142,7 @@ std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const {
|
|||||||
.definition.readable_name[out[*current_entry].definition.readable_name.size() - 1] =
|
.definition.readable_name[out[*current_entry].definition.readable_name.size() - 1] =
|
||||||
'\0';
|
'\0';
|
||||||
|
|
||||||
i += name_size + 1;
|
i += name.length() + 1;
|
||||||
} else if (::isxdigit(data[i])) {
|
} else if (::isxdigit(data[i])) {
|
||||||
if (!current_entry || out[*current_entry].definition.num_opcodes >=
|
if (!current_entry || out[*current_entry].definition.num_opcodes >=
|
||||||
out[*current_entry].definition.opcodes.size()) {
|
out[*current_entry].definition.opcodes.size()) {
|
||||||
|
@ -242,7 +242,6 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR
|
|||||||
}
|
}
|
||||||
if (program.info.uses_subgroup_shuffles) {
|
if (program.info.uses_subgroup_shuffles) {
|
||||||
ctx.header += "bool shfl_in_bounds;";
|
ctx.header += "bool shfl_in_bounds;";
|
||||||
ctx.header += "uint shfl_result;";
|
|
||||||
}
|
}
|
||||||
ctx.code.insert(0, ctx.header);
|
ctx.code.insert(0, ctx.header);
|
||||||
ctx.code += '}';
|
ctx.code += '}';
|
||||||
|
@ -141,8 +141,7 @@ void EmitShuffleIndex(EmitContext& ctx, IR::Inst& inst, std::string_view value,
|
|||||||
const auto src_thread_id{fmt::format("({})|({})", lhs, min_thread_id)};
|
const auto src_thread_id{fmt::format("({})|({})", lhs, min_thread_id)};
|
||||||
ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
|
ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
|
||||||
SetInBoundsFlag(ctx, inst);
|
SetInBoundsFlag(ctx, inst);
|
||||||
ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
|
ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
|
||||||
ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index,
|
void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index,
|
||||||
@ -159,8 +158,7 @@ void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std
|
|||||||
const auto src_thread_id{fmt::format("({}-{})", THREAD_ID, index)};
|
const auto src_thread_id{fmt::format("({}-{})", THREAD_ID, index)};
|
||||||
ctx.Add("shfl_in_bounds=int({})>=int({});", src_thread_id, max_thread_id);
|
ctx.Add("shfl_in_bounds=int({})>=int({});", src_thread_id, max_thread_id);
|
||||||
SetInBoundsFlag(ctx, inst);
|
SetInBoundsFlag(ctx, inst);
|
||||||
ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
|
ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
|
||||||
ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
|
void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
|
||||||
@ -177,8 +175,7 @@ void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
|
|||||||
const auto src_thread_id{fmt::format("({}+{})", THREAD_ID, index)};
|
const auto src_thread_id{fmt::format("({}+{})", THREAD_ID, index)};
|
||||||
ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
|
ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
|
||||||
SetInBoundsFlag(ctx, inst);
|
SetInBoundsFlag(ctx, inst);
|
||||||
ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
|
ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
|
||||||
ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value,
|
void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value,
|
||||||
@ -196,8 +193,7 @@ void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view val
|
|||||||
const auto src_thread_id{fmt::format("({}^{})", THREAD_ID, index)};
|
const auto src_thread_id{fmt::format("({}^{})", THREAD_ID, index)};
|
||||||
ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
|
ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
|
||||||
SetInBoundsFlag(ctx, inst);
|
SetInBoundsFlag(ctx, inst);
|
||||||
ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
|
ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
|
||||||
ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, std::string_view op_a, std::string_view op_b,
|
void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, std::string_view op_a, std::string_view op_b,
|
||||||
|
@ -111,33 +111,16 @@ Id GetCbuf(EmitContext& ctx, Id result_type, Id UniformDefinitions::*member_ptr,
|
|||||||
} else if (element_size > 1) {
|
} else if (element_size > 1) {
|
||||||
const u32 log2_element_size{static_cast<u32>(std::countr_zero(element_size))};
|
const u32 log2_element_size{static_cast<u32>(std::countr_zero(element_size))};
|
||||||
const Id shift{ctx.Const(log2_element_size)};
|
const Id shift{ctx.Const(log2_element_size)};
|
||||||
buffer_offset = ctx.OpShiftRightLogical(ctx.U32[1], ctx.Def(offset), shift);
|
buffer_offset = ctx.OpShiftRightArithmetic(ctx.U32[1], ctx.Def(offset), shift);
|
||||||
} else {
|
} else {
|
||||||
buffer_offset = ctx.Def(offset);
|
buffer_offset = ctx.Def(offset);
|
||||||
}
|
}
|
||||||
if (!binding.IsImmediate()) {
|
if (!binding.IsImmediate()) {
|
||||||
return ctx.OpFunctionCall(result_type, indirect_func, ctx.Def(binding), buffer_offset);
|
return ctx.OpFunctionCall(result_type, indirect_func, ctx.Def(binding), buffer_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Id cbuf{ctx.cbufs[binding.U32()].*member_ptr};
|
const Id cbuf{ctx.cbufs[binding.U32()].*member_ptr};
|
||||||
const Id access_chain{ctx.OpAccessChain(uniform_type, cbuf, ctx.u32_zero_value, buffer_offset)};
|
const Id access_chain{ctx.OpAccessChain(uniform_type, cbuf, ctx.u32_zero_value, buffer_offset)};
|
||||||
const Id val = ctx.OpLoad(result_type, access_chain);
|
return ctx.OpLoad(result_type, access_chain);
|
||||||
|
|
||||||
if (offset.IsImmediate() || !ctx.profile.has_broken_robust) {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto is_float = UniformDefinitions::IsFloat(member_ptr);
|
|
||||||
const auto num_elements = UniformDefinitions::NumElements(member_ptr);
|
|
||||||
const std::array zero_vec{
|
|
||||||
is_float ? ctx.Const(0.0f) : ctx.Const(0u),
|
|
||||||
is_float ? ctx.Const(0.0f) : ctx.Const(0u),
|
|
||||||
is_float ? ctx.Const(0.0f) : ctx.Const(0u),
|
|
||||||
is_float ? ctx.Const(0.0f) : ctx.Const(0u),
|
|
||||||
};
|
|
||||||
const Id cond = ctx.OpULessThanEqual(ctx.TypeBool(), buffer_offset, ctx.Const(0xFFFFu));
|
|
||||||
const Id zero = ctx.OpCompositeConstruct(result_type, std::span(zero_vec.data(), num_elements));
|
|
||||||
return ctx.OpSelect(result_type, cond, val, zero);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Id GetCbufU32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset) {
|
Id GetCbufU32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset) {
|
||||||
@ -155,7 +138,7 @@ Id GetCbufElement(EmitContext& ctx, Id vector, const IR::Value& offset, u32 inde
|
|||||||
const u32 element{(offset.U32() / 4) % 4 + index_offset};
|
const u32 element{(offset.U32() / 4) % 4 + index_offset};
|
||||||
return ctx.OpCompositeExtract(ctx.U32[1], vector, element);
|
return ctx.OpCompositeExtract(ctx.U32[1], vector, element);
|
||||||
}
|
}
|
||||||
const Id shift{ctx.OpShiftRightLogical(ctx.U32[1], ctx.Def(offset), ctx.Const(2u))};
|
const Id shift{ctx.OpShiftRightArithmetic(ctx.U32[1], ctx.Def(offset), ctx.Const(2u))};
|
||||||
Id element{ctx.OpBitwiseAnd(ctx.U32[1], shift, ctx.Const(3u))};
|
Id element{ctx.OpBitwiseAnd(ctx.U32[1], shift, ctx.Const(3u))};
|
||||||
if (index_offset > 0) {
|
if (index_offset > 0) {
|
||||||
element = ctx.OpIAdd(ctx.U32[1], element, ctx.Const(index_offset));
|
element = ctx.OpIAdd(ctx.U32[1], element, ctx.Const(index_offset));
|
||||||
|
@ -64,42 +64,6 @@ struct UniformDefinitions {
|
|||||||
Id F32{};
|
Id F32{};
|
||||||
Id U32x2{};
|
Id U32x2{};
|
||||||
Id U32x4{};
|
Id U32x4{};
|
||||||
|
|
||||||
constexpr static size_t NumElements(Id UniformDefinitions::*member_ptr) {
|
|
||||||
if (member_ptr == &UniformDefinitions::U8) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (member_ptr == &UniformDefinitions::S8) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (member_ptr == &UniformDefinitions::U16) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (member_ptr == &UniformDefinitions::S16) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (member_ptr == &UniformDefinitions::U32) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (member_ptr == &UniformDefinitions::F32) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (member_ptr == &UniformDefinitions::U32x2) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if (member_ptr == &UniformDefinitions::U32x4) {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
ASSERT(false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr static bool IsFloat(Id UniformDefinitions::*member_ptr) {
|
|
||||||
if (member_ptr == &UniformDefinitions::F32) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StorageTypeDefinition {
|
struct StorageTypeDefinition {
|
||||||
|
@ -9,6 +9,7 @@ namespace Shader {
|
|||||||
|
|
||||||
struct Profile {
|
struct Profile {
|
||||||
u32 supported_spirv{0x00010000};
|
u32 supported_spirv{0x00010000};
|
||||||
|
|
||||||
bool unified_descriptor_binding{};
|
bool unified_descriptor_binding{};
|
||||||
bool support_descriptor_aliasing{};
|
bool support_descriptor_aliasing{};
|
||||||
bool support_int8{};
|
bool support_int8{};
|
||||||
@ -81,9 +82,6 @@ struct Profile {
|
|||||||
bool has_broken_spirv_subgroup_mask_vector_extract_dynamic{};
|
bool has_broken_spirv_subgroup_mask_vector_extract_dynamic{};
|
||||||
|
|
||||||
u32 gl_max_compute_smem_size{};
|
u32 gl_max_compute_smem_size{};
|
||||||
|
|
||||||
/// Maxwell and earlier nVidia architectures have broken robust support
|
|
||||||
bool has_broken_robust{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Shader
|
} // namespace Shader
|
||||||
|
@ -86,10 +86,7 @@ public:
|
|||||||
uncommitted_operations.emplace_back(std::move(func));
|
uncommitted_operations.emplace_back(std::move(func));
|
||||||
}
|
}
|
||||||
pending_operations.emplace_back(std::move(uncommitted_operations));
|
pending_operations.emplace_back(std::move(uncommitted_operations));
|
||||||
{
|
QueueFence(new_fence);
|
||||||
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
|
||||||
QueueFence(new_fence);
|
|
||||||
}
|
|
||||||
if (!delay_fence) {
|
if (!delay_fence) {
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
@ -132,16 +132,12 @@ void RendererVulkan::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
|
|||||||
const bool use_accelerated =
|
const bool use_accelerated =
|
||||||
rasterizer.AccelerateDisplay(*framebuffer, framebuffer_addr, framebuffer->stride);
|
rasterizer.AccelerateDisplay(*framebuffer, framebuffer_addr, framebuffer->stride);
|
||||||
const bool is_srgb = use_accelerated && screen_info.is_srgb;
|
const bool is_srgb = use_accelerated && screen_info.is_srgb;
|
||||||
|
RenderScreenshot(*framebuffer, use_accelerated);
|
||||||
|
|
||||||
{
|
Frame* frame = present_manager.GetRenderFrame();
|
||||||
std::scoped_lock lock{rasterizer.LockCaches()};
|
blit_screen.DrawToSwapchain(frame, *framebuffer, use_accelerated, is_srgb);
|
||||||
RenderScreenshot(*framebuffer, use_accelerated);
|
scheduler.Flush(*frame->render_ready);
|
||||||
|
present_manager.Present(frame);
|
||||||
Frame* frame = present_manager.GetRenderFrame();
|
|
||||||
blit_screen.DrawToSwapchain(frame, *framebuffer, use_accelerated, is_srgb);
|
|
||||||
scheduler.Flush(*frame->render_ready);
|
|
||||||
present_manager.Present(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
gpu.RendererFrameEndNotify();
|
gpu.RendererFrameEndNotify();
|
||||||
rasterizer.TickFrame();
|
rasterizer.TickFrame();
|
||||||
|
@ -356,11 +356,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device
|
|||||||
.has_broken_fp16_float_controls = driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY,
|
.has_broken_fp16_float_controls = driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY,
|
||||||
.ignore_nan_fp_comparisons = false,
|
.ignore_nan_fp_comparisons = false,
|
||||||
.has_broken_spirv_subgroup_mask_vector_extract_dynamic =
|
.has_broken_spirv_subgroup_mask_vector_extract_dynamic =
|
||||||
driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY,
|
driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY};
|
||||||
.has_broken_robust =
|
|
||||||
device.IsNvidia() && device.GetNvidiaArch() <= NvidiaArchitecture::Arch_Maxwell,
|
|
||||||
};
|
|
||||||
|
|
||||||
host_info = Shader::HostTranslateInfo{
|
host_info = Shader::HostTranslateInfo{
|
||||||
.support_float64 = device.IsFloat64Supported(),
|
.support_float64 = device.IsFloat64Supported(),
|
||||||
.support_float16 = device.IsFloat16Supported(),
|
.support_float16 = device.IsFloat16Supported(),
|
||||||
|
@ -198,7 +198,7 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
|||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::scoped_lock lock{LockCaches()};
|
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||||
// update engine as channel may be different.
|
// update engine as channel may be different.
|
||||||
pipeline->SetEngine(maxwell3d, gpu_memory);
|
pipeline->SetEngine(maxwell3d, gpu_memory);
|
||||||
pipeline->Configure(is_indexed);
|
pipeline->Configure(is_indexed);
|
||||||
@ -708,7 +708,6 @@ void RasterizerVulkan::TiledCacheBarrier() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::FlushCommands() {
|
void RasterizerVulkan::FlushCommands() {
|
||||||
std::scoped_lock lock{LockCaches()};
|
|
||||||
if (draw_counter == 0) {
|
if (draw_counter == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -806,7 +805,6 @@ void RasterizerVulkan::FlushWork() {
|
|||||||
if ((++draw_counter & 7) != 7) {
|
if ((++draw_counter & 7) != 7) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::scoped_lock lock{LockCaches()};
|
|
||||||
if (draw_counter < DRAWS_TO_DISPATCH) {
|
if (draw_counter < DRAWS_TO_DISPATCH) {
|
||||||
// Send recorded tasks to the worker thread
|
// Send recorded tasks to the worker thread
|
||||||
scheduler.DispatchWork();
|
scheduler.DispatchWork();
|
||||||
@ -1501,7 +1499,7 @@ void RasterizerVulkan::UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs)
|
|||||||
void RasterizerVulkan::InitializeChannel(Tegra::Control::ChannelState& channel) {
|
void RasterizerVulkan::InitializeChannel(Tegra::Control::ChannelState& channel) {
|
||||||
CreateChannel(channel);
|
CreateChannel(channel);
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{LockCaches()};
|
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||||
texture_cache.CreateChannel(channel);
|
texture_cache.CreateChannel(channel);
|
||||||
buffer_cache.CreateChannel(channel);
|
buffer_cache.CreateChannel(channel);
|
||||||
}
|
}
|
||||||
@ -1514,7 +1512,7 @@ void RasterizerVulkan::BindChannel(Tegra::Control::ChannelState& channel) {
|
|||||||
const s32 channel_id = channel.bind_id;
|
const s32 channel_id = channel.bind_id;
|
||||||
BindToChannel(channel_id);
|
BindToChannel(channel_id);
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{LockCaches()};
|
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||||
texture_cache.BindToChannel(channel_id);
|
texture_cache.BindToChannel(channel_id);
|
||||||
buffer_cache.BindToChannel(channel_id);
|
buffer_cache.BindToChannel(channel_id);
|
||||||
}
|
}
|
||||||
@ -1527,7 +1525,7 @@ void RasterizerVulkan::BindChannel(Tegra::Control::ChannelState& channel) {
|
|||||||
void RasterizerVulkan::ReleaseChannel(s32 channel_id) {
|
void RasterizerVulkan::ReleaseChannel(s32 channel_id) {
|
||||||
EraseChannel(channel_id);
|
EraseChannel(channel_id);
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{LockCaches()};
|
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||||
texture_cache.EraseChannel(channel_id);
|
texture_cache.EraseChannel(channel_id);
|
||||||
buffer_cache.EraseChannel(channel_id);
|
buffer_cache.EraseChannel(channel_id);
|
||||||
}
|
}
|
||||||
|
@ -133,10 +133,6 @@ public:
|
|||||||
|
|
||||||
void ReleaseChannel(s32 channel_id) override;
|
void ReleaseChannel(s32 channel_id) override;
|
||||||
|
|
||||||
std::scoped_lock<std::recursive_mutex, std::recursive_mutex> LockCaches() {
|
|
||||||
return std::scoped_lock{buffer_cache.mutex, texture_cache.mutex};
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr size_t MAX_TEXTURES = 192;
|
static constexpr size_t MAX_TEXTURES = 192;
|
||||||
static constexpr size_t MAX_IMAGES = 48;
|
static constexpr size_t MAX_IMAGES = 48;
|
||||||
|
@ -83,6 +83,15 @@ constexpr std::array VK_FORMAT_A4B4G4R4_UNORM_PACK16{
|
|||||||
|
|
||||||
} // namespace Alternatives
|
} // namespace Alternatives
|
||||||
|
|
||||||
|
enum class NvidiaArchitecture {
|
||||||
|
KeplerOrOlder,
|
||||||
|
Maxwell,
|
||||||
|
Pascal,
|
||||||
|
Volta,
|
||||||
|
Turing,
|
||||||
|
AmpereOrNewer,
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SetNext(void**& next, T& data) {
|
void SetNext(void**& next, T& data) {
|
||||||
*next = &data;
|
*next = &data;
|
||||||
@ -317,9 +326,9 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical,
|
|||||||
if (shading_rate_props.primitiveFragmentShadingRateWithMultipleViewports) {
|
if (shading_rate_props.primitiveFragmentShadingRateWithMultipleViewports) {
|
||||||
// Only Ampere and newer support this feature
|
// Only Ampere and newer support this feature
|
||||||
// TODO: Find a way to differentiate Ampere and Ada
|
// TODO: Find a way to differentiate Ampere and Ada
|
||||||
return NvidiaArchitecture::Arch_AmpereOrNewer;
|
return NvidiaArchitecture::AmpereOrNewer;
|
||||||
}
|
}
|
||||||
return NvidiaArchitecture::Arch_Turing;
|
return NvidiaArchitecture::Turing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exts.contains(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME)) {
|
if (exts.contains(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME)) {
|
||||||
@ -331,7 +340,7 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical,
|
|||||||
physical_properties.pNext = &advanced_blending_props;
|
physical_properties.pNext = &advanced_blending_props;
|
||||||
physical.GetProperties2(physical_properties);
|
physical.GetProperties2(physical_properties);
|
||||||
if (advanced_blending_props.advancedBlendMaxColorAttachments == 1) {
|
if (advanced_blending_props.advancedBlendMaxColorAttachments == 1) {
|
||||||
return NvidiaArchitecture::Arch_Maxwell;
|
return NvidiaArchitecture::Maxwell;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exts.contains(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME)) {
|
if (exts.contains(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME)) {
|
||||||
@ -341,13 +350,13 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical,
|
|||||||
physical_properties.pNext = &conservative_raster_props;
|
physical_properties.pNext = &conservative_raster_props;
|
||||||
physical.GetProperties2(physical_properties);
|
physical.GetProperties2(physical_properties);
|
||||||
if (conservative_raster_props.degenerateLinesRasterized) {
|
if (conservative_raster_props.degenerateLinesRasterized) {
|
||||||
return NvidiaArchitecture::Arch_Volta;
|
return NvidiaArchitecture::Volta;
|
||||||
}
|
}
|
||||||
return NvidiaArchitecture::Arch_Pascal;
|
return NvidiaArchitecture::Pascal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NvidiaArchitecture::Arch_KeplerOrOlder;
|
return NvidiaArchitecture::KeplerOrOlder;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char*> ExtensionListForVulkan(
|
std::vector<const char*> ExtensionListForVulkan(
|
||||||
@ -427,10 +436,6 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
|||||||
throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER);
|
throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_nvidia) {
|
|
||||||
nvidia_arch = GetNvidiaArchitecture(physical, supported_extensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetupFamilies(surface);
|
SetupFamilies(surface);
|
||||||
const auto queue_cis = GetDeviceQueueCreateInfos();
|
const auto queue_cis = GetDeviceQueueCreateInfos();
|
||||||
|
|
||||||
@ -527,11 +532,11 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
|||||||
|
|
||||||
if (is_nvidia) {
|
if (is_nvidia) {
|
||||||
const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff;
|
const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff;
|
||||||
const auto arch = GetNvidiaArch();
|
const auto arch = GetNvidiaArchitecture(physical, supported_extensions);
|
||||||
if (arch >= NvidiaArchitecture::Arch_AmpereOrNewer) {
|
if (arch >= NvidiaArchitecture::AmpereOrNewer) {
|
||||||
LOG_WARNING(Render_Vulkan, "Ampere and newer have broken float16 math");
|
LOG_WARNING(Render_Vulkan, "Ampere and newer have broken float16 math");
|
||||||
features.shader_float16_int8.shaderFloat16 = false;
|
features.shader_float16_int8.shaderFloat16 = false;
|
||||||
} else if (arch <= NvidiaArchitecture::Arch_Volta) {
|
} else if (arch <= NvidiaArchitecture::Volta) {
|
||||||
if (nv_major_version < 527) {
|
if (nv_major_version < 527) {
|
||||||
LOG_WARNING(Render_Vulkan, "Volta and older have broken VK_KHR_push_descriptor");
|
LOG_WARNING(Render_Vulkan, "Volta and older have broken VK_KHR_push_descriptor");
|
||||||
RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
||||||
@ -681,8 +686,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
|||||||
RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
} else if (extensions.push_descriptor && is_nvidia) {
|
} else if (extensions.push_descriptor && is_nvidia) {
|
||||||
const auto arch = GetNvidiaArch();
|
const auto arch = GetNvidiaArchitecture(physical, supported_extensions);
|
||||||
if (arch <= NvidiaArchitecture::Arch_Pascal) {
|
if (arch <= NvidiaArchitecture::Pascal) {
|
||||||
LOG_WARNING(Render_Vulkan,
|
LOG_WARNING(Render_Vulkan,
|
||||||
"Pascal and older architectures have broken VK_KHR_push_descriptor");
|
"Pascal and older architectures have broken VK_KHR_push_descriptor");
|
||||||
RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
||||||
|
@ -177,15 +177,6 @@ enum class FormatType { Linear, Optimal, Buffer };
|
|||||||
/// Subgroup size of the guest emulated hardware (Nvidia has 32 threads per subgroup).
|
/// Subgroup size of the guest emulated hardware (Nvidia has 32 threads per subgroup).
|
||||||
const u32 GuestWarpSize = 32;
|
const u32 GuestWarpSize = 32;
|
||||||
|
|
||||||
enum class NvidiaArchitecture {
|
|
||||||
Arch_KeplerOrOlder,
|
|
||||||
Arch_Maxwell,
|
|
||||||
Arch_Pascal,
|
|
||||||
Arch_Volta,
|
|
||||||
Arch_Turing,
|
|
||||||
Arch_AmpereOrNewer,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Handles data specific to a physical device.
|
/// Handles data specific to a physical device.
|
||||||
class Device {
|
class Device {
|
||||||
public:
|
public:
|
||||||
@ -679,14 +670,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsNvidia() const noexcept {
|
|
||||||
return properties.driver.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
NvidiaArchitecture GetNvidiaArch() const noexcept {
|
|
||||||
return nvidia_arch;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Checks if the physical device is suitable and configures the object state
|
/// Checks if the physical device is suitable and configures the object state
|
||||||
/// with all necessary info about its properties.
|
/// with all necessary info about its properties.
|
||||||
@ -805,7 +788,6 @@ private:
|
|||||||
bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow.
|
bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow.
|
||||||
u64 device_access_memory{}; ///< Total size of device local memory in bytes.
|
u64 device_access_memory{}; ///< Total size of device local memory in bytes.
|
||||||
u32 sets_per_pool{}; ///< Sets per Description Pool
|
u32 sets_per_pool{}; ///< Sets per Description Pool
|
||||||
NvidiaArchitecture nvidia_arch{NvidiaArchitecture::Arch_AmpereOrNewer};
|
|
||||||
|
|
||||||
// Telemetry parameters
|
// Telemetry parameters
|
||||||
std::set<std::string, std::less<>> supported_extensions; ///< Reported Vulkan extensions.
|
std::set<std::string, std::less<>> supported_extensions; ///< Reported Vulkan extensions.
|
||||||
|
@ -522,7 +522,7 @@ Instance Instance::Create(u32 version, Span<const char*> layers, Span<const char
|
|||||||
.applicationVersion = VK_MAKE_VERSION(0, 1, 0),
|
.applicationVersion = VK_MAKE_VERSION(0, 1, 0),
|
||||||
.pEngineName = "yuzu Emulator",
|
.pEngineName = "yuzu Emulator",
|
||||||
.engineVersion = VK_MAKE_VERSION(0, 1, 0),
|
.engineVersion = VK_MAKE_VERSION(0, 1, 0),
|
||||||
.apiVersion = VK_API_VERSION_1_3,
|
.apiVersion = version,
|
||||||
};
|
};
|
||||||
const VkInstanceCreateInfo ci{
|
const VkInstanceCreateInfo ci{
|
||||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
|
@ -114,7 +114,7 @@ const std::map<Settings::ShaderBackend, QString> Config::shader_backend_texts_ma
|
|||||||
// This must be in alphabetical order according to action name as it must have the same order as
|
// This must be in alphabetical order according to action name as it must have the same order as
|
||||||
// UISetting::values.shortcuts, which is alphabetically ordered.
|
// UISetting::values.shortcuts, which is alphabetically ordered.
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const std::array<UISettings::Shortcut, 23> Config::default_hotkeys{{
|
const std::array<UISettings::Shortcut, 22> Config::default_hotkeys{{
|
||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Mute/Unmute")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut, false}},
|
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Mute/Unmute")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut, false}},
|
||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Down")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut, true}},
|
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Down")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut, true}},
|
||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Up")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("="), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut, true}},
|
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Up")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("="), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut, true}},
|
||||||
@ -136,7 +136,6 @@ const std::array<UISettings::Shortcut, 23> Config::default_hotkeys{{
|
|||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Filter Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut, false}},
|
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Filter Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut, false}},
|
||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Framerate Limit")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut, false}},
|
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Framerate Limit")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut, false}},
|
||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Mouse Panning")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut, false}},
|
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Mouse Panning")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut, false}},
|
||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Renderdoc Capture")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral(""), QStringLiteral(""), Qt::ApplicationShortcut, false}},
|
|
||||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Status Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut, false}},
|
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Status Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut, false}},
|
||||||
}};
|
}};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
default_mouse_buttons;
|
default_mouse_buttons;
|
||||||
static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys;
|
static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys;
|
||||||
static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods;
|
static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods;
|
||||||
static const std::array<UISettings::Shortcut, 23> default_hotkeys;
|
static const std::array<UISettings::Shortcut, 22> default_hotkeys;
|
||||||
|
|
||||||
static const std::map<Settings::AntiAliasing, QString> anti_aliasing_texts_map;
|
static const std::map<Settings::AntiAliasing, QString> anti_aliasing_texts_map;
|
||||||
static const std::map<Settings::ScalingFilter, QString> scaling_filter_texts_map;
|
static const std::map<Settings::ScalingFilter, QString> scaling_filter_texts_map;
|
||||||
|
@ -319,13 +319,6 @@ void ConfigureHotkeys::ApplyConfiguration(HotkeyRegistry& registry) {
|
|||||||
void ConfigureHotkeys::RestoreDefaults() {
|
void ConfigureHotkeys::RestoreDefaults() {
|
||||||
for (int r = 0; r < model->rowCount(); ++r) {
|
for (int r = 0; r < model->rowCount(); ++r) {
|
||||||
const QStandardItem* parent = model->item(r, 0);
|
const QStandardItem* parent = model->item(r, 0);
|
||||||
const int hotkey_size = static_cast<int>(Config::default_hotkeys.size());
|
|
||||||
|
|
||||||
if (hotkey_size != parent->rowCount()) {
|
|
||||||
QMessageBox::warning(this, tr("Invalid hotkey settings"),
|
|
||||||
tr("An error occurred. Please report this issue on github."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int r2 = 0; r2 < parent->rowCount(); ++r2) {
|
for (int r2 = 0; r2 < parent->rowCount(); ++r2) {
|
||||||
model->item(r, 0)
|
model->item(r, 0)
|
||||||
|
@ -89,7 +89,7 @@ void ConfigureVibration::VibrateController(Core::HID::ControllerTriggerType type
|
|||||||
|
|
||||||
auto& player = Settings::values.players.GetValue()[player_index];
|
auto& player = Settings::values.players.GetValue()[player_index];
|
||||||
auto controller = hid_core.GetEmulatedControllerByIndex(player_index);
|
auto controller = hid_core.GetEmulatedControllerByIndex(player_index);
|
||||||
const int vibration_strength = vibration_spinboxes[player_index]->value();
|
const int vibration_strenght = vibration_spinboxes[player_index]->value();
|
||||||
const auto& buttons = controller->GetButtonsValues();
|
const auto& buttons = controller->GetButtonsValues();
|
||||||
|
|
||||||
bool button_is_pressed = false;
|
bool button_is_pressed = false;
|
||||||
@ -105,10 +105,10 @@ void ConfigureVibration::VibrateController(Core::HID::ControllerTriggerType type
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool old_vibration_enabled = player.vibration_enabled;
|
const int old_vibration_enabled = player.vibration_enabled;
|
||||||
const int old_vibration_strength = player.vibration_strength;
|
const bool old_vibration_strenght = player.vibration_strength;
|
||||||
player.vibration_enabled = true;
|
player.vibration_enabled = true;
|
||||||
player.vibration_strength = vibration_strength;
|
player.vibration_strength = vibration_strenght;
|
||||||
|
|
||||||
const Core::HID::VibrationValue vibration{
|
const Core::HID::VibrationValue vibration{
|
||||||
.low_amplitude = 1.0f,
|
.low_amplitude = 1.0f,
|
||||||
@ -121,7 +121,7 @@ void ConfigureVibration::VibrateController(Core::HID::ControllerTriggerType type
|
|||||||
|
|
||||||
// Restore previous values
|
// Restore previous values
|
||||||
player.vibration_enabled = old_vibration_enabled;
|
player.vibration_enabled = old_vibration_enabled;
|
||||||
player.vibration_strength = old_vibration_strength;
|
player.vibration_strength = old_vibration_strenght;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureVibration::StopVibrations() {
|
void ConfigureVibration::StopVibrations() {
|
||||||
|
Reference in New Issue
Block a user