The Pedigree Project 0.1
X86IsaDma.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef X86_ISA_DMA_H
21#define X86_ISA_DMA_H
22#include "pedigree/kernel/Log.h"
23#include "pedigree/kernel/processor/IoPort.h"
24#include "pedigree/kernel/processor/types.h"
25
26#include <config.h>
27
28#include "../IsaDma.h"
29
31namespace MasterChip {
32enum MasterRegs {
33 Status = 0xD0, // Read
34 Command = 0xD0, // Write
35 Request = 0xD2, // Write
36 ChannelMask = 0xD4, // Write
37 Mode = 0xD6, // Write
38 ByteWord = 0xD8, // Read
39 Intermediate = 0xDA, // Read
40 Mask = 0xDE, // Write
41};
42
43enum BaseRegisters {
44 AddressChannel0_4 = 0xC0,
45 CountChannel0_4 = 0xC1,
46
47 AddressChannel1_5 = 0xC2,
48 CountChannel1_5 = 0xC3,
49
50 AddressChannel2_6 = 0xC4,
51 CountChannel2_6 = 0xC5,
52
53 AddressChannel3_7 = 0xC6,
54 CountChannel3_7 = 0xC7,
55};
56} // namespace MasterChip
57
59namespace SlaveChip {
60enum SlaveRegs {
61 Status = 0x08, // Read
62 Command = 0x08, // Write
63 Request = 0x09, // Write
64 ChannelMask = 0x0A, // Write
65 Mode = 0x0B, // Write
66 ByteWord = 0x0C, // Read
67 Intermediate = 0x0D, // Read
68 Mask = 0x0F, // Write
69};
70
71enum BaseRegisters {
72 AddressChannel0_4 = 0x00,
73 CountChannel0_4 = 0x01,
74
75 AddressChannel1_5 = 0x02,
76 CountChannel1_5 = 0x03,
77
78 AddressChannel2_6 = 0x04,
79 CountChannel2_6 = 0x05,
80
81 AddressChannel3_7 = 0x05,
82 CountChannel3_7 = 0x07,
83};
84} // namespace SlaveChip
85
87namespace PageRegisters {
88enum PageAddressRegister {
89 Channel0 = 0x87,
90 Channel1 = 0x83,
91 Channel2 = 0x81,
92 Channel3 = 0x82,
93 Channel4 = 0x8F,
94 Channel5 = 0x8B,
95 Channel6 = 0x89,
96 Channel7 = 0x8A,
97};
98}
99
105class X86IsaDma : public IsaDma {
106 public:
107 enum TransferModes {
108 SelfTest = 0,
109 Write = (1 << 2),
110 Read = (2 << 2),
111 Cascade = (3 << 2),
112 AutoInit = (1 << 4),
113 Increment = 0,
114 Decrement = (1 << 5),
115 OnDemand = 0,
116 Single = (1 << 6),
117 Block = (2 << 6)
118 };
119
120 X86IsaDma() : m_Io("isa-dma") {
121 if (!m_Io.allocate(0, 0x100))
122 ERROR("X86IsaDma: Couldn't allocate port range");
123 }
124 virtual ~X86IsaDma() {}
125
126 static X86IsaDma& instance() {
127 return m_Instance;
128 }
129
131 virtual bool initTransfer(uint8_t channel, uint8_t mode, size_t length, uintptr_t addr);
132
133 private:
134 void resetFlipFlop(uint8_t chan);
135
136 void resetHard(uint8_t chan);
137
138 void unmaskAll();
139
140 bool internalSetup(uint8_t channel, size_t length, uintptr_t addr);
141
142 IoPort m_Io;
143
144 static X86IsaDma m_Instance;
145};
146
147#endif
I/O port range.
Definition IoPort.h:33
bool allocate(io_port_t ioPort, size_t size)
Definition IoPort.cc:29
virtual bool initTransfer(uint8_t channel, uint8_t mode, size_t length, uintptr_t addr)
Initialises an operation.
Definition X86IsaDma.cc:24