Annotation of kernel/machdep/i386/sel_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:  * Selector value conversion/validation.
                     29:  *
                     30:  * HISTORY
                     31:  *
                     32:  * 19 June 1992 ? at NeXT
                     33:  *     Created.
                     34:  */
                     35:  
                     36: #import <machdep/i386/table_inline.h>
                     37: 
                     38: static inline
                     39: unsigned int
                     40: sel_to_selector(
                     41:     sel_t              sel
                     42: )
                     43: {
                     44:     union {
                     45:        sel_t           sel;
                     46:        unsigned short  selector;
                     47:     } tconv;
                     48:     
                     49:     tconv.sel = sel;
                     50:     
                     51:     return (tconv.selector);
                     52: }
                     53: 
                     54: static inline
                     55: sel_t
                     56: selector_to_sel(
                     57:     unsigned int       selector
                     58: )
                     59: {
                     60:     union {
                     61:        unsigned short  selector;
                     62:        sel_t           sel;
                     63:     } tconv;
                     64:     
                     65:     tconv.selector = selector;
                     66:     
                     67:     return (tconv.sel);
                     68: }
                     69: 
                     70: static inline
                     71: boolean_t
                     72: valid_user_data_selector(
                     73:     unsigned int       selector
                     74: )
                     75: {
                     76:     sel_t              sel = selector_to_sel(selector);
                     77:     
                     78:     if (selector == 0)
                     79:        return (TRUE);
                     80: 
                     81:     if (sel.ti == SEL_LDT)
                     82:        return (TRUE);
                     83:     else if (sel.index < GDTSZ) {
                     84:        data_desc_t     *desc = (data_desc_t *)sel_to_gdt_entry(sel);
                     85:        
                     86:        if (desc->dpl == USER_PRIV)
                     87:            return (TRUE);
                     88:     }
                     89:                
                     90:     return (FALSE);
                     91: }
                     92: 
                     93: static inline
                     94: boolean_t
                     95: valid_user_code_selector(
                     96:     unsigned int       selector
                     97: )
                     98: {
                     99:     sel_t              sel = selector_to_sel(selector);
                    100:     
                    101:     if (selector == 0)
                    102:        return (FALSE);
                    103: 
                    104:     if (sel.ti == SEL_LDT) {
                    105:        if (sel.rpl == USER_PRIV)
                    106:            return (TRUE);
                    107:     }
                    108:     else if (sel.index < GDTSZ && sel.rpl == USER_PRIV) {
                    109:        code_desc_t     *desc = (code_desc_t *)sel_to_gdt_entry(sel);
                    110:        
                    111:        if (desc->dpl == USER_PRIV)
                    112:            return (TRUE);
                    113:     }
                    114: 
                    115:     return (FALSE);
                    116: }
                    117: 
                    118: static inline
                    119: boolean_t
                    120: valid_user_stack_selector(
                    121:     unsigned int       selector
                    122: )
                    123: {
                    124:     sel_t              sel = selector_to_sel(selector);
                    125:     
                    126:     if (selector == 0)
                    127:        return (FALSE);
                    128: 
                    129:     if (sel.ti == SEL_LDT) {
                    130:        if (sel.rpl == USER_PRIV)
                    131:            return (TRUE);
                    132:     }
                    133:     else if (sel.index < GDTSZ && sel.rpl == USER_PRIV) {
                    134:        data_desc_t     *desc = (data_desc_t *)sel_to_gdt_entry(sel);
                    135:        
                    136:        if (desc->dpl == USER_PRIV)
                    137:            return (TRUE);
                    138:     }
                    139:                
                    140:     return (FALSE);
                    141: }

unix.superglobalmegacorp.com

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