1 /* $NetBSD: platid.h,v 1.2 2000/02/06 08:47:17 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 struct platid_name { 73 platid_mask_t *mask; 74 char *name; 75 }; 76 77 #define PLATID_FLAGS_SHIFT 0 78 #define PLATID_CPU_SUBMODEL_SHIFT 8 79 #define PLATID_CPU_MODEL_SHIFT 14 80 #define PLATID_CPU_SERIES_SHIFT 20 81 #define PLATID_CPU_ARCH_SHIFT 26 82 83 #define PLATID_SUBMODEL_SHIFT 0 84 #define PLATID_MODEL_SHIFT 8 85 #define PLATID_SERIES_SHIFT 16 86 #define PLATID_VENDOR_SHIFT 22 87 88 #define PLATID_FLAGS_MASK \ 89 (((1 << PLATID_FLAGS_BITS) - 1) << PLATID_FLAGS_SHIFT) 90 #define PLATID_CPU_SUBMODEL_MASK \ 91 (((1 << PLATID_CPU_SUBMODEL_BITS) - 1) << PLATID_CPU_SUBMODEL_SHIFT) 92 #define PLATID_CPU_MODEL_MASK \ 93 (((1 << PLATID_CPU_MODEL_BITS) - 1) << PLATID_CPU_MODEL_SHIFT) 94 #define PLATID_CPU_SERIES_MASK \ 95 (((1 << PLATID_CPU_SERIES_BITS) - 1) << PLATID_CPU_SERIES_SHIFT) 96 #define PLATID_CPU_ARCH_MASK \ 97 (((1 << PLATID_CPU_ARCH_BITS) - 1) << PLATID_CPU_ARCH_SHIFT) 98 99 #define PLATID_SUBMODEL_MASK \ 100 (((1 << PLATID_SUBMODEL_BITS) - 1) << PLATID_SUBMODEL_SHIFT) 101 #define PLATID_MODEL_MASK \ 102 (((1 << PLATID_MODEL_BITS) - 1) << PLATID_MODEL_SHIFT) 103 #define PLATID_SERIES_MASK \ 104 (((1 << PLATID_SERIES_BITS) - 1) << PLATID_SERIES_SHIFT) 105 #define PLATID_VENDOR_MASK \ 106 (((1 << PLATID_VENDOR_BITS) - 1) << PLATID_VENDOR_SHIFT) 107 108 #define PLATID_UNKNOWN 0 109 #define PLATID_WILD PLATID_UNKNOWN 110 111 extern platid_t platid_unknown; 112 extern platid_t platid_wild; 113 extern platid_t platid; 114 extern struct platid_name platid_name_table[]; 115 extern int platid_name_table_size; 116 117 void platid_ntoh(platid_t *pid); 118 void platid_hton(platid_t *pid); 119 void platid_dump(char *name, void* pxx); 120 int platid_match(platid_t *platid, platid_mask_t *mask); 121 int platid_match_sub(platid_t*, platid_mask_t*, int); 122 char* platid_name(platid_t *platid); 123 124 #define PLATID_DEREFP(pp) ((platid_t*)(pp)) 125 #define PLATID_DEREF(pp) (*PLATID_DEREFP(pp)) 126 127 #include "platid_generated.h" 128