123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- /*++
- Copyright (c) 2012 Minoca Corp.
- This file is licensed under the terms of the GNU General Public License
- version 3. Alternative licensing terms are available. Contact
- info@minocacorp.com for details. See the LICENSE file at the root of this
- project for complete licensing information.
- Module Name:
- crash.c
- Abstract:
- This module implements support for the unfortunate event of a fatal system
- error.
- Author:
- Evan Green 25-Sep-2012
- Environment:
- Kernel
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <minoca/kernel/kernel.h>
- #include <minoca/kernel/kdebug.h>
- #include "kep.h"
- //
- // ---------------------------------------------------------------- Definitions
- //
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // ----------------------------------------------- Internal Function Prototypes
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // ------------------------------------------------------------------ Functions
- //
- KERNEL_API
- VOID
- KeCrashSystemEx (
- ULONG CrashCode,
- PCSTR CrashCodeString,
- ULONGLONG Parameter1,
- ULONGLONG Parameter2,
- ULONGLONG Parameter3,
- ULONGLONG Parameter4
- )
- /*++
- Routine Description:
- This routine officially takes the system down after a fatal system error
- has occurred. This function does not return.
- Arguments:
- CrashCode - Supplies the reason for the system crash.
- CrashCodeString - Supplies the string corresponding to the given crash
- code. This parameter is generated by the macro, and should not be
- filled in directly.
- Parameter1 - Supplies an optional parameter regarding the crash.
- Parameter2 - Supplies an optional parameter regarding the crash.
- Parameter3 - Supplies an optional parameter regarding the crash.
- Parameter4 - Supplies an optional parameter regarding the crash.
- Return Value:
- None. This function does not return.
- --*/
- {
- KSTATUS Status;
- KeRaiseRunLevel(RunLevelHigh);
- //
- // TODO: Freeze all processors before writing crash dump.
- //
- ArDisableInterrupts();
- RtlDebugPrint("\n\n"
- "**********************************************************"
- "**********************\n"
- "* "
- " *\n"
- "* Fatal System Error "
- " *\n"
- "* "
- " *\n"
- "**********************************************************"
- "**********************\n\n"
- "Error Code: %s (0x%x)\n"
- "Parameter1: 0x%08I64x\n"
- "Parameter2: 0x%08I64x\n"
- "Parameter3: 0x%08I64x\n"
- "Parameter4: 0x%08I64x\n\n",
- CrashCodeString,
- CrashCode,
- Parameter1,
- Parameter2,
- Parameter3,
- Parameter4);
- KdBreak();
- //
- // Proceed to attempt writing a crash dump to disk. If this succeeds then
- // reset the system.
- //
- Status = KepWriteCrashDump(CrashCode,
- Parameter1,
- Parameter2,
- Parameter3,
- Parameter4);
- //
- // TODO: Remove the forced failure when crash dumps are finished.
- //
- Status = STATUS_UNSUCCESSFUL;
- if (KSUCCESS(Status)) {
- KdDisconnect();
- Status = HlResetSystem(SystemResetWarm, NULL, 0);
- KdConnect();
- RtlDebugPrint("System reset unsuccessful: %d\n", Status);
- }
- //
- // Spin forever.
- //
- while (TRUE) {
- KdBreak();
- }
- }
- //
- // --------------------------------------------------------- Internal Functions
- //
|