PageRenderTime 92ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm

http://xtideuniversalbios.googlecode.com/
Assembly | 152 lines | 39 code | 18 blank | 95 comment | 0 complexity | d675e21176b46bad2a8de3fd61c942b9 MD5 | raw file
Possible License(s): GPL-2.0
  1. ; Project name : XTIDE Universal BIOS
  2. ; Description : Sets IDE Device specific parameters to DPT.
  3. ;
  4. ; XTIDE Universal BIOS and Associated Tools
  5. ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
  6. ;
  7. ; This program is free software; you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 2 of the License, or
  10. ; (at your option) any later version.
  11. ;
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ; GNU General Public License for more details.
  16. ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  17. ;
  18. ; Section containing code
  19. SECTION .text
  20. ;--------------------------------------------------------------------
  21. ; IdeDPT_Finalize
  22. ; Parameters:
  23. ; DS:DI: Ptr to Disk Parameter Table
  24. ; ES:SI: Ptr to 512-byte ATA information read from the drive
  25. ; CS:BP: Ptr to IDEVARS for the controller
  26. ; Returns:
  27. ; CF: Clear, IDE interface only supports hard disks
  28. ; Corrupts registers:
  29. ; AX, BX, CX, DX
  30. ;--------------------------------------------------------------------
  31. IdeDPT_Finalize:
  32. %ifdef MODULE_FEATURE_SETS
  33. ;--------------------------------------------------------------------
  34. ; .DetectPowerManagementSupport
  35. ; Parameters:
  36. ; DS:DI: Ptr to Disk Parameter Table
  37. ; ES:SI: Ptr to 512-byte ATA information read from the drive
  38. ; Returns:
  39. ; Nothing
  40. ; Corrupts registers:
  41. ; Nothing
  42. ;--------------------------------------------------------------------
  43. .DetectPowerManagementSupport:
  44. test BYTE [es:si+ATA6.wSetSup82], A6_wSetSup82_POWERMAN
  45. jz SHORT .NoPowerManagementSupport
  46. or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_POWER_MANAGEMENT_SUPPORTED
  47. .NoPowerManagementSupport:
  48. %endif ; MODULE_FEATURE_SETS
  49. ;--------------------------------------------------------------------
  50. ; .StoreDeviceType
  51. ; Parameters:
  52. ; DS:DI: Ptr to Disk Parameter Table
  53. ; CS:BP: Ptr to IDEVARS for the controller
  54. ; Returns:
  55. ; Nothing
  56. ; Corrupts registers:
  57. ; AL
  58. ;--------------------------------------------------------------------
  59. .StoreDeviceType:
  60. call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
  61. ;--------------------------------------------------------------------
  62. ; .StoreBlockMode
  63. ; Parameters:
  64. ; DS:DI: Ptr to Disk Parameter Table
  65. ; Returns:
  66. ; Nothing
  67. ; Corrupts registers:
  68. ; Nothing
  69. ;--------------------------------------------------------------------
  70. .StoreBlockMode:
  71. mov BYTE [di+DPT_ATA.bBlockSize], 1
  72. %ifdef MODULE_ADVANCED_ATA
  73. ;--------------------------------------------------------------------
  74. ; .StorePioModeAndTimings
  75. ; Parameters:
  76. ; DS:DI: Ptr to Disk Parameter Table
  77. ; ES:SI: Ptr to 512-byte ATA information read from the drive
  78. ; CS:BP: Ptr to IDEVARS for the controller
  79. ; Returns:
  80. ; Nothing
  81. ; Corrupts registers:
  82. ; AX, BX, CX
  83. ;--------------------------------------------------------------------
  84. .StorePioMode:
  85. call AtaID_GetMaxPioModeToAXandMinCycleTimeToCX
  86. mov [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx
  87. mov [di+DPT_ADVANCED_ATA.bPioMode], al
  88. or [di+DPT.bFlagsHigh], ah
  89. ;--------------------------------------------------------------------
  90. ; .DetectAdvancedIdeController
  91. ; Parameters:
  92. ; DS:DI: Ptr to Disk Parameter Table
  93. ; ES:SI: Ptr to 512-byte ATA information read from the drive
  94. ; CS:BP: Ptr to IDEVARS for the controller
  95. ; Returns:
  96. ; Nothing
  97. ; Corrupts registers:
  98. ; AX, BX, CX, DX
  99. ;--------------------------------------------------------------------
  100. .DetectAdvancedIdeController:
  101. call AccessDPT_GetIdeBasePortToBX
  102. call AdvAtaInit_DetectControllerForIdeBaseInBX
  103. mov [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
  104. mov [di+DPT_ADVANCED_ATA.wControllerBasePort], dx
  105. jnc SHORT .NoAdvancedControllerDetected
  106. ; Use highest common PIO mode from controller and drive.
  107. ; Many VLB controllers support PIO modes up to 2.
  108. call AdvAtaInit_GetControllerMaxPioModeToAL
  109. jnc SHORT .ChangeTo32bitDevice
  110. and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_IORDY ; No IORDY supported if need to limit
  111. MIN_U [di+DPT_ADVANCED_ATA.bPioMode], al
  112. ; We have detected 32-bit controller so change Device Type since
  113. ; it might have been set to 16-bit on IDEVARS
  114. .ChangeTo32bitDevice:
  115. mov BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
  116. .NoAdvancedControllerDetected:
  117. %endif ; MODULE_ADVANCED_ATA
  118. ; End DPT
  119. clc
  120. ret
  121. ;--------------------------------------------------------------------
  122. ; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
  123. ; Parameters:
  124. ; DS:DI: Ptr to Disk Parameter Table
  125. ; CS:BP: Ptr to IDEVARS for the controller
  126. ; Returns:
  127. ; Nothing
  128. ; Corrupts registers:
  129. ; AL
  130. ;--------------------------------------------------------------------
  131. IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI:
  132. mov al, [cs:bp+IDEVARS.bDevice]
  133. mov [di+DPT_ATA.bDevice], al
  134. ret