drivers/pc80/pc: Clean up formatting of PS/2 related ASL code
[coreboot.git] / util / msrtool / sys.c
blob7188705e06715bfba9d3e34930a7f05eb7d93e19
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <pci/pci.h>
5 #include "msrtool.h"
7 static struct cpuid_t id;
9 struct cpuid_t *cpuid(void) {
10 uint32_t outeax;
11 uint32_t outebx;
13 /* First, we need determine which vendor we have */
14 #if defined(__DARWIN__) && !defined(__LP64__)
15 asm volatile (
16 "pushl %%ebx \n"
17 "cpuid \n"
18 "popl %%ebx \n"
19 : "=b" (outebx) : "a" (0) : "%ecx", "%edx"
21 #else
22 asm ("cpuid" : "=b" (outebx) : "a" (0) : "%ecx", "%edx");
23 #endif
25 id.vendor = outebx;
27 /* Then, identificate CPU itself */
28 #if defined(__DARWIN__) && !defined(__LP64__)
29 asm volatile (
30 "pushl %%ebx \n"
31 "cpuid \n"
32 "popl %%ebx \n"
33 : "=a" (outeax) : "a" (1) : "%ecx", "%edx"
35 #else
36 asm ("cpuid" : "=a" (outeax) : "a" (1) : "%ebx", "%ecx", "%edx");
37 #endif
39 id.stepping = outeax & 0xf;
40 outeax >>= 4;
41 id.model = outeax & 0xf;
42 outeax >>= 4;
43 id.family = outeax & 0xf;
44 outeax >>= 8;
45 id.ext_model = outeax & 0xf;
46 outeax >>= 4;
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);
57 return &id;
60 struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device) {
61 struct pci_dev *temp;
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))
70 return temp;
72 return NULL;