Update PawnIO modules to release 0.2.4 and implement SMBus sleep mode setting

master
Adam Honse 3 weeks ago
parent 800ca0aa7c
commit 0691f40588

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -20,6 +20,39 @@
std::unordered_map<std::string, int> i2c_smbus_pawnio::using_handle;
s32 piix4_port_sel(HANDLE pawnio_handle, s32 port)
{
const SIZE_T in_size = 1;
ULONG64 in[in_size] = {(ULONG64)port};
const SIZE_T out_size = 1;
ULONG64 out[out_size];
SIZE_T return_size;
HRESULT status;
/*-----------------------------------------------------*\
| Execute PIIX4 port_sel ioctl |
\*-----------------------------------------------------*/
status = pawnio_execute(pawnio_handle, "ioctl_piix4_port_sel", in, in_size, out, 1, &return_size);
return(status ? -EIO : 0);
}
s32 set_sleep_mode(HANDLE pawnio_handle, s32 sleep_mode)
{
const SIZE_T in_size = 1;
ULONG64 in[in_size] = {(ULONG64)sleep_mode};
const SIZE_T out_size = 0;
SIZE_T return_size;
HRESULT status;
/*-----------------------------------------------------*\
| Execute PIIX4 port_sel ioctl |
\*-----------------------------------------------------*/
status = pawnio_execute(pawnio_handle, "ioctl_set_sleep_mode", in, in_size, NULL, 1, &return_size);
return(status ? -EIO : 0);
}
i2c_smbus_pawnio::i2c_smbus_pawnio(HANDLE handle, std::string name)
{
/*-----------------------------------------------------*\
@ -49,23 +82,23 @@ i2c_smbus_pawnio::i2c_smbus_pawnio(HANDLE handle, std::string name)
if(!status)
{
this->pci_vendor = (out[2] & 0x000000000000FFFF);
this->pci_device = (out[2] & 0x00000000FFFF0000) >> 16;
this->pci_subsystem_vendor = (out[2] & 0x0000FFFF0000FFFF) >> 32;
this->pci_subsystem_device = (out[2] & 0xFFFF000000000000) >> 48;
this->pci_vendor = (int)(out[2] & 0x000000000000FFFF);
this->pci_device = (int)((out[2] & 0x00000000FFFF0000) >> 16);
this->pci_subsystem_vendor = (int)((out[2] & 0x0000FFFF0000FFFF) >> 32);
this->pci_subsystem_device = (int)((out[2] & 0xFFFF000000000000) >> 48);
char name_str[9];
name_str[0] = (out[0] & 0x00000000000000FF);
name_str[1] = (out[0] & 0x000000000000FF00) >> 8;
name_str[2] = (out[0] & 0x0000000000FF0000) >> 16;
name_str[3] = (out[0] & 0x00000000FF000000) >> 24;
name_str[4] = (out[0] & 0x000000FF00000000) >> 32;
name_str[5] = (out[0] & 0x0000FF0000000000) >> 40;
name_str[6] = (out[0] & 0x00FF000000000000) >> 48;
name_str[7] = (out[0] & 0xFF00000000000000) >> 56;
name_str[0] = (char)(out[0] & 0x00000000000000FF);
name_str[1] = (char)((out[0] & 0x000000000000FF00) >> 8);
name_str[2] = (char)((out[0] & 0x0000000000FF0000) >> 16);
name_str[3] = (char)((out[0] & 0x00000000FF000000) >> 24);
name_str[4] = (char)((out[0] & 0x000000FF00000000) >> 32);
name_str[5] = (char)((out[0] & 0x0000FF0000000000) >> 40);
name_str[6] = (char)((out[0] & 0x00FF000000000000) >> 48);
name_str[7] = (char)((out[0] & 0xFF00000000000000) >> 56);
name_str[8] = 0;
strncpy( this->device_name, name_str, 512 );
strncpy(this->device_name, name_str, 512 );
}
/*-----------------------------------------------------*\
@ -79,6 +112,26 @@ i2c_smbus_pawnio::i2c_smbus_pawnio(HANDLE handle, std::string name)
}
/*-----------------------------------------------------*\
| Get shared SMBus access setting |
\*-----------------------------------------------------*/
unsigned int smbus_sleep_mode = PAWNIO_SLEEPMODE_ALWAYSSLEEP;
if(drivers_settings.contains("smbus_sleep_mode"))
{
smbus_sleep_mode = drivers_settings["smbus_sleep_mode"];
}
if(smbus_sleep_mode >= PAWNIO_SLEEPMODE_MAX)
{
smbus_sleep_mode = PAWNIO_SLEEPMODE_ALWAYSSLEEP;
}
/*-----------------------------------------------------*\
| Initialize sleep mode |
\*-----------------------------------------------------*/
set_sleep_mode(handle, smbus_sleep_mode);
/*-----------------------------------------------------*\
| Create global SMBus mutex if enabled |
\*-----------------------------------------------------*/
if(shared_smbus_access)
@ -274,23 +327,6 @@ HRESULT i2c_smbus_pawnio::start_pawnio(std::string filename, PHANDLE phandle)
return(S_OK);
}
s32 piix4_port_sel(HANDLE pawnio_handle, s32 port)
{
const SIZE_T in_size = 1;
ULONG64 in[in_size] = {(ULONG64)port};
const SIZE_T out_size = 1;
ULONG64 out[out_size];
SIZE_T return_size;
HRESULT status;
/*-----------------------------------------------------*\
| Execute PIIX4 port_sel ioctl |
\*-----------------------------------------------------*/
status = pawnio_execute(pawnio_handle, "ioctl_piix4_port_sel", in, in_size, out, 1, &return_size);
return(status ? -EIO : 0);
}
bool i2c_smbus_pawnio_detect()
{
ULONG dll_version;
@ -331,7 +367,7 @@ bool i2c_smbus_pawnio_detect()
\*-----------------------------------------------------*/
if(i2c_smbus_pawnio::start_pawnio("SmbusPIIX4.bin", &pawnio_handle) == S_OK)
{
/*--------------------------------------------------*\
/*-------------------------------------------------*\
| Select port 1 |
\*-------------------------------------------------*/
piix4_port_sel(pawnio_handle, 1);

@ -21,6 +21,14 @@
#define GLOBAL_SMBUS_MUTEX_NAME "Global\\Access_SMBUS.HTP.Method"
enum
{
PAWNIO_SLEEPMODE_ALWAYSBUSY = 0,
PAWNIO_SLEEPMODE_SHORTBUSY = 1,
PAWNIO_SLEEPMODE_ALWAYSSLEEP = 2,
PAWNIO_SLEEPMODE_MAX
};
class i2c_smbus_pawnio : public i2c_smbus_interface
{
public:

Loading…
Cancel
Save