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.

146 lines
3.6 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. diska.c
  13. Abstract:
  14. This module implements the assembly code necessary to detect/collect
  15. hard disk parameter informat.
  16. Author:
  17. Allen Kay (akay) 15-Aug-97
  18. --*/
  19. USHORT NumberBiosDisks;
  20. VOID
  21. GetInt13DriveParameters(
  22. OUT PUCHAR Buffer;
  23. OUT PUSHORT Size
  24. )
  25. /*++
  26. Routine Description:
  27. This function calls int 13h function 8 to get drive parameters
  28. for drive 80h - 87h.
  29. Arguments:
  30. Buffer - Supplies a pointer to a buffer to receive the drive parameter
  31. information.
  32. Size - Supplies a pointer to a USHORT to receive the size of the dirve
  33. parameter information returned.
  34. Return Value:
  35. None.
  36. --*/
  37. {
  38. IA32_BIOS_REGISTER_STATE IA32RegisterState;
  39. BIT32_AND_BIT16 IA32Register, Eax, Edx;
  40. UCHAR TempVal;
  41. USHORT DriveSelect;
  42. PINT13_DRIVE_PARAMETERS DriveParameters;
  43. DriveSelect = 0x80; // starting from drive 0x80
  44. DriveParameters = (PINT13_DRIVE_PARAMETERS) Buffer;
  45. while (DriveSelect <= 0x88) {
  46. NumberBiosDisks++;
  47. IA32Register.LowPart16 = DriveSelect;
  48. IA32Register.HighPart16 = 0;
  49. IA32RegisterState.edx = IA32Register.Part32;
  50. IA32Register.Byte0 = 0;
  51. IA32Register.Byte1 = 0x15; // int 13h function 15h
  52. IA32Register.Byte2 = 0;
  53. IA32Register.Byte3 = 0;
  54. IA32RegisterState.eax = IA32Register.Part32;
  55. SAL_PROC(0x13,&IA32RegisterState,0,0,0,0,0,0);
  56. //
  57. // First get all the needed registers.
  58. //
  59. Eax.Part32 = IA32RegisterState.Eax;
  60. if ( ( IA32RegisterState.Eflags & CARRY_FLAG ) == 0) &&
  61. Eax.Byte1 != 0 ) {
  62. //
  63. // Call int 13h function 8h to read drive parameters.
  64. //
  65. IA32Register.Byte0 = 0;
  66. IA32Register.Byte1 = 0x8; // int 0x13 function 0x8
  67. IA32Register.Byte2 = 0;
  68. IA32Register.Byte3 = 0;
  69. IA32RegisterState.eax = IA32Register.Part32;
  70. SAL_PROC(0x13,&IA32RegisterState,0,0,0,0,0,0);
  71. if ( ( IA32RegisterState.Eflags & CARRY_FLAG ) != 0) {
  72. return 0;
  73. }
  74. //
  75. // First setup of the registers we are going to use.
  76. //
  77. Ecx.Part32 = IA32RegisterState.Eax;
  78. Edx.Part32 = IA32RegisterState.Edx;
  79. //
  80. // Get the maximum usable sector number.
  81. //
  82. DriveParameters->SectorsPerTrack = Ecx.Part32 & 0x3f;
  83. //
  84. // Get the maximum cylinder number.
  85. //
  86. Ecx.Byte0 = Ecx.Byte0 >> 6;
  87. TmpVal = Ecx.Byte0;
  88. Ecx.Byte1 = Ecx.Byte0;
  89. Ecx.Byte0 = TmpVal;
  90. DriveParameters->MaxCylinders = Ecx.LowPart16;
  91. //
  92. // Get the maximum heads.
  93. //
  94. DriveParameters->MaxHeads = Edx.HighPart16;
  95. //
  96. // Get the number of drives.
  97. //
  98. DriveParameters->NumberDrives = Edx.Byte0;
  99. //
  100. // Set the drive select number;
  101. //
  102. DriveParameters->DriveSelect = DriveSelect++;
  103. DriveParameters++;
  104. }
  105. }
  106. Size = NumberOfDisks * sizeof (INT13_DRIVE_PARAMETERS);
  107. }