Annotation of kernel/machdep/i386/cpu_inline.h, revision 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, 1994 NeXT Computer, Inc.
        !            27:  *
        !            28:  * Intel386 Family:    Access to special processor functions.
        !            29:  *
        !            30:  * HISTORY
        !            31:  *
        !            32:  * 5 April 1992 ? at NeXT
        !            33:  *     Created.
        !            34:  */
        !            35:  
        !            36: #import <architecture/i386/cpu.h>
        !            37: 
        !            38: static inline
        !            39: unsigned int
        !            40: eflags(void)
        !            41: {
        !            42:     unsigned int       value;
        !            43: 
        !            44:     asm volatile("
        !            45:        pushf
        !            46:        popl    %0"
        !            47:            : "=r" (value));
        !            48:            
        !            49:     return (value);
        !            50: }
        !            51: 
        !            52: static inline
        !            53: void
        !            54: set_eflags(
        !            55:     unsigned int       value
        !            56: )
        !            57: {
        !            58:     asm volatile("
        !            59:        pushl   %0;
        !            60:        popf"
        !            61:            :
        !            62:            : "r" (value));
        !            63: }
        !            64: 
        !            65: static inline
        !            66: void
        !            67: cli(void)
        !            68: {
        !            69:     asm volatile("
        !            70:        cli");
        !            71: }
        !            72: 
        !            73: static inline
        !            74: void
        !            75: sti(void)
        !            76: {
        !            77:     asm volatile("
        !            78:        sti");
        !            79: }
        !            80: 
        !            81: static inline
        !            82: cr0_t
        !            83: cr0(void)
        !            84: {
        !            85:     cr0_t      value;
        !            86:     
        !            87:     asm volatile("
        !            88:        mov %%cr0,%0"
        !            89:            : "=r" (value));
        !            90:                    
        !            91:     return (value);
        !            92: }
        !            93: 
        !            94: static inline
        !            95: void
        !            96: set_cr0(
        !            97:     cr0_t      value
        !            98: )
        !            99: {
        !           100:     asm volatile("
        !           101:        mov %0,%%cr0"
        !           102:            :
        !           103:            : "r" (value));
        !           104: }
        !           105: 
        !           106: static inline
        !           107: void
        !           108: clts(void)
        !           109: {
        !           110:     asm volatile("
        !           111:        clts");
        !           112: }
        !           113: 
        !           114: static inline
        !           115: void
        !           116: setts(void)
        !           117: {
        !           118:     cr0_t      temp;
        !           119:     
        !           120:     temp = cr0();
        !           121:     temp.ts = 1;
        !           122:     
        !           123:     set_cr0(temp);
        !           124: }
        !           125: 
        !           126: static inline
        !           127: void
        !           128: ltr(void)
        !           129: {
        !           130:     asm volatile("ltr %0"
        !           131:                    :
        !           132:                    : "m" (TSS_SEL));
        !           133: }
        !           134: 
        !           135: static inline
        !           136: void
        !           137: lldt(void)
        !           138: {
        !           139:     asm volatile("lldt %0"
        !           140:                    :
        !           141:                    : "m" (LDT_SEL));
        !           142: }
        !           143: 
        !           144: static inline
        !           145: vm_offset_t
        !           146: cr2(void)
        !           147: {
        !           148:     vm_offset_t        value;
        !           149:     
        !           150:     asm volatile("
        !           151:        mov %%cr2,%0"
        !           152:            : "=r" (value));
        !           153:                    
        !           154:     return (value);
        !           155: }
        !           156: 
        !           157: static inline
        !           158: vm_offset_t
        !           159: cr3(void)
        !           160: {
        !           161:     vm_offset_t        value;
        !           162:     
        !           163:     asm volatile("
        !           164:        mov %%cr3,%0"
        !           165:            : "=r" (value));
        !           166:                    
        !           167:     return (value);
        !           168: }
        !           169: 
        !           170: static inline
        !           171: void
        !           172: set_cr3(
        !           173:     vm_offset_t        value
        !           174: )
        !           175: {
        !           176:     asm volatile("
        !           177:        mov %0,%%cr3"
        !           178:            :
        !           179:            : "r" (value));
        !           180: }
        !           181: 
        !           182: static inline
        !           183: void
        !           184: flush_tlb(void)
        !           185: {
        !           186:     set_cr3(
        !           187:                cr3()
        !           188:     );
        !           189: }
        !           190: 
        !           191: static inline
        !           192: void
        !           193: invlpg(
        !           194:     vm_offset_t                addr,
        !           195:     boolean_t          kernel
        !           196: )
        !           197: {
        !           198:     if (kernel)
        !           199:        asm volatile("
        !           200:            invlpg %0"
        !           201:                :
        !           202:                : "m" (*(unsigned char *)addr));
        !           203:     else
        !           204:        asm volatile("
        !           205:            invlpg %%fs:%0"
        !           206:                :
        !           207:                : "m" (*(unsigned char *)addr));
        !           208: }
        !           209: 
        !           210: static inline
        !           211: void
        !           212: flush_cache(void)
        !           213: {
        !           214:     asm volatile("wbinvd");
        !           215: }
        !           216: 
        !           217: static inline
        !           218: void
        !           219: enable_cache(void)
        !           220: {
        !           221:     cr0_t      _cr0 = cr0();
        !           222:     
        !           223:     _cr0.cd = _cr0.nw = 0;
        !           224:     flush_cache(); set_cr0(_cr0);
        !           225: }
        !           226: 
        !           227: static inline
        !           228: void
        !           229: disable_cache(void)
        !           230: {
        !           231:     cr0_t      _cr0 = cr0();
        !           232:     
        !           233:     _cr0.cd = _cr0.nw = 1;
        !           234:     set_cr0(_cr0); flush_cache();
        !           235: }
        !           236: 
        !           237: static inline
        !           238: void
        !           239: freeze_cache(void)
        !           240: {
        !           241:     cr0_t      _cr0 = cr0();
        !           242:     
        !           243:     _cr0.cd = 1; _cr0.nw = 0;
        !           244:     set_cr0(_cr0);
        !           245: }
        !           246: 
        !           247: static inline
        !           248: dr6_t
        !           249: dr6(
        !           250:     void
        !           251: )
        !           252: {
        !           253:     dr6_t      value;
        !           254:     
        !           255:     asm volatile("
        !           256:        mov %%db6,%0"
        !           257:            : "=r" (value));
        !           258:                    
        !           259:     return (value);
        !           260: }
        !           261: 
        !           262: static inline
        !           263: void
        !           264: set_dr6(
        !           265:     dr6_t      value
        !           266: )
        !           267: {
        !           268:     asm volatile("
        !           269:        mov %0,%%db6"
        !           270:            :
        !           271:            : "r" (value));
        !           272: }

unix.superglobalmegacorp.com

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