gpu_nomali.hh (10916:5c76426fd9ee) gpu_nomali.hh (11168:f98eb2da15a4)
1/*
2 * Copyright (c) 2014-2015 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
48class NoMaliGpuParams;
49class RealView;
50
51class NoMaliGpu : public PioDevice
52{
53 public:
54 NoMaliGpu(const NoMaliGpuParams *p);
55 virtual ~NoMaliGpu();
56
57 public: /* Checkpointing */
1/*
2 * Copyright (c) 2014-2015 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
48class NoMaliGpuParams;
49class RealView;
50
51class NoMaliGpu : public PioDevice
52{
53 public:
54 NoMaliGpu(const NoMaliGpuParams *p);
55 virtual ~NoMaliGpu();
56
57 public: /* Checkpointing */
58 void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
59 void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
58 void serialize(CheckpointOut &cp) const override;
59 void unserialize(CheckpointIn &cp) override;
60
61 public: /* IO device interfaces */
60
61 public: /* IO device interfaces */
62 Tick read(PacketPtr pkt) M5_ATTR_OVERRIDE;
63 Tick write(PacketPtr pkt) M5_ATTR_OVERRIDE;
64 AddrRangeList getAddrRanges() const M5_ATTR_OVERRIDE;
62 Tick read(PacketPtr pkt) override;
63 Tick write(PacketPtr pkt) override;
64 AddrRangeList getAddrRanges() const override;
65
66 private:
67 /**
68 * Interrupt callback from the NoMali library.
69 *
70 * This method calls onInterrupt() on the NoMaliGpu owning this
71 * device.
72 *
73 * @param h NoMali library handle.
74 * @param usr Pointer to an instance of the NoMaliGpu
75 * @param intno GPU interrupt type
76 * @param set Was the interrupt raised (1) or lowered (0)?
77 */
78 static void _interrupt(nomali_handle_t h, void *usr,
79 nomali_int_t intno, int set);
80
81 void onInterrupt(nomali_handle_t h, nomali_int_t intno, bool set);
82
83 /** Wrapper around nomali_reg_read(). */
84 uint32_t readReg(nomali_addr_t reg);
85 /** Wrapper around nomali_reg_write(). */
86 void writeReg(nomali_addr_t reg, uint32_t value);
87
88 /** Wrapper around nomali_reg_read_raw(). */
89 uint32_t readRegRaw(nomali_addr_t reg) const;
90 /** Wrapper around nomali_reg_write_raw(). */
91 void writeRegRaw(nomali_addr_t reg, uint32_t value);
92
93 /**
94 * Format a NoMali error into an error message and panic.
95 *
96 * @param err Error code from the NoMali library.
97 * @param msg Message to print.
98 */
99 static void gpuPanic(nomali_error_t err, const char *msg) M5_ATTR_NORETURN;
100 /**
101 * Panic if the NoMali returned an error, do nothing otherwise.
102 *
103 * @param err Error code from the NoMali library.
104 * @param msg Message to print when panicking.
105 */
106 static void panicOnErr(nomali_error_t err, const char *msg) {
107 if (err != NOMALI_E_OK)
108 gpuPanic(err, msg);
109 }
110
111 /** Device base address */
112 const Addr pioAddr;
113
114 /** Platform, used to discover GIC */
115 RealView *const platform;
116
117 /** Map between NoMali interrupt types and actual GIC
118 * interrupts */
119 const std::map<nomali_int_t, uint32_t> interruptMap;
120
121
122 /** Cached information struct from the NoMali library */
123 nomali_info_t nomaliInfo;
124
125 /** Handle of a NoMali library instance */
126 nomali_handle_t nomali;
127};
128
129
130#endif // __DEV_ARM_NOMALI_GPU_HH__
65
66 private:
67 /**
68 * Interrupt callback from the NoMali library.
69 *
70 * This method calls onInterrupt() on the NoMaliGpu owning this
71 * device.
72 *
73 * @param h NoMali library handle.
74 * @param usr Pointer to an instance of the NoMaliGpu
75 * @param intno GPU interrupt type
76 * @param set Was the interrupt raised (1) or lowered (0)?
77 */
78 static void _interrupt(nomali_handle_t h, void *usr,
79 nomali_int_t intno, int set);
80
81 void onInterrupt(nomali_handle_t h, nomali_int_t intno, bool set);
82
83 /** Wrapper around nomali_reg_read(). */
84 uint32_t readReg(nomali_addr_t reg);
85 /** Wrapper around nomali_reg_write(). */
86 void writeReg(nomali_addr_t reg, uint32_t value);
87
88 /** Wrapper around nomali_reg_read_raw(). */
89 uint32_t readRegRaw(nomali_addr_t reg) const;
90 /** Wrapper around nomali_reg_write_raw(). */
91 void writeRegRaw(nomali_addr_t reg, uint32_t value);
92
93 /**
94 * Format a NoMali error into an error message and panic.
95 *
96 * @param err Error code from the NoMali library.
97 * @param msg Message to print.
98 */
99 static void gpuPanic(nomali_error_t err, const char *msg) M5_ATTR_NORETURN;
100 /**
101 * Panic if the NoMali returned an error, do nothing otherwise.
102 *
103 * @param err Error code from the NoMali library.
104 * @param msg Message to print when panicking.
105 */
106 static void panicOnErr(nomali_error_t err, const char *msg) {
107 if (err != NOMALI_E_OK)
108 gpuPanic(err, msg);
109 }
110
111 /** Device base address */
112 const Addr pioAddr;
113
114 /** Platform, used to discover GIC */
115 RealView *const platform;
116
117 /** Map between NoMali interrupt types and actual GIC
118 * interrupts */
119 const std::map<nomali_int_t, uint32_t> interruptMap;
120
121
122 /** Cached information struct from the NoMali library */
123 nomali_info_t nomaliInfo;
124
125 /** Handle of a NoMali library instance */
126 nomali_handle_t nomali;
127};
128
129
130#endif // __DEV_ARM_NOMALI_GPU_HH__