1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/*
* Copyright (c) 2014-2015 ARM Limited
* All rights reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Authors: Andreas Sandberg
*/
#include "gpucontrol.hh"
#include "gpu.hh"
#include "regutils.hh"
namespace NoMali {
typedef void (GPUControl::*GpuCmdHandler)(uint32_t);
const std::vector<GpuCmdHandler> GPUControl::cmds {
&GPUControl::cmdNop, // GPU_COMMAND_NOP
&GPUControl::cmdSoftReset, // GPU_COMMAND_SOFT_RESET
&GPUControl::cmdHardReset, // GPU_COMMAND_HARD_RESET
&GPUControl::cmdPerfCntClear, // GPU_COMMAND_PRFCNT_CLEAR
&GPUControl::cmdPerfCntSample, // GPU_COMMAND_PRFCNT_SAMPLE
&GPUControl::cmdCycleCountStart, // GPU_COMMAND_CYCLE_COUNT_START
&GPUControl::cmdCycleCountStop, // GPU_COMMAND_COUNT_STOP
&GPUControl::cmdCleanCaches, // GPU_COMMAND_CLEAN_CACHES
&GPUControl::cmdCleanInvCaches, // GPU_COMMAND_CLEAN_INV_CACHES
};
GPUControl::GPUControl(GPU &_gpu)
: GPUBlockInt(_gpu,
RegAddr(GPU_IRQ_RAWSTAT),
RegAddr(GPU_IRQ_CLEAR),
RegAddr(GPU_IRQ_MASK),
RegAddr(GPU_IRQ_STATUS))
{
}
GPUControl::~GPUControl()
{
}
void
GPUControl::reset()
{
GPUBlock::reset();
}
void
GPUControl::writeReg(RegAddr addr, uint32_t value)
{
switch (addr.value) {
case GPU_IRQ_RAWSTAT:
case GPU_IRQ_CLEAR:
case GPU_IRQ_MASK:
case GPU_IRQ_STATUS:
GPUBlockInt::writeReg(addr, value);
break;
case GPU_COMMAND:
gpuCommand(value);
break;
case SHADER_PWRON_LO:
case SHADER_PWRON_HI:
case TILER_PWRON_LO:
case TILER_PWRON_HI:
case L2_PWRON_LO:
case L2_PWRON_HI:
case L3_PWRON_LO:
case L3_PWRON_HI: {
const RegAddr ready_reg(SHADER_READY_LO +
(addr.value - SHADER_PWRON_LO));
const RegAddr present_reg(SHADER_PRESENT_LO +
(addr.value - SHADER_PWRON_LO));
regs[ready_reg] |= value & regs[present_reg];
raiseInterrupt(POWER_CHANGED_SINGLE | POWER_CHANGED_ALL);
} break;
case SHADER_PWROFF_LO:
case SHADER_PWROFF_HI:
case TILER_PWROFF_LO:
case TILER_PWROFF_HI:
case L2_PWROFF_LO:
case L2_PWROFF_HI:
case L3_PWROFF_LO:
case L3_PWROFF_HI: {
const RegAddr ready_reg(SHADER_READY_LO +
(addr.value - SHADER_PWROFF_LO));
regs[ready_reg] &= ~value;
raiseInterrupt(POWER_CHANGED_SINGLE | POWER_CHANGED_ALL);
} break;
default:
// Ignore writes by default
break;
};
}
void
GPUControl::onInterrupt(int set)
{
gpu.intGPU(set);
}
void
GPUControl::gpuCommand(uint32_t cmd)
{
if (cmd < cmds.size())
(this->*cmds[cmd])(cmd);
}
void
GPUControl::cmdNop(uint32_t cmd)
{
}
void
GPUControl::cmdHardReset(uint32_t cmd)
{
gpu.reset();
raiseInterrupt(RESET_COMPLETED);
}
void
GPUControl::cmdSoftReset(uint32_t cmd)
{
gpu.reset();
raiseInterrupt(RESET_COMPLETED);
}
void
GPUControl::cmdPerfCntClear(uint32_t cmd)
{
}
void
GPUControl::cmdPerfCntSample(uint32_t cmd)
{
raiseInterrupt(PRFCNT_SAMPLE_COMPLETED);
}
void
GPUControl::cmdCycleCountStart(uint32_t cmd)
{
}
void
GPUControl::cmdCycleCountStop(uint32_t cmd)
{
}
void
GPUControl::cmdCleanCaches(uint32_t cmd)
{
raiseInterrupt(CLEAN_CACHES_COMPLETED);
}
void
GPUControl::cmdCleanInvCaches(uint32_t cmd)
{
raiseInterrupt(CLEAN_CACHES_COMPLETED);
}
}
|