Annotation of kernel/machdep/i386/pmap_inline.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /*
                     26:  * Copyright (c) 1992 NeXT Computer, Inc.
                     27:  *
                     28:  * Intel386 Family:    Inline expansions for pmap.
                     29:  *
                     30:  * HISTORY
                     31:  *
                     32:  * 9 April 1992 ? at NeXT
                     33:  *     Created.
                     34:  */
                     35: 
                     36: /*
                     37:  * Convert a physical address
                     38:  * into an absolute page index.
                     39:  */
                     40: static inline
                     41: unsigned int
                     42: phys_to_pfn(
                     43:     unsigned int       phys
                     44: )
                     45: {
                     46:     union {
                     47:        unsigned int    phys;
                     48:        struct {
                     49:            unsigned int                :12,
                     50:                                pfn     :20;
                     51:        }               fields;
                     52:     } conv;
                     53:     
                     54:     conv.phys = phys;
                     55:     
                     56:     return (conv.fields.pfn);
                     57: }
                     58: 
                     59: /*
                     60:  * Return the address corresponding
                     61:  * the an absolute physical page
                     62:  * index.
                     63:  */
                     64: static inline
                     65: unsigned int
                     66: pfn_to_phys(
                     67:     unsigned int       pfn
                     68: )
                     69: {
                     70:     union {
                     71:        unsigned int    phys;
                     72:        struct {
                     73:            unsigned int                :12,
                     74:                                pfn     :20;
                     75:        }               fields;
                     76:     } conv;
                     77:     
                     78:     conv.phys = 0;
                     79:     conv.fields.pfn = pfn;
                     80:     
                     81:     return (conv.phys);
                     82: }
                     83: 
                     84: /*
                     85:  * Return the page offset part
                     86:  * of an address, virtual or
                     87:  * physical.
                     88:  */
                     89: static inline
                     90: unsigned int
                     91: page_offset(
                     92:     unsigned int       addr    /* XXX vm or phys */
                     93: )
                     94: {
                     95:     union {
                     96:        unsigned int    addr;
                     97:        struct {
                     98:            unsigned int        offset  :12,
                     99:                                        :20;
                    100:        }               fields;
                    101:     } conv;
                    102:     
                    103:     conv.addr = addr;
                    104:     
                    105:     return (conv.fields.offset);
                    106: }
                    107: 
                    108: /*
                    109:  * Given a ptr to a page
                    110:  * directory and a virtual
                    111:  * address, return a ptr to
                    112:  * the corresponding
                    113:  * page directory entry.
                    114:  */
                    115: static inline
                    116: pd_entry_t *
                    117: pd_to_pd_entry(
                    118:     pd_entry_t         p[],
                    119:     vm_offset_t                v
                    120: )
                    121: {
                    122:     union {
                    123:        vm_offset_t     virt;
                    124:        struct {
                    125:            unsigned int                :12,
                    126:                                        :10,
                    127:                                index   :10;
                    128:        }               fields;
                    129:     } conv;
                    130:     
                    131:     conv.virt = v;
                    132:     
                    133:     return (&p[conv.fields.index]);
                    134: }
                    135: 
                    136: /*
                    137:  * Given a ptr to a page
                    138:  * table and a virtual
                    139:  * address, return a ptr to
                    140:  * the corresponding
                    141:  * page table entry.
                    142:  */
                    143: static inline
                    144: pt_entry_t *
                    145: pt_to_pt_entry(
                    146:     pt_entry_t         p[],
                    147:     vm_offset_t                v
                    148: )
                    149: {
                    150:     union {
                    151:        vm_offset_t     virt;
                    152:        struct {
                    153:            unsigned int                :12,
                    154:                                index   :10,
                    155:                                        :10;
                    156:        }               fields;
                    157:     } conv;
                    158:     
                    159:     conv.virt = v;
                    160:     
                    161:     return (&p[conv.fields.index]);
                    162: }
                    163: 
                    164: /*
                    165:  * Return the virtual address
                    166:  * of the page table referenced
                    167:  * by a page directory entry.
                    168:  */
                    169: static inline
                    170: pt_entry_t *
                    171: pd_entry_to_pt(
                    172:     pd_entry_t         *p
                    173: )
                    174: {
                    175:     return ((pt_entry_t *)(pfn_to_phys(p->pfn) +
                    176:                                    VM_MIN_KERNEL_ADDRESS));
                    177: }
                    178: 
                    179: /*
                    180:  * Given  a ptr to a valid page
                    181:  * directory entry and a virtual
                    182:  * address, walk to the corresponding
                    183:  * page table entry, and return a ptr
                    184:  * to it.
                    185:  */
                    186: static inline
                    187: pt_entry_t *
                    188: pd_entry_to_pt_entry(
                    189:     pd_entry_t         *p,
                    190:     vm_offset_t                v
                    191: )
                    192: {
                    193:     return (pt_to_pt_entry(pd_entry_to_pt(p), v));
                    194: }

unix.superglobalmegacorp.com

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