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.

148 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. picinit.c
  5. Abstract:
  6. This module implements pic initialization code.
  7. Author:
  8. Forrest Foltz (forrestf) 1-Dec-2000
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #include "halcmn.h"
  14. VOID
  15. HalpInitialize8259Tables (
  16. VOID
  17. );
  18. VOID
  19. HalpInitializeIrqlTables (
  20. VOID
  21. );
  22. VOID
  23. HalpInitializePICs (
  24. IN BOOLEAN EnableInterrupts
  25. )
  26. /*++
  27. Routine Description:
  28. This routine sends the 8259 PIC initialization commands and masks all
  29. the interrupts on 8259s.
  30. Parameters:
  31. EnableInterupts - Indicates whether interrupts should be explicitly
  32. enabled just before returning.
  33. Return Value:
  34. Nothing.
  35. --*/
  36. {
  37. ULONG flags;
  38. #if defined(PICACPI)
  39. //
  40. // Build the irq<->IRQL mapping tables
  41. //
  42. HalpInitialize8259Tables();
  43. #else
  44. //
  45. // Build the vector <-> INTI tables
  46. //
  47. HalpInitializeIrqlTables();
  48. #endif
  49. flags = HalpDisableInterrupts();
  50. //
  51. // First, program the master pic with ICW1 through ICW4
  52. //
  53. WRITE_PORT_UCHAR(PIC1_PORT0,
  54. ICW1_ICW +
  55. ICW1_EDGE_TRIG +
  56. ICW1_INTERVAL8 +
  57. ICW1_CASCADE +
  58. ICW1_ICW4_NEEDED);
  59. WRITE_PORT_UCHAR(PIC1_PORT1,
  60. PIC1_BASE);
  61. WRITE_PORT_UCHAR(PIC1_PORT1,
  62. 1 << PIC_SLAVE_IRQ);
  63. WRITE_PORT_UCHAR(PIC1_PORT1,
  64. ICW4_NOT_SPEC_FULLY_NESTED +
  65. ICW4_NON_BUF_MODE +
  66. ICW4_NORM_EOI +
  67. ICW4_8086_MODE);
  68. //
  69. // Mask all irqs on the master
  70. //
  71. WRITE_PORT_UCHAR(PIC1_PORT1,0xFF);
  72. //
  73. // Next, program the slave pic with ICW1 through ICW4
  74. //
  75. WRITE_PORT_UCHAR(PIC2_PORT0,
  76. ICW1_ICW +
  77. ICW1_EDGE_TRIG +
  78. ICW1_INTERVAL8 +
  79. ICW1_CASCADE +
  80. ICW1_ICW4_NEEDED);
  81. WRITE_PORT_UCHAR(PIC2_PORT1,
  82. PIC2_BASE);
  83. WRITE_PORT_UCHAR(PIC2_PORT1,
  84. PIC_SLAVE_IRQ);
  85. WRITE_PORT_UCHAR(PIC2_PORT1,
  86. ICW4_NOT_SPEC_FULLY_NESTED +
  87. ICW4_NON_BUF_MODE +
  88. ICW4_NORM_EOI +
  89. ICW4_8086_MODE);
  90. //
  91. // Mask all IRQs on the slave
  92. //
  93. WRITE_PORT_UCHAR(PIC2_PORT1,0xFF);
  94. if (EnableInterrupts != FALSE) {
  95. HalpEnableInterrupts();
  96. } else {
  97. HalpRestoreInterrupts(flags);
  98. }
  99. }