detect_intel.go 926 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
  2. //+build 386,!gccgo,!noasm amd64,!gccgo,!noasm,!appengine
  3. package cpuid
  4. func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32)
  5. func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32)
  6. func asmXgetbv(index uint32) (eax, edx uint32)
  7. func asmRdtscpAsm() (eax, ebx, ecx, edx uint32)
  8. func initCPU() {
  9. cpuid = asmCpuid
  10. cpuidex = asmCpuidex
  11. xgetbv = asmXgetbv
  12. rdtscpAsm = asmRdtscpAsm
  13. }
  14. func addInfo(c *CPUInfo) {
  15. c.maxFunc = maxFunctionID()
  16. c.maxExFunc = maxExtendedFunction()
  17. c.BrandName = brandName()
  18. c.CacheLine = cacheLine()
  19. c.Family, c.Model = familyModel()
  20. c.Features = support()
  21. c.SGX = hasSGX(c.Features&SGX != 0, c.Features&SGXLC != 0)
  22. c.ThreadsPerCore = threadsPerCore()
  23. c.LogicalCores = logicalCores()
  24. c.PhysicalCores = physicalCores()
  25. c.VendorID, c.VendorString = vendorID()
  26. c.Hz = hertz(c.BrandName)
  27. c.cacheSize()
  28. }