internal unsafe static CString8 *GetBrandName() { UInt32 eax = 0, ebx = 0, ecx = 0, edx = 0; // Check is brand name is available // (ebx&0xff)==0 means it isn't Asm.XOR(R32.EAX, R32.EAX); Asm.INC(R32.EAX); Asm.CPUID(); Asm.MOV(&ebx, R32.EBX); if ((ebx & 0xff) == 0) { return(CString8.Copy("Unknown")); } else { textBuffer->Clear(); for (uint i = 0x80000002; i <= 0x80000004; i++) { Asm.MOV(R32.EAX, &i); Asm.CPUID(); Asm.MOV(&eax, R32.EAX); Asm.MOV(&ebx, R32.EBX); Asm.MOV(&edx, R32.EDX); Asm.MOV(&ecx, R32.ECX); textBuffer->AppendSubstring((byte *)&eax, 0, 4); textBuffer->AppendSubstring((byte *)&ebx, 0, 4); textBuffer->AppendSubstring((byte *)&ecx, 0, 4); textBuffer->AppendSubstring((byte *)&edx, 0, 4); } return(CString8.Copy(textBuffer->buffer)); } }
public static void Execute(CommandExecutionContext *context) { CommandExecutionAttemptResult result = Prompter.CommandTable->HandleLine(context->parameters, false, true); if (result == CommandExecutionAttemptResult.NotFound) { int indexOfSpace = context->parameters->IndexOf(" "); CString8 *tempStr; if (indexOfSpace >= 0) { tempStr = context->parameters->Substring(0, indexOfSpace); } else { tempStr = CString8.Copy(context->parameters); } TextMode.Write("No command '"); TextMode.Write(tempStr); TextMode.WriteLine("' is available to retrieve help for."); TextMode.WriteLine(CommandTableHeader.inform_USE_HELP_COMMANDS); CString8.DISPOSE(tempStr); return; } if (result == CommandExecutionAttemptResult.BlankEntry) { ADC.MemoryUtil.Call((void *)Stubs.GetFunctionPointer(lblGetHelp), (void *)context); } }
private static void DispatchBuffer() { CString8 *bufferCopy = CString8.Copy(textBuffer->buffer); Diagnostics.Assert(bufferCopy != null, "Prompter::DispatchBuffer(): INSANITY CHECK: CString8.Copy(byte*) returned NULL"); Prompter.QueueLine(bufferCopy); CString8.DISPOSE(bufferCopy); textBuffer->Clear(); }
internal unsafe static CString8 *GetVendorName() { UInt32 ebx = 0, ecx = 0, edx = 0; // Vendor Name Asm.XOR(R32.EAX, R32.EAX); Asm.CPUID(); Asm.MOV(&ebx, R32.EBX); Asm.MOV(&edx, R32.EDX); Asm.MOV(&ecx, R32.ECX); textBuffer->Clear(); textBuffer->AppendSubstring((byte *)&ebx, 0, 4); textBuffer->AppendSubstring((byte *)&edx, 0, 4); textBuffer->AppendSubstring((byte *)&ecx, 0, 4); return(CString8.Copy(textBuffer->buffer)); }
internal Processor(uint _index) { Asm.CLI(); index = _index; bool haveCPU = HaveCPUID(); if (!haveCPU) { archType = ProcessorType.IA32; vendorName = CString8.Copy("Unknown"); brandName = CString8.Copy("Unknown"); familyName = CString8.Copy("Unknown"); modelName = CString8.Copy("Unknown"); } if (haveCPU) { UInt32 stepping; UInt32 family; UInt32 model; textBuffer = StringBuilder.CREATE((uint)(20)); vendorName = GetVendorName(); if (vendorName->Compare("GenuineIntel", 12) == 0) { SetIntel(); } else if (vendorName->Compare("AuthenticAMD", 12) == 0) { SetAMD(); } else { brandName = GetBrandName(); familyName = CString8.Copy("Not implemented yet"); modelName = CString8.Copy("Not implemented yet"); } GetProcessorInfo(out stepping, out family, out model, out featureFlags); if (0 != (featureFlags & ProcessorFeatureFlags.IA64)) { archType = ProcessorType.IA64; } else { archType = ProcessorType.IA32; } ulong flags = ((ulong)featureFlags) & ((ulong)ProcessorFeatureFlags.ReservedFlagsMask); uint featureCount = MemoryUtil.BitCount(flags); features = new ProcessorFeature[featureCount]; featureCount = 0; // TODO: this could be improved upon if we had: // constructor support // enum.ToString support // etc. if (0 != (flags & (ulong)ProcessorFeatureFlags.FPU)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("FPU"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.VME)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("VME"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.DE)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DE"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PSE)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PSE"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.TSC)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("TSC"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.MSR)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MSR"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PAE)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PAE"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.MCE)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MCE"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.CX8)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CX8"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.APIC)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("APIC"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SEP)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SEP"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.MTRR)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MTRR"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PGE)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PGE"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.MCA)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MCA"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.CMOV)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CMOV"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PAT)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PAT"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PSE36)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PSE36"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PSN)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PSN"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.CLFSH)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CLFSH"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.DTES)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DTES"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.ACPI)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("ACPI"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.MMX)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MMX"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.FXSR)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("FXSR"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE2)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE2"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SS)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SS"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.HTT)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("HTT"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.TM1)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("TM1"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.IA64)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("IA64"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PBE)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PBE"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE3)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE3"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.DTSE64)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DTSE64"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.MON)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MON"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.DSCPL)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DSCPL"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.VMX)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("VMX"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SMX)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SMX"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.EST)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("EST"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.TM2)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("TM2"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SSSE3)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSSE3"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.CID)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CID"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.CX16)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CX16"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.ETPRD)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("ETPRD"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.PDCM)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PDCM"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.DCA)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DCA"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE4_1)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE4.1"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE4_2)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE4.2"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.X2APIC)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("X2APIC"); featureCount++; } if (0 != (flags & (ulong)ProcessorFeatureFlags.POPCNT)) { features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("POPCNT"); featureCount++; } } Asm.STI(); }
internal unsafe void SetAMD() { brandName = GetBrandName(); familyName = CString8.Copy("Not implemented yet"); modelName = CString8.Copy("Not implemented yet"); }
internal unsafe void SetIntel() { UInt32 eax = 0, ebx = 0, ecx = 0, edx = 0; uint brand, family, model, cpu_signature, cpu_extfamily; 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); brand = ebx & 0x0F; cpu_signature = (eax); family = ((eax >> 8) & 0x0F); // +((eax >> 20) & 0x0F); model = ((eax >> 4) & 0x0F); // | ((eax >> 12) & 0x0F); cpu_extfamily = ((eax >> 20) & 0x0F); switch (family) { case 0x4: familyName = CString8.Copy("Intel Family 486"); break; case 0x5: familyName = CString8.Copy("Intel Family 586"); break; case 0x6: familyName = CString8.Copy("Intel Family 686"); break; case 0x7: familyName = CString8.Copy("Intel Family Itanium"); break; case 0xF: familyName = CString8.Copy("Intel Family Extended"); break; default: familyName = CString8.Copy("Unknown Intel Family"); break; } switch (brand) { case 0x00: brandName = CString8.Copy("brand ID not supported"); switch (family) { case 0x4: modelName = CString8.Copy("Intel 486"); break; case 0x5: modelName = CString8.Copy("Intel 586"); break; case 0x6: switch (model) { case 0x1: modelName = CString8.Copy("Intel Pentium Pro"); break; case 0x3: modelName = CString8.Copy("Intel Pentium II"); break; case 0x5: case 0x6: modelName = CString8.Copy("Intel Celeron"); break; case 0x7: case 0x8: case 0xA: case 0xB: modelName = CString8.Copy("Intel Pentium III"); break; case 0x9: case 0xD: modelName = CString8.Copy("Intel Pentium M"); break; default: modelName = CString8.Copy("Unknown Intel P6 Family"); break; } break; case 0x7: modelName = CString8.Copy("Intel Itanium"); break; case 0xF: switch (cpu_extfamily) { case 0x0: modelName = CString8.Copy("Intel Pentium 4"); break; case 0x1: modelName = CString8.Copy("Intel Itanium 2"); break; } break; default: modelName = CString8.Copy("Unknown Intel Model"); break; } break; case 0x01: case 0x0A: case 0x14: brandName = CString8.Copy("Intel Celeron"); modelName = CString8.Copy("Intel Celeron"); break; case 0x02: case 0x04: brandName = CString8.Copy("Pentium III"); modelName = CString8.Copy("Pentium III"); break; case 0x03: if (cpu_signature == 0x6B1) { brandName = CString8.Copy("Intel Celeron"); modelName = CString8.Copy("Intel Celeron"); } else { brandName = CString8.Copy("Intel Pentium III Xeon"); modelName = CString8.Copy("Intel Pentium III Xeon"); } break; case 0x05: brandName = CString8.Copy("Mobile Intel Pentium III-M"); modelName = CString8.Copy("Mobile Intel Pentium III-M"); break; case 0x07: case 0x0F: case 0x13: case 0x17: brandName = CString8.Copy("Mobile Intel Celeron"); modelName = CString8.Copy("Mobile Intel Pentium III-M"); break; case 0x08: case 0x09: brandName = CString8.Copy("Intel Pentium 4"); modelName = CString8.Copy("Intel Pentium 4"); break; case 0x0B: brandName = CString8.Copy("Intel Xeon"); modelName = CString8.Copy("Intel Xeon"); break; case 0x0C: brandName = CString8.Copy("Intel Xeon MP"); modelName = CString8.Copy("Intel Xeon MP"); break; case 0x0E: if (cpu_signature == 0xF13) { brandName = CString8.Copy("Intel Xeon"); modelName = CString8.Copy("Intel Xeon"); } else { brandName = CString8.Copy("Mobile Intel Pentium 4"); modelName = CString8.Copy("Mobile Intel Pentium 4"); } break; case 0x12: brandName = CString8.Copy("Intel Celeron M"); modelName = CString8.Copy("Intel Celeron M"); break; case 0x16: brandName = CString8.Copy("Intel Pentium M"); modelName = CString8.Copy("Intel Pentium M"); break; case 0x15: case 0x11: brandName = CString8.Copy("Mobile Intel"); modelName = CString8.Copy("Mobile Intel"); break; default: brandName = CString8.Copy("Unknown Intel"); modelName = CString8.Copy("Unknown Intel"); break; } }