33 if (!internalSetup(channel, length, addr)) {
34 NOTICE(
"Internal setup failed");
39 size_t port = 0, port2 = 0;
41 port = SlaveChip::ChannelMask;
42 port2 = SlaveChip::Mode;
44 port = MasterChip::ChannelMask;
45 port2 = MasterChip::Mode;
47 m_Io.
write8(0x4 | (channel & 0x3), port);
51 modeReg |= channel & 0x3;
52 modeReg |= (mode & 0x0C);
53 modeReg |= (mode & 0xC0);
54 m_Io.
write8(modeReg, port2);
57 m_Io.
write8(channel & 0x3, port);
63void X86IsaDma::resetFlipFlop(uint8_t chan) {
65 m_Io.
write8(0xff, SlaveChip::ByteWord);
67 m_Io.
write8(0xff, MasterChip::ByteWord);
70void X86IsaDma::resetHard(uint8_t chan) {
72 m_Io.
write8(0xff, SlaveChip::Intermediate);
74 m_Io.
write8(0xff, MasterChip::Intermediate);
77void X86IsaDma::unmaskAll() {
81bool X86IsaDma::internalSetup(uint8_t channel,
size_t length, uintptr_t addr) {
83 if (channel == 0 || channel == 4)
92 size_t port = 0, port2 = 0;
96 port = SlaveChip::ChannelMask;
98 port = MasterChip::ChannelMask;
99 m_Io.
write8(0x4 | (channel & 0x3), port);
102 resetFlipFlop(channel);
106 port = SlaveChip::AddressChannel1_5;
107 port2 = SlaveChip::CountChannel1_5;
108 }
else if (channel == 2) {
109 port = SlaveChip::AddressChannel2_6;
110 port2 = SlaveChip::CountChannel2_6;
111 }
else if (channel == 3) {
112 port = SlaveChip::AddressChannel3_7;
113 port2 = SlaveChip::CountChannel3_7;
114 }
else if (channel == 5) {
115 port = MasterChip::AddressChannel1_5;
116 port2 = MasterChip::CountChannel1_5;
117 }
else if (channel == 6) {
118 port = MasterChip::AddressChannel2_6;
119 port2 = MasterChip::CountChannel2_6;
120 }
else if (channel == 7) {
121 port = MasterChip::AddressChannel3_7;
122 port2 = MasterChip::CountChannel3_7;
127 m_Io.
write8(addr & 0xFF, port);
128 m_Io.
write8((addr >> 8) & 0xFF, port);
131 resetFlipFlop(channel);
134 m_Io.
write8(length & 0xFF, port2);
135 m_Io.
write8((length >> 8) & 0xFF, port2);
139 port = PageRegisters::Channel1;
140 else if (channel == 2)
141 port = PageRegisters::Channel2;
142 else if (channel == 3)
143 port = PageRegisters::Channel3;
144 else if (channel == 5)
145 port = PageRegisters::Channel5;
146 else if (channel == 6)
147 port = PageRegisters::Channel6;
148 else if (channel == 7)
149 port = PageRegisters::Channel7;
151 FATAL(
"X86 ISA DMA: Somehow channel is zero or four - impossible!");
154 uint8_t extPageReg = addr / 0x10000;
155 m_Io.
write8(extPageReg, port);
159 port = SlaveChip::ChannelMask;
161 port = MasterChip::ChannelMask;
162 m_Io.
write8(channel & 0x3, port);
virtual void write8(uint8_t value, size_t offset=0)
virtual bool initTransfer(uint8_t channel, uint8_t mode, size_t length, uintptr_t addr)
Initialises an operation.