2 * This file is part of msrtool.
4 * Copyright (c) 2008 Peter Stuge <peter@stuge.se>
5 * Copyright (c) 2009 coresystems GmbH
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 static struct cpuid_t id;
27 struct cpuid_t *cpuid(void) {
30 #if defined(__DARWIN__) && !defined(__LP64__)
35 : "=a" (outeax) : "a" (1) : "%ecx", "%edx"
38 asm ("cpuid" : "=a" (outeax) : "a" (1) : "%ebx", "%ecx", "%edx");
41 id.stepping = outeax & 0xf;
43 id.model = outeax & 0xf;
45 id.family = outeax & 0xf;
47 id.ext_model = outeax & 0xf;
49 id.ext_family = outeax & 0xff;
50 if (0xf == 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))