/*
- * Copyright (c) 2014-2015 ARM Limited
+ * Copyright (c) 2014-2016 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#include "mem/packet_access.hh"
#include "params/NoMaliGpu.hh"
+static const std::map<Enums::NoMaliGpuType, nomali_gpu_type_t> gpuTypeMap{
+ { Enums::T60x, NOMALI_GPU_T60X },
+ { Enums::T62x, NOMALI_GPU_T62X },
+ { Enums::T760, NOMALI_GPU_T760 },
+};
+
NoMaliGpu::NoMaliGpu(const NoMaliGpuParams *p)
: PioDevice(p),
pioAddr(p->pio_addr),
nomali_config_t cfg;
memset(&cfg, 0, sizeof(cfg));
- switch (p->gpu_type) {
- case Enums::T60x:
- cfg.type = NOMALI_GPU_T60X;
- break;
-
- case Enums::T62x:
- cfg.type = NOMALI_GPU_T62X;
- break;
-
- case Enums::T760:
- cfg.type = NOMALI_GPU_T760;
- break;
-
- default:
- fatal("Unknown GPU type\n");
+ const auto it_gpu(gpuTypeMap.find(p->gpu_type));
+ if (it_gpu == gpuTypeMap.end()) {
+ fatal("Unrecognized GPU type: %s (%i)\n",
+ Enums::NoMaliGpuTypeStrings[p->gpu_type], p->gpu_type);
}
+ cfg.type = it_gpu->second;
cfg.ver_maj = p->ver_maj;
cfg.ver_min = p->ver_min;
cbk_int.type = NOMALI_CALLBACK_INT;
cbk_int.usr = (void *)this;
cbk_int.func.interrupt = NoMaliGpu::_interrupt;
- panicOnErr(
- nomali_set_callback(nomali, &cbk_int),
- "Failed to setup interrupt callback");
+ setCallback(cbk_int);
panicOnErr(
nomali_get_info(nomali, &nomaliInfo),
nomali_destroy(nomali);
}
-
void
NoMaliGpu::serialize(CheckpointOut &cp) const
{
return AddrRangeList({ RangeSize(pioAddr, nomaliInfo.reg_size) });
}
+void
+NoMaliGpu::reset()
+{
+ DPRINTF(NoMali, "reset()\n");
+
+ panicOnErr(
+ nomali_reset(nomali),
+ "Failed to reset GPU");
+}
+
uint32_t
NoMaliGpu::readReg(nomali_addr_t reg)
{
"GPU raw register write failed");
}
-void
-NoMaliGpu::_interrupt(nomali_handle_t h, void *usr, nomali_int_t intno, int set)
+bool
+NoMaliGpu::intState(nomali_int_t intno)
{
- NoMaliGpu *_this(static_cast<NoMaliGpu *>(usr));
+ int state = 0;
+ panicOnErr(
+ nomali_int_state(nomali, &state, intno),
+ "Failed to get interrupt state");
+
+ return !!state;
+}
- _this->onInterrupt(h, intno, !!set);
+void
+NoMaliGpu::gpuPanic(nomali_error_t err, const char *msg)
+{
+ panic("%s: %s\n", msg, nomali_errstr(err));
}
+
void
-NoMaliGpu::onInterrupt(nomali_handle_t h, nomali_int_t intno, bool set)
+NoMaliGpu::onInterrupt(nomali_int_t intno, bool set)
{
const auto it_int(interruptMap.find(intno));
if (it_int == interruptMap.end())
}
void
-NoMaliGpu::gpuPanic(nomali_error_t err, const char *msg)
+NoMaliGpu::setCallback(const nomali_callback_t &callback)
{
- panic("%s: %s\n", msg, nomali_errstr(err));
+ DPRINTF(NoMali, "Registering callback %i\n",
+ callback.type);
+
+ panicOnErr(
+ nomali_set_callback(nomali, &callback),
+ "Failed to register callback");
+}
+
+void
+NoMaliGpu::_interrupt(nomali_handle_t h, void *usr,
+ nomali_int_t intno, int set)
+{
+ NoMaliGpu *_this(static_cast<NoMaliGpu *>(usr));
+
+ _this->onInterrupt(intno, !!set);
}
NoMaliGpu *
/*
- * Copyright (c) 2014-2015 ARM Limited
+ * Copyright (c) 2014-2016 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
Tick write(PacketPtr pkt) override;
AddrRangeList getAddrRanges() const override;
- private:
+ protected: /* API wrappers/helpers */
/**
- * Interrupt callback from the NoMali library.
- *
- * This method calls onInterrupt() on the NoMaliGpu owning this
- * device.
- *
- * @param h NoMali library handle.
- * @param usr Pointer to an instance of the NoMaliGpu
- * @param intno GPU interrupt type
- * @param set Was the interrupt raised (1) or lowered (0)?
+ * @{
+ * @name API wrappers
*/
- static void _interrupt(nomali_handle_t h, void *usr,
- nomali_int_t intno, int set);
- void onInterrupt(nomali_handle_t h, nomali_int_t intno, bool set);
+ /** Wrapper around nomali_reset(). */
+ void reset();
/** Wrapper around nomali_reg_read(). */
uint32_t readReg(nomali_addr_t reg);
/** Wrapper around nomali_reg_write_raw(). */
void writeRegRaw(nomali_addr_t reg, uint32_t value);
+ /**
+ * Wrapper around nomali_int_state()
+ *
+ * @param intno Interrupt number
+ * @return True if asserted, false otherwise.
+ */
+ bool intState(nomali_int_t intno);
+
+ /** @} */
+
/**
* Format a NoMali error into an error message and panic.
*
gpuPanic(err, msg);
}
+ protected: /* Callbacks */
+ /**
+ * @{
+ * @name Callbacks
+ */
+
+ /**
+ * Interrupt callback from the NoMali library
+ *
+ * This method is called whenever there is an interrupt state change.
+ *
+ * @param intno Interrupt number
+ * @param set True is the interrupt is being asserted, false otherwise.
+ */
+ virtual void onInterrupt(nomali_int_t intno, bool set);
+
+ /** @} */
+
+ private: /* Callback helpers */
+ /** Wrapper around nomali_set_callback() */
+ void setCallback(const nomali_callback_t &callback);
+
+ /**
+ * Interrupt callback from the NoMali library.
+ *
+ * This method calls onInterrupt() on the NoMaliGpu owning this
+ * device.
+ *
+ * @param h NoMali library handle.
+ * @param usr Pointer to an instance of the NoMaliGpu
+ * @param intno GPU interrupt type
+ * @param set Was the interrupt raised (1) or lowered (0)?
+ */
+ static void _interrupt(nomali_handle_t h, void *usr,
+ nomali_int_t intno, int set);
+ protected:
/** Device base address */
const Addr pioAddr;
* interrupts */
const std::map<nomali_int_t, uint32_t> interruptMap;
-
/** Cached information struct from the NoMali library */
nomali_info_t nomaliInfo;