From 8d8f70bfdf6c8a5ce1f7fce797e90144070ab4f5 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Mon, 8 Sep 2025 20:25:53 -0500 Subject: [PATCH] Only build PawnIO support in 64-bit builds, provide non-functional stub implementations in super_io.cpp for 32-bit builds --- OpenRGB.pro | 11 ++++++++--- super_io/super_io.cpp | 26 ++++++++++++++++++++++++-- super_io/super_io_pawnio.cpp | 3 +-- super_io/super_io_pawnio.h | 18 ------------------ 4 files changed, 33 insertions(+), 25 deletions(-) delete mode 100644 super_io/super_io_pawnio.h diff --git a/OpenRGB.pro b/OpenRGB.pro index 86b64c977..8095b6222 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -198,6 +198,7 @@ HEADERS += scsiapi/scsiapi.h \ serial_port/find_usb_serial_port.h \ serial_port/serial_port.h \ + super_io/super_io.h \ StringUtils.h \ SuspendResume/SuspendResume.h \ AutoStart/AutoStart.h \ @@ -342,8 +343,6 @@ win32:SOURCES += dependencies/NVFC/nvapi.cpp \ i2c_smbus/Windows/i2c_smbus_amdadl.cpp \ i2c_smbus/Windows/i2c_smbus_nvapi.cpp \ - i2c_smbus/Windows/i2c_smbus_pawnio.cpp \ - super_io/super_io_pawnio.cpp \ scsiapi/scsiapi_windows.c \ serial_port/find_usb_serial_port_win.cpp \ SuspendResume/SuspendResume_Windows.cpp \ @@ -362,12 +361,15 @@ win32:HEADERS += i2c_smbus/Windows/i2c_smbus_amdadl.h \ i2c_smbus/Windows/i2c_smbus_nvapi.h \ i2c_smbus/Windows/i2c_smbus_pawnio.h \ - super_io/super_io_pawnio.h \ wmi/wmi.h \ AutoStart/AutoStart-Windows.h \ SuspendResume/SuspendResume_Windows.h \ win32:contains(QMAKE_TARGET.arch, x86_64) { + win32:SOURCES += \ + i2c_smbus/Windows/i2c_smbus_pawnio.cpp \ + super_io/super_io_pawnio.cpp \ + LIBS += \ -lws2_32 \ -liphlpapi \ @@ -378,6 +380,9 @@ win32:contains(QMAKE_TARGET.arch, x86_64) { } win32:contains(QMAKE_TARGET.arch, x86) { + win32:SOURCES += \ + super_io/super_io.cpp \ + LIBS += \ -lws2_32 \ -liphlpapi \ diff --git a/super_io/super_io.cpp b/super_io/super_io.cpp index 65e6ae984..40ec69879 100644 --- a/super_io/super_io.cpp +++ b/super_io/super_io.cpp @@ -10,10 +10,10 @@ \*---------------------------------------------------------*/ #include "super_io.h" -#include "super_io_pawnio.h" -#if _MACOSX_X86_X64 +#if defined(_MACOSX_X86_X64) #include "macUSPCIOAccess.h" +#elif defined(_WIN32) #else #include #include @@ -35,6 +35,13 @@ void superio_enter(int ioreg) #if defined(_MACOSX_X86_X64) WriteIoPortByte(ioreg, 0x87); WriteIoPortByte(ioreg, 0x87); +#elif defined(_WIN32) + /*-----------------------------------------------------*\ + | This function is not defined for Windows | + | For 64-bit Windows, super_io_pawnio.cpp is used | + | instead. For 32-bit Windows, this function provides| + | a nonfunctional stub implementation. | + \*-----------------------------------------------------*/ #else unsigned char temp = 0x87; dev_port_fd = open("/dev/port", O_RDWR, "rw"); @@ -72,6 +79,13 @@ void superio_outb(int ioreg, int reg, int val) #if defined(_MACOSX_X86_X64) WriteIoPortByte(ioreg, reg); WriteIoPortByte(ioreg + 1, val); +#elif defined(_WIN32) + /*-----------------------------------------------------*\ + | This function is not defined for Windows | + | For 64-bit Windows, super_io_pawnio.cpp is used | + | instead. For 32-bit Windows, this function provides| + | a nonfunctional stub implementation. | + \*-----------------------------------------------------*/ #else dev_port_fd = open("/dev/port", O_RDWR, "rw"); @@ -107,6 +121,14 @@ int superio_inb(int ioreg, int reg) #if defined(_MACOSX_X86_X64) WriteIoPortByte(ioreg, reg); return ReadIoPortByte(ioreg + 1); +#elif defined(_WIN32) + /*-----------------------------------------------------*\ + | This function is not defined for Windows | + | For 64-bit Windows, super_io_pawnio.cpp is used | + | instead. For 32-bit Windows, this function provides| + | a nonfunctional stub implementation. | + \*-----------------------------------------------------*/ + return -1; #else unsigned char temp = 0; dev_port_fd = open("/dev/port", O_RDWR, "rw"); diff --git a/super_io/super_io_pawnio.cpp b/super_io/super_io_pawnio.cpp index 6d4f85ddd..cd629dfd7 100644 --- a/super_io/super_io_pawnio.cpp +++ b/super_io/super_io_pawnio.cpp @@ -9,13 +9,12 @@ | SPDX-License-Identifier: GPL-2.0-only | \*---------------------------------------------------------*/ -#include "super_io_pawnio.h" +#include "super_io.h" #include #include "PawnIOLib.h" #include "i2c_smbus_pawnio.h" - static HANDLE pawnio_handle = NULL; static int pawnio_chip_type = 0; diff --git a/super_io/super_io_pawnio.h b/super_io/super_io_pawnio.h deleted file mode 100644 index ac4b3b876..000000000 --- a/super_io/super_io_pawnio.h +++ /dev/null @@ -1,18 +0,0 @@ -/*---------------------------------------------------------*\ -| super_io_pawnio.h | -| | -| Functions for interfacing with Super-IO using PawnIO | -| | -| Stephen Horvath (Steve-Tech) 05 May 2025 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-only | -\*---------------------------------------------------------*/ - -#pragma once - -void superio_enter(int ioreg); - -void superio_outb(int ioreg, int reg, int val); - -int superio_inb(int ioreg, int reg);