📄 oem.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
// File: oem.c
//
// This file implements a standard implementation of OEMInterrupt functions
// relating to enabling, disabling and finishing interrupts.
//
#include <windows.h>
#include <nkintr.h>
#include <oal.h>
//------------------------------------------------------------------------------
//
// Function: OEMInterruptEnable
//
// This function enables the IRQ given its corresponding SysIntr value.
// Function returns true if SysIntr is valid, else false.
//
BOOL OEMInterruptEnable(DWORD sysIntr, LPVOID pvData, DWORD cbData)
{
BOOL rc = FALSE;
const UINT32 *pIrqs;
UINT32 count;
OALMSG(OAL_INTR&&OAL_VERBOSE,
(L"+OEMInterruptEnable(%d, 0x%x, %d)\r\n", sysIntr, pvData, cbData
));
// SYSINTR_VMINI & SYSINTR_TIMING are special cases
if (sysIntr == SYSINTR_VMINI || sysIntr == SYSINTR_TIMING) {
rc = TRUE;
goto cleanUp;
}
// Obtain the SYSINTR's underlying IRQ number
if (!OALIntrTranslateSysIntr(sysIntr, &count, &pIrqs)) {
// Indicate invalid SysIntr
OALMSG(OAL_ERROR, (
L"ERROR: OEMInterruptEnable: IRQs are undefined for SysIntr %d\r\n",
sysIntr
));
goto cleanUp;
}
// Enable the interrupt
rc = OALIntrEnableIrqs(count, pIrqs);
cleanUp:
OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OEMInterruptEnable(rc = 1)\r\n"));
return rc;
}
//------------------------------------------------------------------------------
//
// Function: OEMInterruptDisable(DWORD sysIntr)
//
// This function disables the IRQ given its corresponding SysIntr value.
//
//
VOID OEMInterruptDisable(DWORD sysIntr)
{
const UINT32 *pIrqs;
UINT32 count;
OALMSG(OAL_INTR&&OAL_VERBOSE, (L"+OEMInterruptDisable(%d)\r\n", sysIntr));
// Obtain the SYSINTR's underlying IRQ number
if (!OALIntrTranslateSysIntr(sysIntr, &count, &pIrqs)) {
// Indicate invalid SysIntr
OALMSG(OAL_ERROR, (
L"ERROR: OEMInterruptEnable: IRQs are undefined for SysIntr %d\r\n",
sysIntr
));
goto cleanUp;
}
// Disable the interrupt
OALIntrDisableIrqs(count, pIrqs);
cleanUp:
// Indicate exit
OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OEMInterruptDisable\r\n"));
}
//------------------------------------------------------------------------------
//
// Function: OEMInterruptDone
//
// OEMInterruptDone is called by the kernel when a device driver
// calls InterruptDone(). The system is not preemtible when this
// function is called.
//
VOID OEMInterruptDone(DWORD sysIntr)
{
const UINT32 *pIrqs;
UINT32 count;
OALMSG(OAL_INTR&&OAL_VERBOSE, (L"+OEMInterruptDone(%d)\r\n", sysIntr));
if (OALIntrTranslateSysIntr(sysIntr, &count, &pIrqs)) {
OALIntrDoneIrqs(count, pIrqs);
}
OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OEMInterruptDone\r\n"));
}
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -