diff options
| author | 2018-05-23 17:12:56 -0400 | |
|---|---|---|
| committer | 2018-05-23 17:12:56 -0400 | |
| commit | a55f112cb1afe6c53fe076d8e4d6b2313621edef (patch) | |
| tree | 5790f012ae7ab2baf9b9db05e577d9c1fab1a035 /src/core | |
| parent | Merge pull request #461 from lioncash/dynarmic (diff) | |
| parent | change some functions (diff) | |
| download | yuzu-a55f112cb1afe6c53fe076d8e4d6b2313621edef.tar.gz yuzu-a55f112cb1afe6c53fe076d8e4d6b2313621edef.tar.xz yuzu-a55f112cb1afe6c53fe076d8e4d6b2313621edef.zip | |
Merge pull request #459 from greggameplayer/patch-5
Add ioctl commands with their params and size check
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 88 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvmap.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvmap.h | 46 |
3 files changed, 117 insertions, 29 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index 76a8b33c2..aa9b5a14b 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | |||
| @@ -26,12 +26,64 @@ private: | |||
| 26 | IocSyncptIncrCommand = 0x40040015, | 26 | IocSyncptIncrCommand = 0x40040015, |
| 27 | IocSyncptWaitCommand = 0xC00C0016, | 27 | IocSyncptWaitCommand = 0xC00C0016, |
| 28 | IocModuleMutexCommand = 0x40080017, | 28 | IocModuleMutexCommand = 0x40080017, |
| 29 | IocModuleRegRDWRCommand = 0xC008010E, | 29 | IocModuleRegRDWRCommand = 0xC0180018, |
| 30 | IocSyncptWaitexCommand = 0xC0100019, | 30 | IocSyncptWaitexCommand = 0xC0100019, |
| 31 | IocSyncptReadMaxCommand = 0xC008001A, | 31 | IocSyncptReadMaxCommand = 0xC008001A, |
| 32 | IocCtrlEventWaitCommand = 0xC010001D, | ||
| 33 | IocGetConfigCommand = 0xC183001B, | 32 | IocGetConfigCommand = 0xC183001B, |
| 33 | IocCtrlEventSignalCommand = 0xC004001C, | ||
| 34 | IocCtrlEventWaitCommand = 0xC010001D, | ||
| 35 | IocCtrlEventWaitAsyncCommand = 0xC010001E, | ||
| 36 | IocCtrlEventRegisterCommand = 0xC004001F, | ||
| 37 | IocCtrlEventUnregisterCommand = 0xC0040020, | ||
| 38 | IocCtrlEventKillCommand = 0x40080021, | ||
| 39 | }; | ||
| 40 | struct IocSyncptReadParams { | ||
| 41 | u32_le id; | ||
| 42 | u32_le value; | ||
| 43 | }; | ||
| 44 | static_assert(sizeof(IocSyncptReadParams) == 8, "IocSyncptReadParams is incorrect size"); | ||
| 45 | |||
| 46 | struct IocSyncptIncrParams { | ||
| 47 | u32_le id; | ||
| 48 | }; | ||
| 49 | static_assert(sizeof(IocSyncptIncrParams) == 4, "IocSyncptIncrParams is incorrect size"); | ||
| 50 | |||
| 51 | struct IocSyncptWaitParams { | ||
| 52 | u32_le id; | ||
| 53 | u32_le thresh; | ||
| 54 | s32_le timeout; | ||
| 55 | }; | ||
| 56 | static_assert(sizeof(IocSyncptWaitParams) == 12, "IocSyncptWaitParams is incorrect size"); | ||
| 57 | |||
| 58 | struct IocModuleMutexParams { | ||
| 59 | u32_le id; | ||
| 60 | u32_le lock; // (0 = unlock and 1 = lock) | ||
| 61 | }; | ||
| 62 | static_assert(sizeof(IocModuleMutexParams) == 8, "IocModuleMutexParams is incorrect size"); | ||
| 63 | |||
| 64 | struct IocModuleRegRDWRParams { | ||
| 65 | u32_le id; | ||
| 66 | u32_le num_offsets; | ||
| 67 | u32_le block_size; | ||
| 68 | u32_le offsets; | ||
| 69 | u32_le values; | ||
| 70 | u32_le write; | ||
| 71 | }; | ||
| 72 | static_assert(sizeof(IocModuleRegRDWRParams) == 24, "IocModuleRegRDWRParams is incorrect size"); | ||
| 73 | |||
| 74 | struct IocSyncptWaitexParams { | ||
| 75 | u32_le id; | ||
| 76 | u32_le thresh; | ||
| 77 | s32_le timeout; | ||
| 78 | u32_le value; | ||
| 34 | }; | 79 | }; |
| 80 | static_assert(sizeof(IocSyncptWaitexParams) == 16, "IocSyncptWaitexParams is incorrect size"); | ||
| 81 | |||
| 82 | struct IocSyncptReadMaxParams { | ||
| 83 | u32_le id; | ||
| 84 | u32_le value; | ||
| 85 | }; | ||
| 86 | static_assert(sizeof(IocSyncptReadMaxParams) == 8, "IocSyncptReadMaxParams is incorrect size"); | ||
| 35 | 87 | ||
| 36 | struct IocGetConfigParams { | 88 | struct IocGetConfigParams { |
| 37 | std::array<char, 0x41> domain_str; | 89 | std::array<char, 0x41> domain_str; |
| @@ -40,6 +92,12 @@ private: | |||
| 40 | }; | 92 | }; |
| 41 | static_assert(sizeof(IocGetConfigParams) == 387, "IocGetConfigParams is incorrect size"); | 93 | static_assert(sizeof(IocGetConfigParams) == 387, "IocGetConfigParams is incorrect size"); |
| 42 | 94 | ||
| 95 | struct IocCtrlEventSignalParams { | ||
| 96 | u32_le user_event_id; | ||
| 97 | }; | ||
| 98 | static_assert(sizeof(IocCtrlEventSignalParams) == 4, | ||
| 99 | "IocCtrlEventSignalParams is incorrect size"); | ||
| 100 | |||
| 43 | struct IocCtrlEventWaitParams { | 101 | struct IocCtrlEventWaitParams { |
| 44 | u32_le syncpt_id; | 102 | u32_le syncpt_id; |
| 45 | u32_le threshold; | 103 | u32_le threshold; |
| @@ -48,6 +106,32 @@ private: | |||
| 48 | }; | 106 | }; |
| 49 | static_assert(sizeof(IocCtrlEventWaitParams) == 16, "IocCtrlEventWaitParams is incorrect size"); | 107 | static_assert(sizeof(IocCtrlEventWaitParams) == 16, "IocCtrlEventWaitParams is incorrect size"); |
| 50 | 108 | ||
| 109 | struct IocCtrlEventWaitAsyncParams { | ||
| 110 | u32_le syncpt_id; | ||
| 111 | u32_le threshold; | ||
| 112 | u32_le timeout; | ||
| 113 | u32_le value; | ||
| 114 | }; | ||
| 115 | static_assert(sizeof(IocCtrlEventWaitAsyncParams) == 16, | ||
| 116 | "IocCtrlEventWaitAsyncParams is incorrect size"); | ||
| 117 | |||
| 118 | struct IocCtrlEventRegisterParams { | ||
| 119 | u32_le user_event_id; | ||
| 120 | }; | ||
| 121 | static_assert(sizeof(IocCtrlEventRegisterParams) == 4, | ||
| 122 | "IocCtrlEventRegisterParams is incorrect size"); | ||
| 123 | |||
| 124 | struct IocCtrlEventUnregisterParams { | ||
| 125 | u32_le user_event_id; | ||
| 126 | }; | ||
| 127 | static_assert(sizeof(IocCtrlEventUnregisterParams) == 4, | ||
| 128 | "IocCtrlEventUnregisterParams is incorrect size"); | ||
| 129 | |||
| 130 | struct IocCtrlEventKill { | ||
| 131 | u64_le user_events; | ||
| 132 | }; | ||
| 133 | static_assert(sizeof(IocCtrlEventKill) == 8, "IocCtrlEventKill is incorrect size"); | ||
| 134 | |||
| 51 | u32 NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output); | 135 | u32 NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output); |
| 52 | 136 | ||
| 53 | u32 IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& output); | 137 | u32 IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& output); |
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index d66fb3a9c..23fe98190 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp | |||
| @@ -119,25 +119,25 @@ u32 nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 119 | IocParamParams params; | 119 | IocParamParams params; |
| 120 | std::memcpy(¶ms, input.data(), sizeof(params)); | 120 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 121 | 121 | ||
| 122 | NGLOG_WARNING(Service_NVDRV, "(STUBBED) called type={}", params.type); | 122 | NGLOG_WARNING(Service_NVDRV, "(STUBBED) called type={}", params.param); |
| 123 | 123 | ||
| 124 | auto object = GetObject(params.handle); | 124 | auto object = GetObject(params.handle); |
| 125 | ASSERT(object); | 125 | ASSERT(object); |
| 126 | ASSERT(object->status == Object::Status::Allocated); | 126 | ASSERT(object->status == Object::Status::Allocated); |
| 127 | 127 | ||
| 128 | switch (static_cast<ParamTypes>(params.type)) { | 128 | switch (static_cast<ParamTypes>(params.param)) { |
| 129 | case ParamTypes::Size: | 129 | case ParamTypes::Size: |
| 130 | params.value = object->size; | 130 | params.result = object->size; |
| 131 | break; | 131 | break; |
| 132 | case ParamTypes::Alignment: | 132 | case ParamTypes::Alignment: |
| 133 | params.value = object->align; | 133 | params.result = object->align; |
| 134 | break; | 134 | break; |
| 135 | case ParamTypes::Heap: | 135 | case ParamTypes::Heap: |
| 136 | // TODO(Subv): Seems to be a hardcoded value? | 136 | // TODO(Subv): Seems to be a hardcoded value? |
| 137 | params.value = 0x40000000; | 137 | params.result = 0x40000000; |
| 138 | break; | 138 | break; |
| 139 | case ParamTypes::Kind: | 139 | case ParamTypes::Kind: |
| 140 | params.value = object->kind; | 140 | params.result = object->kind; |
| 141 | break; | 141 | break; |
| 142 | default: | 142 | default: |
| 143 | UNIMPLEMENTED(); | 143 | UNIMPLEMENTED(); |
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h index 5a3044167..39fafaa7c 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.h +++ b/src/core/hle/service/nvdrv/devices/nvmap.h | |||
| @@ -59,17 +59,25 @@ private: | |||
| 59 | Create = 0xC0080101, | 59 | Create = 0xC0080101, |
| 60 | FromId = 0xC0080103, | 60 | FromId = 0xC0080103, |
| 61 | Alloc = 0xC0200104, | 61 | Alloc = 0xC0200104, |
| 62 | Free = 0xC0180105, | ||
| 62 | Param = 0xC00C0109, | 63 | Param = 0xC00C0109, |
| 63 | GetId = 0xC008010E, | 64 | GetId = 0xC008010E, |
| 64 | Free = 0xC0180105, | ||
| 65 | }; | 65 | }; |
| 66 | |||
| 67 | struct IocCreateParams { | 66 | struct IocCreateParams { |
| 68 | // Input | 67 | // Input |
| 69 | u32_le size; | 68 | u32_le size; |
| 70 | // Output | 69 | // Output |
| 71 | u32_le handle; | 70 | u32_le handle; |
| 72 | }; | 71 | }; |
| 72 | static_assert(sizeof(IocCreateParams) == 8, "IocCreateParams has wrong size"); | ||
| 73 | |||
| 74 | struct IocFromIdParams { | ||
| 75 | // Input | ||
| 76 | u32_le id; | ||
| 77 | // Output | ||
| 78 | u32_le handle; | ||
| 79 | }; | ||
| 80 | static_assert(sizeof(IocFromIdParams) == 8, "IocFromIdParams has wrong size"); | ||
| 73 | 81 | ||
| 74 | struct IocAllocParams { | 82 | struct IocAllocParams { |
| 75 | // Input | 83 | // Input |
| @@ -81,37 +89,33 @@ private: | |||
| 81 | INSERT_PADDING_BYTES(7); | 89 | INSERT_PADDING_BYTES(7); |
| 82 | u64_le addr; | 90 | u64_le addr; |
| 83 | }; | 91 | }; |
| 92 | static_assert(sizeof(IocAllocParams) == 32, "IocAllocParams has wrong size"); | ||
| 84 | 93 | ||
| 85 | struct IocGetIdParams { | 94 | struct IocFreeParams { |
| 86 | // Output | ||
| 87 | u32_le id; | ||
| 88 | // Input | ||
| 89 | u32_le handle; | ||
| 90 | }; | ||
| 91 | |||
| 92 | struct IocFromIdParams { | ||
| 93 | // Input | ||
| 94 | u32_le id; | ||
| 95 | // Output | ||
| 96 | u32_le handle; | 95 | u32_le handle; |
| 96 | INSERT_PADDING_BYTES(4); | ||
| 97 | u64_le refcount; | ||
| 98 | u32_le size; | ||
| 99 | u32_le flags; | ||
| 97 | }; | 100 | }; |
| 101 | static_assert(sizeof(IocFreeParams) == 24, "IocFreeParams has wrong size"); | ||
| 98 | 102 | ||
| 99 | struct IocParamParams { | 103 | struct IocParamParams { |
| 100 | // Input | 104 | // Input |
| 101 | u32_le handle; | 105 | u32_le handle; |
| 102 | u32_le type; | 106 | u32_le param; |
| 103 | // Output | 107 | // Output |
| 104 | u32_le value; | 108 | u32_le result; |
| 105 | }; | 109 | }; |
| 110 | static_assert(sizeof(IocParamParams) == 12, "IocParamParams has wrong size"); | ||
| 106 | 111 | ||
| 107 | struct IocFreeParams { | 112 | struct IocGetIdParams { |
| 113 | // Output | ||
| 114 | u32_le id; | ||
| 115 | // Input | ||
| 108 | u32_le handle; | 116 | u32_le handle; |
| 109 | INSERT_PADDING_BYTES(4); | ||
| 110 | u64_le refcount; | ||
| 111 | u32_le size; | ||
| 112 | u32_le flags; | ||
| 113 | }; | 117 | }; |
| 114 | static_assert(sizeof(IocFreeParams) == 24, "IocFreeParams has wrong size"); | 118 | static_assert(sizeof(IocGetIdParams) == 8, "IocGetIdParams has wrong size"); |
| 115 | 119 | ||
| 116 | u32 IocCreate(const std::vector<u8>& input, std::vector<u8>& output); | 120 | u32 IocCreate(const std::vector<u8>& input, std::vector<u8>& output); |
| 117 | u32 IocAlloc(const std::vector<u8>& input, std::vector<u8>& output); | 121 | u32 IocAlloc(const std::vector<u8>& input, std::vector<u8>& output); |