1/*
2 * pmc.h
3 * Copyright (C) 2001  Dave Engebretsen & Mike Corrigan IBM Corporation.
4 *
5 * The PPC64 PMC subsystem encompases both the hardware PMC registers and
6 * a set of software event counters.  An interface is provided via the
7 * proc filesystem which can be used to access this subsystem.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22 */
23
24/* Start Change Log
25 * 2001/06/05 : engebret : Created.
26 * End Change Log
27 */
28
29#ifndef _PPC64_TYPES_H
30#include        <asm/types.h>
31#endif
32
33#ifndef _PMC_H
34#define _PMC_H
35
36#define STAB_ENTRY_MAX 64
37
38struct _pmc_hw
39{
40	u64 mmcr0;
41	u64 mmcr1;
42	u64 mmcra;
43
44	u64 pmc1;
45	u64 pmc2;
46	u64 pmc3;
47	u64 pmc4;
48	u64 pmc5;
49	u64 pmc6;
50	u64 pmc7;
51	u64 pmc8;
52};
53
54struct _pmc_sw
55{
56	u64 stab_faults;           /* Count of faults on the stab      */
57	u64 stab_capacity_castouts;/* Count of castouts from the stab  */
58	u64 stab_invalidations;	   /* Count of invalidations from the  */
59                                   /*   stab, not including castouts   */
60	u64 stab_entry_use[STAB_ENTRY_MAX];
61
62	u64 htab_primary_overflows;
63	u64 htab_capacity_castouts;
64	u64 htab_read_to_write_fault;
65};
66
67#define PMC_HW_TEXT_ENTRY_COUNT (sizeof(struct _pmc_hw) / sizeof(u64))
68#define PMC_SW_TEXT_ENTRY_COUNT (sizeof(struct _pmc_sw) / sizeof(u64))
69#define PMC_TEXT_ENTRY_SIZE  64
70
71struct _pmc_sw_text {
72	char buffer[PMC_SW_TEXT_ENTRY_COUNT * PMC_TEXT_ENTRY_SIZE];
73};
74
75struct _pmc_hw_text {
76	char buffer[PMC_HW_TEXT_ENTRY_COUNT * PMC_TEXT_ENTRY_SIZE];
77};
78
79extern struct _pmc_sw pmc_sw_system;
80extern struct _pmc_sw pmc_sw_cpu[];
81
82extern struct _pmc_sw_text pmc_sw_text;
83extern struct _pmc_hw_text pmc_hw_text;
84extern char *ppc64_pmc_stab(int file);
85extern char *ppc64_pmc_htab(int file);
86extern char *ppc64_pmc_hw(int file);
87
88void *btmalloc(unsigned long size);
89void btfree(void *addr);
90
91#define PMC_SW_PROCESSOR(F)      pmc_sw_cpu[smp_processor_id()].F++
92#define PMC_SW_PROCESSOR_A(F, E) (pmc_sw_cpu[smp_processor_id()].F[(E)])++
93#define PMC_SW_SYSTEM(F)         pmc_sw_system.F++
94
95#define PMC_CONTROL_CPI 1
96#define PMC_CONTROL_TLB 2
97
98/* To find an entry in the bolted page-table-directory */
99#define pgd_offset_b(address) (bolted_pgd + pgd_index(address))
100#define BTMALLOC_START 0xB000000000000000
101#define BTMALLOC_END   0xB0000000ffffffff /* 4 GB Max-more or less arbitrary */
102
103#endif /* _PMC_H */
104