gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gpu_nomali.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2016 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  * 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: Andreas Sandberg
38  */
39 
40 #ifndef __DEV_ARM_NOMALI_GPU_HH__
41 #define __DEV_ARM_NOMALI_GPU_HH__
42 
43 #include <map>
44 
45 #include "dev/io_device.hh"
46 #include "libnomali/nomali.h"
47 
48 class NoMaliGpuParams;
49 class CustomNoMaliGpuParams;
50 class RealView;
51 
52 class NoMaliGpu : public PioDevice
53 {
54  public:
55  NoMaliGpu(const NoMaliGpuParams *p);
56  virtual ~NoMaliGpu();
57 
58  void init() override;
59 
60  public: /* Checkpointing */
61  void serialize(CheckpointOut &cp) const override;
62  void unserialize(CheckpointIn &cp) override;
63 
64  public: /* IO device interfaces */
65  Tick read(PacketPtr pkt) override;
66  Tick write(PacketPtr pkt) override;
67  AddrRangeList getAddrRanges() const override;
68 
69  protected: /* API wrappers/helpers */
76  void reset();
77 
79  uint32_t readReg(nomali_addr_t reg);
81  void writeReg(nomali_addr_t reg, uint32_t value);
82 
84  uint32_t readRegRaw(nomali_addr_t reg) const;
86  void writeRegRaw(nomali_addr_t reg, uint32_t value);
87 
94  bool intState(nomali_int_t intno);
95 
104  static void gpuPanic(nomali_error_t err, const char *msg) M5_ATTR_NORETURN;
111  static void panicOnErr(nomali_error_t err, const char *msg) {
112  if (err != NOMALI_E_OK)
113  gpuPanic(err, msg);
114  }
115 
116  protected: /* Callbacks */
130  virtual void onInterrupt(nomali_int_t intno, bool set);
131 
138  virtual void onReset();
139 
142  private: /* Callback helpers */
144  void setCallback(const nomali_callback_t &callback);
145 
157  static void _interrupt(nomali_handle_t h, void *usr,
158  nomali_int_t intno, int set);
159 
169  static void _reset(nomali_handle_t h, void *usr);
170 
171  protected:
173  const Addr pioAddr;
174 
177 
180  const std::map<nomali_int_t, uint32_t> interruptMap;
181 
183  nomali_info_t nomaliInfo;
184 
186  nomali_handle_t nomali;
187 };
188 
189 
191 {
192  public:
193  CustomNoMaliGpu(const CustomNoMaliGpuParams *p);
194  virtual ~CustomNoMaliGpu();
195 
196  protected:
197  void onReset() override;
198 
199  private:
201  std::map<nomali_addr_t, uint32_t> idRegs;
202 };
203 
204 #endif // __DEV_ARM_NOMALI_GPU_HH__
RealView *const platform
Platform, used to discover GIC.
Definition: gpu_nomali.hh:176
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gpu_nomali.cc:170
Bitfield< 5, 3 > reg
Definition: types.hh:89
bool intState(nomali_int_t intno)
Wrapper around nomali_int_state()
Definition: gpu_nomali.cc:255
nomali_handle_t nomali
Handle of a NoMali library instance.
Definition: gpu_nomali.hh:186
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: gpu_nomali.cc:127
static void _interrupt(nomali_handle_t h, void *usr, nomali_int_t intno, int set)
Interrupt callback from the NoMali library.
Definition: gpu_nomali.cc:309
virtual ~NoMaliGpu()
Definition: gpu_nomali.cc:109
virtual void onInterrupt(nomali_int_t intno, bool set)
Interrupt callback from the NoMali library.
Definition: gpu_nomali.cc:273
virtual ~CustomNoMaliGpu()
Definition: gpu_nomali.cc:367
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: gpu_nomali.cc:191
nomali_info_t nomaliInfo
Cached information struct from the NoMali library.
Definition: gpu_nomali.hh:183
NoMaliGpu(const NoMaliGpuParams *p)
Definition: gpu_nomali.cc:57
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: gpu_nomali.cc:138
static void _reset(nomali_handle_t h, void *usr)
Reset callback from the NoMali library.
Definition: gpu_nomali.cc:318
CustomNoMaliGpu(const CustomNoMaliGpuParams *p)
Definition: gpu_nomali.cc:326
cbk_int usr
Definition: gpu_nomali.cc:93
std::map< nomali_addr_t, uint32_t > idRegs
Map between GPU registers and their custom reset values.
Definition: gpu_nomali.hh:201
static void panicOnErr(nomali_error_t err, const char *msg)
Panic if the NoMali returned an error, do nothing otherwise.
Definition: gpu_nomali.hh:111
void writeReg(nomali_addr_t reg, uint32_t value)
Wrapper around nomali_reg_write().
Definition: gpu_nomali.cc:223
uint64_t Tick
Tick count type.
Definition: types.hh:63
void setCallback(const nomali_callback_t &callback)
Wrapper around nomali_set_callback()
Definition: gpu_nomali.cc:298
const Addr pioAddr
Device base address.
Definition: gpu_nomali.hh:173
const std::map< nomali_int_t, uint32_t > interruptMap
Map between NoMali interrupt types and actual GIC interrupts.
Definition: gpu_nomali.hh:180
This device is the base class which all devices senstive to an address range inherit from...
Definition: io_device.hh:84
void onReset() override
Reset callback from the NoMali library.
Definition: gpu_nomali.cc:372
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void writeRegRaw(nomali_addr_t reg, uint32_t value)
Wrapper around nomali_reg_write_raw().
Definition: gpu_nomali.cc:247
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: gpu_nomali.cc:116
void reset()
Wrapper around nomali_reset().
Definition: gpu_nomali.cc:197
uint32_t readReg(nomali_addr_t reg)
Wrapper around nomali_reg_read().
Definition: gpu_nomali.cc:207
virtual void onReset()
Reset callback from the NoMali library.
Definition: gpu_nomali.cc:292
std::ostream CheckpointOut
Definition: serialize.hh:67
uint32_t readRegRaw(nomali_addr_t reg) const
Wrapper around nomali_reg_read_raw().
Definition: gpu_nomali.cc:234
static void gpuPanic(nomali_error_t err, const char *msg) M5_ATTR_NORETURN
Format a NoMali error into an error message and panic.
Definition: gpu_nomali.cc:266
Bitfield< 0 > p
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gpu_nomali.cc:149

Generated on Fri Jun 9 2017 13:03:45 for gem5 by doxygen 1.8.6