AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

core2duotemp.c to core2duotemp.pas

Ein Thema von hathor · begonnen am 5. Aug 2007 · letzter Beitrag vom 31. Mai 2008
Antwort Antwort
Seite 3 von 7     123 45     Letzte »    
Mark90
(Gast)

n/a Beiträge
 
#21

Re: core2duotemp.c to core2duotemp.pas

  Alt 7. Aug 2007, 18:39
Zitat von Muetze1:
Zitat von Mark90:
auf Codegear habe ich vorkurzem gesehen, dass man (ich schätzte mal sofern man c++ builder und delphi hat) auch c++ units oder komponenten in delphi oder anders rum verwenden kann. Ich hab den artikel nicht gelesen und kann daher auch nicht bestätigen ob dies geht!

wenn es gienge wäre es auf jedenfall eine teure angelegenheit!
Schön, nett aber überhaupt nicht neu. Damit programmiere ich täglich auf Arbeit: C++ Teile und Delphi Programmteile zusammen ein Programm. Und was bringt uns das nun in diesem Thread? Auch wenn das C++ Quellcode ist, das ist Schnuppe. Das ist nicht der Grund, warum man es nicht portieren kann, sondern weil der Code spezielle Geräte eines Linux Betriebssystems verwendet und somit nicht unter Windows lauffähig ist, da es diese Geräte dort nicht gibt. Es ist eine Sache des Betriebssystems, nicht der Sprache...
Reg dich mal ab!!
  Mit Zitat antworten Zitat
Benutzerbild von DataCool
DataCool

Registriert seit: 10. Feb 2003
Ort: Lingen
909 Beiträge
 
Delphi 10.3 Rio
 
#22

Re: core2duotemp.c to core2duotemp.pas

  Alt 7. Aug 2007, 20:21
Muetze hat aber Recht !!!!

Greetz DataCool
Der Horizont vieler Menschen ist ein Kreis mit Radius Null, und das nennen sie ihren Standpunkt.
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#23

Re: core2duotemp.c to core2duotemp.pas

  Alt 13. Aug 2007, 23:15
The MSR address is 19C. H = Hexadecimal.
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#24

Re: core2duotemp.c to core2duotemp.pas

  Alt 14. Aug 2007, 06:50
/EDIT: What the hell: I do never post to any of your threads again - as I said. Sorry - was my fault.
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#25

Re: core2duotemp.c to core2duotemp.pas

  Alt 14. Aug 2007, 10:45
What are you talking about,ofcourse it will work i got this info from core temp author..
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#26

Re: core2duotemp.c to core2duotemp.pas

  Alt 24. Aug 2007, 14:16
Has anybody tested this becouse if you translate i can send it to friends who can test.
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#27

Re: core2duotemp.c to core2duotemp.pas

  Alt 24. Aug 2007, 14:37
Okay i found this can somebody translate this please!


Zitat:
Code:
#include <float.h>
#include <stdio.h>
#include <windows.h>
 
#include "C2DTemp.h"
#include "RivaTunerExports.h"
#include "MonitoringSourceDesc.h"

HINSTANCE      g_hModule      = NULL;
HMODULE         g_hHost         = NULL;

READ_MSR_PROC      g_pReadMSR      = NULL;

DWORD         g_dwCPU         = 0;
BOOL         g_bHasDTS      = FALSE;
FLOAT         g_fTjmax      = 100.0f;

const char * const   szDim         = "°C";
const char * const   szDesc         = "CPU temperature as reported by on-die Digital Thermal Sensor";
const char * const   szGroup         = "CPU";

BOOL DetectCPUFeatures(void)
{
   const char   ven_intel[12] = {'G','e','n','u','i','n','e','I','n','t','e','l'};
   char      vendor[12];
   DWORD      last_fn = 0, fn6_eax = 0;

   memset(vendor, 0, 12);

   // try to execute CPUID instruction
   __try {
      __asm   {
         xor      eax, eax
         xor      ebx, ebx
         xor      ecx, ecx
         xor      edx, edx
         cpuid
         mov      dword ptr [last_fn], eax
         mov      dword ptr [vendor], ebx
         mov      dword ptr [vendor + 4], edx
         mov      dword ptr [vendor + 8], ecx
      }
   }
   __except (GetExceptionCode() == STATUS_ILLEGAL_INSTRUCTION) {
      return FALSE;
   }

   // Is it GenuineIntel CPU?
   if (strncmp(vendor, ven_intel, 12) != 0) {
      return FALSE;
   }

   // Does it support Digital Thermal Sensor and Power Management CPUID leaf?
   if (last_fn < 6) {
      return FALSE;
   }

   __asm   {
      mov      eax, 6
      cpuid
      mov      dword ptr [fn6_eax], eax
   }

   // Is Digital Thermal Sensor feature supported?
   if ((fn6_eax & 0x1) == 0) {
      return FALSE;
   }

   return TRUE;
}

BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
   UNREFERENCED_PARAMETER(lpReserved);

   if (dwReason == DLL_PROCESS_ATTACH) {
      g_hModule = hInstance;
      g_bHasDTS = DetectCPUFeatures();
   }

   return TRUE;
}

C2DTEMP_API DWORD GetSourcesNum(void)
{
   SYSTEM_INFO   si;

   GetSystemInfo(&si);

   g_dwCPU = si.dwNumberOfProcessors;

   return g_dwCPU;
}

C2DTEMP_API BOOL GetSourceDesc(DWORD dwIndex, LPMONITORING_SOURCE_DESC pDesc)
{
   DWORD   hi, lo;

   if (g_pReadMSR == NULL) {
      g_hHost = GetModuleHandle(NULL);

      if (g_hHost == NULL) {
         return FALSE;
      }

      g_pReadMSR = (READ_MSR_PROC)GetProcAddress(g_hHost, "ReadMSR");

      if (g_pReadMSR == NULL) {
         return FALSE;
      }

      if (!g_bHasDTS) {
         return FALSE;
      } else {
         // Try to detect Tjunction
         if (!g_pReadMSR(0xEE, &hi, &lo)) {
            return FALSE;
         }
         if (lo & 0x40000000) {
            g_fTjmax = 85.0f;
         }
      }
   }

   sprintf(pDesc->szName, "CPU%ld temperature", dwIndex);
   strcpy(pDesc->szDim   , szDim);
   strcpy(pDesc->szDesc   , szDesc);

   if (pDesc->dwVersion >= 0x00010002) {
      strcpy(pDesc->szGroup, szGroup);
   }

   pDesc->fltMaxLimit   = 100.0f;
   pDesc->fltMinLimit   = 0.0f;
   pDesc->fltGridDim   = 10.0f;

   return TRUE;
}

C2DTEMP_API FLOAT GetSourceData(DWORD dwIndex)
{
static   FLOAT      val[32] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
                FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
                FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
                FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
                FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
                FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
                FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
                FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX
         };

   DWORD_PTR   dwMask, dwProcessAffinityMask, dwSystemAffinityMask;
   DWORD      hi, lo;

   // Is DTS supported by this CPU?
   if (!g_bHasDTS) {
      return FLT_MAX;
   }

   // NOTE: This should be done by RivaTuner before calling plugins
   //       Will be removed when Alexey implements it internally

   // Get current process and system affinity mask
   if (!GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask)) {
      return FLT_MAX;
   }
   
   // Temporarily enable execution on all the CPUs in the system
   if (!SetProcessAffinityMask(GetCurrentProcess(), dwSystemAffinityMask)) {
      return FLT_MAX;
   }

   dwMask = 1 << dwIndex;

   // Move the thread to the proper core
   if (!SetThreadAffinityMask(GetCurrentThread(), dwMask)) {
      return FLT_MAX;
   }

   // Read IA32_THERM_STATUS MSR
   if (!g_pReadMSR(0x19C, &hi, &lo)) {
      return FLT_MAX;
   }

   // Is reading valid?
   // If not, just return previous value
   if ((lo & 0x80000000) == 0) {
      return val[dwIndex];
   }

   val[dwIndex] = g_fTjmax - (FLOAT)((lo >> 16) & 0x7F);

   return val[dwIndex];
}
[edit=SirThornberry]c-Tag eingefügt - bitte zukünftig die richtigen Tags verwenden und nicht bei Zitaten ein Code-Tag und bei Code ein Zitat-Tag - Mfg, SirThornberry[/edit]
  Mit Zitat antworten Zitat
christian_u

Registriert seit: 13. Nov 2006
126 Beiträge
 
#28

Re: core2duotemp.c to core2duotemp.pas

  Alt 24. Aug 2007, 14:58
*ACK*

Unter Windows müsste man einen Treiber schreiben und auf den kann man dann auch mit Delphi zugreifen.
Treiberentwicklung selbst ist mit Delphi auch nicht möglich.
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#29

Re: core2duotemp.c to core2duotemp.pas

  Alt 24. Aug 2007, 15:01
I made a driver already
  Mit Zitat antworten Zitat
christian_u

Registriert seit: 13. Nov 2006
126 Beiträge
 
#30

Re: core2duotemp.c to core2duotemp.pas

  Alt 24. Aug 2007, 16:46
you made an driver, and dont understand this little bit of c code upside ?
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 7     123 45     Letzte »    


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:14 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz