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