msrtool: Use libpci to let system and target probes find PCI devices.
And some more notes in TODO. Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3770 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
ef8ea01c8c
commit
0924dee124
5 changed files with 53 additions and 1 deletions
|
@ -1,8 +1,9 @@
|
|||
Systems
|
||||
-------
|
||||
FreeBSD #defines: see svn diff -r 3697:3698 util/
|
||||
i586: assembly instruction system driver, may have to ignore -c CPU # option
|
||||
|
||||
Other ideas
|
||||
-----------
|
||||
Move MSR definitions and probe instructions into an external text file?
|
||||
Handle PCI registers as well?
|
||||
Handle PCI and port IO registers as well?
|
||||
|
|
19
util/msrtool/configure
vendored
19
util/msrtool/configure
vendored
|
@ -135,6 +135,25 @@ INSTALL=$(findprog "install" "${INSTALL}" install ginstall) || exit
|
|||
test -n "$DEBUG" && myCFLAGS="-O2 -g" || myCFLAGS="-Os"
|
||||
CFLAGS="${CFLAGS} ${myCFLAGS} -Wall -Werror"
|
||||
|
||||
cat > .config.c << EOF
|
||||
#include <pci/pci.h>
|
||||
struct pci_access *pacc;
|
||||
int main(int argc, char *argv[])
|
||||
{ pacc = pci_alloc(); return 0; }
|
||||
EOF
|
||||
|
||||
pc_CFLAGS="$(pkg-config libpci --cflags 2>/dev/null)"
|
||||
pc_LDFLAGS="$(pkg-config libpci --libs 2>/dev/null)"
|
||||
CFLAGS=$(trycompile "libpci (from pciutils)" "${pc_CFLAGS}" "-I/usr/local/include") || {
|
||||
rm -f .config.c
|
||||
exit 1
|
||||
}
|
||||
LDFLAGS=$(trylink "libpci (from pciutils)" "${pc_LDFLAGS}" "-lpci -lz" "-L/usr/local/lib -lpci -lz") || {
|
||||
rm -f .config.c .config.o
|
||||
exit 1
|
||||
}
|
||||
rm -f .config.c .config.o .config
|
||||
|
||||
PREFIX="${PREFIX:-/usr/local}"
|
||||
|
||||
OS_ARCH=$(uname)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
#include "msrtool.h"
|
||||
|
||||
|
@ -36,6 +37,8 @@ const struct targetdef **targets = NULL;
|
|||
const struct sysdef *sys = NULL;
|
||||
uint8_t reserved = 0, verbose = 0, quiet = 0;
|
||||
|
||||
struct pci_access *pacc = NULL;
|
||||
|
||||
static struct targetdef alltargets[] = {
|
||||
{ "geodelx", "AMD Geode(tm) LX", geodelx_probe, geodelx_msrs },
|
||||
{ "cs5536", "AMD Geode(tm) CS5536", cs5536_probe, cs5536_msrs },
|
||||
|
@ -296,6 +299,14 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
printf_quiet("msrtool %s\n", VERSION);
|
||||
|
||||
pacc = pci_alloc();
|
||||
if (NULL == pacc) {
|
||||
fprintf(stderr, "Could not initialize PCI library! pci_alloc() failed.\n");
|
||||
return 1;
|
||||
}
|
||||
pci_init(pacc);
|
||||
pci_scan_bus(pacc);
|
||||
|
||||
if (!sys && !input && !listknown)
|
||||
for (sys = allsystems; !SYSTEM_ISEOT(*sys); sys++) {
|
||||
printf_verbose("Probing for system %s: %s\n", sys->name, sys->prettyname);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
#define HEXCHARS "0123456789abcdefABCDEF"
|
||||
|
||||
|
@ -132,6 +133,8 @@ extern const struct targetdef **targets;
|
|||
|
||||
extern uint8_t reserved, verbose, quiet;
|
||||
|
||||
extern struct pci_access *pacc;
|
||||
|
||||
#define printf_quiet(x...) do { if (!quiet) fprintf(stderr,x); } while(0)
|
||||
#define printf_verbose(x...) do { if (verbose && !quiet) fprintf(stderr,x); } while(0)
|
||||
|
||||
|
@ -145,6 +148,7 @@ extern uint8_t reserved, verbose, quiet;
|
|||
|
||||
/* sys.c */
|
||||
struct cpuid_t *cpuid(void);
|
||||
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
|
||||
|
||||
/* msrutils.c */
|
||||
void hexprint(FILE *f, const struct msr val, const uint8_t bits);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <pci/pci.h>
|
||||
|
||||
#include "msrtool.h"
|
||||
|
||||
static struct cpuid_t id;
|
||||
|
@ -40,3 +42,18 @@ struct cpuid_t *cpuid(void) {
|
|||
}
|
||||
return &id;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue