summaryrefslogtreecommitdiff
path: root/ext/nomali/lib/mali_midgard.cc
blob: fe35f12591a3eada214f50da145178b0ad52e6e7 (plain)
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
/*
 * 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 "mali_midgard.hh"

#include "regutils.hh"

namespace NoMali {

MaliMidgard::MaliMidgard(unsigned gpuType,
                         unsigned major, unsigned minor, unsigned status)
    : MaliMidgard(GPU_ID_MAKE(gpuType, major, minor, status))
{
}

MaliMidgard::MaliMidgard(uint32_t _gpuId)
    : GPU(gpuControl, jobControl, mmu),
      gpuControl(*this),
      jobControl(*this),
      mmu(*this),
      gpuId(_gpuId)
{
}

MaliMidgard::~MaliMidgard()
{
}

void
MaliMidgard::setupControlIdRegisters(RegVector &regs)
{
    regs[RegAddr(L2_FEATURES)] =
        (0x07 << 24) |  // lg2 ext bus width
        (0x13 << 16) |  // lg2 cache size
        (0x02 << 8) |   // lg2 associativity
        (0x06);         // lg2 line size

    regs[RegAddr(TILER_FEATURES)] =
        (0x8 << 8) |    // Maximum no active hierarchy levels
        0x09;           // lg2 bin size

    /* Coherent core group, but incoherent supergroup. 1 L2 slice. */
    regs[RegAddr(MEM_FEATURES)] = 0x1;

    regs[RegAddr(MMU_FEATURES)] = 0x2830;
    regs[RegAddr(AS_PRESENT)] = 0xff;
    regs[RegAddr(JS_PRESENT)] = 0x7;
    regs[RegAddr(JS0_FEATURES)] = 0x20e;
    regs[RegAddr(JS1_FEATURES)] = 0x1fe;
    regs[RegAddr(JS2_FEATURES)] = 0x7e;

    regs[RegAddr(TEXTURE_FEATURES_0)] = 0x00fe001e;
    regs[RegAddr(TEXTURE_FEATURES_1)] = 0xffff;
    regs[RegAddr(TEXTURE_FEATURES_2)] = 0x9f81ffff;

    regs[RegAddr(THREAD_MAX_THREADS)] = 0x100;
    regs[RegAddr(THREAD_MAX_WORKGROUP_SIZE)] = 0x100;
    regs[RegAddr(THREAD_MAX_BARRIER_SIZE)] = 0x100;
    regs[RegAddr(THREAD_FEATURES)] = 0x0a040400;

    regs.set64(RegAddr(SHADER_PRESENT_LO), 0xf);
    regs.set64(RegAddr(TILER_PRESENT_LO), 0x1);
    regs.set64(RegAddr(L2_PRESENT_LO), 0x1);
}

void
MaliMidgard::GPUControlSpec::reset()
{
    GPUControl::reset();

    regs[RegAddr(GPU_ID)] = midgard.gpuId;

    midgard.setupControlIdRegisters(regs);
}

};