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