Annotation of XNU/osfmk/i386/thread_act.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: /*
        !            23:  * @OSF_COPYRIGHT@
        !            24:  */
        !            25: 
        !            26: #ifndef        _I386_THREAD_ACT_H_
        !            27: #define        _I386_THREAD_ACT_H_
        !            28: 
        !            29: #include <mach/boolean.h>
        !            30: #include <mach/i386/vm_types.h>
        !            31: #include <mach/i386/fp_reg.h>
        !            32: #include <mach/thread_status.h>
        !            33: 
        !            34: #include <kern/lock.h>
        !            35: 
        !            36: #include <i386/iopb.h>
        !            37: #include <i386/tss.h>
        !            38: #include <i386/eflags.h>
        !            39: 
        !            40: /*
        !            41:  *     i386_saved_state:
        !            42:  *
        !            43:  *     Has been exported to servers.  See: mach/i386/thread_status.h
        !            44:  *
        !            45:  *     This structure corresponds to the state of user registers
        !            46:  *     as saved upon kernel entry.  It lives in the pcb.
        !            47:  *     It is also pushed onto the stack for exceptions in the kernel.
        !            48:  *     For performance, it is also used directly in syscall exceptions
        !            49:  *     if the server has requested i386_THREAD_STATE flavor for the exception
        !            50:  *     port.
        !            51:  *
        !            52:  *     We define the following as an alias for the "esp" field of the
        !            53:  *     structure, because we actually save cr2 here, not the kernel esp.
        !            54:  */
        !            55: #define cr2    esp
        !            56: 
        !            57: /*
        !            58:  *     Save area for user floating-point state.
        !            59:  *     Allocated only when necessary.
        !            60:  */
        !            61: 
        !            62: struct i386_fpsave_state {
        !            63:        boolean_t               fp_valid;
        !            64:        struct i386_fp_save     fp_save_state;
        !            65:        struct i386_fp_regs     fp_regs;
        !            66: };
        !            67: 
        !            68: /*
        !            69:  *     v86_assist_state:
        !            70:  *
        !            71:  *     This structure provides data to simulate 8086 mode
        !            72:  *     interrupts.  It lives in the pcb.
        !            73:  */
        !            74: 
        !            75: struct v86_assist_state {
        !            76:        vm_offset_t             int_table;
        !            77:        unsigned short          int_count;
        !            78:        unsigned short          flags;  /* 8086 flag bits */
        !            79: };
        !            80: #define        V86_IF_PENDING          0x8000  /* unused bit */
        !            81: 
        !            82: /*
        !            83:  *     i386_interrupt_state:
        !            84:  *
        !            85:  *     This structure describes the set of registers that must
        !            86:  *     be pushed on the current ring-0 stack by an interrupt before
        !            87:  *     we can switch to the interrupt stack.
        !            88:  */
        !            89: 
        !            90: struct i386_interrupt_state {
        !            91:        int     es;
        !            92:        int     ds;
        !            93:        int     edx;
        !            94:        int     ecx;
        !            95:        int     eax;
        !            96:        int     eip;
        !            97:        int     cs;
        !            98:        int     efl;
        !            99: };
        !           100: 
        !           101: /*
        !           102:  *     i386_kernel_state:
        !           103:  *
        !           104:  *     This structure corresponds to the state of kernel registers
        !           105:  *     as saved in a context-switch.  It lives at the base of the stack.
        !           106:  */
        !           107: 
        !           108: struct i386_kernel_state {
        !           109:        int                     k_ebx;  /* kernel context */
        !           110:        int                     k_esp;
        !           111:        int                     k_ebp;
        !           112:        int                     k_edi;
        !           113:        int                     k_esi;
        !           114:        int                     k_eip;
        !           115: };
        !           116: 
        !           117: /*
        !           118:  *     i386_machine_state:
        !           119:  *
        !           120:  *     This structure corresponds to special machine state.
        !           121:  *     It lives in the pcb.  It is not saved by default.
        !           122:  */
        !           123: 
        !           124: struct i386_machine_state {
        !           125:        iopb_tss_t              io_tss;
        !           126:        struct user_ldt *       ldt;
        !           127:        struct i386_fpsave_state *ifps;
        !           128:        struct v86_assist_state v86s;
        !           129: };
        !           130: 
        !           131: typedef struct pcb {
        !           132:        struct i386_interrupt_state iis[2];     /* interrupt and NMI */
        !           133:        struct i386_saved_state iss;
        !           134:        struct i386_machine_state ims;
        !           135: #ifdef MACH_BSD
        !           136:        unsigned long   cthread_self;           /* for use of cthread package */
        !           137: #endif
        !           138:        decl_simple_lock_data(,lock)
        !           139: } *pcb_t;
        !           140: 
        !           141: /*
        !           142:  * Maps state flavor to number of words in the state:
        !           143:  */
        !           144: extern unsigned int state_count[];
        !           145: 
        !           146: 
        !           147: #define USER_REGS(ThrAct)      (&(ThrAct)->mact.pcb->iss)
        !           148: 
        !           149: #define act_machine_state_ptr(ThrAct)  (thread_state_t)USER_REGS(ThrAct)
        !           150: 
        !           151: 
        !           152: #define        is_user_thread(ThrAct)  \
        !           153:        ((USER_REGS(ThrAct)->efl & EFL_VM) \
        !           154:         || ((USER_REGS(ThrAct)->cs & 0x03) != 0))
        !           155: 
        !           156: #define        user_pc(ThrAct)         (USER_REGS(ThrAct)->eip)
        !           157: #define        user_sp(ThrAct)         (USER_REGS(ThrAct)->uesp)
        !           158: 
        !           159: #define syscall_emulation_sync(task)   /* do nothing */
        !           160: 
        !           161: typedef struct MachineThrAct {
        !           162:        /*
        !           163:         * pointer to process control block
        !           164:         *      (actual storage may as well be here, too)
        !           165:         */
        !           166:        struct pcb xxx_pcb;
        !           167:        pcb_t pcb;
        !           168: 
        !           169: } MachineThrAct, *MachineThrAct_t;
        !           170: 
        !           171: /*
        !           172:  * On i386, user stacks of collocated servers are wired.
        !           173:  * Unwire these user stacks when their threads are swapped out.
        !           174:  */
        !           175: #define THREAD_SWAP_UNWIRE_USER_STACK  TRUE
        !           176: 
        !           177: #endif /* _I386_THREAD_ACT_H_ */

unix.superglobalmegacorp.com

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