copy_engine_defs.hh revision 11261:2050602b55f7
113516Sgabeblack@google.com/*
213516Sgabeblack@google.com * Copyright (c) 2008 The Regents of The University of Michigan
313516Sgabeblack@google.com * All rights reserved.
413516Sgabeblack@google.com *
513516Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
613516Sgabeblack@google.com * modification, are permitted provided that the following conditions are
713516Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
813516Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
913516Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1013516Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1113516Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1213516Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1313516Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1413516Sgabeblack@google.com * this software without specific prior written permission.
1513516Sgabeblack@google.com *
1613516Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1713516Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1813516Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1913516Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2013516Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2113516Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2213524Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2313516Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2413516Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2513523Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2613516Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2713516Sgabeblack@google.com *
2813516Sgabeblack@google.com * Authors: Ali Saidi
2913516Sgabeblack@google.com */
3013516Sgabeblack@google.com
3113516Sgabeblack@google.com/* @file
3213516Sgabeblack@google.com * Register and structure descriptions for Intel's I/O AT DMA Engine
3313516Sgabeblack@google.com */
3413516Sgabeblack@google.com#include "base/bitfield.hh"
3513516Sgabeblack@google.com#include "sim/serialize.hh"
3613516Sgabeblack@google.com
3713516Sgabeblack@google.comnamespace CopyEngineReg {
3813516Sgabeblack@google.com
3913516Sgabeblack@google.com
4013516Sgabeblack@google.com// General Channel independant registers, 128 bytes starting at 0x00
4113516Sgabeblack@google.comconst uint32_t GEN_CHANCOUNT    = 0x00;
4213516Sgabeblack@google.comconst uint32_t GEN_XFERCAP      = 0x01;
4313516Sgabeblack@google.comconst uint32_t GEN_INTRCTRL     = 0x03;
4413516Sgabeblack@google.comconst uint32_t GEN_ATTNSTATUS   = 0x04;
4513524Sgabeblack@google.com
4613516Sgabeblack@google.com
4713516Sgabeblack@google.com// Channel specific registers, each block is 128 bytes, starting at 0x80
4813516Sgabeblack@google.comconst uint32_t CHAN_CONTROL         = 0x00;
4913516Sgabeblack@google.comconst uint32_t CHAN_STATUS          = 0x04;
5013516Sgabeblack@google.comconst uint32_t CHAN_CHAINADDR       = 0x0C;
5113516Sgabeblack@google.comconst uint32_t CHAN_CHAINADDR_LOW   = 0x0C;
5213516Sgabeblack@google.comconst uint32_t CHAN_CHAINADDR_HIGH  = 0x10;
5313516Sgabeblack@google.comconst uint32_t CHAN_COMMAND         = 0x14;
5413516Sgabeblack@google.comconst uint32_t CHAN_CMPLNADDR       = 0x18;
5513516Sgabeblack@google.comconst uint32_t CHAN_CMPLNADDR_LOW   = 0x18;
5613516Sgabeblack@google.comconst uint32_t CHAN_CMPLNADDR_HIGH  = 0x1C;
5713516Sgabeblack@google.comconst uint32_t CHAN_ERROR           = 0x28;
5813516Sgabeblack@google.com
5913516Sgabeblack@google.com
6013516Sgabeblack@google.comconst uint32_t DESC_CTRL_INT_GEN    = 0x00000001;
6113516Sgabeblack@google.comconst uint32_t DESC_CTRL_SRC_SN     = 0x00000002;
6213516Sgabeblack@google.comconst uint32_t DESC_CTRL_DST_SN     = 0x00000004;
6313516Sgabeblack@google.comconst uint32_t DESC_CTRL_CP_STS     = 0x00000008;
6413516Sgabeblack@google.comconst uint32_t DESC_CTRL_FRAME      = 0x00000010;
6513516Sgabeblack@google.comconst uint32_t DESC_CTRL_NULL       = 0x00000020;
6613516Sgabeblack@google.com
6713516Sgabeblack@google.comstruct DmaDesc {
6813516Sgabeblack@google.com    uint32_t len;
6913516Sgabeblack@google.com    uint32_t command;
7013516Sgabeblack@google.com    Addr src;
7113516Sgabeblack@google.com    Addr dest;
7213516Sgabeblack@google.com    Addr next;
7313516Sgabeblack@google.com    uint64_t reserved1;
7413516Sgabeblack@google.com    uint64_t reserved2;
7513516Sgabeblack@google.com    uint64_t user1;
7613516Sgabeblack@google.com    uint64_t user2;
7713516Sgabeblack@google.com};
7813516Sgabeblack@google.com
7913523Sgabeblack@google.com#define ADD_FIELD8(NAME, OFFSET, BITS) \
8013516Sgabeblack@google.com    inline uint8_t NAME() { return bits(_data, OFFSET+BITS-1, OFFSET); } \
8113516Sgabeblack@google.com    inline void NAME(uint8_t d) { replaceBits(_data, OFFSET+BITS-1, OFFSET,d); }
8213516Sgabeblack@google.com
8313516Sgabeblack@google.com#define ADD_FIELD16(NAME, OFFSET, BITS) \
8413516Sgabeblack@google.com    inline uint16_t NAME() { return bits(_data, OFFSET+BITS-1, OFFSET); } \
8513516Sgabeblack@google.com    inline void NAME(uint16_t d) { replaceBits(_data, OFFSET+BITS-1, OFFSET,d); }
8613516Sgabeblack@google.com
8713516Sgabeblack@google.com#define ADD_FIELD32(NAME, OFFSET, BITS) \
8813516Sgabeblack@google.com    inline uint32_t NAME() { return bits(_data, OFFSET+BITS-1, OFFSET); } \
8913516Sgabeblack@google.com    inline void NAME(uint32_t d) { replaceBits(_data, OFFSET+BITS-1, OFFSET,d); }
9013516Sgabeblack@google.com
9113516Sgabeblack@google.com#define ADD_FIELD64(NAME, OFFSET, BITS) \
9213516Sgabeblack@google.com    inline uint64_t NAME() { return bits(_data, OFFSET+BITS-1, OFFSET); } \
9313516Sgabeblack@google.com    inline void NAME(uint64_t d) { replaceBits(_data, OFFSET+BITS-1, OFFSET,d); }
9413516Sgabeblack@google.com
9513516Sgabeblack@google.comtemplate<class T>
9613516Sgabeblack@google.comstruct Reg {
9713516Sgabeblack@google.com    T _data;
9813516Sgabeblack@google.com    T operator()() { return _data; }
9913516Sgabeblack@google.com    const Reg<T> &operator=(T d) { _data = d; return *this;}
10013516Sgabeblack@google.com    bool operator==(T d) { return d == _data; }
10113516Sgabeblack@google.com    void operator()(T d) { _data = d; }
10213516Sgabeblack@google.com    Reg() { _data = 0; }
10313516Sgabeblack@google.com    void serialize(CheckpointOut &cp) const
10413516Sgabeblack@google.com    {
10513516Sgabeblack@google.com        SERIALIZE_SCALAR(_data);
10613516Sgabeblack@google.com    }
10713516Sgabeblack@google.com    void unserialize(CheckpointIn &cp)
10813516Sgabeblack@google.com    {
10913516Sgabeblack@google.com        UNSERIALIZE_SCALAR(_data);
11013516Sgabeblack@google.com    }
111};
112
113
114struct Regs : public Serializable {
115    uint8_t chanCount;
116    uint8_t xferCap;
117
118    struct INTRCTRL : public Reg<uint8_t> { // 0x03
119        using Reg<uint8_t>::operator =;
120        ADD_FIELD8(master_int_enable,0,1);
121        ADD_FIELD8(interrupt_status,1,1);
122        ADD_FIELD8(interrupt,2,1);
123    };
124    INTRCTRL intrctrl;
125
126    uint32_t attnStatus; // Read clears
127
128    void serialize(CheckpointOut &cp) const override
129    {
130        SERIALIZE_SCALAR(chanCount);
131        SERIALIZE_SCALAR(xferCap);
132        paramOut(cp, "intrctrl", intrctrl._data);
133        SERIALIZE_SCALAR(attnStatus);
134    }
135
136    void unserialize(CheckpointIn &cp) override
137    {
138        UNSERIALIZE_SCALAR(chanCount);
139        UNSERIALIZE_SCALAR(xferCap);
140        paramIn(cp, "intrctrl", intrctrl._data);
141        UNSERIALIZE_SCALAR(attnStatus);
142    }
143
144};
145
146struct ChanRegs : public Serializable {
147    struct CHANCTRL : public Reg<uint16_t> { // channelX + 0x00
148        using Reg<uint16_t>::operator =;
149        ADD_FIELD16(interrupt_disable,0,1);
150        ADD_FIELD16(error_completion_enable, 2,1);
151        ADD_FIELD16(any_error_abort_enable,3,1);
152        ADD_FIELD16(error_int_enable,4,1);
153        ADD_FIELD16(desc_addr_snoop_control,5,1);
154        ADD_FIELD16(in_use, 8,1);
155    };
156    CHANCTRL ctrl;
157
158    struct CHANSTS : public Reg<uint64_t> { // channelX + 0x04
159        ADD_FIELD64(dma_transfer_status, 0, 3);
160        ADD_FIELD64(unaffiliated_error, 3, 1);
161        ADD_FIELD64(soft_error, 4, 1);
162        ADD_FIELD64(compl_desc_addr, 6, 58);
163    };
164    CHANSTS status;
165
166    uint64_t descChainAddr;
167
168    struct CHANCMD : public Reg<uint8_t> { // channelX + 0x14
169        ADD_FIELD8(start_dma,0,1);
170        ADD_FIELD8(append_dma,1,1);
171        ADD_FIELD8(suspend_dma,2,1);
172        ADD_FIELD8(abort_dma,3,1);
173        ADD_FIELD8(resume_dma,4,1);
174        ADD_FIELD8(reset_dma,5,1);
175    };
176    CHANCMD command;
177
178    uint64_t completionAddr;
179
180    struct CHANERR : public Reg<uint32_t> { // channel X + 0x28
181        ADD_FIELD32(source_addr_error,0,1);
182        ADD_FIELD32(dest_addr_error,1,1);
183        ADD_FIELD32(ndesc_addr_error,2,1);
184        ADD_FIELD32(desc_error,3,1);
185        ADD_FIELD32(chain_addr_error,4,1);
186        ADD_FIELD32(chain_cmd_error,5,1);
187        ADD_FIELD32(chipset_parity_error,6,1);
188        ADD_FIELD32(dma_parity_error,7,1);
189        ADD_FIELD32(read_data_error,8,1);
190        ADD_FIELD32(write_data_error,9,1);
191        ADD_FIELD32(desc_control_error,10,1);
192        ADD_FIELD32(desc_len_error,11,1);
193        ADD_FIELD32(completion_addr_error,12,1);
194        ADD_FIELD32(interrupt_config_error,13,1);
195        ADD_FIELD32(soft_error,14,1);
196        ADD_FIELD32(unaffiliated_error,15,1);
197    };
198    CHANERR error;
199
200    void serialize(CheckpointOut &cp) const override
201    {
202        paramOut(cp, "ctrl", ctrl._data);
203        paramOut(cp, "status", status._data);
204        SERIALIZE_SCALAR(descChainAddr);
205        paramOut(cp, "command", command._data);
206        SERIALIZE_SCALAR(completionAddr);
207        paramOut(cp, "error", error._data);
208    }
209
210    void unserialize(CheckpointIn &cp) override
211    {
212        paramIn(cp, "ctrl", ctrl._data);
213        paramIn(cp, "status", status._data);
214        UNSERIALIZE_SCALAR(descChainAddr);
215        paramIn(cp, "command", command._data);
216        UNSERIALIZE_SCALAR(completionAddr);
217        paramIn(cp, "error", error._data);
218    }
219
220
221};
222
223} // namespace CopyEngineReg
224
225
226