1 /* SPDX-License-Identifier: GPL-2.0-only */
7 static struct cpuid_t id
;
9 struct cpuid_t
*cpuid(void) {
13 /* First, we need determine which vendor we have */
14 #if defined(__DARWIN__) && !defined(__LP64__)
19 : "=b" (outebx
) : "a" (0) : "%ecx", "%edx"
22 asm ("cpuid" : "=b" (outebx
) : "a" (0) : "%ecx", "%edx");
27 /* Then, identificate CPU itself */
28 #if defined(__DARWIN__) && !defined(__LP64__)
33 : "=a" (outeax
) : "a" (1) : "%ecx", "%edx"
36 asm ("cpuid" : "=a" (outeax
) : "a" (1) : "%ebx", "%ecx", "%edx");
39 id
.stepping
= outeax
& 0xf;
41 id
.model
= outeax
& 0xf;
43 id
.family
= outeax
& 0xf;
45 id
.ext_model
= outeax
& 0xf;
47 id
.ext_family
= outeax
& 0xff;
48 if ((0xf == id
.family
) || ((VENDOR_INTEL
== id
.vendor
)
49 && (0x6 == id
.family
))) {
50 /* Intel says always do this, AMD says only for family f */
51 id
.model
|= (id
.ext_model
<< 4);
52 id
.family
+= id
.ext_family
;
54 printf_verbose("CPU: family %x, model %x, stepping %x\n",
55 id
.family
, id
.model
, id
.stepping
);
60 struct pci_dev
*pci_dev_find(uint16_t vendor
, uint16_t device
) {
62 struct pci_filter filter
;
64 pci_filter_init(NULL
, &filter
);
65 filter
.vendor
= vendor
;
66 filter
.device
= device
;
68 for (temp
= pacc
->devices
; temp
; temp
= temp
->next
)
69 if (pci_filter_match(&filter
, temp
))