1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /** 6 * @fileoverview Parses exynos events in the Linux event trace format. 7 */ 8 base.require('linux_perf_parser'); 9 base.exportTo('tracing', function() { 10 11 var LinuxPerfParser = tracing.LinuxPerfParser; 12 13 /** 14 * Parses linux exynos trace events. 15 * @constructor 16 */ 17 function LinuxPerfExynosParser(importer) { 18 LinuxPerfParser.call(this, importer); 19 20 importer.registerEventHandler('exynos_flip_request', 21 LinuxPerfExynosParser.prototype.flipEvent.bind(this)); 22 importer.registerEventHandler('exynos_flip_complete', 23 LinuxPerfExynosParser.prototype.flipEvent.bind(this)); 24 25 importer.registerEventHandler('exynos_busfreq_target_int', 26 LinuxPerfExynosParser.prototype.busfreqTargetIntEvent.bind(this)); 27 importer.registerEventHandler('exynos_busfreq_target_mif', 28 LinuxPerfExynosParser.prototype.busfreqTargetMifEvent.bind(this)); 29 } 30 31 LinuxPerfExynosParser.prototype = { 32 __proto__: LinuxPerfParser.prototype, 33 34 exynosFlipOpenSlice: function(ts, pipe) { 35 // use pipe? 36 var kthread = this.importer.getOrCreatePseudoThread('exynos_flip'); 37 kthread.openSliceTS = ts; 38 kthread.openSlice = 'flip:' + pipe; 39 }, 40 41 exynosFlipCloseSlice: function(ts, args) { 42 var kthread = this.importer.getOrCreatePseudoThread('exynos_flip'); 43 if (kthread.openSlice) { 44 var slice = new tracing.TimelineSlice('', kthread.openSlice, 45 tracing.getStringColorId(kthread.openSlice), 46 kthread.openSliceTS, 47 args, 48 ts - kthread.openSliceTS); 49 50 kthread.thread.pushSlice(slice); 51 } 52 kthread.openSlice = undefined; 53 }, 54 55 /** 56 * Parses exynos events and sets up state in the importer. 57 */ 58 flipEvent: function(eventName, cpuNumber, pid, ts, eventBase) { 59 var event = /pipe=(\d+)/.exec(eventBase[5]); 60 if (!event) 61 return false; 62 63 var pipe = parseInt(event[1]); 64 if (eventName == 'exynos_flip_request') 65 this.exynosFlipOpenSlice(ts, pipe); 66 else 67 this.exynosFlipCloseSlice(ts, 68 { 69 pipe: pipe 70 }); 71 return true; 72 }, 73 74 exynosBusfreqSample: function(name, ts, frequency) { 75 var targetCpu = this.importer.getOrCreateCpuState(0); 76 var counter = targetCpu.cpu.getOrCreateCounter('', name); 77 if (counter.numSeries == 0) { 78 counter.seriesNames.push('frequency'); 79 counter.seriesColors.push( 80 tracing.getStringColorId(counter.name + '.' + 'frequency')); 81 } 82 counter.timestamps.push(ts); 83 counter.samples.push(frequency); 84 }, 85 86 /** 87 * Parses exynos_busfreq_target_int events and sets up state. 88 */ 89 busfreqTargetIntEvent: function(eventName, cpuNumber, pid, ts, eventBase) { 90 var event = /frequency=(\d+)/.exec(eventBase[5]); 91 if (!event) 92 return false; 93 94 this.exynosBusfreqSample('INT Frequency', ts, parseInt(event[1])); 95 return true; 96 }, 97 98 /** 99 * Parses exynos_busfreq_target_mif events and sets up state. 100 */ 101 busfreqTargetMifEvent: function(eventName, cpuNumber, pid, ts, eventBase) { 102 var event = /frequency=(\d+)/.exec(eventBase[5]); 103 if (!event) 104 return false; 105 106 this.exynosBusfreqSample('MIF Frequency', ts, parseInt(event[1])); 107 return true; 108 }, 109 }; 110 111 LinuxPerfParser.registerSubtype(LinuxPerfExynosParser); 112 113 return { 114 LinuxPerfExynosParser: LinuxPerfExynosParser 115 }; 116 }); 117