mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
ee118c4b83
- Bug 1051146 - Part 1: Introduce the B2G specific build flags, initially enabled. r=smaug (341c7565d) - Bug 1051146 - art 2: Introduce the new Pocketsphinx and Sphinxbase code with no build integration. r=smaug, r=gerv (f29eafa78) - Bug 1051146 - Part 3: Introduce build system changes for the new Pocketsphinx and Sphinxbase code. r=smaug, r=gps (06c60429d) - Bug 1051146 - Part 4: Introduce build system changes for the MOZ_WEBSPEECH_TEST_BACKEND flag. r=smaug, r=gps (16195e66e) - Bug 1051146 - Part 5: Introduce new English model with no build integration. r=smaug (24996aa9c) - Bug 1051146 - Part 6: Introduce build integration of new English model. r=smaug, r=gps (b718751a9) - Bug 1051146 - Part 7: Introduce update scripts for Pocketsphinx and Sphinxbase code. r=smaug (5a85c7ed2) - Bug 1051148 - Part 1: Patch that introduces WebSpeech API implementation. r=smaug (d18e5d86e) - Bug 1171249 - Modified configure.in so MOZ_WEBSPEECH undefined implies both MOZ_WEBSPEECH_TEST_BACKEND and MOZ_WEBSPEECH_MODELS are undefined. r=gps (47d13fc61) - Bug 1051148 - Part 2: Patch that turns off the WebSpeech API implementation using flags. r=gps (8b2ceef89) - Bug 1051146 - Disable Pocketsphinx building on Windows due to bustage. r=gps (48f4a1c27) - Bug 1204703 - Make nsContentSecurityManager scriptable (r=sicking) (fb514951a) - Bug 1215745: Safer implemetation of nsJarChannel::AsyncOpen2. r=ckerschb (3ad0270b4) - partial of Bug 1178892 - Split the profiler into Core & Gecko files and break apart monolithic headers. r=mstange (eda571469) - Bug 1213407 - PluginModuleContentParent should delete its Transport. r=billm (153a54404) - Bug 1169945 - Remove unused plugins.enumerable_names whitelist. r=bsmedberg (52126cbd8) - Bug 1160166 - Disabled plugin meta information often isn't available to content processes. r=jimm (d63331192) - Bug 1165981 - Only allow flash as a plugin on Windows 64-bit builds; r=bsmedberg (bfc073186) - missing bit of 1164543 (5ef55bc55) - Bug 1178963 part 1. Use nsIPluginTagInternal instead of nsPluginTag in cases where it may be nsFakePluginTag. r=peterv (f8702aead) - Bug 1200484 (part 1) - Expose the column number in JS::DescribeScriptedCaller(). r=luke. (85cf65a1c) - Bug 1200484 (part 2) - Use JS column numbers in ReportWrapperDenial(). r=mrbkap. (1de0e6331) - Bug 1200484 (part 3) - Use JS column numbers in WebSocket.cpp. r=baku. (3febdd8bc) - Bug 1200484 (part 4) - Expose the column number in nsJSUtils::GetCallingLocation(). r=mrbkap. (479ae5e2a) - Bug 1200484 (part 5) - Use JS column numbers in XPCNativeInterface::NewInstance(). r=mrbkap. (63e5e4e41) - Bug 1200484 (part 6) - Use JS column numbers in ContentParent::OnChannelError(). r=billm. (4c84ef09d) - Bug 1139718 - Warning when sending MM messages that include XPCOM data (r=smaug) (d50774823) - Bug 1200484 (part 7) - Use JS column numbers in GetParamsForMessage() (bf19fc4cb) - Bug 1200484 (part 8) - Use JS column numbers in EventSource. r=khuey. (64374ed83) - Bug 1200484 (part 9) - Use JS column numbers in nsContentUtils::ReportToConsoleNonLocalized. r=khuey. (4d81c5f4f) - Bug 1200484 (part 10) - Use JS column numbers in indexedDB. r=khuey. (64eec5da6) - Bug 1200484 (part 11) - Set source location when initializing an nsJSScriptTimeoutHandler from a Function. r=peterv. (f135b3a2c) - Bug 1200484 (part 12) - Use JS column numbers in nsJSTimeoutHandler. r=peterv. (8ec21dc04) - Bug 1163664 - Don't check for plugin blocklist state on Android. r=jimm, r=jchen (14b8f3e57) - Bug 1178963 part 2. Implement nsFakePluginTag to represent a non-NPAPI "plugin" that is actually implemented in JavaScript. r=peterv (ba11d6de0) - Bug 1178896 - Add support for determining if a plugin is OOP to nsIPluginHost. r=aklotz (e8689641f) - Bug 1178963 part 3. Make nsPluginHost aware of fake plugins. r=peterv (a2a9f8cb3)
311 lines
8.5 KiB
C++
311 lines
8.5 KiB
C++
/*
|
|
* Copyright 2013, Intel Corporation
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* Author: Joe Olivas <joseph.k.olivas@intel.com>
|
|
*/
|
|
|
|
#include "nsDebug.h"
|
|
#include "nsString.h"
|
|
#include "IntelPowerGadget.h"
|
|
#include "prenv.h"
|
|
|
|
IntelPowerGadget::IntelPowerGadget() :
|
|
libpowergadget(nullptr),
|
|
Initialize(nullptr),
|
|
GetNumNodes(nullptr),
|
|
GetMsrName(nullptr),
|
|
GetMsrFunc(nullptr),
|
|
ReadMSR(nullptr),
|
|
WriteMSR(nullptr),
|
|
GetIAFrequency(nullptr),
|
|
GetTDP(nullptr),
|
|
GetMaxTemperature(nullptr),
|
|
GetThresholds(nullptr),
|
|
GetTemperature(nullptr),
|
|
ReadSample(nullptr),
|
|
GetSysTime(nullptr),
|
|
GetRDTSC(nullptr),
|
|
GetTimeInterval(nullptr),
|
|
GetBaseFrequency(nullptr),
|
|
GetPowerData(nullptr),
|
|
StartLog(nullptr),
|
|
StopLog(nullptr),
|
|
GetNumMsrs(nullptr),
|
|
packageMSR(-1),
|
|
cpuMSR(-1),
|
|
freqMSR(-1),
|
|
tempMSR(-1)
|
|
{
|
|
}
|
|
|
|
bool
|
|
IntelPowerGadget::Init()
|
|
{
|
|
bool success = false;
|
|
const char *path = PR_GetEnv("IPG_Dir");
|
|
nsCString ipg_library;
|
|
if (path && *path) {
|
|
ipg_library.Append(path);
|
|
ipg_library.Append('/');
|
|
ipg_library.AppendLiteral(PG_LIBRARY_NAME);
|
|
libpowergadget = PR_LoadLibrary(ipg_library.get());
|
|
}
|
|
|
|
if(libpowergadget) {
|
|
Initialize = (IPGInitialize) PR_FindFunctionSymbol(libpowergadget, "IntelEnergyLibInitialize");
|
|
GetNumNodes = (IPGGetNumNodes) PR_FindFunctionSymbol(libpowergadget, "GetNumNodes");
|
|
GetMsrName = (IPGGetMsrName) PR_FindFunctionSymbol(libpowergadget, "GetMsrName");
|
|
GetMsrFunc = (IPGGetMsrFunc) PR_FindFunctionSymbol(libpowergadget, "GetMsrFunc");
|
|
ReadMSR = (IPGReadMSR) PR_FindFunctionSymbol(libpowergadget, "ReadMSR");
|
|
WriteMSR = (IPGWriteMSR) PR_FindFunctionSymbol(libpowergadget, "WriteMSR");
|
|
GetIAFrequency = (IPGGetIAFrequency) PR_FindFunctionSymbol(libpowergadget, "GetIAFrequency");
|
|
GetTDP = (IPGGetTDP) PR_FindFunctionSymbol(libpowergadget, "GetTDP");
|
|
GetMaxTemperature = (IPGGetMaxTemperature) PR_FindFunctionSymbol(libpowergadget, "GetMaxTemperature");
|
|
GetThresholds = (IPGGetThresholds) PR_FindFunctionSymbol(libpowergadget, "GetThresholds");
|
|
GetTemperature = (IPGGetTemperature) PR_FindFunctionSymbol(libpowergadget, "GetTemperature");
|
|
ReadSample = (IPGReadSample) PR_FindFunctionSymbol(libpowergadget, "ReadSample");
|
|
GetSysTime = (IPGGetSysTime) PR_FindFunctionSymbol(libpowergadget, "GetSysTime");
|
|
GetRDTSC = (IPGGetRDTSC) PR_FindFunctionSymbol(libpowergadget, "GetRDTSC");
|
|
GetTimeInterval = (IPGGetTimeInterval) PR_FindFunctionSymbol(libpowergadget, "GetTimeInterval");
|
|
GetBaseFrequency = (IPGGetBaseFrequency) PR_FindFunctionSymbol(libpowergadget, "GetBaseFrequency");
|
|
GetPowerData = (IPGGetPowerData) PR_FindFunctionSymbol(libpowergadget, "GetPowerData");
|
|
StartLog = (IPGStartLog) PR_FindFunctionSymbol(libpowergadget, "StartLog");
|
|
StopLog = (IPGStopLog) PR_FindFunctionSymbol(libpowergadget, "StopLog");
|
|
GetNumMsrs = (IPGGetNumMsrs) PR_FindFunctionSymbol(libpowergadget, "GetNumMsrs");
|
|
}
|
|
|
|
if(Initialize) {
|
|
Initialize();
|
|
int msrCount = GetNumberMsrs();
|
|
wchar_t name[1024] = {0};
|
|
for(int i = 0; i < msrCount; ++i) {
|
|
GetMsrName(i, name);
|
|
int func = 0;
|
|
GetMsrFunc(i, &func);
|
|
// MSR for frequency
|
|
if(wcscmp(name, L"CPU Frequency") == 0 && (func == 0)) {
|
|
this->freqMSR = i;
|
|
}
|
|
// MSR for Package
|
|
else if(wcscmp(name, L"Processor") == 0 && (func == 1)) {
|
|
this->packageMSR = i;
|
|
}
|
|
// MSR for CPU
|
|
else if(wcscmp(name, L"IA") == 0 && (func == 1)) {
|
|
this->cpuMSR = i;
|
|
}
|
|
// MSR for Temperature
|
|
else if(wcscmp(name, L"Package") == 0 && (func == 2)) {
|
|
this->tempMSR = i;
|
|
}
|
|
}
|
|
// Grab one sample at startup for a diff
|
|
TakeSample();
|
|
success = true;
|
|
}
|
|
return success;
|
|
}
|
|
|
|
IntelPowerGadget::~IntelPowerGadget()
|
|
{
|
|
if(libpowergadget) {
|
|
NS_WARNING("Unloading PowerGadget library!\n");
|
|
PR_UnloadLibrary(libpowergadget);
|
|
libpowergadget = nullptr;
|
|
Initialize = nullptr;
|
|
GetNumNodes = nullptr;
|
|
GetMsrName = nullptr;
|
|
GetMsrFunc = nullptr;
|
|
ReadMSR = nullptr;
|
|
WriteMSR = nullptr;
|
|
GetIAFrequency = nullptr;
|
|
GetTDP = nullptr;
|
|
GetMaxTemperature = nullptr;
|
|
GetThresholds = nullptr;
|
|
GetTemperature = nullptr;
|
|
ReadSample = nullptr;
|
|
GetSysTime = nullptr;
|
|
GetRDTSC = nullptr;
|
|
GetTimeInterval = nullptr;
|
|
GetBaseFrequency = nullptr;
|
|
GetPowerData = nullptr;
|
|
StartLog = nullptr;
|
|
StopLog = nullptr;
|
|
GetNumMsrs = nullptr;
|
|
}
|
|
}
|
|
|
|
int
|
|
IntelPowerGadget::GetNumberNodes()
|
|
{
|
|
int nodes = 0;
|
|
if(GetNumNodes) {
|
|
int ok = GetNumNodes(&nodes);
|
|
}
|
|
return nodes;
|
|
}
|
|
|
|
int
|
|
IntelPowerGadget::GetNumberMsrs()
|
|
{
|
|
int msrs = 0;
|
|
if(GetNumMsrs) {
|
|
int ok = GetNumMsrs(&msrs);
|
|
}
|
|
return msrs;
|
|
}
|
|
|
|
int
|
|
IntelPowerGadget::GetCPUFrequency(int node)
|
|
{
|
|
int frequency = 0;
|
|
if(GetIAFrequency) {
|
|
int ok = GetIAFrequency(node, &frequency);
|
|
}
|
|
return frequency;
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetTdp(int node)
|
|
{
|
|
double tdp = 0.0;
|
|
if(GetTDP) {
|
|
int ok = GetTDP(node, &tdp);
|
|
}
|
|
return tdp;
|
|
}
|
|
|
|
int
|
|
IntelPowerGadget::GetMaxTemp(int node)
|
|
{
|
|
int maxTemperatureC = 0;
|
|
if(GetMaxTemperature) {
|
|
int ok = GetMaxTemperature(node, &maxTemperatureC);
|
|
}
|
|
return maxTemperatureC;
|
|
}
|
|
|
|
int
|
|
IntelPowerGadget::GetTemp(int node)
|
|
{
|
|
int temperatureC = 0;
|
|
if(GetTemperature) {
|
|
int ok = GetTemperature(node, &temperatureC);
|
|
}
|
|
return temperatureC;
|
|
}
|
|
|
|
int
|
|
IntelPowerGadget::TakeSample()
|
|
{
|
|
int ok = 0;
|
|
if(ReadSample) {
|
|
ok = ReadSample();
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
uint64_t
|
|
IntelPowerGadget::GetRdtsc()
|
|
{
|
|
uint64_t rdtsc = 0;
|
|
if(GetRDTSC) {
|
|
int ok = GetRDTSC(&rdtsc);
|
|
}
|
|
return rdtsc;
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetInterval()
|
|
{
|
|
double interval = 0.0;
|
|
if(GetTimeInterval) {
|
|
int ok = GetTimeInterval(&interval);
|
|
}
|
|
return interval;
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetCPUBaseFrequency(int node)
|
|
{
|
|
double freq = 0.0;
|
|
if(GetBaseFrequency) {
|
|
int ok = GetBaseFrequency(node, &freq);
|
|
}
|
|
return freq;
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetTotalPackagePowerInWatts()
|
|
{
|
|
int nodes = GetNumberNodes();
|
|
double totalPower = 0.0;
|
|
for(int i = 0; i < nodes; ++i) {
|
|
totalPower += GetPackagePowerInWatts(i);
|
|
}
|
|
return totalPower;
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetPackagePowerInWatts(int node)
|
|
{
|
|
int numResult = 0;
|
|
double result[] = {0.0, 0.0, 0.0};
|
|
if(GetPowerData && packageMSR != -1) {
|
|
int ok = GetPowerData(node, packageMSR, result, &numResult);
|
|
}
|
|
return result[0];
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetTotalCPUPowerInWatts()
|
|
{
|
|
int nodes = GetNumberNodes();
|
|
double totalPower = 0.0;
|
|
for(int i = 0; i < nodes; ++i) {
|
|
totalPower += GetCPUPowerInWatts(i);
|
|
}
|
|
return totalPower;
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetCPUPowerInWatts(int node)
|
|
{
|
|
int numResult = 0;
|
|
double result[] = {0.0, 0.0, 0.0};
|
|
if(GetPowerData && cpuMSR != -1) {
|
|
int ok = GetPowerData(node, cpuMSR, result, &numResult);
|
|
}
|
|
return result[0];
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetTotalGPUPowerInWatts()
|
|
{
|
|
int nodes = GetNumberNodes();
|
|
double totalPower = 0.0;
|
|
for(int i = 0; i < nodes; ++i) {
|
|
totalPower += GetGPUPowerInWatts(i);
|
|
}
|
|
return totalPower;
|
|
}
|
|
|
|
double
|
|
IntelPowerGadget::GetGPUPowerInWatts(int node)
|
|
{
|
|
return 0.0;
|
|
}
|
|
|