Ejemplo n.º 1
0
		internal unsafe static void GetProcessorInfo(out UInt32 stepping, out UInt32 family, out UInt32 model, out ProcessorFeatureFlags flags)
		{
			UInt32 eax = 0, ebx = 0, ecx = 0, edx = 0;

			// Processor Info & Feature Bits
			Asm.XOR (R32.EAX, R32.EAX);
			Asm.INC (R32.EAX);
			Asm.CPUID ();
			Asm.MOV (&eax, R32.EAX);
			Asm.MOV (&ebx, R32.EBX);
			Asm.MOV (&edx, R32.EDX);
			Asm.MOV (&ecx, R32.ECX);


			// Signature
			// 3:0   - Stepping 
			// 7:4   - Base Model 
			// 11:8  - Base Family
			// 13:12 - Reserved / Processor Type 
			// 19:16 - Extended Model 
			// 27:20 - Extended Family 
			//
			// Family = Base Family + Extended Family
			// Model  = Base Model + (Extended Model << 4)
			stepping = (eax & 0x0F);
			model    = ((eax >> 4) & 0x0F) | ((eax >> 12) & 0x0F);
			family   = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0x0F);


			// Miscellaneous Information
			// 7:0   - brand ID
			// 15:8  - CLFLUSH size
			// 23:16 - LogicalProcessorCount is the number of threads per
			//			CPU core times the number of CPU cores per processor
			// 31:24 - Initial local APIC physical ID.
			UInt32 miscellaneousInformation = ebx; // not sure what to do with this...


			// Feature flags
			UInt64 flags64 = 0;
			UInt32* flags32 = (UInt32*)&flags64;
			*flags32 = edx;
			flags32 += sizeof(UInt32);
			*flags32 = ecx;
			flags = (ProcessorFeatureFlags)flags64;
		}
Ejemplo n.º 2
0
        internal unsafe static void GetProcessorInfo(out UInt32 stepping, out UInt32 family, out UInt32 model, out ProcessorFeatureFlags flags)
        {
            UInt32 eax = 0, ebx = 0, ecx = 0, edx = 0;

            // Processor Info & Feature Bits
            Asm.XOR(R32.EAX, R32.EAX);
            Asm.INC(R32.EAX);
            Asm.CPUID();
            Asm.MOV(&eax, R32.EAX);
            Asm.MOV(&ebx, R32.EBX);
            Asm.MOV(&edx, R32.EDX);
            Asm.MOV(&ecx, R32.ECX);


            // Signature
            // 3:0   - Stepping
            // 7:4   - Base Model
            // 11:8  - Base Family
            // 13:12 - Reserved / Processor Type
            // 19:16 - Extended Model
            // 27:20 - Extended Family
            //
            // Family = Base Family + Extended Family
            // Model  = Base Model + (Extended Model << 4)
            stepping = (eax & 0x0F);
            model    = ((eax >> 4) & 0x0F) | ((eax >> 12) & 0x0F);
            family   = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0x0F);


            // Miscellaneous Information
            // 7:0   - brand ID
            // 15:8  - CLFLUSH size
            // 23:16 - LogicalProcessorCount is the number of threads per
            //			CPU core times the number of CPU cores per processor
            // 31:24 - Initial local APIC physical ID.
            UInt32 miscellaneousInformation = ebx;             // not sure what to do with this...


            // Feature flags
            UInt64  flags64 = 0;
            UInt32 *flags32 = (UInt32 *)&flags64;

            *flags32 = edx;
            flags32 += sizeof(UInt32);
            *flags32 = ecx;
            flags = (ProcessorFeatureFlags)flags64;
        }