2 * This file is part of msrtool.
4 * Copyright (c) 2008 Peter Stuge <peter@stuge.se>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 static struct cpuid_t id;
26 struct cpuid_t *cpuid(void) {
28 asm ("cpuid" : "=a" (outeax) : "a" (1) : "%ebx", "%ecx", "%edx");
29 id.stepping = outeax & 0xf;
31 id.model = outeax & 0xf;
33 id.family = outeax & 0xf;
35 id.ext_model = outeax & 0xf;
37 id.ext_family = outeax & 0xff;
38 if (0xf == id.family) {
39 /* Intel says always do this, AMD says only for family f */
40 id.model |= (id.ext_model << 4);
41 id.family += id.ext_family;
46 struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device) {
48 struct pci_filter filter;
50 pci_filter_init(NULL, &filter);
51 filter.vendor = vendor;
52 filter.device = device;
54 for (temp = pacc->devices; temp; temp = temp->next)
55 if (pci_filter_match(&filter, temp))