Permalink
Browse files

PCI : Move Xbox hardware initialization towards it's own file

  • Loading branch information...
PatrickvL authored and LukeUsher committed Dec 22, 2017
1 parent f1a8689 commit 0d1973828220956be2668c2fd89650f7f0d31321
View
@@ -243,6 +243,7 @@
<ClInclude Include="..\..\src\CxbxKrnl\VMManager.h" />
<ClInclude Include="..\..\src\CxbxKrnl\SMBus.h" />
<ClInclude Include="..\..\src\CxbxKrnl\SMDevice.h" />
<ClInclude Include="..\..\src\CxbxKrnl\Xbox.h" />
<ClInclude Include="..\..\src\CxbxVersion.h" />
<ClInclude Include="..\..\src\Cxbx\DlgAbout.h" />
<ClInclude Include="..\..\src\Cxbx\DlgAudioConfig.h" />
@@ -533,6 +534,7 @@
</ClCompile>
<ClCompile Include="..\..\src\CxbxKrnl\SMBus.cpp" />
<ClCompile Include="..\..\src\CxbxKrnl\SMDevice.cpp" />
<ClCompile Include="..\..\src\CxbxKrnl\Xbox.cpp" />
<ClCompile Include="..\..\src\CxbxKrnl\VMManager.cpp" />
<ClCompile Include="..\..\src\Cxbx\DlgAbout.cpp" />
<ClCompile Include="..\..\src\Cxbx\DlgAudioConfig.cpp" />
@@ -223,6 +223,9 @@
<ClCompile Include="..\..\src\CxbxKrnl\EmuX86.cpp">
<Filter>Hardware</Filter>
</ClCompile>
<ClCompile Include="..\..\src\CxbxKrnl\Xbox.cpp">
<Filter>Hardware</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\Cxbx\DlgControllerConfig.h">
@@ -435,6 +438,9 @@
<ClInclude Include="..\..\src\CxbxKrnl\EmuX86.h">
<Filter>Hardware</Filter>
</ClInclude>
<ClInclude Include="..\..\src\CxbxKrnl\Xbox.h">
<Filter>Hardware</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\resource\Splash.jpg">
View
@@ -63,19 +63,9 @@ namespace xboxkrnl
#include <time.h> // For time()
#include <sstream> // For std::ostringstream
#include "PCIBus.h"
#include "SMBus.h"
#include "EEPROMDevice.h" // For EEPROMDevice
#include "Xbox.h" // For InitXboxHardware()
#include "EEPROMDevice.h" // For g_EEPROM
#include "LED.h" // For LED::Sequence
#include "SMCDevice.h" // For SMCDevice
#include "EmuNVNet.h" // For NVNetDevice
PCIBus* g_PCIBus;
SMBus* g_SMBus;
EEPROMDevice* g_EEPROM;
SMCDevice* g_SMC;
NVNetDevice* g_NVNet;
/* prevent name collisions */
namespace NtDll
@@ -1020,29 +1010,13 @@ __declspec(noreturn) void CxbxKrnlInit
XTL::CxbxInitAudio();
EmuHLEIntercept(pXbeHeader);
SetupXboxDeviceTypes();
#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((uint8_t*)EEPROM);
g_SMBus->ConnectDevice(SMBUS_EEPROM_ADDRESS, g_EEPROM);
// https://github.com/docbrown/vxb/wiki/Xbox-Hardware-Information
// https://web.archive.org/web/20100617022549/http://www.xbox-linux.org/wiki/PIC
g_SMC = new SMCDevice(Revision1_1); // TODO : Make configurable
g_SMBus->ConnectDevice(SMBUS_SMC_SLAVE_ADDRESS, g_SMC);
// 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
SetupXboxDeviceTypes();
g_PCIBus->ConnectDevice(PCI_DEVID(0, PCI_DEVFN(1, 1)), g_SMBus);
InitXboxHardware();
g_NVNet = new NVNetDevice();
g_PCIBus->ConnectDevice(PCI_DEVID(0, PCI_DEVFN(4, 0)), g_NVNet);
// Now the hardware devices exist, couple the EEPROM buffer to it's device
g_EEPROM->SetEEPROM((uint8_t*)EEPROM);
// Always initialise NV2A: We may need it for disabled HLE patches too!
EmuNV2A_Init();
@@ -41,9 +41,6 @@
class EEPROMDevice : public SMDevice {
public:
// constructor
EEPROMDevice(uint8_t* pEEPROM) : m_pEEPROM(pEEPROM) {};
// SMDevice functions
void Init();
void Reset();
@@ -58,6 +55,9 @@ class EEPROMDevice : public SMDevice {
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);
// EEPROMDevice function
void SetEEPROM(uint8_t* pEEPROM) { m_pEEPROM = pEEPROM; };
private:
uint8_t* m_pEEPROM;
};
View
@@ -0,0 +1,72 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
// ******************************************************************
// *
// * .,-::::: .,:: .::::::::. .,:: .:
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
// * src->CxbxKrnl->Xbox.cpp
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them under the terms of the GNU General Public
// * License as published by the Free Software Foundation; either
// * version 2 of the license, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2017 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
// ******************************************************************
#include "Xbox.h"
#include "PCIBus.h" // For PCIBus
#include "SMBus.h" // For SMBus
#include "SMCDevice.h" // For SMCDevice
#include "EEPROMDevice.h" // For EEPROMDevice
#include "EmuNVNet.h" // For NVNetDevice
PCIBus* g_PCIBus;
SMBus* g_SMBus;
SMCDevice* g_SMC;
EEPROMDevice* g_EEPROM;
NVNetDevice* g_NVNet;
#define SMBUS_TV_ENCODER_ID_CONEXANT 0x8A // = Write; Read = 08B
#define SMBUS_TV_ENCODER_ID_FOCUS 0xD4 // = Write; Read = 0D5
void InitXboxHardware()
{
g_PCIBus = new PCIBus();
g_SMBus = new SMBus();
g_SMC = new SMCDevice(Revision1_1); // TODO : Make configurable
g_EEPROM = new EEPROMDevice();
g_NVNet = new NVNetDevice();
g_SMBus->ConnectDevice(SMBUS_SMC_SLAVE_ADDRESS, g_SMC);
g_SMBus->ConnectDevice(SMBUS_EEPROM_ADDRESS, g_EEPROM);
g_PCIBus->ConnectDevice(PCI_DEVID(0, PCI_DEVFN(1, 1)), g_SMBus);
g_PCIBus->ConnectDevice(PCI_DEVID(0, PCI_DEVFN(4, 0)), g_NVNet);
// 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
// https://github.com/docbrown/vxb/wiki/Xbox-Hardware-Information
// https://web.archive.org/web/20100617022549/http://www.xbox-linux.org/wiki/PIC
}
View
@@ -0,0 +1,37 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
// ******************************************************************
// *
// * .,-::::: .,:: .::::::::. .,:: .:
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
// * src->CxbxKrnl->Xbox.h
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them under the terms of the GNU General Public
// * License as published by the Free Software Foundation; either
// * version 2 of the license, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2017 Patrick van Logchem <pvanlogchem@gmail.com>
// *
// * All rights reserved
// *
// ******************************************************************#pragma once
extern void InitXboxHardware();

0 comments on commit 0d19738

Please sign in to comment.