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#ifndef _LIBNOMALIMODEL_ADDRSPACE_HH 21#define _LIBNOMALIMODEL_ADDRSPACE_HH 22 23#include <vector> 24 25#include "gpublock.hh" 26#include "types.hh" 27 28namespace NoMali { 29 30class GPU; 31 32class MMU; 33 34/** 35 * Midgard job slot implementation. 36 * 37 * A job slot is a part of a JobControl block that controls the state 38 * of one out of 16 active jobs. Each slot can contain one running job 39 * and a pending job. 40 */ 41class AddrSpace 42 : public GPUBlock 43{ 44 public: 45 AddrSpace(GPU &_gpu, MMU &_mmu, uint8_t slot_id); 46 AddrSpace(AddrSpace &&rhs); 47 virtual ~AddrSpace(); 48 49 void writeReg(RegAddr idx, uint32_t value) override; 50 51 protected: 52 /** 53 * @{ 54 * @name Address Space Control 55 */ 56 57 58 /** @} */ 59 60 /** 61 * @{ 62 * @name Job slot commands 63 */ 64 65 /** 66 * Address space command dispatcher. 67 * 68 * This method is called whenever there is a write to the 69 * ASn_COMMAND register. The method uses a lookup table to call 70 * the right command handling method. 71 * 72 * @param cmd Command number (see the Midgard architecture 73 * specification) 74 */ 75 void asCommand(uint32_t cmd); 76 77 /** 78 * Command handler for No-ops. 79 * 80 * @param cmd Command number (see the Midgard architecture 81 * specification) 82 */ 83 void cmdNop(uint32_t cmd); 84 85 void cmdUpdate(uint32_t cmd); 86 void cmdLock(uint32_t cmd); 87 void cmdUnlock(uint32_t cmd); 88 void cmdFlushPT(uint32_t cmd); 89 void cmdFlushMem(uint32_t cmd); 90 91 /** @} */ 92 93 /** Address space ID */ 94 const uint8_t id; 95 96 /** Parent MMU block */ 97 MMU &mmu; 98 99 private: 100 typedef void (AddrSpace::*cmd_t)(uint32_t); 101 102 /** 103 * Mapping between command IDs and command handling methods. 104 * 105 * @note The order of this vector <i>MUST</i> correspond to the 106 * address space command IDs in the Midgard architecture 107 * specification. 108 */ 109 static const std::vector<cmd_t> cmds; 110}; 111 112} 113 114#endif // _LIBNOMALIMODEL_ADDRSPACE_HH 115