2 * Copyright (c) 2014-2015 ARM Limited
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * Authors: Andreas Sandberg
20 #ifndef _LIBNOMALIMODEL_GPUCONTROL_HH
21 #define _LIBNOMALIMODEL_GPUCONTROL_HH
26 #include "gpublock.hh"
33 * Limited GPU control block implementation.
35 * This is a minimal implementation of the Midgard GPU control
36 * block. It contains the stuff necessary to do command decoding and
37 * dispatch, interrupt handling, and GPU block ready handling.
39 * An actual GPU implementation should specialize this class to setup
40 * the following registers from the reset() method:
43 * <li>Feature registers (XX_FEATURES)
44 * <li>Present registers (XX_PRESENT)
45 * <li>Thread discovery (THREAD_XX)
46 * <li>Present registers (XX_PRESENT)
53 GPUControl(GPU &_gpu);
54 virtual ~GPUControl();
56 virtual void reset() override = 0;
58 void writeReg(RegAddr idx, uint32_t value) override;
61 void onInterrupt(int set) override;
65 * @name GPU control block commands
69 * Control command dispatcher.
71 * This method is called whenever there is a write to the
72 * GPU_COMMAND register. The method uses a lookup table to call
73 * the right command handling method.
75 * @param cmd Command number (see the Midgard architecture
78 virtual void gpuCommand(uint32_t cmd);
80 * Command handler for No-ops.
82 * @param cmd Command number (see the Midgard architecture
85 virtual void cmdNop(uint32_t cmd);
87 * Command handler for GPU-wide hard resets
89 * @param cmd Command number (see the Midgard architecture
92 virtual void cmdHardReset(uint32_t cmd);
94 * Command handler for GPU-wide soft resets
96 * @param cmd Command number (see the Midgard architecture
99 virtual void cmdSoftReset(uint32_t cmd);
101 * Command handler for performance counter clear operations.
103 * @param cmd Command number (see the Midgard architecture
106 virtual void cmdPerfCntClear(uint32_t cmd);
108 * Command handler for performance counter sample operations.
110 * @param cmd Command number (see the Midgard architecture
113 virtual void cmdPerfCntSample(uint32_t cmd);
115 * Command handler for cycle counter start operations.
117 * @param cmd Command number (see the Midgard architecture
120 virtual void cmdCycleCountStart(uint32_t cmd);
122 * Command handler for cycle counter stop operations.
124 * @param cmd Command number (see the Midgard architecture
127 virtual void cmdCycleCountStop(uint32_t cmd);
129 * Command handler for cache cleaning operations.
131 * @param cmd Command number (see the Midgard architecture
134 virtual void cmdCleanCaches(uint32_t cmd);
136 * Command handler for cache clean and invalidate operations.
138 * @param cmd Command number (see the Midgard architecture
141 virtual void cmdCleanInvCaches(uint32_t cmd);
146 typedef void (GPUControl::*cmd_t)(uint32_t);
148 * Mapping between command IDs and command handling methods.
150 * @note The order of this vector <i>MUST</i> correspond to the
151 * GPU control command IDs in the Midgard architecture
154 static const std::vector<cmd_t> cmds;
159 #endif // _LIBNOMALIMODEL_GPUCONTROL_HH