1 #include "pan_pps_perf.h" 2 3 #include <lib/kmod/pan_kmod.h> 4 #include <perf/pan_perf.h> 5 6 #include <pps/pps.h> 7 #include <util/ralloc.h> 8 9 namespace pps { PanfrostDevice(int fd)10PanfrostDevice::PanfrostDevice(int fd): fd(fd) 11 { 12 assert(fd >= 0); 13 } 14 ~PanfrostDevice()15PanfrostDevice::~PanfrostDevice() 16 { 17 } 18 PanfrostDevice(PanfrostDevice && o)19PanfrostDevice::PanfrostDevice(PanfrostDevice &&o): fd{o.fd} 20 { 21 o.fd = -1; 22 } 23 24 PanfrostDevice & operator =(PanfrostDevice && o)25PanfrostDevice::operator=(PanfrostDevice &&o) 26 { 27 std::swap(fd, o.fd); 28 return *this; 29 } 30 PanfrostPerf(const PanfrostDevice & dev)31PanfrostPerf::PanfrostPerf(const PanfrostDevice &dev) 32 : perf{reinterpret_cast<struct panfrost_perf *>( 33 rzalloc(nullptr, struct panfrost_perf))} 34 { 35 assert(perf); 36 assert(dev.fd >= 0); 37 panfrost_perf_init(perf, dev.fd); 38 } 39 ~PanfrostPerf()40PanfrostPerf::~PanfrostPerf() 41 { 42 if (perf) { 43 panfrost_perf_disable(perf); 44 ralloc_free(perf); 45 } 46 } 47 PanfrostPerf(PanfrostPerf && o)48PanfrostPerf::PanfrostPerf(PanfrostPerf &&o): perf{o.perf} 49 { 50 o.perf = nullptr; 51 } 52 53 PanfrostPerf & operator =(PanfrostPerf && o)54PanfrostPerf::operator=(PanfrostPerf &&o) 55 { 56 std::swap(perf, o.perf); 57 return *this; 58 } 59 60 int enable() const61PanfrostPerf::enable() const 62 { 63 assert(perf); 64 return panfrost_perf_enable(perf); 65 } 66 67 void disable() const68PanfrostPerf::disable() const 69 { 70 assert(perf); 71 panfrost_perf_disable(perf); 72 } 73 74 int dump() const75PanfrostPerf::dump() const 76 { 77 assert(perf); 78 return panfrost_perf_dump(perf); 79 } 80 81 } // namespace pps 82