BOOLEAN PVPanicRegisterBugCheckCallback(IN PVOID PortAddress)
{
	KeInitializeCallbackRecord(&CallbackRecord);

	return KeRegisterBugCheckCallback(&CallbackRecord, PVPanicOnBugCheck,
		(PVOID)PortAddress, sizeof(PVOID), (PUCHAR)("PVPanic"));
}
Exemple #2
0
NTSTATUS
DumpInitialize(
    VOID
    )
{
    UCHAR       Version;
    NTSTATUS    status;

    Version = READ_PORT_UCHAR(PortEB);

    if (Version != DUMP_VERSION)
        goto done;

    KeInitializeCallbackRecord(&DumpBugCheckReasonCallbackRecord);

    status = STATUS_UNSUCCESSFUL;
    if (!KeRegisterBugCheckReasonCallback(&DumpBugCheckReasonCallbackRecord,
                                          DumpBugCheckReasonCallback,
                                          KbCallbackDumpIo,
                                          (PUCHAR)__MODULE__))
        goto fail1;

    Info("callback registered\n");

done:
    return STATUS_SUCCESS;

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}
Exemple #3
0
NTSTATUS
DebugInitialize(
    IN  PXENBUS_FDO                     Fdo,
    OUT PXENBUS_DEBUG_INTERFACE         Interface
    )
{
    PXENBUS_DEBUG_CONTEXT               Context;
    NTSTATUS                            status;

    UNREFERENCED_PARAMETER(Fdo);

    Trace("====>\n");

    Context = __DebugAllocate(sizeof (XENBUS_DEBUG_CONTEXT));

    status = STATUS_NO_MEMORY;
    if (Context == NULL)
        goto fail1;

    InitializeListHead(&Context->List);
    InitializeHighLock(&Context->Lock);

    KeInitializeCallbackRecord(&Context->BugCheckCallbackRecord);

    status = STATUS_UNSUCCESSFUL;
    if (!KeRegisterBugCheckCallback(&Context->BugCheckCallbackRecord,
                                    DebugBugCheckCallback,
                                    Context,
                                    sizeof (XENBUS_DEBUG_CONTEXT),
                                    (PUCHAR)__MODULE__))
        goto fail2;

    Interface->Context = Context;
    Interface->Operations = &Operations;

    Trace("<====\n");

    return STATUS_SUCCESS;

fail2:
    Error("fail2\n");

    RtlZeroMemory(&Context->Lock, sizeof (KSPIN_LOCK));
    RtlZeroMemory(&Context->List, sizeof (LIST_ENTRY));

fail1:
    Error("fail1 (%08x)\n", status);

    return status;
}
Exemple #4
0
VOID
NdisMRegisterAdapterShutdownHandler(
	IN	NDIS_HANDLE				MiniportHandle,
	IN	PVOID					ShutdownContext,
	IN	ADAPTER_SHUTDOWN_HANDLER ShutdownHandler
	)
/*++

Routine Description:

	Deregisters an NDIS adapter.

Arguments:

	MiniportHandle - The miniport.

	ShutdownHandler - The Handler for the Adapter, to be called on shutdown.

Return Value:

	none.

--*/
{
	PNDIS_MINIPORT_BLOCK Miniport = (PNDIS_MINIPORT_BLOCK) MiniportHandle;
	PNDIS_WRAPPER_CONTEXT WrapperContext = Miniport->WrapperContext;

	if (WrapperContext->ShutdownHandler == NULL)
	{
		//
		// Store information
		//

		WrapperContext->ShutdownHandler = ShutdownHandler;
		WrapperContext->ShutdownContext = ShutdownContext;

		//
		// Register our shutdown handler for a bugcheck.  (Note that we are
		// already registered for shutdown notification.)
		//

		KeInitializeCallbackRecord(&WrapperContext->BugcheckCallbackRecord);

		KeRegisterBugCheckCallback(&WrapperContext->BugcheckCallbackRecord,	// callback record.
								   ndisBugcheckHandler,						// callback routine.
								   WrapperContext,							// free form buffer.
								   sizeof(NDIS_WRAPPER_CONTEXT),			// buffer size.
								   "Ndis miniport");						// component id.
	}
}
Exemple #5
0
VOID WvlDebugModuleInit(void) {
    KeInitializeSpinLock(&WvlDebugLock_);
    #if WVL_M_DEBUG
    KeInitializeCallbackRecord(&WvlDebugBugCheckRecord_);
    WvlDebugBugCheckRegistered_ = KeRegisterBugCheckCallback(
        &WvlDebugBugCheckRecord_,
        WvlDebugBugCheck_,
        &WvlDebugLastMsg_,
        sizeof WvlDebugLastMsg_,
        WVL_M_LIT
      );
    if (!WvlDebugBugCheckRegistered_)
      DBG("Couldn't register bug-check callback!\n");
    #endif
    return;
  }
