Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ixswint.c
  5. Abstract:
  6. This module implements the software interrupt handlers
  7. for x86 machines
  8. Author:
  9. John Vert (jvert) 2-Jan-1992
  10. Environment:
  11. Kernel mode only.
  12. Revision History:
  13. Forrest Foltz (forrestf) 23-Oct-2000
  14. Ported from ixswint.asm to ixswint.c
  15. --*/
  16. #include "halcmn.h"
  17. VOID
  18. HalRequestSoftwareInterrupt (
  19. IN KIRQL RequestIrql
  20. )
  21. /*++
  22. Routine Description:
  23. This routine is used to request a software interrupt to the
  24. system. Also, this routine checks to see if any software
  25. interrupt should be generated.
  26. The following condition will cause software interrupt to
  27. be simulated:
  28. any software interrupt which has higher priority than
  29. current IRQL's is pending.
  30. NOTE: This routine simulates software interrupt as long as
  31. any pending SW interrupt level is higher than the current
  32. IRQL, even when interrupts are disabled.
  33. Arguments:
  34. RequestIrql - Supplies the request IRQL value
  35. Return Value:
  36. None.
  37. --*/
  38. {
  39. PHALP_SOFTWARE_INTERRUPT vector;
  40. ULONG mask;
  41. ULONG flags;
  42. PKPCR pcr;
  43. KIRQL highestPending;
  44. mask = (1 << RequestIrql);
  45. //
  46. // Clear the interrupt flag, set the pending interrupt bit, dispatch any
  47. // appropriate software interrupts and restore the interrupt flag.
  48. //
  49. flags = HalpDisableInterrupts();
  50. pcr = KeGetPcr();
  51. pcr->Irr |= mask;
  52. mask = (pcr->Irr) & ((1 << DISPATCH_LEVEL) - 1);
  53. highestPending = SWInterruptLookupTable[mask];
  54. if (highestPending > pcr->Irql) {
  55. vector = HalpSoftwareInterruptTable[RequestIrql];
  56. vector();
  57. }
  58. HalpRestoreInterrupts(flags);
  59. }
  60. VOID
  61. HalClearSoftwareInterrupt (
  62. IN KIRQL RequestIrql
  63. )
  64. /*++
  65. Routine Description:
  66. This routine is used to clear a possible pending software interrupt.
  67. Support for this function is optional, and allows the kernel to
  68. reduce the number of spurious software interrupts it receives.
  69. Arguments:
  70. RequestIrql - Supplies the request IRQL value
  71. Return Value:
  72. None.
  73. --*/
  74. {
  75. ULONG mask;
  76. ULONG irr;
  77. mask = ~(1 << RequestIrql);
  78. KPCR_READ_FIELD(Irr,&irr);
  79. irr &= mask;
  80. KPCR_WRITE_FIELD(Irr,&irr);
  81. }