From 81a8ce356460c020bcab12801d91726ea886f7c2 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Tue, 23 Feb 2016 11:49:34 +0000 Subject: dev, arm: Refactor the NoMali GPU Refactor and cleanup the NoMaliGpu class: * Use a std::map instead of a switch block to map the parameter enum describing the GPU type to a NoMali type. * Remove redundant NoMali handle from the interrupt callback. * Make callbacks and API wrappers protected instead of private to enable future extensions. * Wrap remaining NoMali API calls. --- src/dev/arm/gpu_nomali.hh | 67 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 15 deletions(-) (limited to 'src/dev/arm/gpu_nomali.hh') diff --git a/src/dev/arm/gpu_nomali.hh b/src/dev/arm/gpu_nomali.hh index 4e4f9dbcb..eaf7f37cb 100644 --- a/src/dev/arm/gpu_nomali.hh +++ b/src/dev/arm/gpu_nomali.hh @@ -1,5 +1,5 @@ /* - * 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 @@ -63,22 +63,14 @@ class NoMaliGpu : public PioDevice 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); @@ -90,6 +82,16 @@ class NoMaliGpu : public PioDevice /** 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. * @@ -108,6 +110,42 @@ class NoMaliGpu : public PioDevice 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; @@ -118,7 +156,6 @@ class NoMaliGpu : public PioDevice * interrupts */ const std::map interruptMap; - /** Cached information struct from the NoMali library */ nomali_info_t nomaliInfo; -- cgit v1.2.3