Switched InpOut32 with WinRing0
This commit is contained in:
parent
8b1424a150
commit
cd06401edd
21 changed files with 837 additions and 239 deletions
15
OpenRGB.pro
15
OpenRGB.pro
|
|
@ -976,7 +976,7 @@ FORMS +=
|
|||
win32:INCLUDEPATH += \
|
||||
dependencies/display-library/include \
|
||||
dependencies/hidapi \
|
||||
dependencies/inpout32_1501/Win32/ \
|
||||
dependencies/winring0/include \
|
||||
dependencies/libusb-1.0.22/include \
|
||||
dependencies/mbedtls-2.24.0/include \
|
||||
dependencies/NVFC \
|
||||
|
|
@ -1092,7 +1092,7 @@ win32:HEADERS +=
|
|||
dependencies/display-library/include/adl_defines.h \
|
||||
dependencies/display-library/include/adl_sdk.h \
|
||||
dependencies/display-library/include/adl_structures.h \
|
||||
dependencies/inpout32_1501/Win32/inpout32.h \
|
||||
dependencies/winring0/include/OlsApi.h \
|
||||
dependencies/NVFC/nvapi.h \
|
||||
i2c_smbus/i2c_smbus_i801.h \
|
||||
i2c_smbus/i2c_smbus_nct6775.h \
|
||||
|
|
@ -1108,7 +1108,7 @@ win32:HEADERS +=
|
|||
win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
LIBS += \
|
||||
-lws2_32 \
|
||||
-L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \
|
||||
-L"$$PWD/dependencies/winring0/x64/" -lWinRing0x64 \
|
||||
-L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \
|
||||
-L"$$PWD/dependencies/hidapi-win/x64/" -lhidapi \
|
||||
}
|
||||
|
|
@ -1116,7 +1116,7 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
|
|||
win32:contains(QMAKE_TARGET.arch, x86) {
|
||||
LIBS += \
|
||||
-lws2_32 \
|
||||
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
|
||||
-L"$$PWD/dependencies/winring0/Win32/" -lWinRing0 \
|
||||
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
|
||||
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi \
|
||||
}
|
||||
|
|
@ -1157,7 +1157,8 @@ win32:UI_DIR = _intermediate_$$DESTDIR/.ui
|
|||
|
||||
win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/x64/inpoutx64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/winring0/x64/WinRing0x64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/winring0/x64/WinRing0x64.sys )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS64/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/hidapi-win/x64/hidapi.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
first.depends = $(first) copydata
|
||||
|
|
@ -1168,7 +1169,9 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
|
|||
|
||||
win32:contains(QMAKE_TARGET.arch, x86) {
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/Win32/inpout32.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/winring0/Win32/WinRing0.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/winring0/Win32/WinRing0.sys )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/winring0/x64/WinRing0x64.sys )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS32/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/hidapi-win/x86/hidapi.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ There have been two instances of hardware damage in OpenRGB's development and we
|
|||
2. Open the OpenRGB.pro project in Qt Creator.
|
||||
3. Use the MSVC compiler kit, either 32- or 64-bit, to build the application.
|
||||
4. Run the project from Qt Creator. If you want to use your custom build standalone, download the latest matching Release package and replace the OpenRGB.exe in it with your new build.
|
||||
* **You must run the application as Administrator the first time to allow InpOut32 to set up. It can be run as a normal user afterwards**
|
||||
### SMBus Access
|
||||
* **You must run the application as Administrator the first time to allow WinRing0 to set up. It can be run as a normal user afterwards**
|
||||
* Early versions of OpenRGB used InpOut32. This is no longer needed and should be removed to avoid warnings by some anti-cheat software. You can uninstall Inpout32 by following the instructions [here](https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/669#note_461054255).
|
||||
|
||||
### USB Access
|
||||
|
||||
|
|
@ -202,7 +204,7 @@ There have been two instances of hardware damage in OpenRGB's development and we
|
|||
|
||||
## Projects Used
|
||||
|
||||
* InpOutx64: https://www.highrez.co.uk/downloads/inpout32/
|
||||
* WinRing0: https://openlibsys.org/
|
||||
* libusb: https://github.com/libusb/libusb
|
||||
* hidapi: https://github.com/libusb/hidapi
|
||||
* libe131: https://github.com/hhromic/libe131
|
||||
|
|
|
|||
|
|
@ -1188,8 +1188,8 @@ void ResourceManager::DetectDevicesThreadFunction()
|
|||
"<p>One or more I2C/SMBus interfaces failed to initialize.</p>"
|
||||
"<p>RGB DRAM modules and some motherboards' onboard RGB lighting will not be available without I2C/SMBus.</p>"
|
||||
#ifdef _WIN32
|
||||
"<p>On Windows, this is usually caused by a failure to load the inpout32 driver. "
|
||||
"You must run OpenRGB as administrator at least once to allow inpout32 to set up.</p>"
|
||||
"<p>On Windows, this is usually caused by a failure to load the WinRing0 driver. "
|
||||
"You must run OpenRGB as administrator at least once to allow WinRing0 to set up.</p>"
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
"<p>On Linux, this is usually because the i2c-dev module is not loaded. "
|
||||
|
|
|
|||
BIN
dependencies/inpout32_1501/Win32/inpout32.dll
vendored
BIN
dependencies/inpout32_1501/Win32/inpout32.dll
vendored
Binary file not shown.
32
dependencies/inpout32_1501/Win32/inpout32.h
vendored
32
dependencies/inpout32_1501/Win32/inpout32.h
vendored
|
|
@ -1,32 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
//Functions exported from DLL.
|
||||
//For easy inclusion is user projects.
|
||||
//Original InpOut32 function support
|
||||
void _stdcall Out32(short PortAddress, short data);
|
||||
short _stdcall Inp32(short PortAddress);
|
||||
|
||||
//My extra functions for making life easy
|
||||
BOOL _stdcall IsInpOutDriverOpen(); //Returns TRUE if the InpOut driver was opened successfully
|
||||
BOOL _stdcall IsXP64Bit(); //Returns TRUE if the OS is 64bit (x64) Windows.
|
||||
|
||||
//DLLPortIO function support
|
||||
UCHAR _stdcall DlPortReadPortUchar (USHORT port);
|
||||
void _stdcall DlPortWritePortUchar(USHORT port, UCHAR Value);
|
||||
|
||||
USHORT _stdcall DlPortReadPortUshort (USHORT port);
|
||||
void _stdcall DlPortWritePortUshort(USHORT port, USHORT Value);
|
||||
|
||||
ULONG _stdcall DlPortReadPortUlong(ULONG port);
|
||||
void _stdcall DlPortWritePortUlong(ULONG port, ULONG Value);
|
||||
|
||||
//WinIO function support (Untested and probably does NOT work - esp. on x64!)
|
||||
PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle);
|
||||
BOOL _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr);
|
||||
BOOL _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
|
||||
BOOL _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
dependencies/inpout32_1501/Win32/inpout32.lib
vendored
BIN
dependencies/inpout32_1501/Win32/inpout32.lib
vendored
Binary file not shown.
32
dependencies/inpout32_1501/x64/inpout32.h
vendored
32
dependencies/inpout32_1501/x64/inpout32.h
vendored
|
|
@ -1,32 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
//Functions exported from DLL.
|
||||
//For easy inclusion is user projects.
|
||||
//Original InpOut32 function support
|
||||
void _stdcall Out32(short PortAddress, short data);
|
||||
short _stdcall Inp32(short PortAddress);
|
||||
|
||||
//My extra functions for making life easy
|
||||
BOOL _stdcall IsInpOutDriverOpen(); //Returns TRUE if the InpOut driver was opened successfully
|
||||
BOOL _stdcall IsXP64Bit(); //Returns TRUE if the OS is 64bit (x64) Windows.
|
||||
|
||||
//DLLPortIO function support
|
||||
UCHAR _stdcall DlPortReadPortUchar (USHORT port);
|
||||
void _stdcall DlPortWritePortUchar(USHORT port, UCHAR Value);
|
||||
|
||||
USHORT _stdcall DlPortReadPortUshort (USHORT port);
|
||||
void _stdcall DlPortWritePortUshort(USHORT port, USHORT Value);
|
||||
|
||||
ULONG _stdcall DlPortReadPortUlong(ULONG port);
|
||||
void _stdcall DlPortWritePortUlong(ULONG port, ULONG Value);
|
||||
|
||||
//WinIO function support (Untested and probably does NOT work - esp. on x64!)
|
||||
PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle);
|
||||
BOOL _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr);
|
||||
BOOL _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
|
||||
BOOL _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
dependencies/inpout32_1501/x64/inpoutx64.dll
vendored
BIN
dependencies/inpout32_1501/x64/inpoutx64.dll
vendored
Binary file not shown.
BIN
dependencies/inpout32_1501/x64/inpoutx64.lib
vendored
BIN
dependencies/inpout32_1501/x64/inpoutx64.lib
vendored
Binary file not shown.
BIN
dependencies/winring0/Win32/WinRing0.dll
vendored
Normal file
BIN
dependencies/winring0/Win32/WinRing0.dll
vendored
Normal file
Binary file not shown.
BIN
dependencies/winring0/Win32/WinRing0.lib
vendored
Normal file
BIN
dependencies/winring0/Win32/WinRing0.lib
vendored
Normal file
Binary file not shown.
BIN
dependencies/winring0/Win32/WinRing0.sys
vendored
Normal file
BIN
dependencies/winring0/Win32/WinRing0.sys
vendored
Normal file
Binary file not shown.
580
dependencies/winring0/include/OlsApi.h
vendored
Normal file
580
dependencies/winring0/include/OlsApi.h
vendored
Normal file
|
|
@ -0,0 +1,580 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Author : hiyohiyo
|
||||
// Mail : hiyohiyo@crystalmark.info
|
||||
// Web : http://openlibsys.org/
|
||||
// License : The modified BSD license
|
||||
//
|
||||
// Copyright 2007-2009 OpenLibSys.org. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
// for WinRing0 1.3.x
|
||||
|
||||
#pragma once
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** DLL Information
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GetDllStatus
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // DLL Status, defined OLS_DLL_****
|
||||
WINAPI GetDllStatus();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GetDllVersion
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // DLL Version, defined OLS_VERSION
|
||||
WINAPI GetDllVersion(
|
||||
PBYTE major, // major version
|
||||
PBYTE minor, // minor version
|
||||
PBYTE revision, // revision
|
||||
PBYTE release // release/build
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GetDriverVersion
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // Device Driver Version, defined OLS_DRIVER_VERSION
|
||||
WINAPI GetDriverVersion(
|
||||
PBYTE major, // major version
|
||||
PBYTE minor, // minor version
|
||||
PBYTE revision, // revision
|
||||
PBYTE release // release/build
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GetDriverType
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // Device Driver Type, defined OLS_DRIVER_TYPE_****
|
||||
WINAPI GetDriverType();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InitializeOls
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI InitializeOls();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DeinitializeOls
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID WINAPI DeinitializeOls();
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** CPU
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// IsCpuid
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: support CPUID instruction, FALSE: not support CPUID instruction
|
||||
WINAPI IsCpuid();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// IsMsr
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: support MSR(Model-Specific Register), FALSE: not support MSR
|
||||
WINAPI IsMsr();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// IsTsc
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: support TSC(Time Stamp Counter), FALSE: not support TSC
|
||||
WINAPI IsTsc();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Rdmsr
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI Rdmsr(
|
||||
DWORD index, // MSR index
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx // bit 32-63
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RdmsrTx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI RdmsrTx(
|
||||
DWORD index, // MSR index
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx, // bit 32-63
|
||||
DWORD_PTR threadAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RdmsrPx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI RdmsrPx(
|
||||
DWORD index, // MSR index
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx, // bit 32-63
|
||||
DWORD_PTR processAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Wrmsr
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI Wrmsr(
|
||||
DWORD index, // MSR index
|
||||
DWORD eax, // bit 0-31
|
||||
DWORD edx // bit 32-63
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WrmsrTx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WrmsrTx(
|
||||
DWORD index, // MSR index
|
||||
DWORD eax, // bit 0-31
|
||||
DWORD edx, // bit 32-63
|
||||
DWORD_PTR threadAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WrmsrPx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WrmsrPx(
|
||||
DWORD index, // MSR index
|
||||
DWORD eax, // bit 0-31
|
||||
DWORD edx, // bit 32-63
|
||||
DWORD_PTR processAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Rdpmc
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI Rdpmc(
|
||||
DWORD index, // PMC index
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx // bit 32-63
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RdmsrTx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI RdpmcTx(
|
||||
DWORD index, // PMC index
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx, // bit 32-63
|
||||
DWORD_PTR threadAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RdmsrPx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI RdpmcPx(
|
||||
DWORD index, // PMC index
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx, // bit 32-63
|
||||
DWORD_PTR processAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Cpuid
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI Cpuid(
|
||||
DWORD index, // CPUID index
|
||||
PDWORD eax,
|
||||
PDWORD ebx,
|
||||
PDWORD ecx,
|
||||
PDWORD edx
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuidTx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI CpuidTx(
|
||||
DWORD index, // CPUID index
|
||||
PDWORD eax,
|
||||
PDWORD ebx,
|
||||
PDWORD ecx,
|
||||
PDWORD edx,
|
||||
DWORD_PTR threadAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuidPx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI CpuidPx(
|
||||
DWORD index, // CPUID index
|
||||
PDWORD eax,
|
||||
PDWORD ebx,
|
||||
PDWORD ecx,
|
||||
PDWORD edx,
|
||||
DWORD_PTR processAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Rdtsc
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI Rdtsc(
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx // bit 32-63
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RdmsrTx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI RdtscTx(
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx, // bit 32-63
|
||||
DWORD_PTR threadAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RdmsrPx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI RdtscPx(
|
||||
PDWORD eax, // bit 0-31
|
||||
PDWORD edx, // bit 32-63
|
||||
DWORD_PTR processAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Hlt
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI Hlt();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HltTx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI HltTx(
|
||||
DWORD_PTR threadAffinityMask
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HltPx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI HltTx(
|
||||
DWORD_PTR processAffinityMask
|
||||
);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** I/O
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadIoPortByte
|
||||
//-----------------------------------------------------------------------------
|
||||
BYTE // Read Value
|
||||
WINAPI ReadIoPortByte(
|
||||
WORD port // I/O port address
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadIoPortWord
|
||||
//-----------------------------------------------------------------------------
|
||||
WORD // Read Value
|
||||
WINAPI ReadIoPortWord(
|
||||
WORD port // I/O port address
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadIoPortDword
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // Read Value
|
||||
WINAPI ReadIoPortDword(
|
||||
WORD port // I/O port address
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadIoPortByteEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI ReadIoPortByteEx(
|
||||
WORD port, // I/O port address
|
||||
PBYTE value // Read Value
|
||||
);
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadIoPortWordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI ReadIoPortWordEx(
|
||||
WORD port, // I/O port address
|
||||
PWORD value // Read Value
|
||||
);
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadIoPortDwordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI ReadIoPortDwordEx(
|
||||
WORD port, // I/O port address
|
||||
PDWORD value // Read Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WriteIoPortByte
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID
|
||||
WINAPI WriteIoPortByte(
|
||||
WORD port, // I/O port address
|
||||
BYTE value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WriteIoPortDword
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID
|
||||
WINAPI WriteIoPortDword(
|
||||
WORD port, // I/O port address
|
||||
DWORD value // Write Value
|
||||
);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WriteIoPortWord
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID
|
||||
WINAPI WriteIoPortWord(
|
||||
WORD port, // I/O port address
|
||||
WORD value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WriteIoPortByteEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WriteIoPortByteEx(
|
||||
WORD port, // I/O port address
|
||||
BYTE value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WriteIoPortWordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WriteIoPortWordEx(
|
||||
WORD port, // I/O port address
|
||||
WORD value // Write Value
|
||||
);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WriteIoPortDwordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WriteIoPortDwordEx(
|
||||
WORD port, // I/O port address
|
||||
DWORD value // Write Value
|
||||
);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** PCI
|
||||
**
|
||||
******************************************************************************/
|
||||
// pciAddress
|
||||
// 0- 2: Function Number
|
||||
// 3- 7: Device Number
|
||||
// 8-15: PCI Bus Number
|
||||
// 16-31: Reserved
|
||||
// 0xFFFFFFFF : Error
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SetPciMaxBusNo
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID
|
||||
WINAPI SetPciMaxBusIndex(
|
||||
BYTE max // Max PCI Bus to Scan
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadPciConfigByte
|
||||
//-----------------------------------------------------------------------------
|
||||
BYTE // Read Value
|
||||
WINAPI ReadPciConfigByte(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
BYTE regAddress // Configuration Address 0-255
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadPciConfigWord
|
||||
//-----------------------------------------------------------------------------
|
||||
WORD // Read Value
|
||||
WINAPI ReadPciConfigWord(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
BYTE regAddress // Configuration Address 0-255
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadPciConfigDword
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // Read Value
|
||||
WINAPI ReadPciConfigDword(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
BYTE regAddress // Configuration Address 0-255
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadPciConfigByteEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI ReadPciConfigByteEx(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
DWORD regAddress, // Configuration Address 0-whatever
|
||||
PBYTE value // Read Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadPciConfigWordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI ReadPciConfigWordEx(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
DWORD regAddress, // Configuration Address 0-whatever
|
||||
PWORD value // Read Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadPciConfigDwordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI ReadPciConfigDwordEx(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
DWORD regAddress, // Configuration Address 0-whatever
|
||||
PDWORD value // Read Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WritePciConfigByte
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID
|
||||
WINAPI WritePciConfigByte(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
BYTE regAddress, // Configuration Address 0-255
|
||||
BYTE value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WritePciConfigWord
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID
|
||||
WINAPI WritePciConfigWord(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
BYTE regAddress, // Configuration Address 0-255
|
||||
WORD value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WritePciConfigDword
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID
|
||||
WINAPI WritePciConfigDword(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
BYTE regAddress, // Configuration Address 0-255
|
||||
DWORD value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WritePciConfigByteEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WritePciConfigByteEx(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
DWORD regAddress, // Configuration Address 0-whatever
|
||||
BYTE value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WritePciConfigWordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WritePciConfigWordEx(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
DWORD regAddress, // Configuration Address 0-whatever
|
||||
WORD value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WritePciConfigDwordEx
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL // TRUE: success, FALSE: failure
|
||||
WINAPI WritePciConfigDwordEx(
|
||||
DWORD pciAddress, // PCI Device Address
|
||||
DWORD regAddress, // Configuration Address 0-whatever
|
||||
DWORD value // Write Value
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FindPciDeviceById
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // pciAddress, 0xFFFFFFFF: failure
|
||||
WINAPI FindPciDeviceById(
|
||||
WORD vendorId, // Vendor ID
|
||||
WORD deviceId, // Device ID
|
||||
BYTE index // Index
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FindPciDeviceByClass
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // pciAddress, 0xFFFFFFFF: failure
|
||||
WINAPI FindPciDeviceByClass(
|
||||
BYTE baseClass, // Base Class
|
||||
BYTE subClass, // Sub Class
|
||||
BYTE programIf, // Program Interface
|
||||
BYTE index // Index
|
||||
);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Memory (Special API)
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef _PHYSICAL_MEMORY_SUPPORT
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadDmiMemory
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // Read size(byte), 0: failure
|
||||
WINAPI ReadDmiMemory(
|
||||
PBYTE buffer, // Buffer
|
||||
DWORD count, // Count
|
||||
DWORD unitSize // Unit Size (BYTE, WORD, DWORD)
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ReadPhysicalMemory
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // Read size(byte), 0: failure
|
||||
WINAPI ReadPhysicalMemory(
|
||||
DWORD_PTR address, // Physical Memory Address
|
||||
PBYTE buffer, // Buffer
|
||||
DWORD count, // Count
|
||||
DWORD unitSize // Unit Size (BYTE, WORD, DWORD)
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WritePhysicalMemory
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD // Write size(byte), 0: failure
|
||||
WINAPI WritePhysicalMemory(
|
||||
DWORD_PTR address, // Physical Memory Address
|
||||
PBYTE buffer, // Buffer
|
||||
DWORD count, // Count
|
||||
DWORD unitSize // Unit Size (BYTE, WORD, DWORD)
|
||||
);
|
||||
#endif
|
||||
BIN
dependencies/winring0/x64/WinRing0x64.dll
vendored
Normal file
BIN
dependencies/winring0/x64/WinRing0x64.dll
vendored
Normal file
Binary file not shown.
BIN
dependencies/winring0/x64/WinRing0x64.lib
vendored
Normal file
BIN
dependencies/winring0/x64/WinRing0x64.lib
vendored
Normal file
Binary file not shown.
BIN
dependencies/winring0/x64/WinRing0x64.sys
vendored
Normal file
BIN
dependencies/winring0/x64/WinRing0x64.sys
vendored
Normal file
Binary file not shown.
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "i2c_smbus_i801.h"
|
||||
#include <Windows.h>
|
||||
#include "inpout32.h"
|
||||
#include "OlsApi.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
|
@ -38,35 +38,35 @@ s32 i2c_smbus_i801::i801_access(u16 addr, char read_write, u8 command, int size,
|
|||
switch (size)
|
||||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
Out32(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
WriteIoPortByte(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
xact = I801_QUICK;
|
||||
break;
|
||||
case I2C_SMBUS_BYTE:
|
||||
Out32(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
WriteIoPortByte(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
xact = I801_BYTE;
|
||||
break;
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
Out32(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
Out32(SMBHSTDAT0, data->byte);
|
||||
WriteIoPortByte(SMBHSTDAT0, data->byte);
|
||||
xact = I801_BYTE_DATA;
|
||||
break;
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
Out32(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT0, data->word & 0xff);
|
||||
Out32(SMBHSTDAT1, (data->word & 0xff00) >> 8);
|
||||
WriteIoPortByte(SMBHSTDAT0, data->word & 0xff);
|
||||
WriteIoPortByte(SMBHSTDAT1, (data->word & 0xff00) >> 8);
|
||||
}
|
||||
xact = I801_WORD_DATA;
|
||||
break;
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
Out32(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
block = 1;
|
||||
break;
|
||||
case I2C_SMBUS_I2C_BLOCK_DATA:
|
||||
|
|
@ -76,17 +76,17 @@ s32 i2c_smbus_i801::i801_access(u16 addr, char read_write, u8 command, int size,
|
|||
* However if SPD Write Disable is set (Lynx Point and later),
|
||||
* the read will fail if we don't set the R/#W bit.
|
||||
*/
|
||||
Out32(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
WriteIoPortByte(SMBHSTADD, ((addr & 0x7f) << 1) | (read_write & 0x01));
|
||||
|
||||
if (read_write == I2C_SMBUS_READ)
|
||||
{
|
||||
/* NB: page 240 of ICH5 datasheet also shows
|
||||
* that DATA1 is the cmd field when reading */
|
||||
Out32(SMBHSTDAT1, command);
|
||||
WriteIoPortByte(SMBHSTDAT1, command);
|
||||
}
|
||||
else
|
||||
{
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
}
|
||||
block = 1;
|
||||
break;
|
||||
|
|
@ -98,7 +98,7 @@ s32 i2c_smbus_i801::i801_access(u16 addr, char read_write, u8 command, int size,
|
|||
//if (hwpec) /* enable/disable hardware PEC */
|
||||
// outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, SMBAUXCTL(priv));
|
||||
//else
|
||||
Out32(SMBAUXCTL, Inp32(SMBAUXCTL) & (~SMBAUXCTL_CRC));
|
||||
WriteIoPortByte(SMBAUXCTL, ReadIoPortByte(SMBAUXCTL) & (~SMBAUXCTL_CRC));
|
||||
|
||||
if (block)
|
||||
ret = i801_block_transaction(data, read_write, size, hwpec);
|
||||
|
|
@ -109,7 +109,7 @@ s32 i2c_smbus_i801::i801_access(u16 addr, char read_write, u8 command, int size,
|
|||
time, so we forcibly disable it after every transaction. Turn off
|
||||
E32B for the same reason. */
|
||||
//if (hwpec || block)
|
||||
Out32(SMBAUXCTL, Inp32(SMBAUXCTL) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B));
|
||||
WriteIoPortByte(SMBAUXCTL, ReadIoPortByte(SMBAUXCTL) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B));
|
||||
|
||||
if (block)
|
||||
goto out;
|
||||
|
|
@ -122,10 +122,10 @@ s32 i2c_smbus_i801::i801_access(u16 addr, char read_write, u8 command, int size,
|
|||
{
|
||||
case I801_BYTE: /* Result put in SMBHSTDAT0 */
|
||||
case I801_BYTE_DATA:
|
||||
data->byte = Inp32(SMBHSTDAT0);
|
||||
data->byte = ReadIoPortByte(SMBHSTDAT0);
|
||||
break;
|
||||
case I801_WORD_DATA:
|
||||
data->word = Inp32(SMBHSTDAT0) + (Inp32(SMBHSTDAT1) << 8);
|
||||
data->word = ReadIoPortByte(SMBHSTDAT0) + (ReadIoPortByte(SMBHSTDAT1) << 8);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -209,8 +209,8 @@ int i2c_smbus_i801::i801_block_transaction_byte_by_byte(i2c_smbus_data *data, ch
|
|||
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT0, len);
|
||||
Out32(SMBBLKDAT, data->block[1]);
|
||||
WriteIoPortByte(SMBHSTDAT0, len);
|
||||
WriteIoPortByte(SMBBLKDAT, data->block[1]);
|
||||
}
|
||||
|
||||
if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_READ)
|
||||
|
|
@ -244,10 +244,10 @@ int i2c_smbus_i801::i801_block_transaction_byte_by_byte(i2c_smbus_data *data, ch
|
|||
{
|
||||
if (i == len && read_write == I2C_SMBUS_READ)
|
||||
smbcmd |= SMBHSTCNT_LAST_BYTE;
|
||||
Out32(SMBHSTCNT, smbcmd);
|
||||
WriteIoPortByte(SMBHSTCNT, smbcmd);
|
||||
|
||||
if (i == 1)
|
||||
Out32(SMBHSTCNT, Inp32(SMBHSTCNT) | SMBHSTCNT_START);
|
||||
WriteIoPortByte(SMBHSTCNT, ReadIoPortByte(SMBHSTCNT) | SMBHSTCNT_START);
|
||||
|
||||
status = i801_wait_byte_done();
|
||||
if (status)
|
||||
|
|
@ -255,13 +255,13 @@ int i2c_smbus_i801::i801_block_transaction_byte_by_byte(i2c_smbus_data *data, ch
|
|||
|
||||
if (i == 1 && read_write == I2C_SMBUS_READ && command != I2C_SMBUS_I2C_BLOCK_DATA)
|
||||
{
|
||||
len = Inp32(SMBHSTDAT0);
|
||||
len = ReadIoPortByte(SMBHSTDAT0);
|
||||
if (len < 1 || len > I2C_SMBUS_BLOCK_MAX)
|
||||
{
|
||||
/* Recover */
|
||||
while (Inp32(SMBHSTSTS) & SMBHSTSTS_HOST_BUSY)
|
||||
Out32(SMBHSTSTS, SMBHSTSTS_BYTE_DONE);
|
||||
Out32(SMBHSTSTS, SMBHSTSTS_INTR);
|
||||
while (ReadIoPortByte(SMBHSTSTS) & SMBHSTSTS_HOST_BUSY)
|
||||
WriteIoPortByte(SMBHSTSTS, SMBHSTSTS_BYTE_DONE);
|
||||
WriteIoPortByte(SMBHSTSTS, SMBHSTSTS_INTR);
|
||||
return -EPROTO;
|
||||
}
|
||||
data->block[0] = len;
|
||||
|
|
@ -269,12 +269,12 @@ int i2c_smbus_i801::i801_block_transaction_byte_by_byte(i2c_smbus_data *data, ch
|
|||
|
||||
/* Retrieve/store value in SMBBLKDAT */
|
||||
if (read_write == I2C_SMBUS_READ)
|
||||
data->block[i] = Inp32(SMBBLKDAT);
|
||||
data->block[i] = ReadIoPortByte(SMBBLKDAT);
|
||||
if (read_write == I2C_SMBUS_WRITE && i + 1 <= len)
|
||||
Out32(SMBBLKDAT, data->block[i + 1]);
|
||||
WriteIoPortByte(SMBBLKDAT, data->block[i + 1]);
|
||||
|
||||
/* signals SMBBLKDAT ready */
|
||||
Out32(SMBHSTSTS, SMBHSTSTS_BYTE_DONE);
|
||||
WriteIoPortByte(SMBHSTSTS, SMBHSTSTS_BYTE_DONE);
|
||||
}
|
||||
|
||||
status = i801_wait_intr();
|
||||
|
|
@ -300,12 +300,12 @@ int i2c_smbus_i801::i801_check_post(int status)
|
|||
if (status < 0)
|
||||
{
|
||||
/* try to stop the current command */
|
||||
Out32(SMBHSTCNT, Inp32(SMBHSTCNT) | SMBHSTCNT_KILL);
|
||||
WriteIoPortByte(SMBHSTCNT, ReadIoPortByte(SMBHSTCNT) | SMBHSTCNT_KILL);
|
||||
//usleep_range(1000, 2000);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
Out32(SMBHSTCNT, Inp32(SMBHSTCNT) & (~SMBHSTCNT_KILL));
|
||||
WriteIoPortByte(SMBHSTCNT, ReadIoPortByte(SMBHSTCNT) & (~SMBHSTCNT_KILL));
|
||||
|
||||
Out32(SMBHSTSTS, STATUS_FLAGS);
|
||||
WriteIoPortByte(SMBHSTSTS, STATUS_FLAGS);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ int i2c_smbus_i801::i801_check_post(int status)
|
|||
}
|
||||
|
||||
/* Clear status flags except BYTE_DONE, to be cleared by caller */
|
||||
Out32(SMBHSTSTS, status);
|
||||
WriteIoPortByte(SMBHSTSTS, status);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -360,7 +360,7 @@ int i2c_smbus_i801::i801_check_pre()
|
|||
{
|
||||
int status;
|
||||
|
||||
status = Inp32(SMBHSTSTS);
|
||||
status = ReadIoPortByte(SMBHSTSTS);
|
||||
if (status & SMBHSTSTS_HOST_BUSY)
|
||||
{
|
||||
return -EBUSY;
|
||||
|
|
@ -369,8 +369,8 @@ int i2c_smbus_i801::i801_check_pre()
|
|||
status &= STATUS_FLAGS;
|
||||
if (status)
|
||||
{
|
||||
Out32(SMBHSTSTS, status);
|
||||
status = Inp32(SMBHSTSTS) & STATUS_FLAGS;
|
||||
WriteIoPortByte(SMBHSTSTS, status);
|
||||
status = ReadIoPortByte(SMBHSTSTS) & STATUS_FLAGS;
|
||||
if (status)
|
||||
{
|
||||
return -EBUSY;
|
||||
|
|
@ -412,7 +412,7 @@ int i2c_smbus_i801::i801_transaction(int xact)
|
|||
if (result < 0)
|
||||
return result;
|
||||
|
||||
Out32(SMBHSTCNT, Inp32(SMBHSTCNT) & ~SMBHSTCNT_INTREN);
|
||||
WriteIoPortByte(SMBHSTCNT, ReadIoPortByte(SMBHSTCNT) & ~SMBHSTCNT_INTREN);
|
||||
//if (priv->features & FEATURE_IRQ)
|
||||
//{
|
||||
// outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START,
|
||||
|
|
@ -431,7 +431,7 @@ int i2c_smbus_i801::i801_transaction(int xact)
|
|||
|
||||
/* the current contents of SMBHSTCNT can be overwritten, since PEC,
|
||||
* SMBSCMD are passed in xact */
|
||||
Out32(SMBHSTCNT, xact | SMBHSTCNT_START);
|
||||
WriteIoPortByte(SMBHSTCNT, xact | SMBHSTCNT_START);
|
||||
|
||||
status = i801_wait_intr();
|
||||
return i801_check_post(status);
|
||||
|
|
@ -449,7 +449,7 @@ int i2c_smbus_i801::i801_wait_byte_done()
|
|||
{
|
||||
std::this_thread::sleep_for(1ms);
|
||||
//usleep_range(250, 500);
|
||||
status = Inp32(SMBHSTSTS);
|
||||
status = ReadIoPortByte(SMBHSTSTS);
|
||||
} while (!(status & (STATUS_ERROR_FLAGS | SMBHSTSTS_BYTE_DONE)) && (timeout++ < MAX_RETRIES));
|
||||
|
||||
if (timeout > MAX_RETRIES)
|
||||
|
|
@ -469,7 +469,7 @@ int i2c_smbus_i801::i801_wait_intr()
|
|||
do
|
||||
{
|
||||
//usleep_range(250, 500);
|
||||
status = Inp32(SMBHSTSTS);
|
||||
status = ReadIoPortByte(SMBHSTSTS);
|
||||
} while (((status & SMBHSTSTS_HOST_BUSY) || !(status & (STATUS_ERROR_FLAGS | SMBHSTSTS_INTR))) && (timeout++ < MAX_RETRIES));
|
||||
|
||||
if (timeout > MAX_RETRIES)
|
||||
|
|
@ -494,9 +494,9 @@ s32 i2c_smbus_i801::i2c_xfer(u8 addr, char read_write, int* size, u8* data)
|
|||
|
||||
bool i2c_smbus_i801_detect()
|
||||
{
|
||||
if(!IsInpOutDriverOpen())
|
||||
if(!InitializeOls() || GetDllStatus())
|
||||
{
|
||||
LOG_INFO("inpout32 is not loaded, i801 I2C bus detection aborted");
|
||||
LOG_INFO("WinRing0 is not loaded, i801 I2C bus detection aborted");
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "i2c_smbus_nct6775.h"
|
||||
#include <Windows.h>
|
||||
#include "inpout32.h"
|
||||
#include "OlsApi.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
|
@ -23,45 +23,45 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
cnt = 0;
|
||||
len = 0;
|
||||
|
||||
Out32(SMBHSTCTL, NCT6775_SOFT_RESET);
|
||||
WriteIoPortByte(SMBHSTCTL, NCT6775_SOFT_RESET);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
break;
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
tmp_data.byte = data->byte;
|
||||
case I2C_SMBUS_BYTE:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTIDX, command);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTIDX, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT, tmp_data.byte);
|
||||
Out32(SMBHSTCMD, NCT6775_WRITE_BYTE);
|
||||
WriteIoPortByte(SMBHSTDAT, tmp_data.byte);
|
||||
WriteIoPortByte(SMBHSTCMD, NCT6775_WRITE_BYTE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Out32(SMBHSTCMD, NCT6775_READ_BYTE);
|
||||
WriteIoPortByte(SMBHSTCMD, NCT6775_READ_BYTE);
|
||||
}
|
||||
break;
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTIDX, command);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTIDX, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->word & 0xFF);
|
||||
Out32(SMBHSTDAT, (data->word & 0xFF00) >> 8);
|
||||
Out32(SMBHSTCMD, NCT6775_WRITE_WORD);
|
||||
WriteIoPortByte(SMBHSTDAT, data->word & 0xFF);
|
||||
WriteIoPortByte(SMBHSTDAT, (data->word & 0xFF00) >> 8);
|
||||
WriteIoPortByte(SMBHSTCMD, NCT6775_WRITE_WORD);
|
||||
}
|
||||
else
|
||||
{
|
||||
Out32(SMBHSTCMD, NCT6775_READ_WORD);
|
||||
WriteIoPortByte(SMBHSTCMD, NCT6775_READ_WORD);
|
||||
}
|
||||
break;
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTIDX, command);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTIDX, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
len = data->block[0];
|
||||
|
|
@ -69,7 +69,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
Out32(SMBBLKSZ, len);
|
||||
WriteIoPortByte(SMBBLKSZ, len);
|
||||
|
||||
//Load 4 bytes into FIFO
|
||||
cnt = 1;
|
||||
|
|
@ -77,7 +77,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
{
|
||||
for (i = cnt; i <= 4; i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
WriteIoPortByte(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len -= 4;
|
||||
|
|
@ -87,13 +87,13 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
{
|
||||
for (i = cnt; i <= len; i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
WriteIoPortByte(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len = 0;
|
||||
}
|
||||
|
||||
Out32(SMBHSTCMD, NCT6775_WRITE_BLOCK);
|
||||
WriteIoPortByte(SMBHSTCMD, NCT6775_WRITE_BLOCK);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -105,14 +105,14 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
Out32(SMBHSTCTL, NCT6775_MANUAL_START);
|
||||
WriteIoPortByte(SMBHSTCTL, NCT6775_MANUAL_START);
|
||||
|
||||
while ((size == I2C_SMBUS_BLOCK_DATA) && (len > 0))
|
||||
{
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
timeout = 0;
|
||||
while ((Inp32(SMBHSTSTS) & NCT6775_FIFO_EMPTY) == 0)
|
||||
while ((ReadIoPortByte(SMBHSTSTS) & NCT6775_FIFO_EMPTY) == 0)
|
||||
{
|
||||
if(timeout > NCT6775_MAX_RETRIES)
|
||||
{
|
||||
|
|
@ -127,7 +127,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
{
|
||||
for (i = cnt; i <= (cnt + 4); i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
WriteIoPortByte(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len -= 4;
|
||||
|
|
@ -137,7 +137,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
{
|
||||
for (i = cnt; i <= (cnt + len); i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
WriteIoPortByte(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len = 0;
|
||||
|
|
@ -151,7 +151,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
|
||||
//wait for manual mode to complete
|
||||
timeout = 0;
|
||||
while ((Inp32(SMBHSTSTS) & NCT6775_MANUAL_ACTIVE) != 0)
|
||||
while ((ReadIoPortByte(SMBHSTSTS) & NCT6775_MANUAL_ACTIVE) != 0)
|
||||
{
|
||||
if(timeout > NCT6775_MAX_RETRIES)
|
||||
{
|
||||
|
|
@ -161,7 +161,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
timeout++;
|
||||
}
|
||||
|
||||
if ((Inp32(SMBHSTERR) & NCT6775_NO_ACK) != 0)
|
||||
if ((ReadIoPortByte(SMBHSTERR) & NCT6775_NO_ACK) != 0)
|
||||
{
|
||||
return -EPROTO;
|
||||
}
|
||||
|
|
@ -174,10 +174,10 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
|||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
data->byte = (u8)Inp32(SMBHSTDAT);
|
||||
data->byte = (u8)ReadIoPortByte(SMBHSTDAT);
|
||||
break;
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
data->word = Inp32(SMBHSTDAT) + (Inp32(SMBHSTDAT) << 8);
|
||||
data->word = ReadIoPortByte(SMBHSTDAT) + (ReadIoPortByte(SMBHSTDAT) << 8);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -199,9 +199,9 @@ s32 i2c_smbus_nct6775::i2c_xfer(u8 addr, char read_write, int* size, u8* data)
|
|||
|
||||
bool i2c_smbus_nct6775_detect()
|
||||
{
|
||||
if(!IsInpOutDriverOpen())
|
||||
if(!InitializeOls() || GetDllStatus())
|
||||
{
|
||||
LOG_INFO("inpout32 is not loaded, nct6775 I2C bus detection aborted");
|
||||
LOG_INFO("WinRing0 is not loaded, nct6775 I2C bus detection aborted");
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus_piix4.h"
|
||||
#include "inpout32.h"
|
||||
#include "OlsApi.h"
|
||||
#include "LogManager.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
|
|
@ -49,13 +49,13 @@ int i2c_smbus_piix4::piix4_transaction()
|
|||
int timeout = 0;
|
||||
|
||||
/* Make sure the SMBus host is ready to start transmitting */
|
||||
temp = Inp32(SMBHSTSTS);
|
||||
temp = ReadIoPortByte(SMBHSTSTS);
|
||||
|
||||
if (temp != 0x00)
|
||||
{
|
||||
Out32(SMBHSTSTS, temp);
|
||||
WriteIoPortByte(SMBHSTSTS, temp);
|
||||
|
||||
temp = Inp32(SMBHSTSTS);
|
||||
temp = ReadIoPortByte(SMBHSTSTS);
|
||||
|
||||
if (temp != 0x00)
|
||||
{
|
||||
|
|
@ -64,8 +64,8 @@ int i2c_smbus_piix4::piix4_transaction()
|
|||
}
|
||||
|
||||
/* start the transaction by setting bit 6 */
|
||||
temp = Inp32(SMBHSTCNT);
|
||||
Out32(SMBHSTCNT, temp | 0x040);
|
||||
temp = ReadIoPortByte(SMBHSTCNT);
|
||||
WriteIoPortByte(SMBHSTCNT, temp | 0x040);
|
||||
|
||||
/* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
|
||||
temp = 0;
|
||||
|
|
@ -80,7 +80,7 @@ int i2c_smbus_piix4::piix4_transaction()
|
|||
|
||||
while ((++timeout < MAX_TIMEOUT) && temp <= 1)
|
||||
{
|
||||
temp = Inp32(SMBHSTSTS);
|
||||
temp = ReadIoPortByte(SMBHSTSTS);
|
||||
SetWaitableTimer(delay_timer, &retry_delay, 0, NULL, NULL, FALSE);
|
||||
WaitForSingleObject(delay_timer, INFINITE);
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ int i2c_smbus_piix4::piix4_transaction()
|
|||
{
|
||||
while ((++timeout < MAX_TIMEOUT) && temp <= 1)
|
||||
{
|
||||
temp = Inp32(SMBHSTSTS);
|
||||
temp = ReadIoPortByte(SMBHSTSTS);
|
||||
}
|
||||
}
|
||||
/* If the SMBus is still busy, we give up */
|
||||
|
|
@ -113,10 +113,10 @@ int i2c_smbus_piix4::piix4_transaction()
|
|||
result = -ENXIO;
|
||||
}
|
||||
|
||||
temp = Inp32(SMBHSTSTS);
|
||||
temp = ReadIoPortByte(SMBHSTSTS);
|
||||
if (temp != 0x00)
|
||||
{
|
||||
Out32(SMBHSTSTS, temp);
|
||||
WriteIoPortByte(SMBHSTSTS, temp);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -130,39 +130,39 @@ s32 i2c_smbus_piix4::piix4_access(u16 addr, char read_write, u8 command, int siz
|
|||
switch (size)
|
||||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
size = PIIX4_QUICK;
|
||||
break;
|
||||
case I2C_SMBUS_BYTE:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
}
|
||||
size = PIIX4_BYTE;
|
||||
break;
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT0, data->byte);
|
||||
WriteIoPortByte(SMBHSTDAT0, data->byte);
|
||||
}
|
||||
size = PIIX4_BYTE_DATA;
|
||||
break;
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT0, data->word & 0xFF);
|
||||
Out32(SMBHSTDAT1, (data->word & 0xFF00) >> 8);
|
||||
WriteIoPortByte(SMBHSTDAT0, data->word & 0xFF);
|
||||
WriteIoPortByte(SMBHSTDAT1, (data->word & 0xFF00) >> 8);
|
||||
}
|
||||
size = PIIX4_WORD_DATA;
|
||||
break;
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTCMD, command);
|
||||
WriteIoPortByte(SMBHSTADD, (addr << 1) | read_write);
|
||||
WriteIoPortByte(SMBHSTCMD, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
len = data->block[0];
|
||||
|
|
@ -170,11 +170,11 @@ s32 i2c_smbus_piix4::piix4_access(u16 addr, char read_write, u8 command, int siz
|
|||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
Out32(SMBHSTDAT0, len);
|
||||
Inp32(SMBHSTCNT);
|
||||
WriteIoPortByte(SMBHSTDAT0, len);
|
||||
ReadIoPortByte(SMBHSTCNT);
|
||||
for (i = 1; i <= len; i++)
|
||||
{
|
||||
Out32(SMBBLKDAT, data->block[i]);
|
||||
WriteIoPortByte(SMBBLKDAT, data->block[i]);
|
||||
}
|
||||
}
|
||||
size = PIIX4_BLOCK_DATA;
|
||||
|
|
@ -183,7 +183,7 @@ s32 i2c_smbus_piix4::piix4_access(u16 addr, char read_write, u8 command, int siz
|
|||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
Out32(SMBHSTCNT, (size & 0x1C));
|
||||
WriteIoPortByte(SMBHSTCNT, (size & 0x1C));
|
||||
|
||||
status = piix4_transaction();
|
||||
|
||||
|
|
@ -197,21 +197,21 @@ s32 i2c_smbus_piix4::piix4_access(u16 addr, char read_write, u8 command, int siz
|
|||
{
|
||||
case PIIX4_BYTE:
|
||||
case PIIX4_BYTE_DATA:
|
||||
data->byte = (u8)Inp32(SMBHSTDAT0);
|
||||
data->byte = (u8)ReadIoPortByte(SMBHSTDAT0);
|
||||
break;
|
||||
case PIIX4_WORD_DATA:
|
||||
data->word = Inp32(SMBHSTDAT0) + (Inp32(SMBHSTDAT1) << 8);
|
||||
data->word = ReadIoPortByte(SMBHSTDAT0) + (ReadIoPortByte(SMBHSTDAT1) << 8);
|
||||
break;
|
||||
case PIIX4_BLOCK_DATA:
|
||||
data->block[0] = (u8)Inp32(SMBHSTDAT0);
|
||||
data->block[0] = (u8)ReadIoPortByte(SMBHSTDAT0);
|
||||
if (data->block[0] == 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX)
|
||||
{
|
||||
return -EPROTO;
|
||||
}
|
||||
Inp32(SMBHSTCNT);
|
||||
ReadIoPortByte(SMBHSTCNT);
|
||||
for (i = 1; i <= data->block[0]; i++)
|
||||
{
|
||||
data->block[i] = (u8)Inp32(SMBBLKDAT);
|
||||
data->block[i] = (u8)ReadIoPortByte(SMBBLKDAT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -234,9 +234,9 @@ s32 i2c_smbus_piix4::i2c_xfer(u8 addr, char read_write, int* size, u8* data)
|
|||
|
||||
bool i2c_smbus_piix4_detect()
|
||||
{
|
||||
if(!IsInpOutDriverOpen())
|
||||
if(!InitializeOls() || GetDllStatus())
|
||||
{
|
||||
LOG_INFO("inpout32 is not loaded, piix4 I2C bus detection aborted");
|
||||
LOG_INFO("WinRing0 is not loaded, piix4 I2C bus detection aborted");
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
80
main.cpp
80
main.cpp
|
|
@ -146,6 +146,80 @@ bool AttemptLocalConnection()
|
|||
return success;
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* Install SMBus Driver WinRing0, If not already installed (Win32) *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
#ifdef _WIN32
|
||||
void InstallWinRing0()
|
||||
{
|
||||
TCHAR winring0_install_location[MAX_PATH]; // driver final location usually C:\windows\system32\drivers\WinRing0x64.sys
|
||||
uint system_path_length = GetSystemDirectory(winring0_install_location, MAX_PATH);
|
||||
std::string winring0_filename = "WinRing0.sys";
|
||||
BOOL bIsWow64 = false;
|
||||
#if _WIN64
|
||||
winring0_filename = "WinRing0x64.sys";
|
||||
#else
|
||||
BOOL (*fnIsWow64Process)(HANDLE, PBOOL) = (BOOL (__cdecl *)(HANDLE, PBOOL))GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
|
||||
if (fnIsWow64Process)
|
||||
{
|
||||
fnIsWow64Process(GetCurrentProcess(),&bIsWow64);
|
||||
}
|
||||
if(bIsWow64)
|
||||
{
|
||||
winring0_filename = "WinRing0x64.sys";
|
||||
}
|
||||
#endif
|
||||
std::strncat(winring0_install_location, "\\drivers\\", MAX_PATH - system_path_length - 1);
|
||||
std::strncat(winring0_install_location, winring0_filename.c_str(), MAX_PATH - system_path_length - 10);
|
||||
|
||||
std::string driver_name = winring0_filename.substr(0, winring0_filename.size() - 4); // driver name: WinRing0 or WinRing0x64
|
||||
SC_HANDLE manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (manager)
|
||||
{
|
||||
PVOID wow64_fsredirection_OldValue = NULL;
|
||||
if(bIsWow64)
|
||||
{
|
||||
Wow64DisableWow64FsRedirection(&wow64_fsredirection_OldValue);
|
||||
}
|
||||
if(INVALID_FILE_ATTRIBUTES == GetFileAttributes(winring0_install_location) && GetLastError()==ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
char module_path_buffer[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, module_path_buffer, MAX_PATH);
|
||||
std::string::size_type exe_loc = std::string(module_path_buffer).find_last_of("\\/");
|
||||
std::string driver_source_path = std::string(module_path_buffer).substr(0, exe_loc + 1) + winring0_filename;
|
||||
CopyFile(driver_source_path.c_str(), winring0_install_location, true);
|
||||
}
|
||||
if(bIsWow64)
|
||||
{
|
||||
Wow64RevertWow64FsRedirection(wow64_fsredirection_OldValue);
|
||||
}
|
||||
|
||||
SC_HANDLE service = OpenService(manager, driver_name.c_str(), SERVICE_ALL_ACCESS);
|
||||
if(!service)
|
||||
{
|
||||
std::string service_sys_path = "System32\\Drivers\\" + winring0_filename;
|
||||
service = CreateService(manager,
|
||||
driver_name.c_str(),
|
||||
driver_name.c_str(),
|
||||
SERVICE_ALL_ACCESS,
|
||||
SERVICE_KERNEL_DRIVER,
|
||||
SERVICE_AUTO_START,
|
||||
SERVICE_ERROR_NORMAL,
|
||||
service_sys_path.c_str(),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
CloseServiceHandle(service);
|
||||
CloseServiceHandle(manager);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* main *
|
||||
|
|
@ -177,8 +251,12 @@ int main(int argc, char* argv[])
|
|||
std::thread * InitializeTimerResolutionThread;
|
||||
InitializeTimerResolutionThread = new std::thread(InitializeTimerResolutionThreadFunction);
|
||||
InitializeTimerResolutionThread->detach();
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Windows only - Install SMBus Driver WinRing0 |
|
||||
\*---------------------------------------------------------*/
|
||||
InstallWinRing0();
|
||||
#endif
|
||||
/*---------------------------------------------------------*\
|
||||
| Process command line arguments before detection |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -5,12 +5,11 @@
|
|||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "super_io.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#include "inpout32.h"
|
||||
#include "OlsApi.h"
|
||||
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
|
@ -31,8 +30,8 @@ int dev_port_fd;
|
|||
void superio_enter(int ioreg)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Out32(ioreg, 0x87);
|
||||
Out32(ioreg, 0x87);
|
||||
WriteIoPortByte(ioreg, 0x87);
|
||||
WriteIoPortByte(ioreg, 0x87);
|
||||
#else
|
||||
unsigned char temp = 0x87;
|
||||
dev_port_fd = open("/dev/port", O_RDWR, "rw");
|
||||
|
|
@ -60,8 +59,8 @@ void superio_enter(int ioreg)
|
|||
void superio_outb(int ioreg, int reg, int val)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Out32(ioreg, reg);
|
||||
Out32(ioreg + 1, val);
|
||||
WriteIoPortByte(ioreg, reg);
|
||||
WriteIoPortByte(ioreg + 1, val);
|
||||
#else
|
||||
dev_port_fd = open("/dev/port", O_RDWR, "rw");
|
||||
|
||||
|
|
@ -87,8 +86,8 @@ void superio_outb(int ioreg, int reg, int val)
|
|||
int superio_inb(int ioreg, int reg)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Out32(ioreg, reg);
|
||||
return Inp32(ioreg + 1);
|
||||
WriteIoPortByte(ioreg, reg);
|
||||
return ReadIoPortByte(ioreg + 1);
|
||||
#else
|
||||
unsigned char temp = 0;
|
||||
dev_port_fd = open("/dev/port", O_RDWR, "rw");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue