gpu_nomali.hh revision 11168
1955SN/A/*
2955SN/A * Copyright (c) 2014-2015 ARM Limited
35871Snate@binkert.org * All rights reserved
41762SN/A *
5955SN/A * The license below extends only to copyright in the software and shall
6955SN/A * not be construed as granting a license to any other intellectual
7955SN/A * property including but not limited to intellectual property relating
8955SN/A * to a hardware implementation of the functionality of the software
9955SN/A * licensed hereunder.  You may use the software subject to the license
10955SN/A * terms below provided that you ensure that this notice is replicated
11955SN/A * unmodified and in its entirety in all distributions of the software,
12955SN/A * modified or unmodified, in source code or in binary form.
13955SN/A *
14955SN/A * Redistribution and use in source and binary forms, with or without
15955SN/A * modification, are permitted provided that the following conditions are
16955SN/A * met: redistributions of source code must retain the above copyright
17955SN/A * notice, this list of conditions and the following disclaimer;
18955SN/A * redistributions in binary form must reproduce the above copyright
19955SN/A * notice, this list of conditions and the following disclaimer in the
20955SN/A * documentation and/or other materials provided with the distribution;
21955SN/A * neither the name of the copyright holders nor the names of its
22955SN/A * contributors may be used to endorse or promote products derived from
23955SN/A * this software without specific prior written permission.
24955SN/A *
25955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
292665Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
302665Ssaidi@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
315863Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36955SN/A *
372632Sstever@eecs.umich.edu * Authors: Andreas Sandberg
382632Sstever@eecs.umich.edu */
392632Sstever@eecs.umich.edu
402632Sstever@eecs.umich.edu#ifndef __DEV_ARM_NOMALI_GPU_HH__
41955SN/A#define __DEV_ARM_NOMALI_GPU_HH__
422632Sstever@eecs.umich.edu
432632Sstever@eecs.umich.edu#include <map>
442761Sstever@eecs.umich.edu
452632Sstever@eecs.umich.edu#include "dev/io_device.hh"
462632Sstever@eecs.umich.edu#include "libnomali/nomali.h"
472632Sstever@eecs.umich.edu
482761Sstever@eecs.umich.educlass NoMaliGpuParams;
492761Sstever@eecs.umich.educlass RealView;
502761Sstever@eecs.umich.edu
512632Sstever@eecs.umich.educlass NoMaliGpu : public PioDevice
522632Sstever@eecs.umich.edu{
532761Sstever@eecs.umich.edu  public:
542761Sstever@eecs.umich.edu    NoMaliGpu(const NoMaliGpuParams *p);
552761Sstever@eecs.umich.edu    virtual ~NoMaliGpu();
562761Sstever@eecs.umich.edu
572761Sstever@eecs.umich.edu  public: /* Checkpointing */
582632Sstever@eecs.umich.edu    void serialize(CheckpointOut &cp) const override;
592632Sstever@eecs.umich.edu    void unserialize(CheckpointIn &cp) override;
602632Sstever@eecs.umich.edu
612632Sstever@eecs.umich.edu  public: /* IO device interfaces */
622632Sstever@eecs.umich.edu    Tick read(PacketPtr pkt) override;
632632Sstever@eecs.umich.edu    Tick write(PacketPtr pkt) override;
642632Sstever@eecs.umich.edu    AddrRangeList getAddrRanges() const override;
65955SN/A
66955SN/A  private:
67955SN/A    /**
685863Snate@binkert.org     * Interrupt callback from the NoMali library.
695863Snate@binkert.org     *
705863Snate@binkert.org     * This method calls onInterrupt() on the NoMaliGpu owning this
715863Snate@binkert.org     * device.
725863Snate@binkert.org     *
735863Snate@binkert.org     * @param h NoMali library handle.
745863Snate@binkert.org     * @param usr Pointer to an instance of the NoMaliGpu
755863Snate@binkert.org     * @param intno GPU interrupt type
765863Snate@binkert.org     * @param set Was the interrupt raised (1) or lowered (0)?
775863Snate@binkert.org     */
785863Snate@binkert.org    static void _interrupt(nomali_handle_t h, void *usr,
795863Snate@binkert.org                           nomali_int_t intno, int set);
805863Snate@binkert.org
815863Snate@binkert.org    void onInterrupt(nomali_handle_t h, nomali_int_t intno, bool set);
825863Snate@binkert.org
835863Snate@binkert.org    /** Wrapper around nomali_reg_read(). */
845863Snate@binkert.org    uint32_t readReg(nomali_addr_t reg);
855863Snate@binkert.org    /** Wrapper around nomali_reg_write(). */
865863Snate@binkert.org    void writeReg(nomali_addr_t reg, uint32_t value);
875863Snate@binkert.org
885863Snate@binkert.org    /** Wrapper around nomali_reg_read_raw(). */
895863Snate@binkert.org    uint32_t readRegRaw(nomali_addr_t reg) const;
905863Snate@binkert.org    /** Wrapper around nomali_reg_write_raw(). */
915863Snate@binkert.org    void writeRegRaw(nomali_addr_t reg, uint32_t value);
925863Snate@binkert.org
935863Snate@binkert.org    /**
945863Snate@binkert.org     * Format a NoMali error into an error message and panic.
955863Snate@binkert.org     *
965863Snate@binkert.org     * @param err Error code from the NoMali library.
975863Snate@binkert.org     * @param msg Message to print.
985863Snate@binkert.org     */
99955SN/A    static void gpuPanic(nomali_error_t err, const char *msg) M5_ATTR_NORETURN;
1005396Ssaidi@eecs.umich.edu    /**
1015863Snate@binkert.org     * Panic if the NoMali returned an error, do nothing otherwise.
1025863Snate@binkert.org     *
1034202Sbinkertn@umich.edu     * @param err Error code from the NoMali library.
1045863Snate@binkert.org     * @param msg Message to print when panicking.
1055863Snate@binkert.org     */
1065863Snate@binkert.org    static void panicOnErr(nomali_error_t err, const char *msg) {
1075863Snate@binkert.org        if (err != NOMALI_E_OK)
108955SN/A            gpuPanic(err, msg);
1095273Sstever@gmail.com    }
1105871Snate@binkert.org
1115273Sstever@gmail.com    /** Device base address */
1125871Snate@binkert.org    const Addr pioAddr;
1135863Snate@binkert.org
1145863Snate@binkert.org    /** Platform, used to discover GIC */
1155863Snate@binkert.org    RealView *const platform;
1165871Snate@binkert.org
1175872Snate@binkert.org    /** Map between NoMali interrupt types and actual GIC
1185872Snate@binkert.org     * interrupts */
1195872Snate@binkert.org    const std::map<nomali_int_t, uint32_t> interruptMap;
1205871Snate@binkert.org
1215871Snate@binkert.org
1225871Snate@binkert.org    /** Cached information struct from the NoMali library */
1235871Snate@binkert.org    nomali_info_t nomaliInfo;
1245871Snate@binkert.org
1255871Snate@binkert.org    /** Handle of a NoMali library instance */
1265871Snate@binkert.org    nomali_handle_t nomali;
1275871Snate@binkert.org};
1285871Snate@binkert.org
1295871Snate@binkert.org
1305871Snate@binkert.org#endif // __DEV_ARM_NOMALI_GPU_HH__
1315871Snate@binkert.org