gem5 v24.0.0.0
Loading...
Searching...
No Matches
DataBlock.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef __MEM_RUBY_COMMON_DATABLOCK_HH__
42#define __MEM_RUBY_COMMON_DATABLOCK_HH__
43
44#include <inttypes.h>
45
46#include <cassert>
47#include <deque>
48#include <iomanip>
49#include <iostream>
50
51#include "mem/packet.hh"
52
53namespace gem5
54{
55
56namespace ruby
57{
58
59class WriteMask;
60
62{
63 public:
65 {
66 alloc();
67 }
68
69 DataBlock(const DataBlock &cp);
70
72 {
73 if (m_alloc)
74 delete [] m_data;
75
76 // If data block involved in atomic
77 // operations, free all meta data
78 for (auto log : m_atomicLog) {
79 delete [] log;
80 }
81 }
82
83 DataBlock& operator=(const DataBlock& obj);
84
85 void assign(uint8_t *data);
86
87 void clear();
88 uint8_t getByte(int whichByte) const;
89 const uint8_t *getData(int offset, int len) const;
90 uint8_t* popAtomicLogEntryFront();
91 int numAtomicLogEntries() const;
93 uint8_t *getDataMod(int offset);
94 void setByte(int whichByte, uint8_t data);
95 void setData(const uint8_t *data, int offset, int len);
96 void setData(PacketPtr pkt);
97 void copyPartial(const DataBlock &dblk, int offset, int len);
98 void copyPartial(const DataBlock &dblk, const WriteMask &mask);
99 void atomicPartial(const DataBlock & dblk, const WriteMask & mask,
100 bool isAtomicNoReturn=true);
101 bool equal(const DataBlock& obj) const;
102 void print(std::ostream& out) const;
103
104 private:
105 void alloc();
106 uint8_t *m_data;
108
109 // Tracks block changes when atomic ops are applied
111};
112
113inline void
115{
116 assert(data != NULL);
117 if (m_alloc) {
118 delete [] m_data;
119 }
120 m_data = data;
121 m_alloc = false;
122}
123
124inline uint8_t
125DataBlock::getByte(int whichByte) const
126{
127 return m_data[whichByte];
128}
129
130inline void
131DataBlock::setByte(int whichByte, uint8_t data)
132{
133 m_data[whichByte] = data;
134}
135
136inline void
138{
139 setData(&dblk.m_data[offset], offset, len);
140}
141
142inline std::ostream&
143operator<<(std::ostream& out, const DataBlock& obj)
144{
145 obj.print(out);
146 out << std::flush;
147 return out;
148}
149
150inline bool
151operator==(const DataBlock& obj1,const DataBlock& obj2)
152{
153 return obj1.equal(obj2);
154}
155
156} // namespace ruby
157} // namespace gem5
158
159#endif // __MEM_RUBY_COMMON_DATABLOCK_HH__
const char data[]
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
void atomicPartial(const DataBlock &dblk, const WriteMask &mask, bool isAtomicNoReturn=true)
Definition DataBlock.cc:113
uint8_t getByte(int whichByte) const
Definition DataBlock.hh:125
void assign(uint8_t *data)
Definition DataBlock.hh:114
const uint8_t * getData(int offset, int len) const
Definition DataBlock.cc:157
uint8_t * popAtomicLogEntryFront()
Definition DataBlock.cc:140
void copyPartial(const DataBlock &dblk, int offset, int len)
Definition DataBlock.hh:137
uint8_t * getDataMod(int offset)
Definition DataBlock.cc:164
int numAtomicLogEntries() const
Definition DataBlock.cc:135
DataBlock & operator=(const DataBlock &obj)
Definition DataBlock.cc:184
bool equal(const DataBlock &obj) const
Definition DataBlock.cc:84
void setByte(int whichByte, uint8_t data)
Definition DataBlock.hh:131
std::deque< uint8_t * > m_atomicLog
Definition DataBlock.hh:110
void print(std::ostream &out) const
Definition DataBlock.cc:123
void setData(const uint8_t *data, int offset, int len)
Definition DataBlock.cc:170
STL deque class.
Definition stl.hh:44
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 18, 16 > len
Bitfield< 23, 0 > offset
Definition types.hh:144
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition BoolVec.cc:49
bool operator==(const DataBlock &obj1, const DataBlock &obj2)
Definition DataBlock.hh:151
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Declaration of the Packet class.

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0