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