blob: a0a5d79c947dd5c85c44d56edf746a1827c26981 [file] [log] [blame]
Alexandru Gagniuc67f556c2012-08-10 03:55:42 -05001/*
2 * viatool - dump all registers on an Intel CPU + chipset based system.
3 *
4 * Copyright (C) 2008-2010 by coresystems GmbH
5 * Copyright (C) 2009 Carl-Daniel Hailfinger
6 * Copyright (C) 2013 Alexandru Gagniuc
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Alexandru Gagniuc67f556c2012-08-10 03:55:42 -050016 */
17
18#include <stdint.h>
19
20#ifndef _VIATOOL_H
21#define _VIATOOL_H
22
23#if defined(__GLIBC__)
24#include <sys/io.h>
25#endif
26#if (defined(__MACH__) && defined(__APPLE__))
27/* DirectHW is available here: http://www.coreboot.org/DirectHW */
28#define __DARWIN__
29#include <DirectHW/DirectHW.h>
30#endif
31#include <pci/pci.h>
32
33/* This #include is needed for freebsd_{rd,wr}msr. */
34#if defined(__FreeBSD__)
35#include <machine/cpufunc.h>
36#endif
37
38#include <stdlib.h>
39
40#define VIATOOL_VERSION "1.0"
41
42/* Tested chipsets: */
43#define PCI_VENDOR_ID_VIA 0x1106
44#define PCI_DEVICE_ID_VIA_VX900 0x0410
45#define PCI_DEVICE_ID_VIA_VX900_SATA 0x9001
46#define PCI_DEVICE_ID_VIA_VX900_LPC 0x8410
47
48
49#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
50
51#if !defined(__DARWIN__) && !defined(__FreeBSD__)
52typedef struct { uint32_t hi, lo; } msr_t;
53#endif
54#if defined (__FreeBSD__)
55/* FreeBSD already has conflicting definitions for wrmsr/rdmsr. */
56#undef rdmsr
57#undef wrmsr
58#define rdmsr freebsd_rdmsr
59#define wrmsr freebsd_wrmsr
60typedef struct { uint32_t hi, lo; } msr_t;
61msr_t freebsd_rdmsr(int addr);
62int freebsd_wrmsr(int addr, msr_t msr);
63#endif
64typedef struct { uint16_t addr; int size; char *name; } io_register_t;
65
66void *map_physical(uint64_t phys_addr, size_t len);
67void unmap_physical(void *virt_addr, size_t len);
68
69unsigned int cpuid(unsigned int op);
70int print_intel_core_msrs(void);
71int print_quirks_north(struct pci_dev *nb, struct pci_access *pacc);
72int print_quirks_south(struct pci_dev *sb, struct pci_access *pacc);
73
74#endif /* _VIATOOL_H */