|
|
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) 1993 NeXT Computer, Inc. ! 27: * ! 28: * PC support exception handling. ! 29: * ! 30: * HISTORY ! 31: * ! 32: * 22 Mar 1993 ? at NeXT ! 33: * Created. ! 34: */ ! 35: ! 36: #import <mach/mach_types.h> ! 37: #import <mach/exception.h> ! 38: ! 39: #import <machdep/i386/trap.h> ! 40: #import <machdep/i386/cpu_inline.h> ! 41: #import <machdep/i386/err_inline.h> ! 42: ! 43: #import "PCprivate.h" ! 44: ! 45: static void PCpagefaultContinue(void); ! 46: ! 47: boolean_t ! 48: PCexception( ! 49: thread_t thread, ! 50: thread_saved_state_t *state ! 51: ) ! 52: { ! 53: PCcontext_t context = threadPCContext(thread); ! 54: ! 55: if (!context->running) ! 56: return (FALSE); ! 57: ! 58: if (state->trapno == T_PAGE_FAULT) { ! 59: kern_return_t result; ! 60: vm_offset_t va; ! 61: ! 62: va = cr2(); ! 63: result = vm_fault(thread->task->map, trunc_page(va), ! 64: state->frame.err.pgfault.wrtflt? ! 65: VM_PROT_READ | VM_PROT_WRITE: ! 66: VM_PROT_READ, ! 67: FALSE, 0); ! 68: if (result != KERN_SUCCESS) { ! 69: context->trapNum = state->trapno; ! 70: context->errCode = err_to_error_code(state->frame.err); ! 71: context->exceptionResult = result; ! 72: ! 73: exception_with_continuation( ! 74: EXC_BAD_ACCESS, result, va, PCpagefaultContinue); ! 75: /* NOTREACHED */ ! 76: ! 77: if (context->exceptionResult != KERN_SUCCESS) { ! 78: context->callHandler = PC_HANDLE_FAULT; ! 79: ! 80: PCcallMonitor(thread, state); ! 81: /* NOTREACHED */ ! 82: } ! 83: } ! 84: } ! 85: else if (state->trapno == T_NOEXTENSION && !context->EM_bit) ! 86: fp_noextension(state); ! 87: else if (state->frame.eflags & EFL_VM) { ! 88: if (!PCemulateREAL(thread, state)) ! 89: return (FALSE); ! 90: } ! 91: else { ! 92: if (!PCemulatePROT(thread, state)) ! 93: return (FALSE); ! 94: } ! 95: ! 96: if (context->callHandler == PC_HANDLE_NONE && ! 97: (context->pendingCallbacks || PCtimersPending(context))) { ! 98: PCcallMonitor(thread, state); ! 99: /* NOTREACHED */ ! 100: } ! 101: ! 102: thread_exception_return(); ! 103: /* NOTREACHED */ ! 104: } ! 105: ! 106: static ! 107: void ! 108: PCpagefaultContinue(void) ! 109: { ! 110: thread_t thread = current_thread(); ! 111: thread_saved_state_t *state = USER_REGS(thread); ! 112: PCcontext_t context = threadPCContext(thread); ! 113: ! 114: if (context->exceptionResult != KERN_SUCCESS) { ! 115: context->callHandler = PC_HANDLE_FAULT; ! 116: ! 117: PCcallMonitor(thread, state); ! 118: /* NOTREACHED */ ! 119: } ! 120: ! 121: if (context->callHandler == PC_HANDLE_NONE && ! 122: (context->pendingCallbacks || PCtimersPending(context))) { ! 123: PCcallMonitor(thread, state); ! 124: /* NOTREACHED */ ! 125: } ! 126: ! 127: thread_exception_return(); ! 128: /* NOTREACHED */ ! 129: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.