|
|
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: * HISTORY ! 27: * ! 28: * Revision 1.2 1998/09/30 21:21:01 wsanchez ! 29: * Merged in IntelMerge1 (mburg: Intel support) ! 30: * ! 31: * Revision 1.1.1.1.6.1 1998/09/30 18:13:59 mburg ! 32: * Changes for Intel port ! 33: * ! 34: * Revision 1.1.1.1 1998/09/22 21:05:31 wsanchez ! 35: * Import of Mac OS X kernel (~semeria) ! 36: * ! 37: * Revision 1.1.1.1 1998/03/07 02:25:47 wsanchez ! 38: * Import of OSF Mach kernel (~mburg) ! 39: * ! 40: * Revision 1.2.8.3 1995/01/06 19:50:41 devrcs ! 41: * Fix ri-osc CR880: Make kdb_trap() check exception frame type before ! 42: * trying to copy its contents. ! 43: * [1994/12/22 20:39:01 bolinger] ! 44: * ! 45: * mk6 CR668 - 1.3b26 merge ! 46: * Add MD file to define size of arrays ! 47: * [1994/10/14 03:42:39 dwm] ! 48: * ! 49: * Revision 1.2.8.2 1994/09/23 02:37:48 ezf ! 50: * change marker to not FREE ! 51: * [1994/09/22 21:40:21 ezf] ! 52: * ! 53: * Revision 1.2.8.1 1994/08/07 20:48:59 bolinger ! 54: * Merge up to colo_b7. ! 55: * [1994/08/01 21:01:28 bolinger] ! 56: * ! 57: * Revision 1.2.6.3 1994/06/25 03:47:11 dwm ! 58: * mk6 CR98 - include mach/machine/thread_state.h to ! 59: * get new MD THREAD_STATE_MAX ! 60: * [1994/06/24 21:54:50 dwm] ! 61: * ! 62: * Revision 1.2.6.2 1994/03/01 01:51:57 condict ! 63: * Add fields to i386_saved_state for copying in the user's syscall args. ! 64: * This is part of a performance improvement (see exception()). ! 65: * [1994/02/28 04:07:12 condict] ! 66: * ! 67: * Revision 1.2.6.1 1994/02/09 22:37:25 condict ! 68: * Exported i386_saved_state as a new flavor of state; this is the same ! 69: * struct used by kernel to save user state. Allows avoidance of state ! 70: * copying when doing short-circuited RPC to kernel-loaded servers. ! 71: * [1994/02/09 22:36:46 condict] ! 72: * ! 73: * Revision 1.2.2.2 1993/06/09 02:40:51 gm ! 74: * Added to OSF/1 R1.3 from NMK15.0. ! 75: * [1993/06/02 21:16:28 jeffc] ! 76: * ! 77: * Revision 1.2 1993/04/19 16:34:21 devrcs ! 78: * ansi C conformance changes ! 79: * [1993/02/02 18:56:17 david] ! 80: * ! 81: * Add syscall exception state. [[email protected]] ! 82: * [1992/12/23 13:06:03 david] ! 83: * ! 84: * Revision 1.1 1992/09/30 02:30:52 robert ! 85: * Initial revision ! 86: * ! 87: * $EndLog$ ! 88: */ ! 89: /* CMU_HIST */ ! 90: /* ! 91: * Revision 2.6.3.1 92/03/03 16:21:46 jeffreyh ! 92: * Changes from TRUNK ! 93: * [92/02/26 11:59:48 jeffreyh] ! 94: * ! 95: * Revision 2.7 92/01/03 20:20:19 dbg ! 96: * Add REGS_SEGS flavor to get and set the segment registers. ! 97: * Move fp_reg.h to mach/i386. ! 98: * [91/10/18 dbg] ! 99: * ! 100: * Revision 2.6 91/07/31 17:52:29 dbg ! 101: * Add V86 mode interrupt assist. ! 102: * [91/07/30 17:09:37 dbg] ! 103: * ! 104: * Revision 2.5 91/05/14 16:52:33 mrt ! 105: * Correcting copyright ! 106: * ! 107: * Revision 2.4 91/02/05 17:32:23 mrt ! 108: * Changed to new Mach copyright ! 109: * [91/02/01 17:10:12 mrt] ! 110: * ! 111: * Revision 2.3 91/01/08 17:33:44 rpd ! 112: * Two new flavors (from 2.5): ! 113: * #define i386_FLOAT_STATE 2 ! 114: * Hacked in not presently used, but someday... ! 115: * #define i386_ISA_PORT_MAP_STATE 3 ! 116: * Used ! 117: * [90/12/20 10:23:34 rvb] ! 118: * ! 119: * Revision 2.2 90/05/03 15:48:05 dbg ! 120: * Remove kernel-only definitions. ! 121: * [90/02/05 dbg] ! 122: * ! 123: * Revision 1.3 89/03/09 20:19:59 rpd ! 124: * More cleanup. ! 125: * ! 126: * Revision 1.2 89/02/26 13:01:07 gm0w ! 127: * Changes for cleanup. ! 128: * ! 129: * 24-Feb-89 Robert Baron (rvb) at Carnegie-Mellon University ! 130: * May need some work. ! 131: */ ! 132: /* CMU_ENDHIST */ ! 133: /* ! 134: * Mach Operating System ! 135: * Copyright (c) 1991,1990,1989 Carnegie Mellon University ! 136: * All Rights Reserved. ! 137: * ! 138: * Permission to use, copy, modify and distribute this software and its ! 139: * documentation is hereby granted, provided that both the copyright ! 140: * notice and this permission notice appear in all copies of the ! 141: * software, derivative works or modified versions, and any portions ! 142: * thereof, and that both notices appear in supporting documentation. ! 143: * ! 144: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" ! 145: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ! 146: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 147: * ! 148: * Carnegie Mellon requests users of this software to return to ! 149: * ! 150: * Software Distribution Coordinator or [email protected] ! 151: * School of Computer Science ! 152: * Carnegie Mellon University ! 153: * Pittsburgh PA 15213-3890 ! 154: * ! 155: * any improvements or extensions that they make and grant Carnegie Mellon ! 156: * the rights to redistribute these changes. ! 157: */ ! 158: /* ! 159: */ ! 160: /* ! 161: * File: thread_status.h ! 162: * Author: Avadis Tevanian, Jr. ! 163: * Date: 1985 ! 164: * ! 165: * This file contains the structure definitions for the thread ! 166: * state as applied to I386 processors. ! 167: */ ! 168: ! 169: #ifndef _MACH_I386_THREAD_STATUS_H_ ! 170: #define _MACH_I386_THREAD_STATUS_H_ ! 171: ! 172: #include <mach/i386/fp_reg.h> ! 173: #include <mach/i386/thread_state.h> ! 174: #include <architecture/i386/frame.h> /* FIXME */ ! 175: #include <architecture/i386/fpu.h> /* FIXME */ ! 176: /* ! 177: * i386_thread_state this is the structure that is exported ! 178: * to user threads for use in status/mutate ! 179: * calls. This structure should never ! 180: * change. ! 181: * ! 182: * i386_float_state exported to use threads for access to ! 183: * floating point registers. Try not to ! 184: * change this one, either. ! 185: * ! 186: * i386_isa_port_map_state exported to user threads to allow ! 187: * selective in/out operations ! 188: * ! 189: * i386_v86_assist_state ! 190: * ! 191: * thread_syscall_state ! 192: */ ! 193: ! 194: /* THREAD_STATE_FLAVOR_LIST 0 */ ! 195: #define i386_NEW_THREAD_STATE 1 /* used to be i386_THREAD_STATE */ ! 196: #define i386_FLOAT_STATE 2 ! 197: #define i386_ISA_PORT_MAP_STATE 3 ! 198: #define i386_V86_ASSIST_STATE 4 ! 199: #define i386_REGS_SEGS_STATE 5 ! 200: #define THREAD_SYSCALL_STATE 6 ! 201: #define THREAD_STATE_NONE 7 ! 202: #define i386_SAVED_STATE 8 ! 203: ! 204: /* ! 205: * This structure is used for both ! 206: * i386_THREAD_STATE and i386_REGS_SEGS_STATE. ! 207: */ ! 208: struct i386_new_thread_state { ! 209: unsigned int gs; ! 210: unsigned int fs; ! 211: unsigned int es; ! 212: unsigned int ds; ! 213: unsigned int edi; ! 214: unsigned int esi; ! 215: unsigned int ebp; ! 216: unsigned int esp; ! 217: unsigned int ebx; ! 218: unsigned int edx; ! 219: unsigned int ecx; ! 220: unsigned int eax; ! 221: unsigned int eip; ! 222: unsigned int cs; ! 223: unsigned int efl; ! 224: unsigned int uesp; ! 225: unsigned int ss; ! 226: }; ! 227: #define i386_NEW_THREAD_STATE_COUNT \ ! 228: (sizeof (struct i386_new_thread_state)/sizeof(unsigned int)) ! 229: ! 230: /* ! 231: * Subset of saved state stored by processor on kernel-to-kernel ! 232: * trap. (Used by ddb to examine state guaranteed to be present ! 233: * on all traps into debugger.) ! 234: */ ! 235: struct i386_saved_state_from_kernel { ! 236: unsigned int gs; ! 237: unsigned int fs; ! 238: unsigned int es; ! 239: unsigned int ds; ! 240: unsigned int edi; ! 241: unsigned int esi; ! 242: unsigned int ebp; ! 243: unsigned int esp; /* kernel esp stored by pusha - ! 244: we save cr2 here later */ ! 245: unsigned int ebx; ! 246: unsigned int edx; ! 247: unsigned int ecx; ! 248: unsigned int eax; ! 249: unsigned int trapno; ! 250: unsigned int err; ! 251: unsigned int eip; ! 252: unsigned int cs; ! 253: unsigned int efl; ! 254: }; ! 255: ! 256: /* ! 257: * The format in which thread state is saved by Mach on this machine. This ! 258: * state flavor is most efficient for exception RPC's to kernel-loaded ! 259: * servers, because copying can be avoided: ! 260: */ ! 261: struct i386_saved_state { ! 262: unsigned int gs; ! 263: unsigned int fs; ! 264: unsigned int es; ! 265: unsigned int ds; ! 266: unsigned int edi; ! 267: unsigned int esi; ! 268: unsigned int ebp; ! 269: unsigned int esp; /* kernel esp stored by pusha - ! 270: we save cr2 here later */ ! 271: unsigned int ebx; ! 272: unsigned int edx; ! 273: unsigned int ecx; ! 274: unsigned int eax; ! 275: unsigned int trapno; ! 276: unsigned int err; ! 277: unsigned int eip; ! 278: unsigned int cs; ! 279: unsigned int efl; ! 280: unsigned int uesp; ! 281: unsigned int ss; ! 282: struct v86_segs { ! 283: unsigned int v86_es; /* virtual 8086 segment registers */ ! 284: unsigned int v86_ds; ! 285: unsigned int v86_fs; ! 286: unsigned int v86_gs; ! 287: } v86_segs; ! 288: #define i386_SAVED_ARGV_COUNT 7 ! 289: unsigned int argv_status; /* Boolean flag indicating whether or ! 290: * not Mach copied in the args */ ! 291: unsigned int argv[i386_SAVED_ARGV_COUNT]; ! 292: /* The return address, and the first several ! 293: * function call args from the stack, for ! 294: * efficient syscall exceptions */ ! 295: }; ! 296: #define i386_SAVED_STATE_COUNT (sizeof (struct i386_saved_state)/sizeof(unsigned int)) ! 297: #define i386_REGS_SEGS_STATE_COUNT i386_SAVED_STATE_COUNT ! 298: ! 299: /* ! 300: * Machine-independent way for servers and Mach's exception mechanism to ! 301: * choose the most efficient state flavor for exception RPC's: ! 302: */ ! 303: #define MACHINE_THREAD_STATE i386_SAVED_STATE ! 304: #define MACHINE_THREAD_STATE_COUNT i386_SAVED_STATE_COUNT ! 305: ! 306: /* ! 307: * Largest state on this machine: ! 308: * (be sure mach/machine/thread_state.h matches!) ! 309: */ ! 310: #define THREAD_MACHINE_STATE_MAX i386_SAVED_STATE_COUNT ! 311: ! 312: /* ! 313: * Floating point state. ! 314: * ! 315: * fpkind tells in what way floating point operations are supported. ! 316: * See the values for fp_kind in <mach/i386/fp_reg.h>. ! 317: * ! 318: * If the kind is FP_NO, then calls to set the state will fail, and ! 319: * thread_getstatus will return garbage for the rest of the state. ! 320: * If "initialized" is false, then the rest of the state is garbage. ! 321: * Clients can set "initialized" to false to force the coprocessor to ! 322: * be reset. ! 323: * "exc_status" is non-zero if the thread has noticed (but not ! 324: * proceeded from) a coprocessor exception. It contains the status ! 325: * word with the exception bits set. The status word in "fp_status" ! 326: * will have the exception bits turned off. If an exception bit in ! 327: * "fp_status" is turned on, then "exc_status" should be zero. This ! 328: * happens when the coprocessor exception is noticed after the system ! 329: * has context switched to some other thread. ! 330: * ! 331: * If kind is FP_387, then "state" is a i387_state. Other kinds might ! 332: * also use i387_state, but somebody will have to verify it (XXX). ! 333: * Note that the registers are ordered from top-of-stack down, not ! 334: * according to physical register number. ! 335: */ ! 336: ! 337: #define FP_STATE_BYTES \ ! 338: (sizeof (struct i386_fp_save) + sizeof (struct i386_fp_regs)) ! 339: ! 340: struct i386_float_state { ! 341: int fpkind; /* FP_NO..FP_387 (readonly) */ ! 342: int initialized; ! 343: unsigned char hw_state[FP_STATE_BYTES]; /* actual "hardware" state */ ! 344: int exc_status; /* exception status (readonly) */ ! 345: }; ! 346: #define i386_FLOAT_STATE_COUNT \ ! 347: (sizeof(struct i386_float_state)/sizeof(unsigned int)) ! 348: ! 349: ! 350: #define PORT_MAP_BITS 0x400 ! 351: struct i386_isa_port_map_state { ! 352: unsigned char pm[PORT_MAP_BITS>>3]; ! 353: }; ! 354: ! 355: #define i386_ISA_PORT_MAP_STATE_COUNT \ ! 356: (sizeof(struct i386_isa_port_map_state)/sizeof(unsigned int)) ! 357: ! 358: /* ! 359: * V8086 assist supplies a pointer to an interrupt ! 360: * descriptor table in task space. ! 361: */ ! 362: struct i386_v86_assist_state { ! 363: unsigned int int_table; /* interrupt table address */ ! 364: int int_count; /* interrupt table size */ ! 365: }; ! 366: ! 367: struct v86_interrupt_table { ! 368: unsigned int count; /* count of pending interrupts */ ! 369: unsigned short mask; /* ignore this interrupt if true */ ! 370: unsigned short vec; /* vector to take */ ! 371: }; ! 372: ! 373: #define i386_V86_ASSIST_STATE_COUNT \ ! 374: (sizeof(struct i386_v86_assist_state)/sizeof(unsigned int)) ! 375: ! 376: struct thread_syscall_state { ! 377: unsigned eax; ! 378: unsigned edx; ! 379: unsigned efl; ! 380: unsigned eip; ! 381: unsigned esp; ! 382: }; ! 383: ! 384: #define i386_THREAD_SYSCALL_STATE_COUNT \ ! 385: (sizeof(struct thread_syscall_state) / sizeof(unsigned int)) ! 386: ! 387: /* ! 388: * Main thread state consists of ! 389: * general registers, segment registers, ! 390: * eip and eflags. ! 391: */ ! 392: ! 393: #define i386_THREAD_STATE -1 ! 394: ! 395: typedef struct { ! 396: unsigned int eax; ! 397: unsigned int ebx; ! 398: unsigned int ecx; ! 399: unsigned int edx; ! 400: unsigned int edi; ! 401: unsigned int esi; ! 402: unsigned int ebp; ! 403: unsigned int esp; ! 404: unsigned int ss; ! 405: unsigned int eflags; ! 406: unsigned int eip; ! 407: unsigned int cs; ! 408: unsigned int ds; ! 409: unsigned int es; ! 410: unsigned int fs; ! 411: unsigned int gs; ! 412: } i386_thread_state_t; ! 413: ! 414: #define i386_THREAD_STATE_COUNT \ ! 415: ( sizeof (i386_thread_state_t) / sizeof (int) ) ! 416: ! 417: /* ! 418: * Default segment register values. ! 419: */ ! 420: ! 421: #define USER_CODE_SELECTOR 0x0017 ! 422: #define USER_DATA_SELECTOR 0x001f ! 423: #define KERN_CODE_SELECTOR 0x0008 ! 424: #define KERN_DATA_SELECTOR 0x0010 ! 425: ! 426: /* ! 427: * Thread floating point state ! 428: * includes FPU environment as ! 429: * well as the register stack. ! 430: */ ! 431: ! 432: #define i386_THREAD_FPSTATE -2 ! 433: ! 434: typedef struct { ! 435: fp_env_t environ; ! 436: fp_stack_t stack; ! 437: } i386_thread_fpstate_t; ! 438: ! 439: #define i386_THREAD_FPSTATE_COUNT \ ! 440: ( sizeof (i386_thread_fpstate_t) / sizeof (int) ) ! 441: ! 442: /* ! 443: * Extra state that may be ! 444: * useful to exception handlers. ! 445: */ ! 446: ! 447: #define i386_THREAD_EXCEPTSTATE -3 ! 448: ! 449: typedef struct { ! 450: unsigned int trapno; ! 451: err_code_t err; ! 452: } i386_thread_exceptstate_t; ! 453: ! 454: #define i386_THREAD_EXCEPTSTATE_COUNT \ ! 455: ( sizeof (i386_thread_exceptstate_t) / sizeof (int) ) ! 456: ! 457: /* ! 458: * Per-thread variable used ! 459: * to store 'self' id for cthreads. ! 460: */ ! 461: ! 462: #define i386_THREAD_CTHREADSTATE -4 ! 463: ! 464: typedef struct { ! 465: unsigned int self; ! 466: } i386_thread_cthreadstate_t; ! 467: ! 468: #define i386_THREAD_CTHREADSTATE_COUNT \ ! 469: ( sizeof (i386_thread_cthreadstate_t) / sizeof (int) ) ! 470: ! 471: #endif /* _MACH_I386_THREAD_STATUS_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.