blob: ed90112c18fd82fe58834bb56547ea40294e51e2 [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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <stdint.h>
23
24#ifndef _VIATOOL_H
25#define _VIATOOL_H
26
27#if defined(__GLIBC__)
28#include <sys/io.h>
29#endif
30#if (defined(__MACH__) && defined(__APPLE__))
31/* DirectHW is available here: http://www.coreboot.org/DirectHW */
32#define __DARWIN__
33#include <DirectHW/DirectHW.h>
34#endif
35#include <pci/pci.h>
36
37/* This #include is needed for freebsd_{rd,wr}msr. */
38#if defined(__FreeBSD__)
39#include <machine/cpufunc.h>
40#endif
41
42#include <stdlib.h>
43
44#define VIATOOL_VERSION "1.0"
45
46/* Tested chipsets: */
47#define PCI_VENDOR_ID_VIA 0x1106
48#define PCI_DEVICE_ID_VIA_VX900 0x0410
49#define PCI_DEVICE_ID_VIA_VX900_SATA 0x9001
50#define PCI_DEVICE_ID_VIA_VX900_LPC 0x8410
51
52
53#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
54
55#if !defined(__DARWIN__) && !defined(__FreeBSD__)
56typedef struct { uint32_t hi, lo; } msr_t;
57#endif
58#if defined (__FreeBSD__)
59/* FreeBSD already has conflicting definitions for wrmsr/rdmsr. */
60#undef rdmsr
61#undef wrmsr
62#define rdmsr freebsd_rdmsr
63#define wrmsr freebsd_wrmsr
64typedef struct { uint32_t hi, lo; } msr_t;
65msr_t freebsd_rdmsr(int addr);
66int freebsd_wrmsr(int addr, msr_t msr);
67#endif
68typedef struct { uint16_t addr; int size; char *name; } io_register_t;
69
70void *map_physical(uint64_t phys_addr, size_t len);
71void unmap_physical(void *virt_addr, size_t len);
72
73unsigned int cpuid(unsigned int op);
74int print_intel_core_msrs(void);
75int print_quirks_north(struct pci_dev *nb, struct pci_access *pacc);
76int print_quirks_south(struct pci_dev *sb, struct pci_access *pacc);
77
78#endif /* _VIATOOL_H */