1/* 2 * Copyright (c) 2016 ARM Limited 3 * All rights reserved 4 * 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 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 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. 16 * 17 * Authors: Andreas Sandberg 18 */ 19 20#include "jobslot.hh" 21 22#include <cassert> 23#include <cstdlib> 24 25#include "addrspace.hh" 26#include "gpu.hh" 27#include "regutils.hh" 28 29namespace NoMali { 30 31const std::vector<AddrSpace::cmd_t> AddrSpace::cmds { 32 &AddrSpace::cmdNop, // ASn_COMMAND_NOP 33 &AddrSpace::cmdUpdate, // ASn_COMMAND_UPDATE 34 &AddrSpace::cmdLock, // ASn_COMMAND_LOCK 35 &AddrSpace::cmdUnlock, // ASn_COMMAND_UNLOCK 36 &AddrSpace::cmdFlushPT, // ASn_COMMAND_FLUSH_PT 37 &AddrSpace::cmdFlushMem, // ASn_COMMAND_FLUSH_MEM 38}; 39 40AddrSpace::AddrSpace(GPU &_gpu, MMU &_mmu, uint8_t _id) 41 : GPUBlock(_gpu, ASn_NO_REGS), 42 id(_id), 43 mmu(_mmu) 44{ 45} 46 47AddrSpace::AddrSpace(AddrSpace &&rhs) 48 : GPUBlock(std::move(rhs)), 49 id(std::move(rhs.id)), 50 mmu(rhs.mmu) 51{ 52} 53 54AddrSpace::~AddrSpace() 55{ 56} 57 58void 59AddrSpace::writeReg(RegAddr addr, uint32_t value) 60{ 61 switch (addr.value) { 62 case ASn_COMMAND: 63 asCommand(value); 64 break; 65 66 case ASn_TRANSTAB_LO: 67 case ASn_TRANSTAB_HI: 68 case ASn_MEMATTR_LO: 69 case ASn_MEMATTR_HI: 70 case ASn_LOCKADDR_LO: 71 case ASn_LOCKADDR_HI: 72 GPUBlock::writeReg(addr, value); 73 break; 74 75 default: 76 // Ignore writes by default 77 break; 78 }; 79} 80 81void 82AddrSpace::asCommand(uint32_t cmd) 83{ 84 if (cmd < cmds.size()) 85 (this->*cmds[cmd])(cmd); 86} 87 88void 89AddrSpace::cmdNop(uint32_t cmd) 90{ 91 assert(cmd == ASn_COMMAND_NOP); 92} 93 94 95void 96AddrSpace::cmdUpdate(uint32_t cmd) 97{ 98 assert(cmd == ASn_COMMAND_UPDATE); 99} 100 101void 102AddrSpace::cmdLock(uint32_t cmd) 103{ 104 assert(cmd == ASn_COMMAND_LOCK); 105} 106 107void 108AddrSpace::cmdUnlock(uint32_t cmd) 109{ 110 assert(cmd == ASn_COMMAND_UNLOCK); 111} 112 113void 114AddrSpace::cmdFlushPT(uint32_t cmd) 115{ 116 assert(cmd == ASn_COMMAND_FLUSH_PT); 117} 118 119void 120AddrSpace::cmdFlushMem(uint32_t cmd) 121{ 122 assert(cmd == ASn_COMMAND_FLUSH_MEM); 123} 124 125} 126