1 /* This file is part of msrtool. */
2 /* SPDX-License-Identifier: GPL-2.0-only */
8 static struct cpuid_t id
;
10 struct cpuid_t
*cpuid(void) {
14 /* First, we need determine which vendor we have */
15 #if defined(__DARWIN__) && !defined(__LP64__)
20 : "=b" (outebx
) : "a" (0) : "%ecx", "%edx"
23 asm ("cpuid" : "=b" (outebx
) : "a" (0) : "%ecx", "%edx");
28 /* Then, identificate CPU itself */
29 #if defined(__DARWIN__) && !defined(__LP64__)
34 : "=a" (outeax
) : "a" (1) : "%ecx", "%edx"
37 asm ("cpuid" : "=a" (outeax
) : "a" (1) : "%ebx", "%ecx", "%edx");
40 id
.stepping
= outeax
& 0xf;
42 id
.model
= outeax
& 0xf;
44 id
.family
= outeax
& 0xf;
46 id
.ext_model
= outeax
& 0xf;
48 id
.ext_family
= outeax
& 0xff;
49 if ((0xf == id
.family
) || ((VENDOR_INTEL
== id
.vendor
)
50 && (0x6 == id
.family
))) {
51 /* Intel says always do this, AMD says only for family f */
52 id
.model
|= (id
.ext_model
<< 4);
53 id
.family
+= id
.ext_family
;
55 printf_verbose("CPU: family %x, model %x, stepping %x\n",
56 id
.family
, id
.model
, id
.stepping
);
61 struct pci_dev
*pci_dev_find(uint16_t vendor
, uint16_t device
) {
63 struct pci_filter filter
;
65 pci_filter_init(NULL
, &filter
);
66 filter
.vendor
= vendor
;
67 filter
.device
= device
;
69 for (temp
= pacc
->devices
; temp
; temp
= temp
->next
)
70 if (pci_filter_match(&filter
, temp
))