DVDInterface: Migrate bitfields over to Common::BitField
This commit is contained in:
parent
32c7524f4d
commit
15566048f0
|
@ -12,6 +12,7 @@
|
||||||
#include "AudioCommon/AudioCommon.h"
|
#include "AudioCommon/AudioCommon.h"
|
||||||
|
|
||||||
#include "Common/Align.h"
|
#include "Common/Align.h"
|
||||||
|
#include "Common/BitField.h"
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Config/Config.h"
|
#include "Common/Config/Config.h"
|
||||||
|
@ -78,61 +79,57 @@ constexpr u32 DI_CONFIG_REGISTER = 0x24;
|
||||||
// DI Status Register
|
// DI Status Register
|
||||||
union UDISR
|
union UDISR
|
||||||
{
|
{
|
||||||
u32 Hex;
|
u32 Hex = 0;
|
||||||
struct
|
|
||||||
{
|
BitField<0, 1, u32> BREAK; // Stop the Device + Interrupt
|
||||||
u32 BREAK : 1; // Stop the Device + Interrupt
|
BitField<1, 1, u32> DEINTMASK; // Access Device Error Int Mask
|
||||||
u32 DEINTMASK : 1; // Access Device Error Int Mask
|
BitField<2, 1, u32> DEINT; // Access Device Error Int
|
||||||
u32 DEINT : 1; // Access Device Error Int
|
BitField<3, 1, u32> TCINTMASK; // Transfer Complete Int Mask
|
||||||
u32 TCINTMASK : 1; // Transfer Complete Int Mask
|
BitField<4, 1, u32> TCINT; // Transfer Complete Int
|
||||||
u32 TCINT : 1; // Transfer Complete Int
|
BitField<5, 1, u32> BRKINTMASK;
|
||||||
u32 BRKINTMASK : 1;
|
BitField<6, 1, u32> BRKINT; // w 1: clear brkint
|
||||||
u32 BRKINT : 1; // w 1: clear brkint
|
BitField<7, 25, u32> reserved;
|
||||||
u32 : 25;
|
|
||||||
};
|
UDISR() = default;
|
||||||
UDISR() { Hex = 0; }
|
explicit UDISR(u32 hex) : Hex{hex} {}
|
||||||
UDISR(u32 _hex) { Hex = _hex; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// DI Cover Register
|
// DI Cover Register
|
||||||
union UDICVR
|
union UDICVR
|
||||||
{
|
{
|
||||||
u32 Hex;
|
u32 Hex = 0;
|
||||||
struct
|
|
||||||
{
|
BitField<0, 1, u32> CVR; // 0: Cover closed 1: Cover open
|
||||||
u32 CVR : 1; // 0: Cover closed 1: Cover open
|
BitField<1, 1, u32> CVRINTMASK; // 1: Interrupt enabled
|
||||||
u32 CVRINTMASK : 1; // 1: Interrupt enabled
|
BitField<2, 1, u32> CVRINT; // r 1: Interrupt requested w 1: Interrupt clear
|
||||||
u32 CVRINT : 1; // r 1: Interrupt requested w 1: Interrupt clear
|
BitField<3, 29, u32> reserved;
|
||||||
u32 : 29;
|
|
||||||
};
|
UDICVR() = default;
|
||||||
UDICVR() { Hex = 0; }
|
explicit UDICVR(u32 hex) : Hex{hex} {}
|
||||||
UDICVR(u32 _hex) { Hex = _hex; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// DI DMA Control Register
|
// DI DMA Control Register
|
||||||
union UDICR
|
union UDICR
|
||||||
{
|
{
|
||||||
u32 Hex;
|
u32 Hex = 0;
|
||||||
struct
|
|
||||||
{
|
BitField<0, 1, u32> TSTART; // w:1 start r:0 ready
|
||||||
u32 TSTART : 1; // w:1 start r:0 ready
|
BitField<1, 1, u32> DMA; // 1: DMA Mode
|
||||||
u32 DMA : 1; // 1: DMA Mode 0: Immediate Mode (can only do Access Register Command)
|
// 0: Immediate Mode (can only do Access Register Command)
|
||||||
u32 RW : 1; // 0: Read Command (DVD to Memory) 1: Write Command (Memory to DVD)
|
BitField<2, 1, u32> RW; // 0: Read Command (DVD to Memory) 1: Write Command (Memory to DVD)
|
||||||
u32 : 29;
|
BitField<3, 29, u32> reserved;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// DI Config Register
|
// DI Config Register
|
||||||
union UDICFG
|
union UDICFG
|
||||||
{
|
{
|
||||||
u32 Hex;
|
u32 Hex = 0;
|
||||||
struct
|
|
||||||
{
|
BitField<0, 8, u32> CONFIG;
|
||||||
u32 CONFIG : 8;
|
BitField<8, 24, u32> reserved;
|
||||||
u32 : 24;
|
|
||||||
};
|
UDICFG() = default;
|
||||||
UDICFG() { Hex = 0; }
|
explicit UDICFG(u32 hex) : Hex{hex} {}
|
||||||
UDICFG(u32 _hex) { Hex = _hex; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
|
@ -582,7 +579,7 @@ bool AutoChangeDisc()
|
||||||
|
|
||||||
static void SetLidOpen()
|
static void SetLidOpen()
|
||||||
{
|
{
|
||||||
u32 old_value = s_DICVR.CVR;
|
const u32 old_value = s_DICVR.CVR;
|
||||||
s_DICVR.CVR = IsDiscInside() ? 0 : 1;
|
s_DICVR.CVR = IsDiscInside() ? 0 : 1;
|
||||||
if (s_DICVR.CVR != old_value)
|
if (s_DICVR.CVR != old_value)
|
||||||
GenerateDIInterrupt(DIInterruptType::CVRINT);
|
GenerateDIInterrupt(DIInterruptType::CVRINT);
|
||||||
|
@ -600,20 +597,20 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||||
{
|
{
|
||||||
mmio->Register(base | DI_STATUS_REGISTER, MMIO::DirectRead<u32>(&s_DISR.Hex),
|
mmio->Register(base | DI_STATUS_REGISTER, MMIO::DirectRead<u32>(&s_DISR.Hex),
|
||||||
MMIO::ComplexWrite<u32>([](u32, u32 val) {
|
MMIO::ComplexWrite<u32>([](u32, u32 val) {
|
||||||
UDISR tmpStatusReg(val);
|
const UDISR tmp_status_reg(val);
|
||||||
|
|
||||||
s_DISR.DEINTMASK = tmpStatusReg.DEINTMASK;
|
s_DISR.DEINTMASK = tmp_status_reg.DEINTMASK.Value();
|
||||||
s_DISR.TCINTMASK = tmpStatusReg.TCINTMASK;
|
s_DISR.TCINTMASK = tmp_status_reg.TCINTMASK.Value();
|
||||||
s_DISR.BRKINTMASK = tmpStatusReg.BRKINTMASK;
|
s_DISR.BRKINTMASK = tmp_status_reg.BRKINTMASK.Value();
|
||||||
s_DISR.BREAK = tmpStatusReg.BREAK;
|
s_DISR.BREAK = tmp_status_reg.BREAK.Value();
|
||||||
|
|
||||||
if (tmpStatusReg.DEINT)
|
if (tmp_status_reg.DEINT)
|
||||||
s_DISR.DEINT = 0;
|
s_DISR.DEINT = 0;
|
||||||
|
|
||||||
if (tmpStatusReg.TCINT)
|
if (tmp_status_reg.TCINT)
|
||||||
s_DISR.TCINT = 0;
|
s_DISR.TCINT = 0;
|
||||||
|
|
||||||
if (tmpStatusReg.BRKINT)
|
if (tmp_status_reg.BRKINT)
|
||||||
s_DISR.BRKINT = 0;
|
s_DISR.BRKINT = 0;
|
||||||
|
|
||||||
if (s_DISR.BREAK)
|
if (s_DISR.BREAK)
|
||||||
|
@ -626,11 +623,11 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||||
|
|
||||||
mmio->Register(base | DI_COVER_REGISTER, MMIO::DirectRead<u32>(&s_DICVR.Hex),
|
mmio->Register(base | DI_COVER_REGISTER, MMIO::DirectRead<u32>(&s_DICVR.Hex),
|
||||||
MMIO::ComplexWrite<u32>([](u32, u32 val) {
|
MMIO::ComplexWrite<u32>([](u32, u32 val) {
|
||||||
UDICVR tmpCoverReg(val);
|
const UDICVR tmp_cover_reg(val);
|
||||||
|
|
||||||
s_DICVR.CVRINTMASK = tmpCoverReg.CVRINTMASK;
|
s_DICVR.CVRINTMASK = tmp_cover_reg.CVRINTMASK.Value();
|
||||||
|
|
||||||
if (tmpCoverReg.CVRINT)
|
if (tmp_cover_reg.CVRINT)
|
||||||
s_DICVR.CVRINT = 0;
|
s_DICVR.CVRINT = 0;
|
||||||
|
|
||||||
UpdateInterrupts();
|
UpdateInterrupts();
|
||||||
|
@ -670,9 +667,9 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||||
|
|
||||||
static void UpdateInterrupts()
|
static void UpdateInterrupts()
|
||||||
{
|
{
|
||||||
const bool set_mask = (s_DISR.DEINT & s_DISR.DEINTMASK) || (s_DISR.TCINT & s_DISR.TCINTMASK) ||
|
const bool set_mask =
|
||||||
(s_DISR.BRKINT & s_DISR.BRKINTMASK) ||
|
(s_DISR.DEINT & s_DISR.DEINTMASK) != 0 || (s_DISR.TCINT & s_DISR.TCINTMASK) != 0 ||
|
||||||
(s_DICVR.CVRINT & s_DICVR.CVRINTMASK);
|
(s_DISR.BRKINT & s_DISR.BRKINTMASK) != 0 || (s_DICVR.CVRINT & s_DICVR.CVRINTMASK) != 0;
|
||||||
|
|
||||||
ProcessorInterface::SetInterrupt(ProcessorInterface::INT_CAUSE_DI, set_mask);
|
ProcessorInterface::SetInterrupt(ProcessorInterface::INT_CAUSE_DI, set_mask);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue