| File: | Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h |
| Location: | line 60, column 7 |
| Description: | Value stored to 'BufferIn' during its initialization is never read |
| 1 | // Copyright 2013 Dolphin Emulator Project |
| 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. |
| 4 | |
| 5 | #ifndef _WII_IPC_HLE_DEVICE_STM_H_ |
| 6 | #define _WII_IPC_HLE_DEVICE_STM_H_ |
| 7 | |
| 8 | #include "WII_IPC_HLE_Device.h" |
| 9 | |
| 10 | enum |
| 11 | { |
| 12 | IOCTL_STM_EVENTHOOK = 0x1000, |
| 13 | IOCTL_STM_GET_IDLEMODE = 0x3001, |
| 14 | IOCTL_STM_RELEASE_EH = 0x3002, |
| 15 | IOCTL_STM_HOTRESET = 0x2001, |
| 16 | IOCTL_STM_HOTRESET_FOR_PD = 0x2002, |
| 17 | IOCTL_STM_SHUTDOWN = 0x2003, |
| 18 | IOCTL_STM_IDLE = 0x2004, |
| 19 | IOCTL_STM_WAKEUP = 0x2005, |
| 20 | IOCTL_STM_VIDIMMING = 0x5001, |
| 21 | IOCTL_STM_LEDFLASH = 0x6001, |
| 22 | IOCTL_STM_LEDMODE = 0x6002, |
| 23 | IOCTL_STM_READVER = 0x7001, |
| 24 | IOCTL_STM_READDDRREG = 0x4001, |
| 25 | IOCTL_STM_READDDRREG2 = 0x4002, |
| 26 | }; |
| 27 | |
| 28 | // The /dev/stm/immediate |
| 29 | class CWII_IPC_HLE_Device_stm_immediate : public IWII_IPC_HLE_Device |
| 30 | { |
| 31 | public: |
| 32 | |
| 33 | CWII_IPC_HLE_Device_stm_immediate(u32 _DeviceID, const std::string& _rDeviceName) : |
| 34 | IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) |
| 35 | {} |
| 36 | |
| 37 | virtual ~CWII_IPC_HLE_Device_stm_immediate() |
| 38 | {} |
| 39 | |
| 40 | virtual bool Open(u32 _CommandAddress, u32 _Mode) |
| 41 | { |
| 42 | INFO_LOG(WII_IPC_STM, "STM immediate: Open")do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 42, "STM immediate: Open"); } } while (0); |
| 43 | Memory::Write_U32(GetDeviceID(), _CommandAddress+4); |
| 44 | m_Active = true; |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | virtual bool Close(u32 _CommandAddress, bool _bForce) |
| 49 | { |
| 50 | INFO_LOG(WII_IPC_STM, "STM immediate: Close")do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 50, "STM immediate: Close"); } } while (0); |
| 51 | if (!_bForce) |
| 52 | Memory::Write_U32(0, _CommandAddress+4); |
| 53 | m_Active = false; |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | virtual bool IOCtl(u32 _CommandAddress) |
| 58 | { |
| 59 | u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C); |
| 60 | u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); |
Value stored to 'BufferIn' during its initialization is never read | |
| 61 | u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); |
| 62 | u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); |
| 63 | u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); |
| 64 | |
| 65 | // Prepare the out buffer(s) with zeroes as a safety precaution |
| 66 | // to avoid returning bad values |
| 67 | Memory::Memset(BufferOut, 0, BufferOutSize); |
| 68 | u32 ReturnValue = 0; |
| 69 | |
| 70 | switch(Parameter) |
| 71 | { |
| 72 | case IOCTL_STM_RELEASE_EH: |
| 73 | INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str())do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 73, "%s - IOCtl:", GetDeviceName().c_str()); } } while (0); |
| 74 | INFO_LOG(WII_IPC_STM, " IOCTL_STM_RELEASE_EH")do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 74, " IOCTL_STM_RELEASE_EH"); } } while (0); |
| 75 | break; |
| 76 | |
| 77 | case IOCTL_STM_HOTRESET: |
| 78 | INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str())do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 78, "%s - IOCtl:", GetDeviceName().c_str()); } } while (0); |
| 79 | INFO_LOG(WII_IPC_STM, " IOCTL_STM_HOTRESET")do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 79, " IOCTL_STM_HOTRESET"); } } while (0); |
| 80 | break; |
| 81 | |
| 82 | case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes) |
| 83 | INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str())do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 83, "%s - IOCtl:", GetDeviceName().c_str()); } } while (0); |
| 84 | INFO_LOG(WII_IPC_STM, " IOCTL_STM_VIDIMMING")do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 84, " IOCTL_STM_VIDIMMING"); } } while (0); |
| 85 | //DumpCommands(BufferIn, BufferInSize / 4, LogTypes::WII_IPC_STM); |
| 86 | //Memory::Write_U32(1, BufferOut); |
| 87 | //ReturnValue = 1; |
| 88 | break; |
| 89 | |
| 90 | case IOCTL_STM_LEDMODE: // (Input: 20 bytes, Output: 20 bytes) |
| 91 | INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str())do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 91, "%s - IOCtl:", GetDeviceName().c_str()); } } while (0); |
| 92 | INFO_LOG(WII_IPC_STM, " IOCTL_STM_LEDMODE")do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 92, " IOCTL_STM_LEDMODE"); } } while (0); |
| 93 | break; |
| 94 | |
| 95 | default: |
| 96 | { |
| 97 | _dbg_assert_msg_(WII_IPC_STM, 0, "CWII_IPC_HLE_Device_stm_immediate: 0x%x", Parameter){}; |
| 98 | |
| 99 | INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str())do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 99, "%s - IOCtl:", GetDeviceName().c_str()); } } while (0); |
| 100 | DEBUG_LOG(WII_IPC_STM, " Parameter: 0x%x", Parameter)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 100, " Parameter: 0x%x", Parameter); } } while (0); |
| 101 | DEBUG_LOG(WII_IPC_STM, " InBuffer: 0x%08x", BufferIn)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 101, " InBuffer: 0x%08x", BufferIn); } } while (0); |
| 102 | DEBUG_LOG(WII_IPC_STM, " InBufferSize: 0x%08x", BufferInSize)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 102, " InBufferSize: 0x%08x", BufferInSize); } } while ( 0); |
| 103 | DEBUG_LOG(WII_IPC_STM, " OutBuffer: 0x%08x", BufferOut)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 103, " OutBuffer: 0x%08x", BufferOut); } } while (0); |
| 104 | DEBUG_LOG(WII_IPC_STM, " OutBufferSize: 0x%08x", BufferOutSize)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 104, " OutBufferSize: 0x%08x", BufferOutSize); } } while (0); |
| 105 | } |
| 106 | break; |
| 107 | } |
| 108 | |
| 109 | // Write return value to the IPC call |
| 110 | Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); |
| 111 | return true; |
| 112 | } |
| 113 | }; |
| 114 | |
| 115 | // The /dev/stm/eventhook |
| 116 | class CWII_IPC_HLE_Device_stm_eventhook : public IWII_IPC_HLE_Device |
| 117 | { |
| 118 | public: |
| 119 | |
| 120 | CWII_IPC_HLE_Device_stm_eventhook(u32 _DeviceID, const std::string& _rDeviceName) |
| 121 | : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) |
| 122 | , m_EventHookAddress(0) |
| 123 | {} |
| 124 | |
| 125 | virtual ~CWII_IPC_HLE_Device_stm_eventhook() |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | virtual bool Open(u32 _CommandAddress, u32 _Mode) |
| 130 | { |
| 131 | Memory::Write_U32(GetDeviceID(), _CommandAddress + 4); |
| 132 | m_Active = true; |
| 133 | return true; |
| 134 | } |
| 135 | |
| 136 | virtual bool Close(u32 _CommandAddress, bool _bForce) |
| 137 | { |
| 138 | m_EventHookAddress = 0; |
| 139 | |
| 140 | INFO_LOG(WII_IPC_STM, "STM eventhook: Close")do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 140, "STM eventhook: Close"); } } while (0); |
| 141 | if (!_bForce) |
| 142 | Memory::Write_U32(0, _CommandAddress+4); |
| 143 | m_Active = false; |
| 144 | return true; |
| 145 | } |
| 146 | |
| 147 | virtual bool IOCtl(u32 _CommandAddress) |
| 148 | { |
| 149 | u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C); |
| 150 | u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); |
| 151 | u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); |
| 152 | u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); |
| 153 | u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); |
| 154 | |
| 155 | // Prepare the out buffer(s) with zeros as a safety precaution |
| 156 | // to avoid returning bad values |
| 157 | Memory::Memset(BufferOut, 0, BufferOutSize); |
| 158 | u32 ReturnValue = 0; |
| 159 | |
| 160 | // write return value |
| 161 | switch (Parameter) |
| 162 | { |
| 163 | case IOCTL_STM_EVENTHOOK: |
| 164 | { |
| 165 | m_EventHookAddress = _CommandAddress; |
| 166 | |
| 167 | INFO_LOG(WII_IPC_STM, "%s registers event hook:", GetDeviceName().c_str())do { { if (LogTypes::LINFO <= 3) GenericLog(LogTypes::LINFO , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 167, "%s registers event hook:", GetDeviceName().c_str()); } } while (0); |
| 168 | DEBUG_LOG(WII_IPC_STM, "%x - IOCTL_STM_EVENTHOOK", Parameter)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 168, "%x - IOCTL_STM_EVENTHOOK", Parameter); } } while (0); |
| 169 | DEBUG_LOG(WII_IPC_STM, "BufferIn: 0x%08x", BufferIn)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 169, "BufferIn: 0x%08x", BufferIn); } } while (0); |
| 170 | DEBUG_LOG(WII_IPC_STM, "BufferInSize: 0x%08x", BufferInSize)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 170, "BufferInSize: 0x%08x", BufferInSize); } } while (0); |
| 171 | DEBUG_LOG(WII_IPC_STM, "BufferOut: 0x%08x", BufferOut)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 171, "BufferOut: 0x%08x", BufferOut); } } while (0); |
| 172 | DEBUG_LOG(WII_IPC_STM, "BufferOutSize: 0x%08x", BufferOutSize)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG , LogTypes::WII_IPC_STM, "/home/anal/dolphin-emu/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h" , 172, "BufferOutSize: 0x%08x", BufferOutSize); } } while (0); |
| 173 | |
| 174 | DumpCommands(BufferIn, BufferInSize/4, LogTypes::WII_IPC_STM); |
| 175 | } |
| 176 | break; |
| 177 | |
| 178 | default: |
| 179 | _dbg_assert_msg_(WII_IPC_STM, 0, "unknown %s ioctl %x",{} |
| 180 | GetDeviceName().c_str(), Parameter){}; |
| 181 | break; |
| 182 | } |
| 183 | |
| 184 | // Write return value to the IPC call, 0 means success |
| 185 | Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); |
| 186 | return false; |
| 187 | } |
| 188 | |
| 189 | // STATE_TO_SAVE |
| 190 | u32 m_EventHookAddress; |
| 191 | }; |
| 192 | |
| 193 | #endif |