2008-11-22 18:13:36 +01:00
|
|
|
/*
|
|
|
|
* This file is part of msrtool.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Peter Stuge <peter@stuge.se>
|
2009-09-01 12:03:01 +02:00
|
|
|
* Copyright (c) 2009 coresystems GmbH
|
2008-11-22 18:13:36 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
Remove address from GPLv2 headers
As per discussion with lawyers[tm], it's not a good idea to
shorten the license header too much - not for legal reasons
but because there are tools that look for them, and giving
them a standard pattern simplifies things.
However, we got confirmation that we don't have to update
every file ever added to coreboot whenever the FSF gets a
new lease, but can drop the address instead.
util/kconfig is excluded because that's imported code that
we may want to synchronize every now and then.
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} +
$ find * -type f
-a \! -name \*.patch \
-a \! -name \*_shipped \
-a \! -name LICENSE_GPL \
-a \! -name LGPL.txt \
-a \! -name COPYING \
-a \! -name DISCLAIMER \
-exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} +
Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9233
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-03-26 15:17:45 +01:00
|
|
|
* Foundation, Inc.
|
2008-11-22 18:13:36 +01:00
|
|
|
*/
|
|
|
|
|
2008-11-25 03:03:16 +01:00
|
|
|
#include <pci/pci.h>
|
|
|
|
|
2008-11-22 18:13:36 +01:00
|
|
|
#include "msrtool.h"
|
|
|
|
|
|
|
|
static struct cpuid_t id;
|
|
|
|
|
|
|
|
struct cpuid_t *cpuid(void) {
|
|
|
|
uint32_t outeax;
|
2012-07-04 05:31:37 +02:00
|
|
|
uint32_t outebx;
|
2009-09-01 12:03:01 +02:00
|
|
|
|
2012-07-04 05:31:37 +02:00
|
|
|
/* First, we need determine which vendor we have */
|
|
|
|
#if defined(__DARWIN__) && !defined(__LP64__)
|
|
|
|
asm volatile (
|
|
|
|
"pushl %%ebx \n"
|
|
|
|
"cpuid \n"
|
|
|
|
"popl %%ebx \n"
|
|
|
|
: "=b" (outebx) : "a" (0) : "%ecx", "%edx"
|
|
|
|
);
|
|
|
|
#else
|
|
|
|
asm ("cpuid" : "=b" (outebx) : "a" (0) : "%ecx", "%edx");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
id.vendor = (outebx == 0x756e6547) ? VENDOR_INTEL : VENDOR_AMD;
|
|
|
|
|
|
|
|
/* Then, identificate CPU itself */
|
2009-09-01 12:03:01 +02:00
|
|
|
#if defined(__DARWIN__) && !defined(__LP64__)
|
|
|
|
asm volatile (
|
|
|
|
"pushl %%ebx \n"
|
|
|
|
"cpuid \n"
|
|
|
|
"popl %%ebx \n"
|
|
|
|
: "=a" (outeax) : "a" (1) : "%ecx", "%edx"
|
|
|
|
);
|
|
|
|
#else
|
2008-11-22 18:13:36 +01:00
|
|
|
asm ("cpuid" : "=a" (outeax) : "a" (1) : "%ebx", "%ecx", "%edx");
|
2009-09-01 12:03:01 +02:00
|
|
|
#endif
|
|
|
|
|
2008-11-22 18:13:36 +01:00
|
|
|
id.stepping = outeax & 0xf;
|
|
|
|
outeax >>= 4;
|
|
|
|
id.model = outeax & 0xf;
|
|
|
|
outeax >>= 4;
|
|
|
|
id.family = outeax & 0xf;
|
|
|
|
outeax >>= 8;
|
|
|
|
id.ext_model = outeax & 0xf;
|
|
|
|
outeax >>= 4;
|
|
|
|
id.ext_family = outeax & 0xff;
|
2012-07-04 05:31:37 +02:00
|
|
|
if ((0xf == id.family) || ((VENDOR_INTEL == id.vendor)
|
|
|
|
&& (0x6 == id.family))) {
|
2008-11-22 18:13:36 +01:00
|
|
|
/* Intel says always do this, AMD says only for family f */
|
|
|
|
id.model |= (id.ext_model << 4);
|
|
|
|
id.family += id.ext_family;
|
|
|
|
}
|
2009-09-01 12:03:01 +02:00
|
|
|
printf_verbose("CPU: family %x, model %x, stepping %x\n",
|
|
|
|
id.family, id.model, id.stepping);
|
|
|
|
|
2008-11-22 18:13:36 +01:00
|
|
|
return &id;
|
|
|
|
}
|
2008-11-25 03:03:16 +01:00
|
|
|
|
|
|
|
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device) {
|
|
|
|
struct pci_dev *temp;
|
|
|
|
struct pci_filter filter;
|
|
|
|
|
|
|
|
pci_filter_init(NULL, &filter);
|
|
|
|
filter.vendor = vendor;
|
|
|
|
filter.device = device;
|
|
|
|
|
|
|
|
for (temp = pacc->devices; temp; temp = temp->next)
|
|
|
|
if (pci_filter_match(&filter, temp))
|
|
|
|
return temp;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|