42 #include "debug/NoMali.hh" 45 #include "enums/MemoryMode.hh" 47 #include "nomali/lib/mali_midg_regmap.h" 48 #include "params/CustomNoMaliGpu.hh" 49 #include "params/NoMaliGpu.hh" 51 static const std::map<Enums::NoMaliGpuType, nomali_gpu_type_t>
gpuTypeMap{
52 { Enums::T60x, NOMALI_GPU_T60X },
53 { Enums::T62x, NOMALI_GPU_T62X },
54 { Enums::T760, NOMALI_GPU_T760 },
60 platform(p->platform),
62 { NOMALI_INT_GPU, p->int_gpu },
63 { NOMALI_INT_JOB, p->int_job },
64 { NOMALI_INT_MMU, p->int_mmu },
67 if (nomali_api_version() != NOMALI_API_VERSION)
68 panic(
"NoMali library API mismatch!\n");
72 memset(&cfg, 0,
sizeof(cfg));
76 fatal(
"Unrecognized GPU type: %s (%i)\n",
77 Enums::NoMaliGpuTypeStrings[
p->gpu_type],
p->gpu_type);
79 cfg.type = it_gpu->second;
81 cfg.ver_maj =
p->ver_maj;
82 cfg.ver_min =
p->ver_min;
83 cfg.ver_status =
p->ver_status;
86 nomali_create(&
nomali, &cfg),
87 "Failed to instantiate NoMali");
91 nomali_callback_t cbk_int;
92 cbk_int.type = NOMALI_CALLBACK_INT;
93 cbk_int.usr = (
void *)
this;
98 nomali_callback_t cbk_rst;
99 cbk_rst.type = NOMALI_CALLBACK_RESET;
100 cbk_rst.usr = (
void *)
this;
106 "Failed to get NoMali information struct");
156 panic(
"GPU register '0x%x' out of range!\n",
addr);
159 panic(
"Unexpected GPU register read size: %i\n",
size);
177 panic(
"GPU register '0x%x' out of range!\n",
addr);
180 panic(
"Unexpected GPU register write size: %i\n",
size);
182 panic(
"Unaligned GPU write: %i\n",
size);
203 "Failed to reset GPU");
212 nomali_reg_read(
nomali, &value, reg),
213 "GPU register read failed");
215 DPRINTF(NoMali,
"readReg(0x%x): 0x%x\n",
225 DPRINTF(NoMali,
"writeReg(0x%x, 0x%x)\n",
229 nomali_reg_write(
nomali, reg, value),
230 "GPU register write failed");
239 nomali_reg_read_raw(
nomali, &value, reg),
240 "GPU raw register read failed");
250 nomali_reg_write_raw(
nomali, reg, value),
251 "GPU raw register write failed");
259 nomali_int_state(
nomali, &state, intno),
260 "Failed to get interrupt state");
268 panic(
"%s: %s\n", msg, nomali_errstr(err));
277 panic(
"Unhandled interrupt from NoMali: %i\n", intno);
279 DPRINTF(NoMali,
"Interrupt %i->%i: %i\n",
280 intno, it_int->second,
set);
300 DPRINTF(NoMali,
"Registering callback %i\n",
304 nomali_set_callback(
nomali, &callback),
305 "Failed to register callback");
310 nomali_int_t intno,
int set)
312 NoMaliGpu *_this(static_cast<NoMaliGpu *>(usr));
320 NoMaliGpu *_this(static_cast<NoMaliGpu *>(usr));
329 { GPU_CONTROL_REG(GPU_ID), p->gpu_id },
330 { GPU_CONTROL_REG(L2_FEATURES), p->l2_features },
331 { GPU_CONTROL_REG(TILER_FEATURES), p->tiler_features },
332 { GPU_CONTROL_REG(MEM_FEATURES), p->mem_features },
333 { GPU_CONTROL_REG(MMU_FEATURES), p->mmu_features },
334 { GPU_CONTROL_REG(AS_PRESENT), p->as_present },
335 { GPU_CONTROL_REG(JS_PRESENT), p->js_present },
337 { GPU_CONTROL_REG(THREAD_MAX_THREADS), p->thread_max_threads },
338 { GPU_CONTROL_REG(THREAD_MAX_WORKGROUP_SIZE),
339 p->thread_max_workgroup_size },
340 { GPU_CONTROL_REG(THREAD_MAX_BARRIER_SIZE),
341 p->thread_max_barrier_size },
342 { GPU_CONTROL_REG(THREAD_FEATURES), p->thread_features },
344 { GPU_CONTROL_REG(SHADER_PRESENT_LO),
bits(p->shader_present, 31, 0) },
345 { GPU_CONTROL_REG(SHADER_PRESENT_HI),
bits(p->shader_present, 63, 32) },
346 { GPU_CONTROL_REG(TILER_PRESENT_LO),
bits(p->tiler_present, 31, 0) },
347 { GPU_CONTROL_REG(TILER_PRESENT_HI),
bits(p->tiler_present, 63, 32) },
348 { GPU_CONTROL_REG(L2_PRESENT_LO),
bits(p->l2_present, 31, 0) },
349 { GPU_CONTROL_REG(L2_PRESENT_HI),
bits(p->l2_present, 63, 32) },
353 "Too many texture feature registers specified (%i)\n",
354 p->texture_features.size());
357 "Too many job slot feature registers specified (%i)\n",
358 p->js_features.size());
360 for (
int i = 0;
i <
p->texture_features.size();
i++)
361 idRegs[TEXTURE_FEATURES_REG(
i)] =
p->texture_features[
i];
363 for (
int i = 0;
i <
p->js_features.size();
i++)
364 idRegs[JS_FEATURES_REG(
i)] =
p->js_features[
i];
383 NoMaliGpuParams::create()
389 CustomNoMaliGpuParams::create()
#define panic(...)
This implements a cprintf based panic() function.
AddrRange RangeSize(Addr start, Addr size)
RealView *const platform
Platform, used to discover GIC.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
#define fatal(...)
This implements a cprintf based fatal() function.
bool intState(nomali_int_t intno)
Wrapper around nomali_int_state()
virtual void clearInt(uint32_t num)=0
Clear an interrupt from a device that is connected to the GIC.
nomali_handle_t nomali
Handle of a NoMali library instance.
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
static void _interrupt(nomali_handle_t h, void *usr, nomali_int_t intno, int set)
Interrupt callback from the NoMali library.
virtual void onInterrupt(nomali_int_t intno, bool set)
Interrupt callback from the NoMali library.
Declaration of top level class for the RealView platform chips.
virtual ~CustomNoMaliGpu()
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
void setLE(T v)
Set the value in the data pointer to v as little endian.
nomali_info_t nomaliInfo
Cached information struct from the NoMali library.
NoMaliGpu(const NoMaliGpuParams *p)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static void _reset(nomali_handle_t h, void *usr)
Reset callback from the NoMali library.
CustomNoMaliGpu(const CustomNoMaliGpuParams *p)
#define SERIALIZE_CONTAINER(member)
std::map< nomali_addr_t, uint32_t > idRegs
Map between GPU registers and their custom reset values.
static void panicOnErr(nomali_error_t err, const char *msg)
Panic if the NoMali returned an error, do nothing otherwise.
virtual void sendInt(uint32_t num)=0
Post an interrupt from a device that is connected to the GIC.
void makeAtomicResponse()
void writeReg(nomali_addr_t reg, uint32_t value)
Wrapper around nomali_reg_write().
uint64_t Tick
Tick count type.
void setCallback(const nomali_callback_t &callback)
Wrapper around nomali_set_callback()
const Addr pioAddr
Device base address.
const std::map< nomali_int_t, uint32_t > interruptMap
Map between NoMali interrupt types and actual GIC interrupts.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
This device is the base class which all devices senstive to an address range inherit from...
void onReset() override
Reset callback from the NoMali library.
#define UNSERIALIZE_CONTAINER(member)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void writeRegRaw(nomali_addr_t reg, uint32_t value)
Wrapper around nomali_reg_write_raw().
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
void reset()
Wrapper around nomali_reset().
uint32_t readReg(nomali_addr_t reg)
Wrapper around nomali_reg_read().
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
virtual void onReset()
Reset callback from the NoMali library.
Base class for ARM GIC implementations.
std::ostream CheckpointOut
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
uint32_t readRegRaw(nomali_addr_t reg) const
Wrapper around nomali_reg_read_raw().
static void gpuPanic(nomali_error_t err, const char *msg) M5_ATTR_NORETURN
Format a NoMali error into an error message and panic.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
static const std::map< Enums::NoMaliGpuType, nomali_gpu_type_t > gpuTypeMap
Addr pioAddr
Address that the device listens to.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.