cleanup
[linux-2.4.git] / include / asm-ppc64 / pmc.h
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
38 struct _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
54 struct _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
71 struct _pmc_sw_text {
72         char buffer[PMC_SW_TEXT_ENTRY_COUNT * PMC_TEXT_ENTRY_SIZE];
73 };
74
75 struct _pmc_hw_text {
76         char buffer[PMC_HW_TEXT_ENTRY_COUNT * PMC_TEXT_ENTRY_SIZE];
77 };
78
79 extern struct _pmc_sw pmc_sw_system;
80 extern struct _pmc_sw pmc_sw_cpu[];
81
82 extern struct _pmc_sw_text pmc_sw_text;
83 extern struct _pmc_hw_text pmc_hw_text;
84 extern char *ppc64_pmc_stab(int file);
85 extern char *ppc64_pmc_htab(int file);
86 extern char *ppc64_pmc_hw(int file);
87
88 void *btmalloc(unsigned long size);
89 void btfree(void *addr);
90
91 #if 1
92 #define PMC_SW_PROCESSOR(F)      pmc_sw_cpu[smp_processor_id()].F++
93 #define PMC_SW_PROCESSOR_A(F, E) (pmc_sw_cpu[smp_processor_id()].F[(E)])++
94 #define PMC_SW_SYSTEM(F)         pmc_sw_system.F++
95 #else
96 #define PMC_SW_PROCESSOR(F)   do {;} while (0)
97 #define PMC_SW_PROCESSOR_A(F) do {;} while (0)
98 #define PMC_SW_SYSTEM(F)      do {;} while (0)
99 #endif
100
101 #define PMC_CONTROL_CPI 1
102 #define PMC_CONTROL_TLB 2
103
104 /* To find an entry in the bolted page-table-directory */
105 #define pgd_offset_b(address) (bolted_pgd + pgd_index(address))
106 #define BTMALLOC_START 0xB000000000000000
107 #define BTMALLOC_END   0xB0000000ffffffff /* 4 GB Max-more or less arbitrary */
108
109 #endif /* _PMC_H */