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