|
|
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: * Handling of double faults. ! 29: * ! 30: * HISTORY ! 31: * ! 32: * 12 May 1993 ? at NeXT ! 33: * Created. ! 34: */ ! 35: ! 36: #import <mach/mach_types.h> ! 37: ! 38: #import <architecture/i386/table.h> ! 39: ! 40: #import <machdep/i386/trap.h> ! 41: #import <machdep/i386/idt.h> ! 42: #import <machdep/i386/desc_inline.h> ! 43: #import <machdep/i386/table_inline.h> ! 44: ! 45: tss_t dbf_tss; ! 46: thread_saved_state_t dbf_state; ! 47: #define DBF_STACK_SIZE 1024 ! 48: unsigned char dbf_stack[DBF_STACK_SIZE]; ! 49: ! 50: void dbf_handler_(void); ! 51: ! 52: void ! 53: dbf_init(void) ! 54: { ! 55: tss_t *tss = &dbf_tss; ! 56: ! 57: tss->cr3 = pmap_kernel()->cr3; ! 58: tss->esp0 = (unsigned int)&dbf_stack[DBF_STACK_SIZE]; ! 59: tss->ss0 = KDS_SEL; ! 60: tss->esp = tss->ebp = tss->esp0; ! 61: tss->ss = KDS_SEL; ! 62: tss->eip = (unsigned int)dbf_handler_; ! 63: tss->cs = KCS_SEL; ! 64: tss->ds = KDS_SEL; ! 65: tss->es = KDS_SEL; ! 66: tss->io_bmap = TSS_SIZE(0); ! 67: ! 68: map_tss( ! 69: sel_to_gdt_entry(DBLFLT_SEL), ! 70: (vm_offset_t)&dbf_tss + KERNEL_LINEAR_BASE, ! 71: (vm_size_t)TSS_SIZE(0)); ! 72: ! 73: make_task_gate( ! 74: (task_gate_t *)&idt[T_DOUBLE_FAULT], ! 75: DBLFLT_SEL, 0, KERN_PRIV); ! 76: } ! 77: ! 78: void ! 79: dbf_handler( ! 80: err_code_t err ! 81: ) ! 82: { ! 83: thread_saved_state_t *state = &dbf_state; ! 84: tss_t *tss = current_thread()->pcb->tss; ! 85: ! 86: while (TRUE) { ! 87: state->trapno = T_DOUBLE_FAULT; ! 88: ! 89: state->frame.err = err; ! 90: state->frame.eip = tss->eip; ! 91: state->frame.cs = tss->cs; ! 92: state->frame.eflags = tss->eflags; ! 93: ! 94: state->regs.eax = tss->eax; ! 95: state->regs.ecx = tss->ecx; ! 96: state->regs.edx = tss->edx; ! 97: state->regs.ebx = tss->ebx; ! 98: state->regs.ebp = tss->ebp; ! 99: state->regs.esi = tss->esi; ! 100: state->regs.edi = tss->edi; ! 101: state->regs.ds = tss->ds; ! 102: state->regs.es = tss->es; ! 103: state->regs.fs = tss->fs; ! 104: state->regs.gs = tss->gs; ! 105: ! 106: kernel_trap(state); ! 107: } ! 108: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.