addrspace.cc revision 11313
111313Sandreas.sandberg@arm.com/* 211313Sandreas.sandberg@arm.com * Copyright (c) 2016 ARM Limited 311313Sandreas.sandberg@arm.com * All rights reserved 411313Sandreas.sandberg@arm.com * 511313Sandreas.sandberg@arm.com * Licensed under the Apache License, Version 2.0 (the "License"); 611313Sandreas.sandberg@arm.com * you may not use this file except in compliance with the License. 711313Sandreas.sandberg@arm.com * You may obtain a copy of the License at 811313Sandreas.sandberg@arm.com * 911313Sandreas.sandberg@arm.com * http://www.apache.org/licenses/LICENSE-2.0 1011313Sandreas.sandberg@arm.com * 1111313Sandreas.sandberg@arm.com * Unless required by applicable law or agreed to in writing, software 1211313Sandreas.sandberg@arm.com * distributed under the License is distributed on an "AS IS" BASIS, 1311313Sandreas.sandberg@arm.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1411313Sandreas.sandberg@arm.com * See the License for the specific language governing permissions and 1511313Sandreas.sandberg@arm.com * limitations under the License. 1611313Sandreas.sandberg@arm.com * 1711313Sandreas.sandberg@arm.com * Authors: Andreas Sandberg 1811313Sandreas.sandberg@arm.com */ 1911313Sandreas.sandberg@arm.com 2011313Sandreas.sandberg@arm.com#include "jobslot.hh" 2111313Sandreas.sandberg@arm.com 2211313Sandreas.sandberg@arm.com#include <cassert> 2311313Sandreas.sandberg@arm.com#include <cstdlib> 2411313Sandreas.sandberg@arm.com 2511313Sandreas.sandberg@arm.com#include "addrspace.hh" 2611313Sandreas.sandberg@arm.com#include "gpu.hh" 2711313Sandreas.sandberg@arm.com#include "regutils.hh" 2811313Sandreas.sandberg@arm.com 2911313Sandreas.sandberg@arm.comnamespace NoMali { 3011313Sandreas.sandberg@arm.com 3111313Sandreas.sandberg@arm.comconst std::vector<AddrSpace::cmd_t> AddrSpace::cmds { 3211313Sandreas.sandberg@arm.com &AddrSpace::cmdNop, // ASn_COMMAND_NOP 3311313Sandreas.sandberg@arm.com &AddrSpace::cmdUpdate, // ASn_COMMAND_UPDATE 3411313Sandreas.sandberg@arm.com &AddrSpace::cmdLock, // ASn_COMMAND_LOCK 3511313Sandreas.sandberg@arm.com &AddrSpace::cmdUnlock, // ASn_COMMAND_UNLOCK 3611313Sandreas.sandberg@arm.com &AddrSpace::cmdFlushPT, // ASn_COMMAND_FLUSH_PT 3711313Sandreas.sandberg@arm.com &AddrSpace::cmdFlushMem, // ASn_COMMAND_FLUSH_MEM 3811313Sandreas.sandberg@arm.com}; 3911313Sandreas.sandberg@arm.com 4011313Sandreas.sandberg@arm.comAddrSpace::AddrSpace(GPU &_gpu, MMU &_mmu, uint8_t _id) 4111313Sandreas.sandberg@arm.com : GPUBlock(_gpu, ASn_NO_REGS), 4211313Sandreas.sandberg@arm.com id(_id), 4311313Sandreas.sandberg@arm.com mmu(_mmu) 4411313Sandreas.sandberg@arm.com{ 4511313Sandreas.sandberg@arm.com} 4611313Sandreas.sandberg@arm.com 4711313Sandreas.sandberg@arm.comAddrSpace::AddrSpace(AddrSpace &&rhs) 4811313Sandreas.sandberg@arm.com : GPUBlock(std::move(rhs)), 4911313Sandreas.sandberg@arm.com id(std::move(rhs.id)), 5011313Sandreas.sandberg@arm.com mmu(rhs.mmu) 5111313Sandreas.sandberg@arm.com{ 5211313Sandreas.sandberg@arm.com} 5311313Sandreas.sandberg@arm.com 5411313Sandreas.sandberg@arm.comAddrSpace::~AddrSpace() 5511313Sandreas.sandberg@arm.com{ 5611313Sandreas.sandberg@arm.com} 5711313Sandreas.sandberg@arm.com 5811313Sandreas.sandberg@arm.comvoid 5911313Sandreas.sandberg@arm.comAddrSpace::writeReg(RegAddr addr, uint32_t value) 6011313Sandreas.sandberg@arm.com{ 6111313Sandreas.sandberg@arm.com switch (addr.value) { 6211313Sandreas.sandberg@arm.com case ASn_COMMAND: 6311313Sandreas.sandberg@arm.com asCommand(value); 6411313Sandreas.sandberg@arm.com break; 6511313Sandreas.sandberg@arm.com 6611313Sandreas.sandberg@arm.com case ASn_TRANSTAB_LO: 6711313Sandreas.sandberg@arm.com case ASn_TRANSTAB_HI: 6811313Sandreas.sandberg@arm.com case ASn_MEMATTR_LO: 6911313Sandreas.sandberg@arm.com case ASn_MEMATTR_HI: 7011313Sandreas.sandberg@arm.com case ASn_LOCKADDR_LO: 7111313Sandreas.sandberg@arm.com case ASn_LOCKADDR_HI: 7211313Sandreas.sandberg@arm.com GPUBlock::writeReg(addr, value); 7311313Sandreas.sandberg@arm.com break; 7411313Sandreas.sandberg@arm.com 7511313Sandreas.sandberg@arm.com default: 7611313Sandreas.sandberg@arm.com // Ignore writes by default 7711313Sandreas.sandberg@arm.com break; 7811313Sandreas.sandberg@arm.com }; 7911313Sandreas.sandberg@arm.com} 8011313Sandreas.sandberg@arm.com 8111313Sandreas.sandberg@arm.comvoid 8211313Sandreas.sandberg@arm.comAddrSpace::asCommand(uint32_t cmd) 8311313Sandreas.sandberg@arm.com{ 8411313Sandreas.sandberg@arm.com if (cmd < cmds.size()) 8511313Sandreas.sandberg@arm.com (this->*cmds[cmd])(cmd); 8611313Sandreas.sandberg@arm.com} 8711313Sandreas.sandberg@arm.com 8811313Sandreas.sandberg@arm.comvoid 8911313Sandreas.sandberg@arm.comAddrSpace::cmdNop(uint32_t cmd) 9011313Sandreas.sandberg@arm.com{ 9111313Sandreas.sandberg@arm.com assert(cmd == ASn_COMMAND_NOP); 9211313Sandreas.sandberg@arm.com} 9311313Sandreas.sandberg@arm.com 9411313Sandreas.sandberg@arm.com 9511313Sandreas.sandberg@arm.comvoid 9611313Sandreas.sandberg@arm.comAddrSpace::cmdUpdate(uint32_t cmd) 9711313Sandreas.sandberg@arm.com{ 9811313Sandreas.sandberg@arm.com assert(cmd == ASn_COMMAND_UPDATE); 9911313Sandreas.sandberg@arm.com} 10011313Sandreas.sandberg@arm.com 10111313Sandreas.sandberg@arm.comvoid 10211313Sandreas.sandberg@arm.comAddrSpace::cmdLock(uint32_t cmd) 10311313Sandreas.sandberg@arm.com{ 10411313Sandreas.sandberg@arm.com assert(cmd == ASn_COMMAND_LOCK); 10511313Sandreas.sandberg@arm.com} 10611313Sandreas.sandberg@arm.com 10711313Sandreas.sandberg@arm.comvoid 10811313Sandreas.sandberg@arm.comAddrSpace::cmdUnlock(uint32_t cmd) 10911313Sandreas.sandberg@arm.com{ 11011313Sandreas.sandberg@arm.com assert(cmd == ASn_COMMAND_UNLOCK); 11111313Sandreas.sandberg@arm.com} 11211313Sandreas.sandberg@arm.com 11311313Sandreas.sandberg@arm.comvoid 11411313Sandreas.sandberg@arm.comAddrSpace::cmdFlushPT(uint32_t cmd) 11511313Sandreas.sandberg@arm.com{ 11611313Sandreas.sandberg@arm.com assert(cmd == ASn_COMMAND_FLUSH_PT); 11711313Sandreas.sandberg@arm.com} 11811313Sandreas.sandberg@arm.com 11911313Sandreas.sandberg@arm.comvoid 12011313Sandreas.sandberg@arm.comAddrSpace::cmdFlushMem(uint32_t cmd) 12111313Sandreas.sandberg@arm.com{ 12211313Sandreas.sandberg@arm.com assert(cmd == ASn_COMMAND_FLUSH_MEM); 12311313Sandreas.sandberg@arm.com} 12411313Sandreas.sandberg@arm.com 12511313Sandreas.sandberg@arm.com} 126