platid.h revision 1.1 1 1.1 uch /* $NetBSD: platid.h,v 1.1 2002/02/01 18:16:04 uch Exp $ */
2 1.1 uch
3 1.1 uch /*-
4 1.1 uch * Copyright (c) 1999-2001
5 1.1 uch * Shin Takemura and PocketBSD Project. All rights reserved.
6 1.1 uch *
7 1.1 uch * Redistribution and use in source and binary forms, with or without
8 1.1 uch * modification, are permitted provided that the following conditions
9 1.1 uch * are met:
10 1.1 uch * 1. Redistributions of source code must retain the above copyright
11 1.1 uch * notice, this list of conditions and the following disclaimer.
12 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 uch * notice, this list of conditions and the following disclaimer in the
14 1.1 uch * documentation and/or other materials provided with the distribution.
15 1.1 uch * 3. All advertising materials mentioning features or use of this software
16 1.1 uch * must display the following acknowledgement:
17 1.1 uch * This product includes software developed by the PocketBSD project
18 1.1 uch * and its contributors.
19 1.1 uch * 4. Neither the name of the project nor the names of its contributors
20 1.1 uch * may be used to endorse or promote products derived from this software
21 1.1 uch * without specific prior written permission.
22 1.1 uch *
23 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 uch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 uch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 uch * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 uch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 uch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 uch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 uch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 uch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 uch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 uch * SUCH DAMAGE.
34 1.1 uch *
35 1.1 uch */
36 1.1 uch
37 1.1 uch #ifndef _HPC_PLATID_H_
38 1.1 uch #define _HPC_PLATID_H_
39 1.1 uch
40 1.1 uch #include <sys/cdefs.h>
41 1.1 uch
42 1.1 uch #define PLATID_FLAGS_BITS 8
43 1.1 uch #define PLATID_CPU_SUBMODEL_BITS 6
44 1.1 uch #define PLATID_CPU_MODEL_BITS 6
45 1.1 uch #define PLATID_CPU_SERIES_BITS 6
46 1.1 uch #define PLATID_CPU_ARCH_BITS 6
47 1.1 uch
48 1.1 uch #define PLATID_SUBMODEL_BITS 8
49 1.1 uch #define PLATID_MODEL_BITS 8
50 1.1 uch #define PLATID_SERIES_BITS 6
51 1.1 uch #define PLATID_VENDOR_BITS 10
52 1.1 uch
53 1.1 uch typedef union {
54 1.1 uch struct {
55 1.1 uch unsigned long dw0, dw1;
56 1.1 uch } dw;
57 1.1 uch #if BYTE_ORDER == LITTLE_ENDIAN
58 1.1 uch struct platid {
59 1.1 uch unsigned int flags :PLATID_FLAGS_BITS;
60 1.1 uch unsigned int cpu_submodel :PLATID_CPU_SUBMODEL_BITS;
61 1.1 uch unsigned int cpu_model :PLATID_CPU_MODEL_BITS;
62 1.1 uch unsigned int cpu_series :PLATID_CPU_SERIES_BITS;
63 1.1 uch unsigned int cpu_arch :PLATID_CPU_ARCH_BITS;
64 1.1 uch
65 1.1 uch unsigned int submodel :PLATID_SUBMODEL_BITS;
66 1.1 uch unsigned int model :PLATID_MODEL_BITS;
67 1.1 uch unsigned int series :PLATID_SERIES_BITS;
68 1.1 uch unsigned int vendor :PLATID_VENDOR_BITS;
69 1.1 uch } s;
70 1.1 uch #else
71 1.1 uch #error BYTE_ORDER != LITTLE_ENDIAN
72 1.1 uch #endif
73 1.1 uch } platid_t;
74 1.1 uch
75 1.1 uch typedef platid_t platid_mask_t;
76 1.1 uch
77 1.1 uch #ifdef UNICODE
78 1.1 uch typedef unsigned short tchar;
79 1.1 uch #ifndef TEXT
80 1.1 uch #define TEXT(x) L##x
81 1.1 uch #endif
82 1.1 uch #else
83 1.1 uch typedef char tchar;
84 1.1 uch #define TEXT(x) x
85 1.1 uch #endif
86 1.1 uch
87 1.1 uch struct platid_name {
88 1.1 uch platid_mask_t *mask;
89 1.1 uch tchar *name;
90 1.1 uch };
91 1.1 uch
92 1.1 uch struct platid_data {
93 1.1 uch platid_mask_t *mask;
94 1.1 uch void *data;
95 1.1 uch };
96 1.1 uch
97 1.1 uch #define PLATID_FLAGS_SHIFT 0
98 1.1 uch #define PLATID_CPU_SUBMODEL_SHIFT 8
99 1.1 uch #define PLATID_CPU_MODEL_SHIFT 14
100 1.1 uch #define PLATID_CPU_SERIES_SHIFT 20
101 1.1 uch #define PLATID_CPU_ARCH_SHIFT 26
102 1.1 uch
103 1.1 uch #define PLATID_SUBMODEL_SHIFT 0
104 1.1 uch #define PLATID_MODEL_SHIFT 8
105 1.1 uch #define PLATID_SERIES_SHIFT 16
106 1.1 uch #define PLATID_VENDOR_SHIFT 22
107 1.1 uch
108 1.1 uch #define PLATID_FLAGS_MASK \
109 1.1 uch (((1 << PLATID_FLAGS_BITS) - 1) << PLATID_FLAGS_SHIFT)
110 1.1 uch #define PLATID_CPU_SUBMODEL_MASK \
111 1.1 uch (((1 << PLATID_CPU_SUBMODEL_BITS) - 1) << PLATID_CPU_SUBMODEL_SHIFT)
112 1.1 uch #define PLATID_CPU_MODEL_MASK \
113 1.1 uch (((1 << PLATID_CPU_MODEL_BITS) - 1) << PLATID_CPU_MODEL_SHIFT)
114 1.1 uch #define PLATID_CPU_SERIES_MASK \
115 1.1 uch (((1 << PLATID_CPU_SERIES_BITS) - 1) << PLATID_CPU_SERIES_SHIFT)
116 1.1 uch #define PLATID_CPU_ARCH_MASK \
117 1.1 uch (((1 << PLATID_CPU_ARCH_BITS) - 1) << PLATID_CPU_ARCH_SHIFT)
118 1.1 uch
119 1.1 uch #define PLATID_SUBMODEL_MASK \
120 1.1 uch (((1 << PLATID_SUBMODEL_BITS) - 1) << PLATID_SUBMODEL_SHIFT)
121 1.1 uch #define PLATID_MODEL_MASK \
122 1.1 uch (((1 << PLATID_MODEL_BITS) - 1) << PLATID_MODEL_SHIFT)
123 1.1 uch #define PLATID_SERIES_MASK \
124 1.1 uch (((1 << PLATID_SERIES_BITS) - 1) << PLATID_SERIES_SHIFT)
125 1.1 uch #define PLATID_VENDOR_MASK \
126 1.1 uch (((1 << PLATID_VENDOR_BITS) - 1) << PLATID_VENDOR_SHIFT)
127 1.1 uch
128 1.1 uch #define PLATID_UNKNOWN 0
129 1.1 uch #define PLATID_WILD PLATID_UNKNOWN
130 1.1 uch #define PLATID_DEREFP(pp) ((platid_t *)(pp))
131 1.1 uch #define PLATID_DEREF(pp) (*PLATID_DEREFP(pp))
132 1.1 uch
133 1.1 uch __BEGIN_DECLS
134 1.1 uch extern platid_t platid_unknown;
135 1.1 uch extern platid_t platid_wild;
136 1.1 uch extern platid_t platid;
137 1.1 uch extern struct platid_name platid_name_table[];
138 1.1 uch extern int platid_name_table_size;
139 1.1 uch
140 1.1 uch void platid_ntoh(platid_t *);
141 1.1 uch void platid_hton(platid_t *);
142 1.1 uch void platid_dump(char *, void *);
143 1.1 uch int platid_match(platid_t *, platid_mask_t *);
144 1.1 uch int platid_match_sub(platid_t *, platid_mask_t *, int);
145 1.1 uch tchar* platid_name(platid_t *);
146 1.1 uch struct platid_data *platid_search_data(platid_t *, struct platid_data *);
147 1.1 uch void *platid_search(platid_t *, void *, int, int);
148 1.1 uch __END_DECLS
149 1.1 uch
150 1.1 uch #if defined(_KERNEL_OPT)
151 1.1 uch #include "opt_spec_platform.h"
152 1.1 uch #endif
153 1.1 uch #include <machine/platid_generated.h>
154 1.1 uch
155 1.1 uch #endif /* _HPC_PLATID_H_ */
156