40#include "debug/NoMali.hh"
43#include "enums/MemoryMode.hh"
45#include "nomali/lib/mali_midg_regmap.h"
46#include "params/CustomNoMaliGpu.hh"
47#include "params/NoMaliGpu.hh"
52static const std::map<enums::NoMaliGpuType, nomali_gpu_type_t>
gpuTypeMap{
53 { enums::T60x, NOMALI_GPU_T60X },
54 { enums::T62x, NOMALI_GPU_T62X },
55 { enums::T760, NOMALI_GPU_T760 },
63 { NOMALI_INT_GPU,
p.int_gpu },
64 { NOMALI_INT_JOB,
p.int_job },
65 { NOMALI_INT_MMU,
p.int_mmu },
68 if (nomali_api_version() != NOMALI_API_VERSION)
69 panic(
"NoMali library API mismatch!\n");
73 memset(&cfg, 0,
sizeof(cfg));
77 fatal(
"Unrecognized GPU type: %s (%i)\n",
78 enums::NoMaliGpuTypeStrings[
p.gpu_type],
p.gpu_type);
80 cfg.type = it_gpu->second;
82 cfg.ver_maj =
p.ver_maj;
83 cfg.ver_min =
p.ver_min;
84 cfg.ver_status =
p.ver_status;
87 nomali_create(&nomali, &cfg),
88 "Failed to instantiate NoMali");
92 nomali_callback_t cbk_int;
93 cbk_int.type = NOMALI_CALLBACK_INT;
94 cbk_int.usr = (
void *)
this;
95 cbk_int.func.interrupt = NoMaliGpu::_interrupt;
99 nomali_callback_t cbk_rst;
100 cbk_rst.type = NOMALI_CALLBACK_RESET;
101 cbk_rst.usr = (
void *)
this;
102 cbk_rst.func.reset = NoMaliGpu::_reset;
103 setCallback(cbk_rst);
106 nomali_get_info(nomali, &nomaliInfo),
107 "Failed to get NoMali information struct");
154 const unsigned size(pkt->
getSize());
157 panic(
"GPU register '0x%x' out of range!\n",
addr);
160 panic(
"Unexpected GPU register read size: %i\n", size);
162 panic(
"Unaligned GPU read: %i\n", size);
175 const unsigned size(pkt->
getSize());
178 panic(
"GPU register '0x%x' out of range!\n",
addr);
181 panic(
"Unexpected GPU register write size: %i\n", size);
183 panic(
"Unaligned GPU write: %i\n", size);
204 "Failed to reset GPU");
214 "GPU register read failed");
216 DPRINTF(NoMali,
"readReg(0x%x): 0x%x\n",
226 DPRINTF(NoMali,
"writeReg(0x%x, 0x%x)\n",
231 "GPU register write failed");
240 nomali_reg_read_raw(
nomali, &value,
reg),
241 "GPU raw register read failed");
251 nomali_reg_write_raw(
nomali,
reg, value),
252 "GPU raw register write failed");
260 nomali_int_state(
nomali, &state, intno),
261 "Failed to get interrupt state");
269 panic(
"%s: %s\n", msg, nomali_errstr(
err));
278 panic(
"Unhandled interrupt from NoMali: %i\n", intno);
280 DPRINTF(NoMali,
"Interrupt %i->%i: %i\n",
281 intno, it_int->second,
set);
287 platform->gic->sendInt(it_int->second);
289 platform->gic->clearInt(it_int->second);
301 DPRINTF(NoMali,
"Registering callback %i\n",
305 nomali_set_callback(
nomali, &callback),
306 "Failed to register callback");
311 nomali_int_t intno,
int set)
330 { GPU_CONTROL_REG(GPU_ID),
p.gpu_id },
331 { GPU_CONTROL_REG(L2_FEATURES),
p.l2_features },
332 { GPU_CONTROL_REG(TILER_FEATURES),
p.tiler_features },
333 { GPU_CONTROL_REG(MEM_FEATURES),
p.mem_features },
334 { GPU_CONTROL_REG(MMU_FEATURES),
p.mmu_features },
335 { GPU_CONTROL_REG(AS_PRESENT),
p.as_present },
336 { GPU_CONTROL_REG(JS_PRESENT),
p.js_present },
338 { GPU_CONTROL_REG(THREAD_MAX_THREADS),
p.thread_max_threads },
339 { GPU_CONTROL_REG(THREAD_MAX_WORKGROUP_SIZE),
340 p.thread_max_workgroup_size },
341 { GPU_CONTROL_REG(THREAD_MAX_BARRIER_SIZE),
342 p.thread_max_barrier_size },
343 { GPU_CONTROL_REG(THREAD_FEATURES),
p.thread_features },
345 { GPU_CONTROL_REG(SHADER_PRESENT_LO),
bits(
p.shader_present, 31, 0) },
346 { GPU_CONTROL_REG(SHADER_PRESENT_HI),
bits(
p.shader_present, 63, 32) },
347 { GPU_CONTROL_REG(TILER_PRESENT_LO),
bits(
p.tiler_present, 31, 0) },
348 { GPU_CONTROL_REG(TILER_PRESENT_HI),
bits(
p.tiler_present, 63, 32) },
349 { GPU_CONTROL_REG(L2_PRESENT_LO),
bits(
p.l2_present, 31, 0) },
350 { GPU_CONTROL_REG(L2_PRESENT_HI),
bits(
p.l2_present, 63, 32) },
354 "Too many texture feature registers specified (%i)\n",
355 p.texture_features.size());
358 "Too many job slot feature registers specified (%i)\n",
359 p.js_features.size());
361 for (
int i = 0;
i <
p.texture_features.size();
i++)
362 idRegs[TEXTURE_FEATURES_REG(
i)] =
p.texture_features[
i];
364 for (
int i = 0;
i <
p.js_features.size();
i++)
365 idRegs[JS_FEATURES_REG(
i)] =
p.js_features[
i];
Base class for ARM GIC implementations.
std::map< nomali_addr_t, uint32_t > idRegs
Map between GPU registers and their custom reset values.
void onReset() override
Reset callback from the NoMali library.
virtual ~CustomNoMaliGpu()
CustomNoMaliGpu(const CustomNoMaliGpuParams &p)
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.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void setCallback(const nomali_callback_t &callback)
Wrapper around nomali_set_callback()
RealView *const platform
Platform, used to discover GIC.
uint32_t readReg(nomali_addr_t reg)
Wrapper around nomali_reg_read().
static void _reset(nomali_handle_t h, void *usr)
Reset callback from the NoMali library.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static void panicOnErr(nomali_error_t err, const char *msg)
Panic if the NoMali returned an error, do nothing otherwise.
const Addr pioAddr
Device base address.
static void gpuPanic(nomali_error_t err, const char *msg)
Format a NoMali error into an error message and panic.
uint32_t readRegRaw(nomali_addr_t reg) const
Wrapper around nomali_reg_read_raw().
const std::map< nomali_int_t, uint32_t > interruptMap
Map between NoMali interrupt types and actual GIC interrupts.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
NoMaliGpu(const NoMaliGpuParams &p)
bool intState(nomali_int_t intno)
Wrapper around nomali_int_state()
nomali_info_t nomaliInfo
Cached information struct from the NoMali library.
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
virtual void onInterrupt(nomali_int_t intno, bool set)
Interrupt callback from the NoMali library.
void reset()
Wrapper around nomali_reset().
void writeReg(nomali_addr_t reg, uint32_t value)
Wrapper around nomali_reg_write().
nomali_handle_t nomali
Handle of a NoMali library instance.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void writeRegRaw(nomali_addr_t reg, uint32_t value)
Wrapper around nomali_reg_write_raw().
virtual void onReset()
Reset callback from the NoMali library.
void setLE(T v)
Set the value in the data pointer to v as little endian.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
void makeAtomicResponse()
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
PioDevice(const Params &p)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
AddrRange RangeSize(Addr start, Addr size)
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define fatal(...)
This implements a cprintf based fatal() function.
#define UNSERIALIZE_CONTAINER(member)
#define SERIALIZE_CONTAINER(member)
Copyright (c) 2024 Arm Limited All rights reserved.
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
static const std::map< enums::NoMaliGpuType, nomali_gpu_type_t > gpuTypeMap
Declaration of top level class for the RealView platform chips.