2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Erik Hallnor
33 * Declaration of a IBM memory trace format reader.
37 #include "base/misc.hh" // for fatal
38 #include "cpu/trace/reader/ibm_reader.hh"
39 #include "params/IBMReader.hh"
43 IBMReader::IBMReader(const string
&name
, const string
&filename
)
44 : MemTraceReader(name
)
46 if (strcmp((filename
.c_str() + filename
.length() -3), ".gz") == 0) {
47 // Compressed file, need to use a pipe to gzip.
49 buf
<< "gzip -d -c " << filename
<< endl
;
50 trace
= popen(buf
.str().c_str(), "r");
52 trace
= fopen(filename
.c_str(), "rb");
55 fatal("Can't open file %s", filename
);
60 IBMReader::getNextReq(MemReqPtr
&req
)
66 tmp_req
= new MemReq();
67 //int cpu_id = (c & 0xf0) >> 4;
69 // We have L1 miss traces, so all accesses are 128 bytes
73 for (int i
= 2; i
>= 0; --i
) {
76 fatal("Unexpected end of file");
78 tmp_req
->paddr
|= ((c
& 0xff) << (8 * i
));
80 tmp_req
->paddr
= tmp_req
->paddr
<< 7;
83 case IBM_COND_EXCLUSIVE_FETCH
:
84 case IBM_READ_ONLY_FETCH
:
87 case IBM_EXCLUSIVE_FETCH
:
88 case IBM_FETCH_NO_DATA
:
95 fatal("Unknown trace entry type.");
104 IBMReaderParams::create()
106 return new IBMReader(name
, filename
);