Skip to content

Commit

Permalink
Merge pull request #5105 from lioncash/namespace
Browse files Browse the repository at this point in the history
EXI: Namespace device classes
  • Loading branch information
lioncash committed Apr 8, 2017
2 parents f09d17f + 44fb429 commit ab18eba
Show file tree
Hide file tree
Showing 37 changed files with 156 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/Boot/Boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename)
SConfig::GetDirectoryForRegion(boot_region));

// Run the descrambler over the encrypted section containing BS1/BS2
CEXIIPL::Descrambler((u8*)data.data() + 0x100, 0x1AFE00);
ExpansionInterface::CEXIIPL::Descrambler((u8*)data.data() + 0x100, 0x1AFE00);

// TODO: Execution is supposed to start at 0xFFF00000, not 0x81200000;
// copying the initial boot code to 0x81200000 is a hack.
Expand Down
17 changes: 15 additions & 2 deletions Source/Core/Core/Boot/Boot_BS2Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"

namespace
{
void PresetTimeBaseTicks()
{
const u64 emulated_time =
ExpansionInterface::CEXIIPL::GetEmulatedTime(ExpansionInterface::CEXIIPL::GC_EPOCH);

const u64 time_base_ticks = emulated_time * 40500000ULL;

PowerPC::HostWrite_U64(time_base_ticks, 0x800030D8);
}
} // Anonymous namespace

void CBoot::RunFunction(u32 address)
{
PC = address;
Expand Down Expand Up @@ -93,8 +106,8 @@ bool CBoot::EmulatedBS2_GC(bool skip_app_loader)
PowerPC::HostWrite_U32(0x4c000064, 0x80000800); // Write default FPU Handler: rfi
PowerPC::HostWrite_U32(0x4c000064, 0x80000C00); // Write default Syscall Handler: rfi

PowerPC::HostWrite_U64((u64)CEXIIPL::GetEmulatedTime(CEXIIPL::GC_EPOCH) * (u64)40500000,
0x800030D8); // Preset time base ticks
PresetTimeBaseTicks();

// HIO checks this
// PowerPC::HostWrite_U16(0x8200, 0x000030e6); // Console type

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/BootManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct ConfigCache
std::string m_strGPUDeterminismMode;
std::array<int, MAX_BBMOTES> iWiimoteSource;
std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads;
std::array<TEXIDevices, ExpansionInterface::MAX_EXI_CHANNELS> m_EXIDevice;
std::array<ExpansionInterface::TEXIDevices, ExpansionInterface::MAX_EXI_CHANNELS> m_EXIDevice;
};

void ConfigCache::SaveConfig(const SConfig& config)
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("MemcardBPath", &m_strMemoryCardB);
core->Get("AgpCartAPath", &m_strGbaCartA);
core->Get("AgpCartBPath", &m_strGbaCartB);
core->Get("SlotA", (int*)&m_EXIDevice[0], EXIDEVICE_MEMORYCARD);
core->Get("SlotB", (int*)&m_EXIDevice[1], EXIDEVICE_NONE);
core->Get("SerialPort1", (int*)&m_EXIDevice[2], EXIDEVICE_NONE);
core->Get("SlotA", (int*)&m_EXIDevice[0], ExpansionInterface::EXIDEVICE_MEMORYCARD);
core->Get("SlotB", (int*)&m_EXIDevice[1], ExpansionInterface::EXIDEVICE_NONE);
core->Get("SerialPort1", (int*)&m_EXIDevice[2], ExpansionInterface::EXIDEVICE_NONE);
core->Get("BBA_MAC", &m_bba_mac);
core->Get("TimeProfiling", &bJITILTimeProfiling, false);
core->Get("OutputIR", &bJITILOutputIR, false);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ struct SConfig : NonCopyable
std::string m_strMemoryCardB;
std::string m_strGbaCartA;
std::string m_strGbaCartB;
TEXIDevices m_EXIDevice[3];
ExpansionInterface::TEXIDevices m_EXIDevice[3];
SerialInterface::SIDevices m_SIDevice[4];
std::string m_bba_mac;

Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/BBA-TAP/TAP_Apple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Core/HW/EXI/EXI_Device.h"
#include "Core/HW/EXI/EXI_DeviceEthernet.h"

