gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mmapped_ipr.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
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  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Authors: Gabe Black
38  */
39 
40 #ifndef __ARCH_X86_MMAPPEDIPR_HH__
41 #define __ARCH_X86_MMAPPEDIPR_HH__
42 
50 #include "arch/x86/regs/misc.hh"
51 #include "cpu/base.hh"
52 #include "cpu/thread_context.hh"
53 #include "mem/packet.hh"
54 #include "mem/packet_access.hh"
55 #include "sim/pseudo_inst.hh"
56 
57 namespace X86ISA
58 {
59  inline Cycles
61  {
62  Addr addr = pkt->getAddr();
63  auto m5opRange = tc->getSystemPtr()->m5opRange();
64  if (m5opRange.contains(addr)) {
65  uint8_t func;
66  PseudoInst::decodeAddrOffset(addr - m5opRange.start(), func);
67  uint64_t ret = PseudoInst::pseudoInst<X86PseudoInstABI>(tc, func);
68  pkt->setLE(ret);
69  } else {
70  Addr offset = addr & mask(3);
71  MiscRegIndex index = (MiscRegIndex)(addr / sizeof(RegVal));
72  RegVal data = htole(tc->readMiscReg(index));
73  // Make sure we don't trot off the end of data.
74  assert(offset + pkt->getSize() <= sizeof(RegVal));
75  pkt->setData(((uint8_t *)&data) + offset);
76  }
77  return Cycles(1);
78  }
79 
80  inline Cycles
82  {
83  Addr addr = pkt->getAddr();
84  auto m5opRange = tc->getSystemPtr()->m5opRange();
85  if (m5opRange.contains(addr)) {
86  uint8_t func;
87  PseudoInst::decodeAddrOffset(addr - m5opRange.start(), func);
88  PseudoInst::pseudoInst<X86PseudoInstABI>(tc, func);
89  } else {
90  Addr offset = addr & mask(3);
91  MiscRegIndex index = (MiscRegIndex)(addr / sizeof(RegVal));
92  RegVal data = htole(tc->readMiscRegNoEffect(index));
93  // Make sure we don't trot off the end of data.
94  assert(offset + pkt->getSize() <= sizeof(RegVal));
95  pkt->writeData(((uint8_t *)&data) + offset);
96  tc->setMiscReg(index, letoh(data));
97  }
98  return Cycles(1);
99  }
100 }
101 
102 #endif // __ARCH_X86_MMAPPEDIPR_HH__
offset
Definition: misc.hh:1026
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
virtual System * getSystemPtr()=0
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Bitfield< 5, 3 > index
Definition: types.hh:95
static void decodeAddrOffset(Addr offset, uint8_t &func)
Definition: pseudo_inst.hh:93
uint64_t RegVal
Definition: types.hh:168
T letoh(T value)
Definition: byteswap.hh:145
ThreadContext is the external interface to all thread state for anything outside of the CPU...
MiscRegIndex
Definition: misc.hh:102
void setLE(T v)
Set the value in the data pointer to v as little endian.
unsigned getSize() const
Definition: packet.hh:736
T htole(T value)
Definition: byteswap.hh:144
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
Definition: packet.hh:1158
mask
Definition: misc.hh:798
Addr getAddr() const
Definition: packet.hh:726
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
Definition: packet.hh:1187
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
const AddrRange & m5opRange() const
Range used by memory-mapped m5 pseudo-ops if enabled.
Definition: system.hh:591
Cycles handleIprRead(ThreadContext *tc, Packet *pkt)
Definition: mmapped_ipr.hh:60
Cycles handleIprWrite(ThreadContext *tc, Packet *pkt)
Definition: mmapped_ipr.hh:81
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
Declaration of the Packet class.
This is exposed globally, independent of the ISA.
Definition: acpi.hh:57
virtual RegVal readMiscReg(RegIndex misc_reg)=0
const char data[]
Bitfield< 3 > addr
Definition: types.hh:81

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13