1 /* -*-C-*-
2 
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts
6     Institute of Technology
7 
8 This file is part of MIT/GNU Scheme.
9 
10 MIT/GNU Scheme is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or (at
13 your option) any later version.
14 
15 MIT/GNU Scheme is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with MIT/GNU Scheme; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
23 USA.
24 
25 */
26 
27 #ifndef HPPACACHE_H		/* Prevent multiple inclusion */
28 #define HPPACACHE_H
29 
30 #define I_CACHE		1
31 #define D_CACHE		2
32 
33 #include <fcntl.h>
34 
35 #ifdef __HPUX__
36 #include <sys/utsname.h>
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <machine/cpu.h>
40 #include <machine/pdc_rqsts.h>
41 #endif /* __HPUX__ */
42 
43 /* PDC_CACHE (processor dependent code cache information call)
44    return data destructuring.
45 
46    This is the same information as in machine/pdc_rqsts.h
47    pdc_cache_rtn_block, but with fields as defined in the PDC_CACHE
48    section of the I/O Architecture Manual.
49 
50    The main difference is the cache configuration field.
51    Which is correct?  */
52 
53 union cache_conf
54 {
55   unsigned long word;
56   struct
57   {
58     unsigned block:	8;
59     unsigned line:	3;
60     unsigned res1:	2;
61     unsigned wt:	1;
62     unsigned fsel:	2;
63     unsigned cst:	3;
64     unsigned res2:	11;
65     unsigned hv:	2;
66   } bits;
67 };
68 
69 struct cache_info
70 {
71   unsigned long size;		/* in bytes */
72   union cache_conf conf;	/* format description */
73   unsigned long base;		/* start address */
74   unsigned long stride;		/* in bytes */
75   unsigned long count;		/* number of entries */
76   unsigned long loop;		/* set associativity */
77 };
78 
79 union tlb_conf
80 {
81   unsigned long word;
82   struct
83   {
84     unsigned res1:	12;
85     unsigned psel:	2;
86     unsigned hv1:	1;
87     unsigned res2:	1;
88     unsigned cst:	3;
89     unsigned res3:	11;
90     unsigned hv2:	2;
91   } bits;
92 };
93 
94 struct tlb_info
95 {
96   unsigned long size;		/* number of entries */
97   union tlb_conf conf;		/* format description */
98   unsigned long sp_base;	/* space parameters */
99   unsigned long sp_stride;
100   unsigned long sp_count;
101   unsigned long off_base;	/* offset parameters */
102   unsigned long off_stride;
103   unsigned long off_count;
104   unsigned long loop;		/* set associativity */
105 };
106 
107 struct pdc_cache_result
108 {
109   struct cache_info I_info;
110   struct cache_info D_info;
111   struct tlb_info IT_info;
112   struct tlb_info DT_info;
113 };
114 
115 #ifdef __HPUX__
116 
117 #  define HARDWARE_SIZE sizeof (utsname.machine)
118 
119 #else /* not __HPUX__ */
120 /* Presumably BSD */
121 
122 #  define HARDWARE_SIZE 9
123 
124 struct pdc_cache_rtn_block
125 {
126   struct pdc_cache_result goodies;
127   int filler[2];
128 };
129 
130 #endif /* __HPUX__ */
131 
132 struct pdc_cache_dump
133 {
134   char hardware[HARDWARE_SIZE];
135   struct pdc_cache_rtn_block cache_format;
136 };
137 
138 #endif /* HPPACACHE_H */
139