Annotation of XNU/EXTERNAL_HEADERS/architecture/i386/reg_help.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /* Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved.
        !            23:  *
        !            24:  *     File:   architecture/i386/reg_help.h
        !            25:  *     Author: Mike DeMoney, NeXT Computer, Inc.
        !            26:  *      Modified for i386 by: Bruce Martin, NeXT Computer, Inc.
        !            27:  *
        !            28:  *     This header file defines cpp macros useful for defining
        !            29:  *     machine register and doing machine-level operations.
        !            30:  *
        !            31:  * HISTORY
        !            32:  * 10-Mar-92  Bruce Martin ([email protected])
        !            33:  *     Adapted to i386
        !            34:  * 23-Jan-91  Mike DeMoney ([email protected])
        !            35:  *     Created.
        !            36:  */
        !            37: 
        !            38: #ifndef        _ARCH_I386_REG_HELP_H_
        !            39: #define        _ARCH_I386_REG_HELP_H_
        !            40: 
        !            41: /* Bitfield definition aid */
        !            42: #define        BITS_WIDTH(msb, lsb)    ((msb)-(lsb)+1)
        !            43: #define        BIT_WIDTH(pos)          (1)     /* mostly to record the position */
        !            44: 
        !            45: /* Mask creation */
        !            46: #define        MKMASK(width, offset)   (((unsigned)-1)>>(32-(width))<<(offset))
        !            47: #define        BITSMASK(msb, lsb)      MKMASK(BITS_WIDTH(msb, lsb), lsb & 0x1f)
        !            48: #define        BITMASK(pos)            MKMASK(BIT_WIDTH(pos), pos & 0x1f)
        !            49: 
        !            50: /* Register addresses */
        !            51: #if    __ASSEMBLER__
        !            52: # define       REG_ADDR(type, addr)    (addr)
        !            53: #else  /* __ASSEMBLER__ */
        !            54: # define       REG_ADDR(type, addr)    (*(volatile type *)(addr))
        !            55: #endif /* __ASSEMBLER__ */
        !            56: 
        !            57: /* Cast a register to be an unsigned */
        !            58: #define        CONTENTS(foo)   (*(unsigned *) &(foo))
        !            59: 
        !            60: /* Stack pointer must always be a multiple of 4 */
        !            61: #define        STACK_INCR      4
        !            62: #define        ROUND_FRAME(x)  ((((unsigned)(x)) + STACK_INCR - 1) & ~(STACK_INCR-1))
        !            63: 
        !            64: /* STRINGIFY -- perform all possible substitutions, then stringify */
        !            65: #define        __STR(x)        #x              /* just a helper macro */
        !            66: #define        STRINGIFY(x)    __STR(x)
        !            67: 
        !            68: /*
        !            69:  * REG_PAIR_DEF -- define a register pair
        !            70:  * Register pairs are appropriately aligned to allow access via
        !            71:  * ld.d and st.d.
        !            72:  *
        !            73:  * Usage:
        !            74:  *     struct foo {
        !            75:  *             REG_PAIR_DEF(
        !            76:  *                     bar_t *,        barp,
        !            77:  *                     afu_t,          afu
        !            78:  *             );
        !            79:  *     };
        !            80:  *
        !            81:  * Access to individual entries of the pair is via the REG_PAIR
        !            82:  * macro (below).
        !            83:  */
        !            84: #define        REG_PAIR_DEF(type0, name0, type1, name1)                \
        !            85:        struct {                                                \
        !            86:                type0   name0 __attribute__(( aligned(8) ));    \
        !            87:                type1   name1;                                  \
        !            88:        } name0##_##name1
        !            89: 
        !            90: /*
        !            91:  * REG_PAIR -- Macro to define names for accessing individual registers
        !            92:  * of register pairs.
        !            93:  *
        !            94:  * Usage:
        !            95:  *     arg0 is first element of pair
        !            96:  *     arg1 is second element of pair
        !            97:  *     arg2 is desired element of pair
        !            98:  * eg:
        !            99:  *     #define foo_barp        REG_PAIR(barp, afu, afu)
        !           100:  */
        !           101: #define        REG_PAIR(name0, name1, the_name)                        \
        !           102:        name0##_##name1.the_name
        !           103: 
        !           104: #endif /* _ARCH_I386_REG_HELP_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.