Introduced EEPROM device
This commit is contained in:
parent
806266c08e
commit
c630daacdc
|
@ -45,7 +45,7 @@ namespace xboxkrnl
|
|||
#include <shlobj.h> // For HANDLE, CreateFile, CreateFileMapping, MapViewOfFile
|
||||
|
||||
#include "Cxbx.h" // For DbgPrintf
|
||||
#include "EmuEEPROM.h" // For EEPROMInfo, EEPROMInfos
|
||||
#include "EmuEEPROM.h" // For EEPROMInfo, EEPROMInfos, EEPROMDevice
|
||||
|
||||
xboxkrnl::XBOX_EEPROM *EEPROM = nullptr; // Set using CxbxRestoreEEPROM()
|
||||
|
||||
|
@ -153,3 +153,20 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
|
|||
|
||||
return pEEPROM;
|
||||
}
|
||||
|
||||
// EEPROMDevice
|
||||
|
||||
void EEPROMDevice::Init() {}
|
||||
|
||||
void EEPROMDevice::Reset() {}
|
||||
|
||||
void EEPROMDevice::QuickCommand(int read) {}
|
||||
uint8_t EEPROMDevice::ReceiveByte() { return 0; }
|
||||
uint8_t EEPROMDevice::ReadByte(uint8_t command) { return *(((PBYTE)EEPROM) + command); }
|
||||
uint16_t EEPROMDevice::ReadWord(uint8_t command) { return *((PWORD)(((PBYTE)EEPROM) + command)); }
|
||||
int EEPROMDevice::ReadBlock(uint8_t command, uint8_t *data) { return 0; }
|
||||
|
||||
void EEPROMDevice::SendByte(uint8_t data) {}
|
||||
void EEPROMDevice::WriteByte(uint8_t command, uint8_t value) { *((PWORD)(((PBYTE)EEPROM) + command)) = value; }
|
||||
void EEPROMDevice::WriteWord(uint8_t command, uint16_t value) { *((PWORD)(((PBYTE)EEPROM) + command)) = value; }
|
||||
void EEPROMDevice::WriteBlock(uint8_t command, uint8_t* data, int length) { memcpy(((PBYTE)EEPROM) + command, data, length); }
|
||||
|
|
|
@ -103,4 +103,31 @@ extern xboxkrnl::ULONG XboxFactoryGameRegion;
|
|||
}
|
||||
#endif
|
||||
|
||||
#include "../CxbxKrnl/SMDevice.h"
|
||||
|
||||
class EEPROMDevice : public SMDevice {
|
||||
public:
|
||||
using SMDevice::SMDevice;
|
||||
|
||||
// SMDevice functions
|
||||
void Init();
|
||||
void Reset();
|
||||
|
||||
void QuickCommand(int read);
|
||||
uint8_t ReceiveByte();
|
||||
uint8_t ReadByte(uint8_t command);
|
||||
uint16_t ReadWord(uint8_t command);
|
||||
int ReadBlock(uint8_t command, uint8_t *data);
|
||||
|
||||
void SendByte(uint8_t data);
|
||||
void WriteByte(uint8_t command, uint8_t value);
|
||||
void WriteWord(uint8_t command, uint16_t value);
|
||||
void WriteBlock(uint8_t command, uint8_t* data, int length);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
extern EEPROMDevice* g_EEPROM;
|
||||
|
||||
#endif // EMU_EEPROM_H
|
|
@ -68,6 +68,7 @@ namespace xboxkrnl
|
|||
|
||||
PCIBus* g_PCIBus;
|
||||
SMBus* g_SMBus;
|
||||
EEPROMDevice* g_EEPROM;
|
||||
|
||||
/* prevent name collisions */
|
||||
namespace NtDll
|
||||
|
@ -1008,9 +1009,20 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
EmuHLEIntercept(pXbeHeader);
|
||||
SetupXboxDeviceTypes();
|
||||
|
||||
#define SMBUS_SMC_SLAVE_ADDRESS 0x20 // = Write; Read = 0x21
|
||||
#define SMBUS_EEPROM_ADDRESS 0xA8 // = Write; Read = 0xA9
|
||||
#define SMBUS_TV_ENCODER_ID_CONEXANT 0x8A // = Write; Read = 08B
|
||||
#define SMBUS_TV_ENCODER_ID_FOCUS 0xD4 // = Write; Read = 0D5
|
||||
|
||||
// Init Hardware
|
||||
g_PCIBus = new PCIBus();
|
||||
g_SMBus = new SMBus();
|
||||
g_EEPROM = new EEPROMDevice();
|
||||
g_SMBus->ConnectDevice(SMBUS_EEPROM_ADDRESS, g_EEPROM);
|
||||
// TODO : Handle other SMBUS Addresses, like PIC_ADDRESS, XCALIBUR_ADDRESS
|
||||
// Resources : http://pablot.com/misc/fancontroller.cpp
|
||||
// https://github.com/JayFoxRox/Chihiro-Launcher/blob/master/hook.h
|
||||
|
||||
g_PCIBus->ConnectDevice(PCI_DEVID(0, PCI_DEVFN(1, 1)), g_SMBus);
|
||||
|
||||
// Always initialise NV2A: We may need it for disabled HLE patches too!
|
||||
|
|
Loading…
Reference in New Issue