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.

150 lines
3.9 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. /*++
  10. Copyright (c) 1991 Microsoft Corporation
  11. Module Name:
  12. hwpcia.c
  13. Abstract:
  14. Calls the PCI rom function to determine what type of PCI
  15. support is present, if any.
  16. Author:
  17. Allen Kay (akay) 15-Aug-97
  18. --*/
  19. BOOLEAN
  20. HwGetPciSystemData(
  21. PPCI_SYSTEM_DATA PciSystemData,
  22. BOOLEAN BiosDateFound
  23. )
  24. /*++
  25. Routine Description:
  26. This function retrieves the PCI System Data
  27. Arguments:
  28. PciSystemData - Supplies a pointer to the structure which will
  29. receive the PCI System Data.
  30. Return Value:
  31. True - PCI System Detected and System Data valid
  32. False - PCI System Not Detected
  33. --*/
  34. {
  35. IA32_BIOS_REGISTER_STATE IA32RegisterState;
  36. BIT32_AND_BIT16 IA32Register, Eax, Edx;
  37. ULONG NoBuses;
  38. if (BiosDateFound == 1) {
  39. IA32Register.LowPart16 = PCI_BIOS_PRESENT
  40. IA32Register.HighPart16 = 0;
  41. IA32RegisterState.eax = IA32Register.Part32;
  42. SAL_PROC(0x1a,&IA32RegisterState,0,0,0,0,0,0);
  43. //
  44. // First get all the needed registers.
  45. //
  46. Eax.Part32 = IA32RegisterState.Eax;
  47. Ebx.Part32 = IA32RegisterState.Ebx;
  48. Ecx.Part32 = IA32RegisterState.Ecx;
  49. Edx.Part32 = IA32RegisterState.Edx;
  50. if ( ( IA32RegisterState.Eflags & CARRY_FLAG ) == 0) &&
  51. Eax.Byte1 == 0 &&
  52. Edx.Byte0 == 'P' &&
  53. Edx.Byte1 == 'C' &&
  54. Edx.Byte2 == 'I' ) {
  55. //
  56. // Found PCI BIOS Version > 1.0
  57. //
  58. // The only thing left to do is squirrel the data away
  59. //
  60. PciSystemData->MajorRevision = Ebx.Byte1;
  61. PciSystemData->MinorRevision = Ebx.Byte0;
  62. PciSystemData->NoBuses = Ecx.Byte0 + 1; // LastBus + 1
  63. PciSystemData->HwMechanism = Eax.Byte0;
  64. } else {
  65. //
  66. // Look for BIOS Version 1.0. this has a different function #
  67. //
  68. IA32Register.LowPart16 = PCI10_BIOS_PRESENT
  69. IA32Register.HighPart16 = 0;
  70. IA32RegisterState.eax = IA32Register.Part32;
  71. SAL_PROC(0x1a,&IA32RegisterState,0,0,0,0,0,0);
  72. //
  73. // Version 1.0 has "PCI " in dx and cx, the Version number in ax,
  74. // and the carry flag cleared. These are all the indications
  75. // available.
  76. //
  77. //
  78. // First get all the needed registers.
  79. //
  80. Eax.Part32 = IA32RegisterState.Eax;
  81. Ebx.Part32 = IA32RegisterState.Ebx;
  82. Ecx.Part32 = IA32RegisterState.Ecx;
  83. Edx.Part32 = IA32RegisterState.Edx;
  84. if (Edx.Byte0 == 'P' &&
  85. Edx.Byte1 == 'C' &&
  86. Ecx.Byte0 == 'I') {
  87. //
  88. // Found PCI BIOS Version 1.0
  89. //
  90. // The only thing left to do is squirrel the data away for
  91. // the caller.
  92. //
  93. PciSystemData->MajorRevision = Eax.Byte1;
  94. PciSystemData->MinorRevision = Eax.Byte0;
  95. //
  96. // The Version 1.0 BIOS is only early HW that couldn't
  97. // support multifunction devices or multiple bus's. So
  98. // without reading any device data, mark it as such.
  99. //
  100. PciSystemData->HwMechanism = 2;
  101. PciSystemData->NoBuses = 1;
  102. } else {
  103. //
  104. // PCI device not found.
  105. //
  106. return(FALSE);
  107. }
  108. }
  109. } else {
  110. //
  111. // PCI device not found.
  112. //
  113. return(FALSE);
  114. }
  115. return(TRUE);
  116. }