namespace ExpansionInterface
{
bool CEXIETHERNET::Activate()
{
if (IsActivated())
Expand Down Expand Up @@ -105,3 +107,4 @@ void CEXIETHERNET::RecvStop()
{
readEnabled.Clear();
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/BBA-TAP/TAP_Unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <sys/socket.h>
#endif

namespace ExpansionInterface
{
#define NOTIMPLEMENTED(Name) \
NOTICE_LOG(SP1, "CEXIETHERNET::%s not implemented for your UNIX", Name);

Expand Down Expand Up @@ -181,3 +183,4 @@ void CEXIETHERNET::RecvStop()
NOTIMPLEMENTED("RecvStop");
#endif
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ bool OpenTAP(HANDLE& adapter, const std::basic_string<TCHAR>& device_guid)

} // namespace Win32TAPHelper

namespace ExpansionInterface
{
bool CEXIETHERNET::Activate()
{
if (IsActivated())
Expand Down Expand Up @@ -362,3 +364,4 @@ void CEXIETHERNET::RecvStop()
{
readEnabled.Clear();
}
} // namespace ExpansionInterface
8 changes: 5 additions & 3 deletions Source/Core/Core/HW/EXI/EXI.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

#include "Common/CommonTypes.h"

class CEXIChannel;
class IEXIDevice;
class PointerWrap;
enum TEXIDevices : int;

namespace CoreTiming
{
enum class FromThread;
Expand All @@ -21,6 +19,10 @@ class Mapping;

namespace ExpansionInterface
{
class CEXIChannel;
class IEXIDevice;
enum TEXIDevices : int;

enum
{
MAX_MEMORYCARD_SLOTS = 2,
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "Core/HW/EXI/EXI_Device.h"
#include "Core/HW/MMIO.h"

namespace ExpansionInterface
{
enum
{
EXI_READ,
Expand Down Expand Up @@ -268,3 +270,4 @@ IEXIDevice* CEXIChannel::FindDevice(TEXIDevices device_type, int custom_index)
}
return nullptr;
}
} // namespace ExpansionInterface
9 changes: 7 additions & 2 deletions Source/Core/Core/HW/EXI/EXI_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
#include <memory>
#include "Common/CommonTypes.h"

class IEXIDevice;
class PointerWrap;
enum TEXIDevices : int;

namespace MMIO
{
class Mapping;
}

namespace ExpansionInterface
{
class IEXIDevice;
enum TEXIDevices : int;

class CEXIChannel
{
public:
Expand Down Expand Up @@ -113,3 +117,4 @@ class CEXIChannel
// Since channels operate a bit differently from each other
u32 m_channel_id;
};
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "Core/HW/EXI/EXI_DeviceMic.h"
#include "Core/HW/Memmap.h"

namespace ExpansionInterface
{
void IEXIDevice::ImmWrite(u32 data, u32 size)
{
while (size--)
Expand Down Expand Up @@ -153,3 +155,4 @@ std::unique_ptr<IEXIDevice> EXIDevice_Create(const TEXIDevices device_type, cons

return result;
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

class PointerWrap;

namespace ExpansionInterface
{
enum TEXIDevices : int
{
EXIDEVICE_DUMMY,
Expand Down Expand Up @@ -64,3 +66,4 @@ class IEXIDevice
};

std::unique_ptr<IEXIDevice> EXIDevice_Create(TEXIDevices device_type, int channel_num);
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceAD16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"

namespace ExpansionInterface
{
CEXIAD16::CEXIAD16() = default;

void CEXIAD16::SetCS(int cs)
Expand Down Expand Up @@ -106,3 +108,4 @@ void CEXIAD16::DoState(PointerWrap& p)
p.Do(m_command);
p.Do(m_ad16_register);
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceAD16.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class PointerWrap;

namespace ExpansionInterface
{
class CEXIAD16 : public IEXIDevice
{
public:
Expand Down Expand Up @@ -37,3 +39,4 @@ class CEXIAD16 : public IEXIDevice

void TransferByte(u8& byte) override;
};
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"

namespace ExpansionInterface
{
CEXIAgp::CEXIAgp(int index)
{
m_slot = index;
Expand Down Expand Up @@ -381,3 +383,4 @@ void CEXIAgp::DoState(PointerWrap& p)
p.Do(m_rom_size);
p.Do(m_rw_offset);
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceAGP.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

class PointerWrap;

namespace ExpansionInterface
{
class CEXIAgp : public IEXIDevice
{
public:
Expand Down Expand Up @@ -63,3 +65,4 @@ class CEXIAgp : public IEXIDevice
u32 m_current_cmd = 0;
u32 m_return_pos = 0;
};
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceDummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"

namespace ExpansionInterface
{
CEXIDummy::CEXIDummy(const std::string& name) : m_name{name}
{
}
Expand Down Expand Up @@ -42,3 +44,4 @@ bool CEXIDummy::IsPresent() const
void CEXIDummy::TransferByte(u8& byte)
{
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceDummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "Common/CommonTypes.h"
#include "Core/HW/EXI/EXI_Device.h"

namespace ExpansionInterface
{
// Just a dummy that logs reads and writes
// to be used for EXI devices we haven't emulated
// DOES NOT FUNCTION AS "NO DEVICE INSERTED" -> Appears as unknown device
Expand All @@ -30,3 +32,4 @@ class CEXIDummy final : public IEXIDevice

std::string m_name;
};
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "Core/HW/EXI/EXI.h"
#include "Core/HW/Memmap.h"

namespace ExpansionInterface
{
// XXX: The BBA stores multi-byte elements as little endian.
// Multiple parts of this implementation depend on Dolphin
// being compiled for a little endian host.
Expand Down Expand Up @@ -589,3 +591,4 @@ bool CEXIETHERNET::RecvHandlePacket()

return true;
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

class PointerWrap;

namespace ExpansionInterface
{
// Network Control Register A
enum NCRA
{
Expand Down Expand Up @@ -338,3 +340,4 @@ class CEXIETHERNET : public IEXIDevice
Common::Flag readThreadShutdown;
#endif
};
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceGecko.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "Common/Thread.h"
#include "Core/Core.h"

namespace ExpansionInterface
{
u16 GeckoSockServer::server_port;
int GeckoSockServer::client_count;
std::thread GeckoSockServer::connectionThread;
Expand Down Expand Up @@ -221,3 +223,4 @@ void CEXIGecko::ImmReadWrite(u32& _uData, u32 _uSize)
break;
}
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceGecko.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "Common/Flag.h"
#include "Core/HW/EXI/EXI_Device.h"

namespace ExpansionInterface
{
class GeckoSockServer
{
public:
Expand Down Expand Up @@ -66,3 +68,4 @@ class CEXIGecko : public IEXIDevice, private GeckoSockServer

static const u32 ident = 0x04700000;
};
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include "DiscIO/Enums.h"

namespace ExpansionInterface
{
// We should provide an option to choose from the above, or figure out the checksum (the algo in
// yagcd seems wrong)
// so that people can change default language.
Expand Down Expand Up @@ -435,3 +437,4 @@ u32 CEXIIPL::GetEmulatedTime(u32 epoch)

return static_cast<u32>(ltime) - epoch;
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceIPL.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

class PointerWrap;

namespace ExpansionInterface
{
class CEXIIPL : public IEXIDevice
{
public:
Expand Down Expand Up @@ -76,3 +78,4 @@ class CEXIIPL : public IEXIDevice
void LoadFontFile(const std::string& filename, u32 offset);
std::string FindIPLDump(const std::string& path_prefix);
};
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "DiscIO/Enums.h"
#include "DiscIO/NANDContentLoader.h"

namespace ExpansionInterface
{
#define MC_STATUS_BUSY 0x80
#define MC_STATUS_UNLOCKED 0x40
#define MC_STATUS_SLEEP 0x20
Expand Down Expand Up @@ -532,3 +534,4 @@ void CEXIMemoryCard::DMAWrite(u32 _uAddr, u32 _uSize)
CoreTiming::ScheduleEvent(_uSize * (SystemTimers::GetTicksPerSecond() / MC_TRANSFER_RATE_WRITE),
s_et_transfer_complete[card_index], (u64)card_index);
}
} // namespace ExpansionInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class MemoryCardBase;
class PointerWrap;

namespace ExpansionInterface
{
class CEXIMemoryCard : public IEXIDevice
{
public:
Expand Down Expand Up @@ -91,3 +93,4 @@ class CEXIMemoryCard : public IEXIDevice
protected:
void TransferByte(u8& byte) override;
};
} // namespace ExpansionInterface

0 comments on commit ab18eba

Please sign in to comment.