~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Source/Core/Core/Src/HW/EXI_Channel.h

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Dolphin Emulator Project
 
2
// Licensed under GPLv2
 
3
// Refer to the license.txt file included.
 
4
 
 
5
#ifndef _EXICHANNEL_H
 
6
#define _EXICHANNEL_H
 
7
 
 
8
#include "CommonTypes.h"
 
9
 
 
10
#include "EXI_Device.h"
 
11
 
 
12
#ifdef _WIN32
 
13
#pragma warning(disable:4201)
 
14
#endif
 
15
 
 
16
class CEXIChannel
 
17
{
 
18
private:
 
19
 
 
20
        enum
 
21
        {
 
22
                EXI_STATUS              = 0,
 
23
                EXI_DMAADDR             = 1,
 
24
                EXI_DMALENGTH   = 2,
 
25
                EXI_DMACONTROL  = 3,
 
26
                EXI_IMMDATA             = 4
 
27
        };
 
28
        const char* Debug_GetRegisterName(u32 _register)
 
29
        {
 
30
                switch (_register)
 
31
                {
 
32
                case EXI_STATUS:                return "STATUS";
 
33
                case EXI_DMAADDR:               return "DMAADDR";
 
34
                case EXI_DMALENGTH:             return "DMALENGTH";
 
35
                case EXI_DMACONTROL:    return "DMACONTROL";
 
36
                case EXI_IMMDATA:               return "IMMDATA";
 
37
                default:                                return "!!! Unknown EXI Register !!!";
 
38
                }
 
39
        }
 
40
 
 
41
        // EXI Status Register - "Channel Parameter Register"
 
42
        union UEXI_STATUS
 
43
        {
 
44
                u32 Hex;
 
45
                // DO NOT obey the warning and give this struct a name. Things will fail.
 
46
                struct
 
47
                {
 
48
                // Indentation Meaning:
 
49
                //      Channels 0, 1, 2
 
50
                //              Channels 0, 1 only
 
51
                //                      Channel 0 only
 
52
                        u32 EXIINTMASK          : 1;
 
53
                        u32 EXIINT                      : 1;
 
54
                        u32 TCINTMASK           : 1;
 
55
                        u32 TCINT                       : 1;
 
56
                        u32 CLK                         : 3;
 
57
                        u32 CHIP_SELECT         : 3; // CS1 and CS2 are Channel 0 only
 
58
                                u32 EXTINTMASK  : 1;
 
59
                                u32 EXTINT              : 1;
 
60
                                u32 EXT                 : 1; // External Insertion Status (1: External EXI device present)
 
61
                                        u32 ROMDIS      : 1; // ROM Disable
 
62
                        u32                                     :18;
 
63
                };
 
64
                UEXI_STATUS() {Hex = 0;}
 
65
                UEXI_STATUS(u32 _hex) {Hex = _hex;}
 
66
        };
 
67
 
 
68
        // EXI Control Register
 
69
        union UEXI_CONTROL
 
70
        {
 
71
                u32 Hex;
 
72
                struct
 
73
                {
 
74
                        u32 TSTART              : 1;
 
75
                        u32 DMA                 : 1;
 
76
                        u32 RW                  : 2;
 
77
                        u32 TLEN                : 2;
 
78
                        u32                             :26;
 
79
                };
 
80
        };
 
81
 
 
82
        // STATE_TO_SAVE
 
83
        UEXI_STATUS             m_Status;
 
84
        u32                             m_DMAMemoryAddress;
 
85
        u32                             m_DMALength;
 
86
        UEXI_CONTROL    m_Control;
 
87
        u32                             m_ImmData;
 
88
 
 
89
        // Devices
 
90
        enum
 
91
        {
 
92
                NUM_DEVICES = 3
 
93
        };
 
94
 
 
95
        IEXIDevice* m_pDevices[NUM_DEVICES];
 
96
 
 
97
        // Since channels operate a bit differently from each other
 
98
        u32 m_ChannelId;
 
99
 
 
100
        int updateInterrupts;
 
101
 
 
102
        static void UpdateInterrupts(u64 userdata, int cyclesLate);
 
103
public:
 
104
        // get device
 
105
        IEXIDevice* GetDevice(const u8 _CHIP_SELECT);
 
106
        IEXIDevice* FindDevice(TEXIDevices device_type, int customIndex=-1);
 
107
 
 
108
        CEXIChannel(u32 ChannelId);
 
109
        ~CEXIChannel();
 
110
 
 
111
        void AddDevice(const TEXIDevices device_type, const int device_num);
 
112
        void AddDevice(IEXIDevice* pDevice, const int device_num, bool notifyPresenceChanged=true);
 
113
 
 
114
        // Remove all devices
 
115
        void RemoveDevices();
 
116
 
 
117
        void Read32(u32& _uReturnValue, const u32 _iRegister);
 
118
        void Write32(const u32 _iValue, const u32 _iRegister);
 
119
 
 
120
        void Update();
 
121
        bool IsCausingInterrupt();
 
122
        void DoState(PointerWrap &p);
 
123
        void PauseAndLock(bool doLock, bool unpauseOnUnlock);
 
124
 
 
125
        // This should only be used to transition interrupts from SP1 to Channel 2
 
126
        void SetEXIINT(bool exiint) { m_Status.EXIINT = !!exiint; }
 
127
};
 
128
 
 
129
#endif