addrspace.cc revision 11313
16019Shines@cs.fsu.edu/*
27091Sgblack@eecs.umich.edu * Copyright (c) 2016 ARM Limited
37091Sgblack@eecs.umich.edu * All rights reserved
47091Sgblack@eecs.umich.edu *
57091Sgblack@eecs.umich.edu * Licensed under the Apache License, Version 2.0 (the "License");
67091Sgblack@eecs.umich.edu * you may not use this file except in compliance with the License.
77091Sgblack@eecs.umich.edu * You may obtain a copy of the License at
87091Sgblack@eecs.umich.edu *
97091Sgblack@eecs.umich.edu *     http://www.apache.org/licenses/LICENSE-2.0
107091Sgblack@eecs.umich.edu *
117091Sgblack@eecs.umich.edu * Unless required by applicable law or agreed to in writing, software
127091Sgblack@eecs.umich.edu * distributed under the License is distributed on an "AS IS" BASIS,
137091Sgblack@eecs.umich.edu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
146019Shines@cs.fsu.edu * See the License for the specific language governing permissions and
156019Shines@cs.fsu.edu * limitations under the License.
166019Shines@cs.fsu.edu *
176019Shines@cs.fsu.edu * Authors: Andreas Sandberg
186019Shines@cs.fsu.edu */
196019Shines@cs.fsu.edu
206019Shines@cs.fsu.edu#include "jobslot.hh"
216019Shines@cs.fsu.edu
226019Shines@cs.fsu.edu#include <cassert>
236019Shines@cs.fsu.edu#include <cstdlib>
246019Shines@cs.fsu.edu
256019Shines@cs.fsu.edu#include "addrspace.hh"
266019Shines@cs.fsu.edu#include "gpu.hh"
276019Shines@cs.fsu.edu#include "regutils.hh"
286019Shines@cs.fsu.edu
296019Shines@cs.fsu.edunamespace NoMali {
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.educonst std::vector<AddrSpace::cmd_t> AddrSpace::cmds {
326019Shines@cs.fsu.edu    &AddrSpace::cmdNop,                     // ASn_COMMAND_NOP
336019Shines@cs.fsu.edu    &AddrSpace::cmdUpdate,                  // ASn_COMMAND_UPDATE
346019Shines@cs.fsu.edu    &AddrSpace::cmdLock,                    // ASn_COMMAND_LOCK
356019Shines@cs.fsu.edu    &AddrSpace::cmdUnlock,                  // ASn_COMMAND_UNLOCK
366019Shines@cs.fsu.edu    &AddrSpace::cmdFlushPT,                 // ASn_COMMAND_FLUSH_PT
376019Shines@cs.fsu.edu    &AddrSpace::cmdFlushMem,                // ASn_COMMAND_FLUSH_MEM
386019Shines@cs.fsu.edu};
396019Shines@cs.fsu.edu
406019Shines@cs.fsu.eduAddrSpace::AddrSpace(GPU &_gpu, MMU &_mmu, uint8_t _id)
416019Shines@cs.fsu.edu    : GPUBlock(_gpu, ASn_NO_REGS),
426019Shines@cs.fsu.edu      id(_id),
436019Shines@cs.fsu.edu      mmu(_mmu)
446019Shines@cs.fsu.edu{
456019Shines@cs.fsu.edu}
466019Shines@cs.fsu.edu
476019Shines@cs.fsu.eduAddrSpace::AddrSpace(AddrSpace &&rhs)
486019Shines@cs.fsu.edu    : GPUBlock(std::move(rhs)),
496019Shines@cs.fsu.edu      id(std::move(rhs.id)),
507639Sgblack@eecs.umich.edu      mmu(rhs.mmu)
516019Shines@cs.fsu.edu{
526019Shines@cs.fsu.edu}
536019Shines@cs.fsu.edu
546019Shines@cs.fsu.eduAddrSpace::~AddrSpace()
556312Sgblack@eecs.umich.edu{
566312Sgblack@eecs.umich.edu}
577720Sgblack@eecs.umich.edu
586312Sgblack@eecs.umich.eduvoid
597186Sgblack@eecs.umich.eduAddrSpace::writeReg(RegAddr addr, uint32_t value)
607720Sgblack@eecs.umich.edu{
617186Sgblack@eecs.umich.edu    switch (addr.value) {
627186Sgblack@eecs.umich.edu      case ASn_COMMAND:
636312Sgblack@eecs.umich.edu        asCommand(value);
647093Sgblack@eecs.umich.edu        break;
656312Sgblack@eecs.umich.edu
666312Sgblack@eecs.umich.edu      case ASn_TRANSTAB_LO:
677148Sgblack@eecs.umich.edu      case ASn_TRANSTAB_HI:
687148Sgblack@eecs.umich.edu      case ASn_MEMATTR_LO:
697148Sgblack@eecs.umich.edu      case ASn_MEMATTR_HI:
707148Sgblack@eecs.umich.edu      case ASn_LOCKADDR_LO:
717184Sgblack@eecs.umich.edu      case ASn_LOCKADDR_HI:
727184Sgblack@eecs.umich.edu        GPUBlock::writeReg(addr, value);
737289Sgblack@eecs.umich.edu        break;
747289Sgblack@eecs.umich.edu
757289Sgblack@eecs.umich.edu      default:
767289Sgblack@eecs.umich.edu        // Ignore writes by default
777184Sgblack@eecs.umich.edu        break;
787184Sgblack@eecs.umich.edu    };
797184Sgblack@eecs.umich.edu}
807184Sgblack@eecs.umich.edu
817184Sgblack@eecs.umich.eduvoid
827184Sgblack@eecs.umich.eduAddrSpace::asCommand(uint32_t cmd)
837797Sgblack@eecs.umich.edu{
847797Sgblack@eecs.umich.edu    if (cmd < cmds.size())
857797Sgblack@eecs.umich.edu        (this->*cmds[cmd])(cmd);
867797Sgblack@eecs.umich.edu}
877797Sgblack@eecs.umich.edu
887797Sgblack@eecs.umich.eduvoid
897797Sgblack@eecs.umich.eduAddrSpace::cmdNop(uint32_t cmd)
907797Sgblack@eecs.umich.edu{
917797Sgblack@eecs.umich.edu    assert(cmd == ASn_COMMAND_NOP);
927797Sgblack@eecs.umich.edu}
937797Sgblack@eecs.umich.edu
947797Sgblack@eecs.umich.edu
957797Sgblack@eecs.umich.eduvoid
967797Sgblack@eecs.umich.eduAddrSpace::cmdUpdate(uint32_t cmd)
977797Sgblack@eecs.umich.edu{
987797Sgblack@eecs.umich.edu    assert(cmd == ASn_COMMAND_UPDATE);
997797Sgblack@eecs.umich.edu}
1007797Sgblack@eecs.umich.edu
1017797Sgblack@eecs.umich.eduvoid
1027797Sgblack@eecs.umich.eduAddrSpace::cmdLock(uint32_t cmd)
1037797Sgblack@eecs.umich.edu{
1047797Sgblack@eecs.umich.edu    assert(cmd == ASn_COMMAND_LOCK);
1057797Sgblack@eecs.umich.edu}
1067797Sgblack@eecs.umich.edu
1077797Sgblack@eecs.umich.eduvoid
1087797Sgblack@eecs.umich.eduAddrSpace::cmdUnlock(uint32_t cmd)
1097797Sgblack@eecs.umich.edu{
1107797Sgblack@eecs.umich.edu    assert(cmd == ASn_COMMAND_UNLOCK);
1117797Sgblack@eecs.umich.edu}
1127797Sgblack@eecs.umich.edu
1137797Sgblack@eecs.umich.eduvoid
1147797Sgblack@eecs.umich.eduAddrSpace::cmdFlushPT(uint32_t cmd)
1157797Sgblack@eecs.umich.edu{
1167797Sgblack@eecs.umich.edu    assert(cmd == ASn_COMMAND_FLUSH_PT);
1177797Sgblack@eecs.umich.edu}
1187797Sgblack@eecs.umich.edu
1197797Sgblack@eecs.umich.eduvoid
1207797Sgblack@eecs.umich.eduAddrSpace::cmdFlushMem(uint32_t cmd)
1217797Sgblack@eecs.umich.edu{
1227797Sgblack@eecs.umich.edu    assert(cmd == ASn_COMMAND_FLUSH_MEM);
1237797Sgblack@eecs.umich.edu}
1247797Sgblack@eecs.umich.edu
1257797Sgblack@eecs.umich.edu}
1267797Sgblack@eecs.umich.edu