void ParaNdis_DebugInitialize(PVOID DriverObject,PVOID RegistryPath)
{
	NDIS_STRING usRegister, usDeregister, usPrint;
	PVOID pr, pd;
	BOOLEAN res;
	WPP_INIT_TRACING(DriverObject, RegistryPath);

	NdisAllocateSpinLock(&CrashLock);
	KeInitializeCallbackRecord(&CallbackRecord);
	ParaNdis_PrepareBugCheckData();
	NdisInitUnicodeString(&usPrint, L"vDbgPrintEx");
	NdisInitUnicodeString(&usRegister, L"KeRegisterBugCheckReasonCallback");
	NdisInitUnicodeString(&usDeregister, L"KeDeregisterBugCheckReasonCallback");
	pd = MmGetSystemRoutineAddress(&usPrint);
	if (pd) PrintProcedure = (vDbgPrintExType)pd;
	pr = MmGetSystemRoutineAddress(&usRegister);
	pd = MmGetSystemRoutineAddress(&usDeregister);
	if (pr && pd)
	{
		BugCheckRegisterCallback = (KeRegisterBugCheckReasonCallbackType)pr;
		BugCheckDeregisterCallback = (KeDeregisterBugCheckReasonCallbackType)pd;
	}
	res = BugCheckRegisterCallback(&CallbackRecord, ParaNdis_OnBugCheck, KbCallbackSecondaryDumpData, "NetKvm");
	DPrintf(0, ("[%s] Crash callback %sregistered", __FUNCTION__, res ? "" : "NOT "));

#ifdef OVERRIDE_DEBUG_BREAK
	if (sizeof(PVOID) == sizeof(ULONG))
	{
		UCHAR replace[5] = {0xe9,0,0,0,0};
		ULONG replacement;
		NDIS_STRING usDbgBreakPointName;
		NdisInitUnicodeString(&usDbgBreakPointName, L"DbgBreakPoint");
		pDbgBreakPoint = (PUCHAR)MmGetSystemRoutineAddress(&usDbgBreakPointName);
		if (pDbgBreakPoint)
		{
			DPrintf(0, ("Replacing original BP handler at %p", pDbgBreakPoint));
			replacement = RtlPointerToOffset(pDbgBreakPoint + 5, AnotherDbgBreak);
			RtlCopyMemory(replace + 1, &replacement, sizeof(replacement));
			RtlCopyMemory(DbgBreakPointChunk, pDbgBreakPoint, sizeof(DbgBreakPointChunk));
			RtlCopyMemory(pDbgBreakPoint, replace, sizeof(replace));
		}
	}
#endif
}
void ParaNdis_DebugInitialize()
{
    NDIS_STRING usRegister, usDeregister, usPrint;
    PVOID pr, pd;
    BOOLEAN res;

    NdisAllocateSpinLock(&CrashLock);
    KeInitializeCallbackRecord(&CallbackRecord);
    ParaNdis_PrepareBugCheckData();
    NdisInitUnicodeString(&usPrint, L"vDbgPrintEx");
    NdisInitUnicodeString(&usRegister, L"KeRegisterBugCheckReasonCallback");
    NdisInitUnicodeString(&usDeregister, L"KeDeregisterBugCheckReasonCallback");
    pd = MmGetSystemRoutineAddress(&usPrint);
    if (pd) PrintProcedure = (vDbgPrintExType)pd;
    pr = MmGetSystemRoutineAddress(&usRegister);
    pd = MmGetSystemRoutineAddress(&usDeregister);
    if (pr && pd)
    {
        BugCheckRegisterCallback = (KeRegisterBugCheckReasonCallbackType)pr;
        BugCheckDeregisterCallback = (KeDeregisterBugCheckReasonCallbackType)pd;
    }
    res = BugCheckRegisterCallback(&CallbackRecord, ParaNdis_OnBugCheck, KbCallbackSecondaryDumpData, (const PUCHAR)"NetKvm");
    DPrintf(0, ("[%s] Crash callback %sregistered\n", __FUNCTION__, res ? "" : "NOT "));
}
VOID
FxInitializeBugCheckDriverInfo()
{
    NTSTATUS                                 status;
    UNICODE_STRING                           funcName;
    PKBUGCHECK_REASON_CALLBACK_RECORD        callbackRecord;
    PFN_KE_REGISTER_BUGCHECK_REASON_CALLBACK funcPtr;
    SIZE_T                                   arraySize;
    ULONG                                    arrayCount;
    

    callbackRecord = &FxLibraryGlobals.BugCheckCallbackRecord;
    RtlZeroMemory(callbackRecord, sizeof(KBUGCHECK_REASON_CALLBACK_RECORD));

    FxLibraryGlobals.BugCheckDriverInfoCount = 0;
    FxLibraryGlobals.BugCheckDriverInfoIndex = 0;
    FxLibraryGlobals.BugCheckDriverInfo = NULL;











    // The KeRegisterBugCheckReasonCallback exists for xp sp1 and above. So
    // check whether this function is defined on the current OS and register
    // for the bugcheck callback only if this function is defined.
    //
    RtlInitUnicodeString(&funcName, L"KeRegisterBugCheckReasonCallback");
    funcPtr = (PFN_KE_REGISTER_BUGCHECK_REASON_CALLBACK)
        MmGetSystemRoutineAddress(&funcName);

    if (NULL == funcPtr) {
        goto Done;
    }

    arraySize = sizeof(FX_DUMP_DRIVER_INFO_ENTRY) * FX_DUMP_DRIVER_INFO_INCREMENT;
    arrayCount = FX_DUMP_DRIVER_INFO_INCREMENT;

    FxLibraryGlobals.BugCheckDriverInfo = 
        (PFX_DUMP_DRIVER_INFO_ENTRY)MxMemory::MxAllocatePoolWithTag(
                                    NonPagedPool,
                                    arraySize,
                                    FX_TAG);
    
    if (NULL == FxLibraryGlobals.BugCheckDriverInfo) {
        goto Done;
    }

    FxLibraryGlobals.BugCheckDriverInfoCount = arrayCount;
    
    //
    // Init first entry for the framework.
    //
    FxLibraryGlobals.BugCheckDriverInfo[0].FxDriverGlobals = NULL;
    FxLibraryGlobals.BugCheckDriverInfo[0].Version.Major = __WDF_MAJOR_VERSION;
    FxLibraryGlobals.BugCheckDriverInfo[0].Version.Minor = __WDF_MINOR_VERSION;
    FxLibraryGlobals.BugCheckDriverInfo[0].Version.Build = __WDF_BUILD_NUMBER;
    
    status = RtlStringCbCopyA(
                    FxLibraryGlobals.BugCheckDriverInfo[0].DriverName,
                    sizeof(FxLibraryGlobals.BugCheckDriverInfo[0].DriverName),
                    WdfLdrType);
    
    if (!NT_SUCCESS(status)) {
        ASSERT(FALSE);
        FxLibraryGlobals.BugCheckDriverInfo[0].DriverName[0] = '\0';     
    }

    FxLibraryGlobals.BugCheckDriverInfoIndex++;

    //
    // Initialize the callback record.
    //
    KeInitializeCallbackRecord(callbackRecord);

    //
    // Register the bugcheck callback.
    //
    funcPtr(callbackRecord,
            FxpLibraryBugCheckCallback,
            KbCallbackSecondaryDumpData,
            (PUCHAR)WdfLdrType);

    ASSERT(callbackRecord->CallbackRoutine != NULL);

Done:;
}
VOID
FxRegisterBugCheckCallback(
    __inout PFX_DRIVER_GLOBALS FxDriverGlobals,
    __in    PDRIVER_OBJECT DriverObject
    )
{
    UNICODE_STRING funcName;
    PKBUGCHECK_REASON_CALLBACK_RECORD callbackRecord;
    PFN_KE_REGISTER_BUGCHECK_REASON_CALLBACK funcPtr;
    BOOLEAN enableDriverTracking;

    //
    // If any problem during this setup, disable driver tracking.
    //
    enableDriverTracking = FxDriverGlobals->FxTrackDriverForMiniDumpLog;
    FxDriverGlobals->FxTrackDriverForMiniDumpLog = FALSE;

    //
    // Zero out callback record.
    //
    callbackRecord = &FxDriverGlobals->BugCheckCallbackRecord;
    RtlZeroMemory(callbackRecord, sizeof(KBUGCHECK_REASON_CALLBACK_RECORD));

    //
    // Get the Image base address and size before registering the bugcheck
    // callbacks. If the image base address and size cannot be computed,
    // then the bugcheck callbacks depend on these values being properly
    // set.
    //
    FxDriverGlobals->ImageAddress = NULL;
    FxDriverGlobals->ImageSize = 0;

    if (!NT_SUCCESS(FxpGetImageBase(DriverObject,
                                   &FxDriverGlobals->ImageAddress,
                                   &FxDriverGlobals->ImageSize))) {
        goto Done;
    }











    // The KeRegisterBugCheckReasonCallback exists for xp sp1 and above. So
    // check whether this function is defined on the current OS and register
    // for the bugcheck callback only if this function is defined.
    //
    RtlInitUnicodeString(&funcName, L"KeRegisterBugCheckReasonCallback");
    funcPtr = (PFN_KE_REGISTER_BUGCHECK_REASON_CALLBACK)
        MmGetSystemRoutineAddress(&funcName);

    if (NULL == funcPtr) {
        goto Done;
    }

    //
    // Register this driver with driver tracker.
    //
    if (enableDriverTracking) {
        if (NT_SUCCESS(FxLibraryGlobals.DriverTracker.Register(
                            FxDriverGlobals))) {
            FxDriverGlobals->FxTrackDriverForMiniDumpLog = TRUE;
        }
    }
    
    //
    // Initialize the callback record.
    //
    KeInitializeCallbackRecord(callbackRecord);

    //
    // Register the bugcheck callback.
    //
    funcPtr(callbackRecord,
            FxpBugCheckCallback,
            KbCallbackSecondaryDumpData,
            (PUCHAR)FxDriverGlobals->Public.DriverName);

    ASSERT(callbackRecord->CallbackRoutine != NULL);

Done:;
}
Exemple #10
0
BOOLEAN
HalInitSystem (
    IN ULONG Phase,
    IN PLOADER_PARAMETER_BLOCK LoaderBlock
    )

