Prevent non xbox code threads from hogging the Xbox code execution core
This commit is contained in:
parent
c6e7360157
commit
84e90157ab
|
@ -250,6 +250,7 @@ void InputDeviceManager::StartInputThread()
|
|||
|
||||
void InputDeviceManager::InputThread(InputDeviceManager* pVoid)
|
||||
{
|
||||
SetThreadAffinityMask(GetCurrentThread(), g_CPUOthers);
|
||||
bool bContinue = true;
|
||||
SDL_Event event;
|
||||
|
||||
|
|
|
@ -2366,7 +2366,6 @@ DWORD WINAPI WndMain::DebuggerMonitor(LPVOID lpVoid)
|
|||
}
|
||||
void WndMain::DebuggerMonitorClose()
|
||||
{
|
||||
|
||||
if (m_hDebuggerProc != nullptr) {
|
||||
HANDLE hDebuggerProcTemp = m_hDebuggerProc;
|
||||
std::thread hDebuggerMonitorThreadTemp = std::thread(std::move(m_hDebuggerMonitorThread));
|
||||
|
|
|
@ -515,11 +515,6 @@ VOID XTL::CxbxInitWindow(bool bFullInit)
|
|||
ExitProcess(0);
|
||||
}
|
||||
|
||||
// Ported from Dxbx :
|
||||
// If possible, assign this thread to another core than the one that runs Xbox1 code :
|
||||
if (bFullInit)
|
||||
SetThreadAffinityMask(hRenderWindowThread, g_CPUOthers);
|
||||
|
||||
while(!g_bRenderWindowActive)
|
||||
Sleep(0);
|
||||
|
||||
|
@ -1384,6 +1379,7 @@ static BOOL WINAPI EmuEnumDisplayDevices(GUID FAR *lpGUID, LPSTR lpDriverDescrip
|
|||
static DWORD WINAPI EmuRenderWindow(LPVOID lpVoid)
|
||||
{
|
||||
CxbxSetThreadName("Cxbx Render Window");
|
||||
SetThreadAffinityMask(GetCurrentThread(), g_CPUOthers);
|
||||
|
||||
// register window class
|
||||
{
|
||||
|
|
|
@ -556,10 +556,11 @@ VOID WINAPI XTL::EMUPATCH(DirectSoundDoWork)()
|
|||
}
|
||||
// For Async process purpose only
|
||||
static void dsound_thread_worker(LPVOID nullPtr)
|
||||
{
|
||||
while (true) {
|
||||
Sleep(0);
|
||||
{
|
||||
SetThreadAffinityMask(GetCurrentThread(), g_CPUOthers);
|
||||
|
||||
while (true) {
|
||||
Sleep(0);
|
||||
enterCriticalSection;
|
||||
|
||||
vector_ds_stream::iterator ppDSStream = g_pDSoundStreamCache.begin();
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
// 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->devices->AC97Device.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) 2018 Luke Usher <luke.usher@outlook.coM>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "AC97Device.h"
|
||||
|
||||
void AC97Device::Init()
|
||||
{
|
||||
PCIBarRegister r;
|
||||
r.Raw.type = PCI_BAR_TYPE_MEMORY;
|
||||
r.Memory.address = AC97_BASE >> 4;
|
||||
RegisterBAR(0, AC97_SIZE, r.value);
|
||||
|
||||
m_DeviceId = 0x01B1;
|
||||
m_VendorId = PCI_VENDOR_ID_NVIDIA;
|
||||
}
|
||||
|
||||
void AC97Device::Reset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t AC97Device::IORead(int barIndex, uint32_t addr, unsigned size)
|
||||
{
|
||||
printf("AC97Device: Unimplemented IORead %X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AC97Device::IOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned size)
|
||||
{
|
||||
printf("AC97Device: Unimplemented IOWrite %X\n", addr);
|
||||
}
|
||||
|
||||
uint32_t AC97Device::MMIORead(int barIndex, uint32_t addr, unsigned size)
|
||||
{
|
||||
printf("AC97Device: Unimplemented MMIORead %X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AC97Device::MMIOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned size)
|
||||
{
|
||||
printf("AC97Device: Unimplemented MMIOWrite %X\n", addr);
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
// 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->devices->AC97Device.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) 2018 Luke Usher <luke.usher@outlook.com>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#ifndef _AC97_H_
|
||||
#define _AC97_H_
|
||||
|
||||
#include "../PCIDevice.h"
|
||||
class AC97Device : public PCIDevice {
|
||||
public:
|
||||
using PCIDevice::PCIDevice;
|
||||
|
||||
// PCI Functions
|
||||
void Init();
|
||||
void Reset();
|
||||
|
||||
uint32_t IORead(int barIndex, uint32_t addr, unsigned size = sizeof(uint8_t));
|
||||
void IOWrite(int barIndex, uint32_t addr, uint32_t data, unsigned size = sizeof(uint8_t));
|
||||
|
||||
uint32_t MMIORead(int barIndex, uint32_t addr, unsigned size);
|
||||
void MMIOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned size);
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,170 @@
|
|||
// 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->devices->APUDevice.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) 2018 Luke Usher <luke.usher@outlook.coM>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "APUDevice.h"
|
||||
|
||||
extern uint32_t GetAPUTime();
|
||||
|
||||
// TODO: Everything :P
|
||||
// TODO: Audio Processing/Thread
|
||||
|
||||
#define APU_VP_BASE 0x20000
|
||||
#define APU_VP_SIZE 0x10000
|
||||
|
||||
#define APU_GP_BASE 0x30000
|
||||
#define APU_GP_SIZE 0x10000
|
||||
|
||||
#define APU_EP_BASE 0x50000
|
||||
#define APU_EP_SIZE 0x10000
|
||||
|
||||
void APUDevice::Init()
|
||||
{
|
||||
PCIBarRegister r;
|
||||
r.Raw.type = PCI_BAR_TYPE_IO;
|
||||
r.IO.address = 0xD000 >> 4;
|
||||
RegisterBAR(0, 256, r.value);
|
||||
|
||||
r.Raw.type = PCI_BAR_TYPE_IO;
|
||||
r.IO.address = 0xD200 >> 4;
|
||||
RegisterBAR(0, 128, r.value);
|
||||
|
||||
r.Raw.type = PCI_BAR_TYPE_MEMORY;
|
||||
r.Memory.address = APU_BASE >> 4;
|
||||
RegisterBAR(2, APU_SIZE, r.value);
|
||||
|
||||
m_DeviceId = 0x01B0;
|
||||
m_VendorId = PCI_VENDOR_ID_NVIDIA;
|
||||
}
|
||||
|
||||
void APUDevice::Reset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t APUDevice::IORead(int barIndex, uint32_t addr, unsigned size)
|
||||
{
|
||||
printf("APUDevice: Unimplemented IORead %X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void APUDevice::IOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned size)
|
||||
{
|
||||
printf("APUDevice: Unimplemented IOWrite %X\n", addr);
|
||||
}
|
||||
|
||||
uint32_t APUDevice::MMIORead(int barIndex, uint32_t addr, unsigned size)
|
||||
{
|
||||
if (addr >= APU_VP_BASE && addr < APU_VP_BASE + APU_VP_SIZE) {
|
||||
return VPRead(addr - APU_VP_BASE, size);
|
||||
}
|
||||
|
||||
if (addr >= APU_GP_BASE && addr < APU_GP_BASE + APU_GP_SIZE) {
|
||||
return GPRead(addr - APU_GP_BASE, size);
|
||||
}
|
||||
|
||||
if (addr >= APU_EP_BASE && addr < APU_EP_BASE + APU_EP_SIZE) {
|
||||
return EPRead(addr - APU_EP_BASE, size);
|
||||
}
|
||||
|
||||
switch (addr) {
|
||||
case 0x200C: return GetAPUTime();
|
||||
}
|
||||
|
||||
printf("APUDevice: Unimplemented MMIORead %X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void APUDevice::MMIOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned size)
|
||||
{
|
||||
if (addr >= APU_VP_BASE && addr < APU_VP_BASE + APU_VP_SIZE) {
|
||||
VPWrite(addr - APU_VP_BASE, value, size);
|
||||
return;
|
||||
}
|
||||
|
||||
if (addr >= APU_GP_BASE && addr < APU_GP_BASE + APU_GP_SIZE) {
|
||||
GPWrite(addr - APU_GP_BASE, value, size);
|
||||
return;
|
||||
}
|
||||
|
||||
if (addr >= APU_EP_BASE && addr < APU_EP_BASE + APU_EP_SIZE) {
|
||||
EPWrite(addr - APU_EP_BASE, value, size);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("APUDevice: Unimplemented MMIOWrite %X\n", addr);
|
||||
}
|
||||
|
||||
|
||||
uint32_t APUDevice::GPRead(uint32_t addr, unsigned size)
|
||||
{
|
||||
printf("APUDevice: Unimplemented GP MMIORead %X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void APUDevice::GPWrite(uint32_t addr, uint32_t value, unsigned size)
|
||||
{
|
||||
printf("APUDevice: Unimplemented GP MMIOWrite %X\n", addr);
|
||||
}
|
||||
|
||||
|
||||
uint32_t APUDevice::VPRead(uint32_t addr, unsigned size)
|
||||
{
|
||||
switch (addr) {
|
||||
case 0x10: return 0x80; // HACK: Pretend the FIFO is always empty, bypasses hangs when APU isn't fully implemented
|
||||
}
|
||||
|
||||
printf("APUDevice: Unimplemented VP MMIORead %X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void APUDevice::VPWrite(uint32_t addr, uint32_t value, unsigned size)
|
||||
{
|
||||
printf("APUDevice: Unimplemented VP MMIOWrite %X\n", addr);
|
||||
}
|
||||
|
||||
|
||||
uint32_t APUDevice::EPRead(uint32_t addr, unsigned size)
|
||||
{
|
||||
printf("APUDevice: Unimplemented EP MMIORead %X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void APUDevice::EPWrite(uint32_t addr, uint32_t value, unsigned size)
|
||||
{
|
||||
printf("APUDevice: Unimplemented EP MMIOWrite %X\n", addr);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
// 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->devices->APUDevice.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) 2018 Luke Usher <luke.usher@outlook.com>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#ifndef _APU_H_
|
||||
#define _APU_H_
|
||||
|
||||
#include "../PCIDevice.h"
|
||||
class APUDevice : public PCIDevice {
|
||||
public:
|
||||
using PCIDevice::PCIDevice;
|
||||
|
||||
// PCI Functions
|
||||
void Init();
|
||||
void Reset();
|
||||
|
||||
uint32_t IORead(int barIndex, uint32_t addr, unsigned size = sizeof(uint8_t));
|
||||
void IOWrite(int barIndex, uint32_t addr, uint32_t data, unsigned size = sizeof(uint8_t));
|
||||
|
||||
uint32_t MMIORead(int barIndex, uint32_t addr, unsigned size);
|
||||
void MMIOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned size);
|
||||
private:
|
||||
uint32_t GPRead(uint32_t addr, unsigned size);
|
||||
void GPWrite(uint32_t addr, uint32_t value, unsigned size);
|
||||
uint32_t EPRead(uint32_t addr, unsigned size);
|
||||
void EPWrite(uint32_t addr, uint32_t value, unsigned size);
|
||||
uint32_t VPRead(uint32_t addr, unsigned size);
|
||||
void VPWrite(uint32_t addr, uint32_t value, unsigned size);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -227,6 +227,7 @@ static void pfifo_run_puller(NV2AState *d)
|
|||
|
||||
int pfifo_puller_thread(NV2AState *d)
|
||||
{
|
||||
SetThreadAffinityMask(GetCurrentThread(), g_CPUOthers);
|
||||
CxbxSetThreadName("Cxbx NV2A FIFO puller");
|
||||
|
||||
glo_set_current(d->pgraph.gl_context);
|
||||
|
@ -461,6 +462,7 @@ static void pfifo_run_pusher(NV2AState *d)
|
|||
|
||||
int pfifo_pusher_thread(NV2AState *d)
|
||||
{
|
||||
SetThreadAffinityMask(GetCurrentThread(), g_CPUOthers);
|
||||
CxbxSetThreadName("Cxbx NV2A FIFO pusher");
|
||||
|
||||
qemu_mutex_lock(&d->pfifo.pfifo_lock);
|
||||
|
|
|
@ -1113,6 +1113,7 @@ void NV2ADevice::UpdateHostDisplay(NV2AState *d)
|
|||
// TODO: Fix this properly
|
||||
static void nv2a_vblank_thread(NV2AState *d)
|
||||
{
|
||||
SetThreadAffinityMask(GetCurrentThread(), g_CPUOthers);
|
||||
CxbxSetThreadName("Cxbx NV2A VBLANK");
|
||||
auto nextVBlankTime = GetNextVBlankTime();
|
||||
|
||||
|
|
Loading…
Reference in New Issue