unsafe fn gp_handler(a: &ExceptionArguments) {
    let desc = &EXCEPTIONS[a.vector as usize];
    sprint!("\n[IRQ] GENERAL PROTECTION FAULT: ");
    sprintln!("From {}", desc.source);

    // Enable user-space access
    x86::current::rflags::stac();

    if a.exception > 0 {
        sprintln!(
            "Error value: {:?}",
            SegmentSelector::from_raw(a.exception as u16)
        );
    } else {
        sprintln!("No error!");
    }

    // Print the RIP that triggered the fault:
    //use crate::arch::kcb;
    sprint!("Instruction Pointer: {:#x}", a.rip);
    /*kcb::try_get_kcb::<Arch86Kcb>().map(|k| {
        sprintln!(
            " (in ELF: {:#x})",
            a.rip - k.kernel_args().kernel_elf_offset.as_u64()
        )
    });*/

    sprintln!("{:?}", a);
    let kcb = get_kcb();
    sprintln!("Register State:\n{:?}", kcb.arch.save_area);

    for i in 0..12 {
        let ptr = (a.rsp as *const u64).offset(i);
        sprintln!("stack[{}] = {:#x}", i, *ptr);
    }

    if !kcb.in_panic_mode {
        kcb.arch.save_area.as_ref().map(|sa| {
            backtrace_from(sa.rbp, sa.rsp, sa.rip);
        });
    }

    debug::shutdown(ExitReason::GeneralProtectionFault);
}
/// Handler for a general protection exception.
///
/// TODO: Right now we terminate kernel.
/// Should abort process and resume.
Handler for a general protection exception.
TODO: Right now we terminate kernel.
Should abort process and resume.
Handler for a general protection exception . TODO : Right now we terminate kernel . Should abort process and resume .
unsafe fn gp_handler(a: &ExceptionArguments) {
    let desc = &EXCEPTIONS[a.vector as usize];
    sprint!("\n[IRQ] GENERAL PROTECTION FAULT: ");
    sprintln!("From {}", desc.source);
    // Enable user-space access
    x86::current::rflags::stac();
    if a.exception > 0 {
        sprintln!(
            "Error value: {:?}",
            SegmentSelector::from_raw(a.exception as u16)
        );
    } else {
        sprintln!("No error!");
    }
    // Print the RIP that triggered the fault:
    //use crate::arch::kcb;
    sprint!("Instruction Pointer: {:#x}", a.rip);
    /*kcb::try_get_kcb::<Arch86Kcb>().map(|k| {
        sprintln!(
            " (in ELF: {:#x})",
            a.rip - k.kernel_args().kernel_elf_offset.as_u64()
        )
    });*/
    sprintln!("{:?}", a);
    let kcb = get_kcb();
    sprintln!("Register State:\n{:?}", kcb.arch.save_area);
    for i in 0..12 {
        let ptr = (a.rsp as *const u64).offset(i);
        sprintln!("stack[{}] = {:#x}", i, *ptr);
    }
    if !kcb.in_panic_mode {
        kcb.arch.save_area.as_ref().map(|sa| {
            backtrace_from(sa.rbp, sa.rsp, sa.rip);
        });
    }
    debug::shutdown(ExitReason::GeneralProtectionFault);
}
unsafe fn gp_handler ( a : & ExceptionArguments ) { let desc = & EXCEPTIONS [ a . vector as usize ] ; sprint ! ( " \n " ) ; sprintln ! ( " " desc source ) ; // Enable user-space access x86 :: current :: rflags :: stac ( ) ; if a . exception > 0 { sprintln ! ( " " SegmentSelector from_raw ( a exception as u16 ) ) ; } else { sprintln ! ( " " ) ; } // Print the RIP that triggered the fault: //use crate::arch::kcb; sprint ! ( " " a rip ) ; /*kcb::try_get_kcb::<Arch86Kcb>().map(|k| {
        sprintln!(
            " (in ELF: {:#x})",
            a.rip - k.kernel_args().kernel_elf_offset.as_u64()
        )
    });*/ sprintln ! ( " " a ) ; let kcb = get_kcb ( ) ; sprintln ! ( " \n " kcb arch save_area ) ; for i in 0 .. 12 { let ptr = ( a . rsp as * const u64 ) . offset ( i ) ; sprintln ! ( " " i ptr ) ; } if ! kcb . in_panic_mode { kcb . arch . save_area . as_ref ( ) . map ( | sa | { backtrace_from ( sa . rbp , sa . rsp , sa . rip ) ; } ) ; } debug :: shutdown ( ExitReason :: GeneralProtectionFault ) ; }
Handler for a general protection exception.
Handler for a general protection exception .
a
&ExceptionArguments
a
&ExceptionArguments