/*++

Routine Description:

    This function initializes the Hardware Architecture Layer (HAL) for a
    MIPS R3000 or R4000 system.

Arguments:

    Phase - Supplies the initialization phase (zero or one).

    LoaderBlock - Supplies a pointer to a loader parameter block.

Return Value:

    A value of TRUE is returned is the initialization was successfully
    complete. Otherwise a value of FALSE is returend.

--*/

{

    ULONG FailedAddress;
    PKPRCB Prcb;
    PHYSICAL_ADDRESS PhysicalAddress;
    PHYSICAL_ADDRESS ZeroAddress;
    ULONG AddressSpace;

    //
    // Initialize the HAL components based on the phase of initialization
    // and the processor number.
    //

    Prcb = PCR->Prcb;
    PCR->DataBusError = HalpBusError;
    PCR->InstructionBusError = HalpBusError;
    if ((Phase == 0) || (Prcb->Number != 0)) {

        //
        // Phase 0 initialization.
        //
        // N.B. Phase 0 initialization is executed on all processors.
        //
        // Verify that the processor block major version number conform
        // to the system that is being loaded.
        //

        if (Prcb->MajorVersion != PRCB_MAJOR_VERSION) {
            KeBugCheck(MISMATCHED_HAL);
        }

        //
        // Map the fixed TB entries.
        //

        HalpMapFixedTbEntries();

        //
        // If processor 0 is being initialized, then initialize various
        // variables, spin locks, and the display adapter.
        //

        if (Prcb->Number == 0) {

            //
            // Set the number of process id's and TB entries.
            //

            **((PULONG *)(&KeNumberProcessIds)) = 256;
            **((PULONG *)(&KeNumberTbEntries)) = 48;

            //
            // Set the interval clock increment value.
            //

            HalpCurrentTimeIncrement = MAXIMUM_INCREMENT;
            HalpNextTimeIncrement = MAXIMUM_INCREMENT;
            HalpNextIntervalCount = 0;
            KeSetTimeIncrement(MAXIMUM_INCREMENT, MINIMUM_INCREMENT);

            //
            // Initialize all spin locks.
            //

#if defined(_DUO_)

            KeInitializeSpinLock(&HalpBeepLock);
            KeInitializeSpinLock(&HalpDisplayAdapterLock);
            KeInitializeSpinLock(&HalpSystemInterruptLock);

#endif

            //
            // Set address of cache error routine.
            //

            KeSetCacheErrorRoutine(HalpCacheErrorRoutine);

            //
            // Initialize the display adapter.
            //

            HalpInitializeDisplay0(LoaderBlock);

            //
            // Allocate map register memory.
            //

            HalpAllocateMapRegisters(LoaderBlock);

            //
            // Initialize and register a bug check callback record.
            //

            KeInitializeCallbackRecord(&HalpCallbackRecord);
            KeRegisterBugCheckCallback(&HalpCallbackRecord,
                                       HalpBugCheckCallback,
                                       &HalpBugCheckBuffer,
                                       sizeof(HALP_BUGCHECK_BUFFER),
                                       &HalpComponentId[0]);
        }

        //
        // Clear memory address error registers.
        //

#if defined(_DUO_)

        FailedAddress = ((PDMA_REGISTERS)DMA_VIRTUAL_BASE)->InvalidAddress.Long;

#endif

        FailedAddress = ((PDMA_REGISTERS)DMA_VIRTUAL_BASE)->MemoryFailedAddress.Long;

        //
        // Initialize interrupts
        //

        HalpInitializeInterrupts();
        return TRUE;

    } else {

        //
        // Phase 1 initialization.
        //
        // N.B. Phase 1 initialization is only executed on processor 0.
        //
        // Complete initialization of the display adapter.
        //

        if (HalpInitializeDisplay1(LoaderBlock) == FALSE) {
            return FALSE;

        } else {

            //
            // Map I/O space, calibrate the stall execution scale factor,
            // and create DMA data structures.
            //

            HalpMapIoSpace();
            HalpCalibrateStall();
            HalpCreateDmaStructures();

            //
            // Map EISA memory space so the x86 bios emulator emulator can
            // initialze a video adapter in an EISA slot.
            //

            ZeroAddress.QuadPart = 0;
            AddressSpace = 0;
            HalTranslateBusAddress(Isa,
                                   0,
                                   ZeroAddress,
                                   &AddressSpace,
                                   &PhysicalAddress);

            HalpEisaMemoryBase = MmMapIoSpace(PhysicalAddress,
                                              PAGE_SIZE * 256,
                                              FALSE);

            HalpInitializeX86DisplayAdapter();
            return TRUE;
        }
    }
}