20 #include "X86IsaDma.h" 25 uint8_t channel, uint8_t mode,
size_t length, uintptr_t addr)
35 if (!internalSetup(channel, length, addr))
37 NOTICE(
"Internal setup failed");
42 size_t port = 0, port2 = 0;
45 port = SlaveChip::ChannelMask;
46 port2 = SlaveChip::Mode;
50 port = MasterChip::ChannelMask;
51 port2 = MasterChip::Mode;
53 m_Io.
write8(0x4 | (channel & 0x3), port);
57 modeReg |= channel & 0x3;
58 modeReg |= (mode & 0x0C);
59 modeReg |= (mode & 0xC0);
60 m_Io.
write8(modeReg, port2);
63 m_Io.
write8(channel & 0x3, port);
69 void X86IsaDma::resetFlipFlop(uint8_t chan)
72 m_Io.
write8(0xff, SlaveChip::ByteWord);
74 m_Io.
write8(0xff, MasterChip::ByteWord);
77 void X86IsaDma::resetHard(uint8_t chan)
80 m_Io.
write8(0xff, SlaveChip::Intermediate);
82 m_Io.
write8(0xff, MasterChip::Intermediate);
85 void X86IsaDma::unmaskAll()
90 bool X86IsaDma::internalSetup(uint8_t channel,
size_t length, uintptr_t addr)
93 if (channel == 0 || channel == 4)
102 size_t port = 0, port2 = 0;
106 port = SlaveChip::ChannelMask;
108 port = MasterChip::ChannelMask;
109 m_Io.
write8(0x4 | (channel & 0x3), port);
112 resetFlipFlop(channel);
117 port = SlaveChip::AddressChannel1_5;
118 port2 = SlaveChip::CountChannel1_5;
120 else if (channel == 2)
122 port = SlaveChip::AddressChannel2_6;
123 port2 = SlaveChip::CountChannel2_6;
125 else if (channel == 3)
127 port = SlaveChip::AddressChannel3_7;
128 port2 = SlaveChip::CountChannel3_7;
130 else if (channel == 5)
132 port = MasterChip::AddressChannel1_5;
133 port2 = MasterChip::CountChannel1_5;
135 else if (channel == 6)
137 port = MasterChip::AddressChannel2_6;
138 port2 = MasterChip::CountChannel2_6;
140 else if (channel == 7)
142 port = MasterChip::AddressChannel3_7;
143 port2 = MasterChip::CountChannel3_7;
149 m_Io.
write8(addr & 0xFF, port);
150 m_Io.
write8((addr >> 8) & 0xFF, port);
153 resetFlipFlop(channel);
156 m_Io.
write8(length & 0xFF, port2);
157 m_Io.
write8((length >> 8) & 0xFF, port2);
161 port = PageRegisters::Channel1;
162 else if (channel == 2)
163 port = PageRegisters::Channel2;
164 else if (channel == 3)
165 port = PageRegisters::Channel3;
166 else if (channel == 5)
167 port = PageRegisters::Channel5;
168 else if (channel == 6)
169 port = PageRegisters::Channel6;
170 else if (channel == 7)
171 port = PageRegisters::Channel7;
173 FATAL(
"X86 ISA DMA: Somehow channel is zero or four - impossible!");
176 uint8_t extPageReg = addr / 0x10000;
177 m_Io.
write8(extPageReg, port);
181 port = SlaveChip::ChannelMask;
183 port = MasterChip::ChannelMask;
184 m_Io.
write8(channel & 0x3, port);
virtual bool initTransfer(uint8_t channel, uint8_t mode, size_t length, uintptr_t addr)
Initialises an operation.
virtual void write8(uint8_t value, size_t offset=0)