summaryrefslogtreecommitdiff
path: root/dxr3cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'dxr3cpu.c')
-rw-r--r--dxr3cpu.c170
1 files changed, 86 insertions, 84 deletions
diff --git a/dxr3cpu.c b/dxr3cpu.c
index 41f2435..d991e2d 100644
--- a/dxr3cpu.c
+++ b/dxr3cpu.c
@@ -29,111 +29,113 @@
//! constructor
cDxr3CPU::cDxr3CPU()
{
- unsigned long eax,ebx,edx,unused;
-
- // readout the vendor
- Cpuid(0,eax,ebx,unused,edx);
-
- // set Vendor to ""
- memset(m_Info.Vendor, 0, 16);
-
- // connect the single register values to the vendor string
- // maybe there is an better solution - i will google :)
- *(unsigned long *)(m_Info.Vendor) = ebx;
- *(unsigned long *)(m_Info.Vendor + 4) = edx;
- *(unsigned long *)(m_Info.Vendor + 8) = unused;
-
- // check the features
- // could we get the needed infos?
- if (Cpuid(1,eax,ebx,unused,edx))
+ unsigned long eax, ebx, edx, unused;
+
+ // readout the vendor
+ Cpuid(0, eax, ebx, unused, edx);
+
+ // set Vendor to ""
+ memset(m_Info.Vendor, 0, 16);
+
+ // connect the single register values to the vendor string
+ // maybe there is an better solution - i will google :)
+ *(unsigned long *)(m_Info.Vendor) = ebx;
+ *(unsigned long *)(m_Info.Vendor + 4) = edx;
+ *(unsigned long *)(m_Info.Vendor + 8) = unused;
+
+ // check the features
+ // could we get the needed infos?
+ if (Cpuid(1, eax, ebx, unused, edx))
+ {
+ m_Info.MMX = ((edx & 1<<23) != 0);
+ m_Info.SSE = ((edx & 1<<25) != 0);
+ m_Info.SSE2 = ((edx & 1<<26) != 0);
+ m_Info.RDTSC = ((edx & 1<<4) != 0); /*0x10*/
+ m_Info.HT = ((edx & 1<<28) !=0 ); // need additional checks?
+
+ // 3DNow is a litle bit harder to read out
+ // We read the ext. CPUID level 0x80000000
+ if (Cpuid(0x80000000, eax, ebx, unused, edx))
{
- m_Info.MMX = ((edx & 1<<23) != 0);
- m_Info.SSE = ((edx & 1<<25) != 0);
- m_Info.SSE2= ((edx & 1<<26) != 0);
- m_Info.RDTSC=((edx & 1<<4) != 0); /*0x10*/
- m_Info.HT = ((edx & 1<<28) !=0); // should we do here addinonal checks?
-
- // 3DNow is a litle bit harder to read out
- // We read the ext. CPUID level 0x80000000
- if (Cpuid(0x80000000,eax,ebx,unused,edx))
+ // now in eax there is the max. supported extended CPUID level
+ // we check if theres an extended CPUID level support
+ if (eax >= 0x80000001)
+ {
+ // If we can access the extended CPUID level 0x80000001 we
+ // get the edx register
+ if (Cpuid(0x80000001, eax, ebx, unused, edx))
{
- // now in eax there is the max. supported extended CPUID level
- // we check if theres an extended CPUID level support
- if (eax >= 0x80000001)
- {
- // If we can access the extended CPUID level 0x80000001 we get the
- // edx register
- if (Cpuid(0x80000001,eax,ebx,unused,edx))
- {
- // Now we can mask some AMD specific cpu extensions
- // 22 ... Extended MMX_MultimediaExtensions
- m_Info.MMXEXT = ((edx & 1<<22) != 0);
- m_Info.AMD64Bit = ((edx & 1<<29) != 0);
- // 30 ... Extended 3DNOW_InstructionExtensions
- m_Info.Now = ((edx & (1<<31)) != 0);
- }
- }
+ // Now we can mask some AMD specific cpu extensions
+ // 22 ... Extended MMX_MultimediaExtensions
+ m_Info.MMXEXT = ((edx & 1<<22) != 0);
+ m_Info.AMD64Bit = ((edx & 1<<29) != 0);
+ // 30 ... Extended 3DNOW_InstructionExtensions
+ m_Info.Now = ((edx & 1<<31) != 0);
}
+ }
}
+ }
- // MPlayer, Xine-lib, Transcode: SSE implies MMXEXT
- m_Info.MMXEXT = m_Info.MMXEXT || m_Info.SSE;
+ // MPlayer, Xine-lib, Transcode: SSE implies MMXEXT
+ m_Info.MMXEXT = m_Info.MMXEXT || m_Info.SSE;
- // fill cabs
- if (m_Info.MMX)
- {
- m_Info.caps |= CC_MMX;
- }
+ // fill cabs
+ if (m_Info.MMX)
+ {
+ m_Info.caps |= CC_MMX;
+ }
- if (m_Info.MMXEXT)
- {
- m_Info.caps |= CC_MMXEXT;
- }
+ if (m_Info.MMXEXT)
+ {
+ m_Info.caps |= CC_MMXEXT;
+ }
- if (m_Info.SSE)
- {
- m_Info.caps |= CC_SSE;
- }
+ if (m_Info.SSE)
+ {
+ m_Info.caps |= CC_SSE;
+ }
- if (m_Info.Now)
- {
- m_Info.caps |= CC_3DNOW;
- }
+ if (m_Info.Now)
+ {
+ m_Info.caps |= CC_3DNOW;
+ }
+
+ // print some infos about cpu
+ cLog::Instance() << "cpu vendor: " << m_Info.Vendor << "\n";
+ cLog::Instance() << "cpu extensions:\n";
+ cLog::Instance() << "mmx: " << m_Info.MMX << "\n";
+ cLog::Instance() << "mmx-ext: " << m_Info.MMXEXT << "\n";
+ cLog::Instance() << "sse: " << m_Info.SSE << "\n";
+ cLog::Instance() << "sse2: " << m_Info.SSE2 << "\n";
+ cLog::Instance() << "3dnow: " << m_Info.Now << "\n";
- // print some infos about cpu
- cLog::Instance() << "cpu vendor: " << m_Info.Vendor << "\n";
- cLog::Instance() << "cpu extensions:\n";
- cLog::Instance() << "mmx: " << m_Info.MMX << "\n";
- cLog::Instance() << "mmx-ext: " << m_Info.MMXEXT << "\n";
- cLog::Instance() << "sse: " << m_Info.SSE << "\n";
- cLog::Instance() << "sse2: " << m_Info.SSE2 << "\n";
- cLog::Instance() << "3dnow: " << m_Info.Now << "\n";
-
- // now we select the best memcpy mehtode
- cDxr3MemcpyBench Benchmark(m_Info.caps);
+ // now we select the best memcpy mehtode
+ cDxr3MemcpyBench Benchmark(m_Info.caps);
}
// ==================================
//! does the cpu support cpuid instructions
bool cDxr3CPU::CheckCPUIDPresence()
{
- // todo
- return true;
+ // todo
+ return true;
}
// ==================================
//! cpuid function
-bool cDxr3CPU::Cpuid(unsigned long function, unsigned long& out_eax, unsigned long& out_ebx, unsigned long& out_ecx, unsigned long& out_edx)
+bool cDxr3CPU::Cpuid(unsigned long function, unsigned long& out_eax,
+ unsigned long& out_ebx, unsigned long& out_ecx,
+ unsigned long& out_edx)
{
- // This works with PIC/non-PIC, from ffmpeg (libavcodec/i386/cputest.c)
- __asm __volatile \
- ("movl %%ebx, %%esi\n\t" \
- "cpuid\n\t" \
- "xchgl %%ebx, %%esi" \
- : "=a" (out_eax), "=S" (out_ebx), \
- "=c" (out_ecx), "=d" (out_edx) \
- : "0" (function));
- return true;
+ // This works with PIC/non-PIC, from ffmpeg (libavcodec/i386/cputest.c)
+ __asm __volatile \
+ ("movl %%ebx, %%esi\n\t" \
+ "cpuid\n\t" \
+ "xchgl %%ebx, %%esi" \
+ : "=a" (out_eax), "=S" (out_ebx), \
+ "=c" (out_ecx), "=d" (out_edx) \
+ : "0" (function));
+ return true;
}
// Local variables: