Leaked source code of windows server 2003
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.

161 lines
3.6 KiB

  1. /*
  2. *
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. *
  5. * VT586.C - VIA Technologies PCI chipset routines.
  6. *
  7. * Notes:
  8. * Algorithms from VIATECH 82C586B Data Sheet
  9. * Compaq contact:
  10. *
  11. */
  12. #include "local.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(INIT, VT586ValidateTable)
  15. #endif //ALLOC_PRAGMA
  16. /****************************************************************************
  17. *
  18. * VT586SetIRQ - Set a VIATECH 82C586B PCI link to a specific IRQ
  19. *
  20. * Exported.
  21. *
  22. * ENTRY: bIRQNumber is the new IRQ to be used.
  23. *
  24. * bLink is the Link to be set.
  25. *
  26. * EXIT: Standard PCIMP return value.
  27. *
  28. ***************************************************************************/
  29. PCIMPRET CDECL
  30. VT586SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  31. {
  32. UCHAR bOffset, bOldValue;
  33. switch (bLink)
  34. {
  35. case 1: case 2:
  36. case 3: case 5:
  37. break;
  38. default:
  39. return (PCIMP_INVALID_LINK);
  40. }
  41. //
  42. // Compute the offset in config space.
  43. //
  44. bOffset=(bLink/2)+0x55;
  45. //
  46. // Read the old VT82C586 IRQ register.
  47. //
  48. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  49. if (bLink&1) {
  50. bOldValue&=0x0f;
  51. bOldValue|=(bIRQNumber<<4);
  52. }
  53. else {
  54. bOldValue&=0xf0;
  55. bOldValue|=bIRQNumber;
  56. }
  57. //
  58. // Set the VT82C586B IRQ register.
  59. //
  60. WriteConfigUchar(bBusPIC, bDevFuncPIC, bOffset, bOldValue);
  61. return(PCIMP_SUCCESS);
  62. }
  63. /****************************************************************************
  64. *
  65. * VT586GetIRQ - Get the IRQ of a VIATECH 82C586B PCI link
  66. *
  67. * Exported.
  68. *
  69. * ENTRY: pbIRQNumber is the buffer to fill.
  70. *
  71. * bLink is the Link to be read.
  72. *
  73. * EXIT: Standard PCIMP return value.
  74. *
  75. ***************************************************************************/
  76. PCIMPRET CDECL
  77. VT586GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  78. {
  79. UCHAR bOffset, bOldValue;
  80. switch (bLink)
  81. {
  82. case 1: case 2:
  83. case 3: case 5:
  84. break;
  85. default:
  86. return (PCIMP_INVALID_LINK);
  87. }
  88. //
  89. // Set various values.
  90. //
  91. bOffset=(bLink/2)+0x55;
  92. //
  93. // Read the old VT82C586 IRQ register.
  94. //
  95. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  96. if (bLink&1)
  97. bOldValue>>=4;
  98. *pbIRQNumber=bOldValue&0x0f;
  99. return(PCIMP_SUCCESS);
  100. }
  101. /****************************************************************************
  102. *
  103. * VT586ValidateTable - Validate an IRQ table
  104. *
  105. * Exported.
  106. *
  107. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  108. * by an IRQ Routing Table.
  109. *
  110. * ulFlags are PCIMP_VALIDATE flags.
  111. *
  112. * EXIT: Standard PCIMP return value.
  113. *
  114. ***************************************************************************/
  115. PCIMPRET CDECL
  116. VT586ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  117. {
  118. PIRQINFO pii=(PIRQINFO)(((PUCHAR) piihIRQInfoHeader)+sizeof(IRQINFOHEADER));
  119. ULONG i, j;
  120. ULONG cEntries=(piihIRQInfoHeader->TableSize-sizeof(IRQINFOHEADER))/sizeof(IRQINFO);
  121. PAGED_CODE();
  122. for (i=0; i<cEntries; i++, pii++) {
  123. for (j=0; j<4; j++) {
  124. if (pii->PinInfo[j].Link<=3 || pii->PinInfo[j].Link==5)
  125. continue;
  126. return (PCIMP_FAILURE);
  127. }
  128. }
  129. return(i? PCIMP_SUCCESS : PCIMP_FAILURE);
  130. }