util: Remove viatool
It somehow creeps into `make clean`, but is not used at all. Since no VIA platform remains in coreboot, drop the utility as well. Change-Id: Ia7e11379a6db650b5190a056226a9101c2be7dec Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38853 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
761dbe228d
commit
446e4dc238
|
@ -118,7 +118,6 @@ util/pmh7tool/pmh7tool
|
||||||
util/runfw/googlesnow
|
util/runfw/googlesnow
|
||||||
util/superiotool/superiotool
|
util/superiotool/superiotool
|
||||||
util/vgabios/testbios
|
util/vgabios/testbios
|
||||||
util/viatool/viatool
|
|
||||||
util/autoport/autoport
|
util/autoport/autoport
|
||||||
util/kbc1126/kbc1126_ec_dump
|
util/kbc1126/kbc1126_ec_dump
|
||||||
util/kbc1126/kbc1126_ec_insert
|
util/kbc1126/kbc1126_ec_insert
|
||||||
|
|
|
@ -126,8 +126,6 @@ operating system (only Linux at this time). `C`
|
||||||
* __util_readme__ - Creates README.md of description files in `./util`
|
* __util_readme__ - Creates README.md of description files in `./util`
|
||||||
subdirectories `Bash`
|
subdirectories `Bash`
|
||||||
* __vgabios__ - emulated vga driver for qemu `C`
|
* __vgabios__ - emulated vga driver for qemu `C`
|
||||||
* __viatool__ - Extract certain configuration bits on VIA chipsets and
|
|
||||||
CPUs. `C`
|
|
||||||
* __x86__ - Generates 32-bit PAE page tables based on a CSV input file.
|
* __x86__ - Generates 32-bit PAE page tables based on a CSV input file.
|
||||||
`Go`
|
`Go`
|
||||||
* __xcompile__ - Cross compile setup `Bash`
|
* __xcompile__ - Cross compile setup `Bash`
|
||||||
|
|
|
@ -119,8 +119,6 @@ operating system (only Linux at this time). `C`
|
||||||
* __util_readme__ - Creates README.md of description files in `./util`
|
* __util_readme__ - Creates README.md of description files in `./util`
|
||||||
subdirectories `Bash`
|
subdirectories `Bash`
|
||||||
* __vgabios__ - emulated vga driver for qemu `C`
|
* __vgabios__ - emulated vga driver for qemu `C`
|
||||||
* __viatool__ - Extract certain configuration bits on VIA chipsets and
|
|
||||||
CPUs. `C`
|
|
||||||
* __x86__ - Generates 32-bit PAE page tables based on a CSV input file.
|
* __x86__ - Generates 32-bit PAE page tables based on a CSV input file.
|
||||||
`Go`
|
`Go`
|
||||||
* __xcompile__ - Cross compile setup `Bash`
|
* __xcompile__ - Cross compile setup `Bash`
|
||||||
|
|
|
@ -66,8 +66,7 @@ futility \
|
||||||
inteltool \
|
inteltool \
|
||||||
intelvbttool \
|
intelvbttool \
|
||||||
nvramtool \
|
nvramtool \
|
||||||
superiotool \
|
superiotool
|
||||||
viatool
|
|
||||||
|
|
||||||
TEST_PAYLOADLIST_INTERNAL= \
|
TEST_PAYLOADLIST_INTERNAL= \
|
||||||
coreinfo \
|
coreinfo \
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile for viatool utility
|
|
||||||
#
|
|
||||||
# Copyright (C) 2008 by coresystems GmbH
|
|
||||||
# written by Stefan Reinauer <stepan@coresystems.de>
|
|
||||||
# Copyright (C) 2013 Alexandru Gagniuc
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
|
|
||||||
PROGRAM = viatool
|
|
||||||
|
|
||||||
CC ?= gcc
|
|
||||||
INSTALL ?= /usr/bin/env install
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
CFLAGS ?= -O2 -g -Wall -Wextra -I$(CURDIR)
|
|
||||||
LDFLAGS += -lpci -lz
|
|
||||||
|
|
||||||
SRCS = viatool.c \
|
|
||||||
cpu.c \
|
|
||||||
quirks/quirks.c \
|
|
||||||
quirks/vx900_quirks.c
|
|
||||||
|
|
||||||
OBJS = $(sort ${SRCS:.c=.o})
|
|
||||||
|
|
||||||
OS_ARCH = $(shell uname)
|
|
||||||
ifeq ($(OS_ARCH), Darwin)
|
|
||||||
LDFLAGS += -framework DirectHW
|
|
||||||
endif
|
|
||||||
ifeq ($(OS_ARCH), FreeBSD)
|
|
||||||
CFLAGS += -I/usr/local/include
|
|
||||||
LDFLAGS += -L/usr/local/lib
|
|
||||||
LIBS = -lz
|
|
||||||
endif
|
|
||||||
ifeq ($(OS_ARCH), NetBSD)
|
|
||||||
CFLAGS += -I/usr/pkg/include
|
|
||||||
LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib -lz -lpciutils -lpci -l$(shell uname -p)
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: pciutils dep $(PROGRAM)
|
|
||||||
|
|
||||||
$(PROGRAM): $(OBJS)
|
|
||||||
$(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
# Remove build results
|
|
||||||
rm -f $(PROGRAM) $(OBJS)
|
|
||||||
# Remove backup files created by some editors
|
|
||||||
find ./ |grep *~ |xargs rm -f
|
|
||||||
rm -f junit.xml
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
rm -f .dependencies
|
|
||||||
|
|
||||||
dep:
|
|
||||||
@$(CC) $(CFLAGS) -MM *.c > .dependencies
|
|
||||||
|
|
||||||
define LIBPCI_TEST
|
|
||||||
/* Avoid a failing test due to libpci header symbol shadowing breakage */
|
|
||||||
#define index shadow_workaround_index
|
|
||||||
#ifdef __NetBSD__
|
|
||||||
#include <pciutils/pci.h>
|
|
||||||
#else
|
|
||||||
#include <pci/pci.h>
|
|
||||||
#endif
|
|
||||||
struct pci_access *pacc;
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
(void) argc;
|
|
||||||
(void) argv;
|
|
||||||
pacc = pci_alloc();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
endef
|
|
||||||
export LIBPCI_TEST
|
|
||||||
|
|
||||||
pciutils:
|
|
||||||
@printf "\nChecking for pciutils and zlib... "
|
|
||||||
@echo "$$LIBPCI_TEST" > .test.c
|
|
||||||
@$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) >/dev/null 2>&1 && \
|
|
||||||
printf "found.\n" || ( printf "not found.\n\n"; \
|
|
||||||
printf "Please install pciutils-devel and zlib-devel.\n"; \
|
|
||||||
printf "See README for more information.\n\n"; \
|
|
||||||
rm -f .test.c .test; exit 1)
|
|
||||||
@rm -rf .test.c .test .test.dSYM
|
|
||||||
|
|
||||||
install: $(PROGRAM)
|
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/sbin
|
|
||||||
$(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
|
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
|
|
||||||
$(INSTALL) $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
|
|
||||||
|
|
||||||
.PHONY: all clean distclean dep pciutils
|
|
||||||
|
|
||||||
-include .dependencies
|
|
|
@ -1,12 +0,0 @@
|
||||||
viatool is a utility for extracting useful for extracting certain configuration
|
|
||||||
bits on VIA chipsets and CPUs. It is a fork of inteltool.
|
|
||||||
|
|
||||||
viatool is currently focused on "quirks". Quirks are device configurations that
|
|
||||||
cannot be accessed directly. They are implemented as hierarchical configurations
|
|
||||||
in the PCI or memory address spaces (index/data register pairs). Such
|
|
||||||
configurations refer to hardware parameters that are board specific. Those
|
|
||||||
parameters would otherwise be difficult to extract from a system running the
|
|
||||||
vendor's firmware.
|
|
||||||
|
|
||||||
viatool also preserves inteltool's MSR dumps. VIA CPU and Intel CPU MSRs are
|
|
||||||
nearly identical.
|
|
1019
util/viatool/cpu.c
1019
util/viatool/cpu.c
File diff suppressed because it is too large
Load Diff
|
@ -1 +0,0 @@
|
||||||
Extract certain configuration bits on VIA chipsets and CPUs. `C`
|
|
|
@ -1,115 +0,0 @@
|
||||||
/*
|
|
||||||
* viatool - dump all registers on a VIA CPU + chipset based system.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Alexandru Gagniuc
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "quirks.h"
|
|
||||||
#include <viatool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
extern struct quirk_list vx900_sb_quirk_list;
|
|
||||||
|
|
||||||
struct quirk_list *sb_quirks[] = {
|
|
||||||
&vx900_sb_quirk_list,
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct quirk_list *nb_quirks[] = {
|
|
||||||
0,
|
|
||||||
};
|
|
||||||
|
|
||||||
int print_quirks(struct pci_dev *sb, struct pci_access *pacc,
|
|
||||||
struct quirk_list **qlists);
|
|
||||||
|
|
||||||
int print_quirks_north(struct pci_dev *nb, struct pci_access *pacc)
|
|
||||||
{
|
|
||||||
printf("\n====== Northbridge Quirks =======\n\n");
|
|
||||||
return print_quirks(nb, pacc, nb_quirks);
|
|
||||||
}
|
|
||||||
|
|
||||||
int print_quirks_south(struct pci_dev *sb, struct pci_access *pacc)
|
|
||||||
{
|
|
||||||
printf("\n====== Southbridge Quirks =======\n\n");
|
|
||||||
return print_quirks(sb, pacc, sb_quirks);
|
|
||||||
}
|
|
||||||
|
|
||||||
int print_quirks(struct pci_dev *sb, struct pci_access *pacc,
|
|
||||||
struct quirk_list **qlists)
|
|
||||||
{
|
|
||||||
size_t i, j;
|
|
||||||
struct quirk *q;
|
|
||||||
struct quirk_list *qlist;
|
|
||||||
struct pci_dev *dev;
|
|
||||||
|
|
||||||
for (i = 0; ; i++)
|
|
||||||
{
|
|
||||||
qlist = qlists[i];
|
|
||||||
|
|
||||||
if (qlist == NULL) {
|
|
||||||
/* OOPS. We've tried all we know, but no quirk */
|
|
||||||
printf("No quirks supported.\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Is this the right device ? */
|
|
||||||
if ( (qlist->pci_vendor_id != sb->vendor_id) ||
|
|
||||||
qlist->pci_device_id != sb->device_id)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (j = 0; ; j++)
|
|
||||||
{
|
|
||||||
q = &qlist->dev_quirks[j];
|
|
||||||
|
|
||||||
if(q->pci_device_id == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
printf("Probing PCI device %i:%.2x.%i\n",
|
|
||||||
q->pci_bus, q->pci_dev, q->pci_func);
|
|
||||||
|
|
||||||
dev = pci_get_dev(pacc, q->pci_domain, q->pci_bus,
|
|
||||||
q->pci_dev, q->pci_func);
|
|
||||||
|
|
||||||
if (!dev) {
|
|
||||||
perror("Error: no device found\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_fill_info(dev, PCI_FILL_IDENT |
|
|
||||||
PCI_FILL_BASES |
|
|
||||||
PCI_FILL_SIZES |
|
|
||||||
PCI_FILL_CLASS );
|
|
||||||
|
|
||||||
if (dev->device_id != q->pci_device_id) {
|
|
||||||
printf("Expected %.4x:%.4x, got %.4x:%.4x\n",
|
|
||||||
q->pci_vendor_id, q->pci_device_id,
|
|
||||||
dev->vendor_id, dev->device_id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!q->quirk_func) {
|
|
||||||
perror("BUG: Quirk missing.\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
q->quirk_func(dev);
|
|
||||||
/* On to next quirk */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Done. No need to go through the remainder of the list */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* viatool - dump all registers on a VIA CPU + chipset based system.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Alexandru Gagniuc
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <viatool.h>
|
|
||||||
|
|
||||||
struct quirk {
|
|
||||||
int pci_domain;
|
|
||||||
int pci_bus;
|
|
||||||
int pci_dev;
|
|
||||||
int pci_func;
|
|
||||||
int pci_vendor_id;
|
|
||||||
int pci_device_id;
|
|
||||||
int (*quirk_func)(struct pci_dev *dev);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct quirk_list {
|
|
||||||
int pci_vendor_id;
|
|
||||||
int pci_device_id;
|
|
||||||
/* NULL-terminated list of quirks */
|
|
||||||
struct quirk *dev_quirks;
|
|
||||||
};
|
|
|
@ -1,81 +0,0 @@
|
||||||
/*
|
|
||||||
* viatool - dump all registers on a VIA CPU + chipset based system.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Alexandru Gagniuc
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "quirks.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
typedef u8 sata_phy_config[64];
|
|
||||||
|
|
||||||
static u32 sata_phy_read32(struct pci_dev *dev, u8 index)
|
|
||||||
{
|
|
||||||
/* The SATA PHY control registers are accessed by a funny index/value
|
|
||||||
* scheme. Each byte (0,1,2,3) has its own 4-bit index */
|
|
||||||
index = (index >> 2) & 0xf;
|
|
||||||
u16 i16 = index | (index << 4) | (index << 8)| (index << 12);
|
|
||||||
/* The index */
|
|
||||||
pci_write_word(dev, 0x68, i16);
|
|
||||||
/* The value */
|
|
||||||
return pci_read_long(dev, 0x64);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vx900_sata_read_phy_config(struct pci_dev *dev, sata_phy_config cfg)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
u32* data = (u32*)cfg;
|
|
||||||
for (i = 0; i < ( sizeof(sata_phy_config) ) >> 2; i++) {
|
|
||||||
data[i] = sata_phy_read32(dev, i<<2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int quirk_vx900_sata(struct pci_dev *dev)
|
|
||||||
{
|
|
||||||
sata_phy_config ephy;
|
|
||||||
|
|
||||||
/* Get all the info in one pass */
|
|
||||||
vx900_sata_read_phy_config(dev, ephy);
|
|
||||||
|
|
||||||
/* Put it on the terminal for the user to read and be done with it */
|
|
||||||
printf("SATA PHY config:\n");
|
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < sizeof(sata_phy_config); i++) {
|
|
||||||
if ((i & 0x0f) == 0) {
|
|
||||||
printf("%.2x :", i);
|
|
||||||
}
|
|
||||||
if( (i & 0x0f) == 0x08 )
|
|
||||||
printf("| ");
|
|
||||||
printf("%.2x ", ephy[i]);
|
|
||||||
if ((i & 0x0f) == 0x0f) {
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct quirk vx900_sb_quirks[] = {
|
|
||||||
{0, 0, 0x0f, 0, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX900_SATA,
|
|
||||||
quirk_vx900_sata },
|
|
||||||
{0, 0, 0, 0, 0, 0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct quirk_list vx900_sb_quirk_list = {
|
|
||||||
.pci_vendor_id = PCI_VENDOR_ID_VIA,
|
|
||||||
.pci_device_id = PCI_DEVICE_ID_VIA_VX900_LPC,
|
|
||||||
.dev_quirks = vx900_sb_quirks
|
|
||||||
};
|
|
|
@ -1,262 +0,0 @@
|
||||||
/*
|
|
||||||
* viatool - dump all registers on an Intel CPU + chipset based system.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008-2010 by coresystems GmbH
|
|
||||||
* written by Stefan Reinauer <stepan@coresystems.de>
|
|
||||||
* Copyright (C) 2009 Carl-Daniel Hailfinger
|
|
||||||
* Copyright (C) 2013 Alexandru Gagniuc
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "viatool.h"
|
|
||||||
|
|
||||||
#ifdef __NetBSD__
|
|
||||||
#include <machine/sysarch.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* http://pci-ids.ucw.cz/read/PC/8086
|
|
||||||
* http://en.wikipedia.org/wiki/Intel_Tick-Tock
|
|
||||||
* http://en.wikipedia.org/wiki/List_of_Intel_chipsets
|
|
||||||
* http://en.wikipedia.org/wiki/Intel_Xeon_chipsets
|
|
||||||
*/
|
|
||||||
static const struct {
|
|
||||||
uint16_t vendor_id, device_id;
|
|
||||||
char *name;
|
|
||||||
} supported_chips_list[] = {
|
|
||||||
{ PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX900_SATA, "VX900 SATA"},
|
|
||||||
/* Host bridges/DRAM controllers (Northbridges) */
|
|
||||||
{ PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX900, "VX900"},
|
|
||||||
/* Southbridges (LPC controllers) */
|
|
||||||
{ PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX900_LPC, "VX900" },
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
|
||||||
static int fd_mem;
|
|
||||||
|
|
||||||
void *map_physical(uint64_t phys_addr, size_t len)
|
|
||||||
{
|
|
||||||
void *virt_addr;
|
|
||||||
|
|
||||||
virt_addr = mmap(0, len, PROT_WRITE | PROT_READ, MAP_SHARED,
|
|
||||||
fd_mem, (off_t) phys_addr);
|
|
||||||
|
|
||||||
if (virt_addr == MAP_FAILED) {
|
|
||||||
printf("Error mapping physical memory 0x%08" PRIx64 "[0x%zx]\n",
|
|
||||||
phys_addr, len);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return virt_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unmap_physical(void *virt_addr, size_t len)
|
|
||||||
{
|
|
||||||
munmap(virt_addr, len);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void print_version(void)
|
|
||||||
{
|
|
||||||
printf("inteltool v%s -- ", VIATOOL_VERSION);
|
|
||||||
printf("Copyright (C) 2013 Alexandru Gagniuc\n\n");
|
|
||||||
printf(
|
|
||||||
"This program is free software: you can redistribute it and/or modify\n"
|
|
||||||
"it under the terms of the GNU General Public License as published by\n"
|
|
||||||
"the Free Software Foundation, version 2 of the License.\n\n"
|
|
||||||
"This program is distributed in the hope that it will be useful,\n"
|
|
||||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
|
||||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
|
||||||
"GNU General Public License for more details.\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_usage(const char *name)
|
|
||||||
{
|
|
||||||
printf("usage: %s [-vh?gGrpmedPMa]\n", name);
|
|
||||||
printf("\n"
|
|
||||||
" -v | --version: print the version\n"
|
|
||||||
" -h | --help: print this help\n\n"
|
|
||||||
" -M | --msrs: dump CPU MSRs\n"
|
|
||||||
" -a | --all: dump all known registers\n"
|
|
||||||
" -q | --quirks: dump hierarchical configs\n"
|
|
||||||
"\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
struct pci_access *pacc;
|
|
||||||
struct pci_dev *sb = NULL, *nb, *dev;
|
|
||||||
int i, opt, option_index = 0;
|
|
||||||
unsigned int id;
|
|
||||||
|
|
||||||
char *sbname = "unknown", *nbname = "unknown";
|
|
||||||
|
|
||||||
int dump_coremsrs = 0, dump_quirks = 0;
|
|
||||||
|
|
||||||
static struct option long_options[] = {
|
|
||||||
{"version", 0, 0, 'v'},
|
|
||||||
{"help", 0, 0, 'h'},
|
|
||||||
{"mchbar", 0, 0, 'm'},
|
|
||||||
{"msrs", 0, 0, 'M'},
|
|
||||||
{"quirks", 0, 0, 'q'},
|
|
||||||
{"all", 0, 0, 'a'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaA",
|
|
||||||
long_options, &option_index)) != EOF) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'v':
|
|
||||||
print_version();
|
|
||||||
exit(0);
|
|
||||||
break;
|
|
||||||
case 'M':
|
|
||||||
dump_coremsrs = 1;
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
dump_quirks = 1;
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
dump_coremsrs = 1;
|
|
||||||
dump_quirks = 1;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
case '?':
|
|
||||||
default:
|
|
||||||
print_usage(argv[0]);
|
|
||||||
exit(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
|
||||||
if (open("/dev/io", O_RDWR) < 0) {
|
|
||||||
perror("/dev/io");
|
|
||||||
#elif defined(__NetBSD__)
|
|
||||||
# ifdef __i386__
|
|
||||||
if (i386_iopl(3)) {
|
|
||||||
perror("iopl");
|
|
||||||
# else
|
|
||||||
if (x86_64_iopl(3)) {
|
|
||||||
perror("iopl");
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
if (iopl(3)) {
|
|
||||||
perror("iopl");
|
|
||||||
#endif
|
|
||||||
printf("You need to be root.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
|
||||||
if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
|
|
||||||
perror("Can not open /dev/mem");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pacc = pci_alloc();
|
|
||||||
pci_init(pacc);
|
|
||||||
pci_scan_bus(pacc);
|
|
||||||
|
|
||||||
/* Find the required devices */
|
|
||||||
for (dev = pacc->devices; dev; dev = dev->next) {
|
|
||||||
pci_fill_info(dev, PCI_FILL_CLASS);
|
|
||||||
/* The ISA/LPC bridge can be 0x1f, 0x07, or 0x04 so we probe. */
|
|
||||||
if (dev->device_class == 0x0601) { /* ISA/LPC bridge */
|
|
||||||
if (sb == NULL)
|
|
||||||
sb = dev;
|
|
||||||
else
|
|
||||||
fprintf(stderr, "Multiple devices with class ID"
|
|
||||||
" 0x0601, using %02x%02x:%02x.%02x\n",
|
|
||||||
dev->domain, dev->bus, dev->dev,
|
|
||||||
dev->func);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sb) {
|
|
||||||
printf("No southbridge found.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
|
|
||||||
|
|
||||||
if (sb->vendor_id != PCI_VENDOR_ID_VIA) {
|
|
||||||
printf("Not a VIA southbridge.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
|
|
||||||
if (!nb) {
|
|
||||||
printf("No northbridge found.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
|
|
||||||
|
|
||||||
if (nb->vendor_id != PCI_VENDOR_ID_VIA) {
|
|
||||||
printf("Not a VIA northbridge.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
id = cpuid(1);
|
|
||||||
|
|
||||||
/* Intel has suggested applications to display the family of a CPU as
|
|
||||||
* the sum of the "Family" and the "Extended Family" fields shown
|
|
||||||
* above, and the model as the sum of the "Model" and the 4-bit
|
|
||||||
* left-shifted "Extended Model" fields.
|
|
||||||
* http://download.intel.com/design/processor/applnots/24161832.pdf
|
|
||||||
*/
|
|
||||||
printf("CPU: Processor Type: %x, Family %x, Model %x, Stepping %x\n",
|
|
||||||
(id >> 12) & 0x3, ((id >> 8) & 0xf) + ((id >> 20) & 0xff),
|
|
||||||
((id >> 12) & 0xf0) + ((id >> 4) & 0xf), (id & 0xf));
|
|
||||||
|
|
||||||
/* Determine names */
|
|
||||||
for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
|
|
||||||
if (nb->device_id == supported_chips_list[i].device_id)
|
|
||||||
nbname = supported_chips_list[i].name;
|
|
||||||
for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
|
|
||||||
if (sb->device_id == supported_chips_list[i].device_id)
|
|
||||||
sbname = supported_chips_list[i].name;
|
|
||||||
|
|
||||||
printf("Northbridge: %04x:%04x (%s)\n",
|
|
||||||
nb->vendor_id, nb->device_id, nbname);
|
|
||||||
|
|
||||||
printf("Southbridge: %04x:%04x (%s)\n",
|
|
||||||
sb->vendor_id, sb->device_id, sbname);
|
|
||||||
|
|
||||||
/* Now do the deed */
|
|
||||||
|
|
||||||
if (dump_coremsrs) {
|
|
||||||
print_intel_core_msrs();
|
|
||||||
printf("\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dump_quirks) {
|
|
||||||
print_quirks_north(nb, pacc);
|
|
||||||
print_quirks_south(sb, pacc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up */
|
|
||||||
pci_free_dev(nb);
|
|
||||||
// pci_free_dev(sb); // TODO: glibc detected "double free or corruption"
|
|
||||||
pci_cleanup(pacc);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
/*
|
|
||||||
* viatool - dump all registers on an Intel CPU + chipset based system.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008-2010 by coresystems GmbH
|
|
||||||
* Copyright (C) 2009 Carl-Daniel Hailfinger
|
|
||||||
* Copyright (C) 2013 Alexandru Gagniuc
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#ifndef _VIATOOL_H
|
|
||||||
#define _VIATOOL_H
|
|
||||||
|
|
||||||
#if defined(__GLIBC__)
|
|
||||||
#include <sys/io.h>
|
|
||||||
#endif
|
|
||||||
#if (defined(__MACH__) && defined(__APPLE__))
|
|
||||||
/* DirectHW is available here: https://www.coreboot.org/DirectHW */
|
|
||||||
#define __DARWIN__
|
|
||||||
#include <DirectHW/DirectHW.h>
|
|
||||||
#endif
|
|
||||||
#ifdef __NetBSD__
|
|
||||||
#include <pciutils/pci.h>
|
|
||||||
#else
|
|
||||||
#include <pci/pci.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This #include is needed for freebsd_{rd,wr}msr. */
|
|
||||||
#if defined(__FreeBSD__)
|
|
||||||
#include <machine/cpufunc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __NetBSD__
|
|
||||||
static inline uint8_t inb(unsigned port)
|
|
||||||
{
|
|
||||||
uint8_t data;
|
|
||||||
__asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
static inline uint16_t inw(unsigned port)
|
|
||||||
{
|
|
||||||
uint16_t data;
|
|
||||||
__asm volatile("inw %w1,%0": "=a" (data) : "d" (port));
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
static inline uint32_t inl(unsigned port)
|
|
||||||
{
|
|
||||||
uint32_t data;
|
|
||||||
__asm volatile("inl %w1,%0": "=a" (data) : "d" (port));
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define VIATOOL_VERSION "1.0"
|
|
||||||
|
|
||||||
/* Tested chipsets: */
|
|
||||||
#define PCI_VENDOR_ID_VIA 0x1106
|
|
||||||
#define PCI_DEVICE_ID_VIA_VX900 0x0410
|
|
||||||
#define PCI_DEVICE_ID_VIA_VX900_SATA 0x9001
|
|
||||||
#define PCI_DEVICE_ID_VIA_VX900_LPC 0x8410
|
|
||||||
|
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
|
|
||||||
|
|
||||||
#if !defined(__DARWIN__) && !defined(__FreeBSD__)
|
|
||||||
typedef struct { uint32_t hi, lo; } msr_t;
|
|
||||||
#endif
|
|
||||||
#if defined (__FreeBSD__)
|
|
||||||
/* FreeBSD already has conflicting definitions for wrmsr/rdmsr. */
|
|
||||||
#undef rdmsr
|
|
||||||
#undef wrmsr
|
|
||||||
#define rdmsr freebsd_rdmsr
|
|
||||||
#define wrmsr freebsd_wrmsr
|
|
||||||
typedef struct { uint32_t hi, lo; } msr_t;
|
|
||||||
msr_t freebsd_rdmsr(int addr);
|
|
||||||
int freebsd_wrmsr(int addr, msr_t msr);
|
|
||||||
#endif
|
|
||||||
typedef struct { uint16_t addr; int size; char *name; } io_register_t;
|
|
||||||
|
|
||||||
void *map_physical(uint64_t phys_addr, size_t len);
|
|
||||||
void unmap_physical(void *virt_addr, size_t len);
|
|
||||||
|
|
||||||
unsigned int cpuid(unsigned int op);
|
|
||||||
int print_intel_core_msrs(void);
|
|
||||||
int print_quirks_north(struct pci_dev *nb, struct pci_access *pacc);
|
|
||||||
int print_quirks_south(struct pci_dev *sb, struct pci_access *pacc);
|
|
||||||
|
|
||||||
#endif /* _VIATOOL_H */
|
|
Loading…
Reference in New Issue