Windows NT 4.0 source code leak
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.

210 lines
4.9 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Copyright (c) 1995-96 International Business Machines Corporation
  4. Module Name:
  5. pxsysbus.c
  6. Abstract:
  7. Author:
  8. Environment:
  9. Revision History:
  10. Jim Wooldridge - ported to PowerPC
  11. --*/
  12. #include "halp.h"
  13. #include "eisa.h"
  14. #include "pxmemctl.h"
  15. #include "pxidesup.h"
  16. extern UCHAR VectorToIrqlTable[];
  17. ULONG HalpDefaultInterruptAffinity;
  18. BOOLEAN
  19. HalpTranslateSystemBusAddress(
  20. IN PBUS_HANDLER BusHandler,
  21. IN PBUS_HANDLER RootHandler,
  22. IN PHYSICAL_ADDRESS BusAddress,
  23. IN OUT PULONG AddressSpace,
  24. OUT PPHYSICAL_ADDRESS TranslatedAddress
  25. );
  26. ULONG
  27. HalpGetSystemInterruptVector(
  28. IN PBUS_HANDLER BusHandler,
  29. IN PBUS_HANDLER RootHandler,
  30. IN ULONG BusInterruptLevel,
  31. IN ULONG BusInterruptVector,
  32. OUT PKIRQL Irql,
  33. OUT PKAFFINITY Affinity
  34. );
  35. #ifdef ALLOC_PRAGMA
  36. #pragma alloc_text(PAGE,HalpGetSystemInterruptVector)
  37. #endif
  38. BOOLEAN
  39. HalpTranslateSystemBusAddress(
  40. IN PBUS_HANDLER BusHandler,
  41. IN PBUS_HANDLER RootHandler,
  42. IN PHYSICAL_ADDRESS BusAddress,
  43. IN OUT PULONG AddressSpace,
  44. OUT PPHYSICAL_ADDRESS TranslatedAddress
  45. )
  46. /*++
  47. Routine Description:
  48. This function translates a bus-relative address space and address into
  49. a system physical address.
  50. Arguments:
  51. BusAddress - Supplies the bus-relative address
  52. AddressSpace - Supplies the address space number.
  53. Returns the host address space number.
  54. AddressSpace == 0 => memory space
  55. AddressSpace == 1 => I/O space
  56. TranslatedAddress - Supplies a pointer to return the translated address
  57. Return Value:
  58. A return value of TRUE indicates that a system physical address
  59. corresponding to the supplied bus relative address and bus address
  60. number has been returned in TranslatedAddress.
  61. A return value of FALSE occurs if the translation for the address was
  62. not possible
  63. --*/
  64. {
  65. PSUPPORTED_RANGE pRange;
  66. pRange = NULL;
  67. switch (*AddressSpace) {
  68. case 0:
  69. // verify memory address is within buses memory limits
  70. for (pRange = &BusHandler->BusAddresses->PrefetchMemory; pRange; pRange = pRange->Next) {
  71. if (BusAddress.QuadPart >= pRange->Base &&
  72. BusAddress.QuadPart <= pRange->Limit) {
  73. break;
  74. }
  75. }
  76. if (!pRange) {
  77. for (pRange = &BusHandler->BusAddresses->Memory; pRange; pRange = pRange->Next) {
  78. if (BusAddress.QuadPart >= pRange->Base &&
  79. BusAddress.QuadPart <= pRange->Limit) {
  80. break;
  81. }
  82. }
  83. }
  84. break;
  85. case 1:
  86. // verify IO address is within buses IO limits
  87. for (pRange = &BusHandler->BusAddresses->IO; pRange; pRange = pRange->Next) {
  88. if (BusAddress.QuadPart >= pRange->Base &&
  89. BusAddress.QuadPart <= pRange->Limit) {
  90. break;
  91. }
  92. }
  93. break;
  94. }
  95. if (pRange) {
  96. TranslatedAddress->QuadPart = BusAddress.QuadPart + pRange->SystemBase;
  97. *AddressSpace = pRange->SystemAddressSpace;
  98. return TRUE;
  99. }
  100. return FALSE;
  101. }
  102. ULONG
  103. HalpGetSystemInterruptVector(
  104. IN PBUS_HANDLER BusHandler,
  105. IN PBUS_HANDLER RootHandler,
  106. IN ULONG BusInterruptLevel,
  107. IN ULONG BusInterruptVector,
  108. OUT PKIRQL Irql,
  109. OUT PKAFFINITY Affinity
  110. )
  111. /*++
  112. Routine Description:
  113. Arguments:
  114. BusInterruptLevel - Supplies the bus specific interrupt level.
  115. BusInterruptVector - Supplies the bus specific interrupt vector.
  116. Irql - Returns the system request priority.
  117. Affinity - Returns the system wide irq affinity.
  118. Return Value:
  119. Returns the system interrupt vector corresponding to the specified device.
  120. --*/
  121. {
  122. UNREFERENCED_PARAMETER( BusHandler );
  123. UNREFERENCED_PARAMETER( RootHandler );
  124. *Affinity = 1;
  125. //NOTE - this should probably go in pxsiosup.c since it is specific to the SIO
  126. //
  127. // Set the IRQL level. Map the interrupt controllers priority scheme to
  128. // NT irql values. The SIO prioritizes irq's as follows:
  129. //
  130. // irq0, irq1, irq8, irq9 ... irq15, irq3, irq4 ... irq7.
  131. //
  132. *Irql = (KIRQL) VectorToIrqlTable[BusInterruptLevel];
  133. //
  134. // Calculate vector and irql for IDE devices on delmar/carolina systems
  135. //
  136. if (BusInterruptLevel == PRIMARY_IDE_VECTOR ) {
  137. *Irql = (KIRQL) (MAXIMUM_DEVICE_LEVEL - IDE_DISPATCH_VECTOR + 5);
  138. return(PRIMARY_IDE_VECTOR + DEVICE_VECTORS);
  139. } else if (BusInterruptLevel == SECONDARY_IDE_VECTOR){
  140. *Irql = (KIRQL) (MAXIMUM_DEVICE_LEVEL - IDE_DISPATCH_VECTOR + 5);
  141. return(SECONDARY_IDE_VECTOR + DEVICE_VECTORS);
  142. }
  143. //
  144. // The vector is equal to the specified bus level plus the DEVICE_VECTORS.
  145. //
  146. return(BusInterruptLevel + DEVICE_VECTORS);
  147. }