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.

172 lines
4.1 KiB

  1. title "Cmos Access Routines"
  2. ;++
  3. ;
  4. ; Copyright (c) 1992 NCR Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; mccmos.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; Procedures necessary to access CMOS/ECMOS information.
  13. ;
  14. ; Author:
  15. ;
  16. ; David Risner (o-ncrdr) 20 Apr 1992
  17. ;
  18. ; Revision History:
  19. ;
  20. ;--
  21. .386p
  22. .xlist
  23. ;include ks386.inc
  24. ;include mac386.inc
  25. include callconv.inc
  26. .list
  27. ; extrn _HalpSystemHardwareLock:DWORD
  28. subttl "HalpGetCmosData"
  29. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  30. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  31. ;++
  32. ;
  33. ; CMOS space read and write functions.
  34. ;
  35. ;--
  36. CmosAddressPort equ 70H
  37. CmosDataPort equ 71H
  38. ECmosAddressLsbPort equ 74H
  39. ECmosAddressMsbPort equ 75H
  40. ECmosDataPort equ 76H
  41. ;++
  42. ;
  43. ; ULONG
  44. ; HalpGetCmosData(
  45. ; IN ULONG SourceLocation
  46. ; IN ULONG SourceAddress
  47. ; IN ULONG ReturnBuffer
  48. ; IN PUCHAR ByteCount
  49. ; )
  50. ;
  51. ; This routine reads the requested number of bytes from CMOS/ECMOS and
  52. ; stores the data read into the supplied buffer in system memory. If
  53. ; the requested data amount exceeds the allowable extent of the source
  54. ; location, the return data is truncated.
  55. ;
  56. ; Arguments:
  57. ;
  58. ; SourceLocation : where data is to be read from CMOS or ECMOS
  59. ; 0 - CMOS, 1 - ECMOS
  60. ;
  61. ; SourceAddress : address in CMOS/ECMOS where data is to be read from
  62. ;
  63. ; ReturnBuffer : address in system memory for return data
  64. ;
  65. ; ByteCount : number of bytes to be read
  66. ;
  67. ; Returns:
  68. ;
  69. ; Number of byte actually read.
  70. ;
  71. ;--
  72. SourceLocation equ 2*4[ebp]
  73. SourceAddress equ 3*4[ebp]
  74. ReturnBuffer equ 4*4[ebp]
  75. ByteCount equ 5*4[ebp]
  76. cPublicProc _HalpGetCmosData,4
  77. push ebp
  78. mov ebp, esp
  79. push ebx
  80. push edi
  81. ;
  82. ; NOTE: The spinlock is needed even in the UP case, because
  83. ; the resource is also used in an interrupt handler (profiler).
  84. ; If we own the spinlock in this routine, and we service
  85. ; the profiler interrupt (which will wait for the spinlock forever),
  86. ; then we have a hosed system.
  87. ;
  88. Hgcd01:
  89. cli
  90. ; lea eax, _HalpSystemHardwareLock
  91. ; ACQUIRE_SPINLOCK eax, Hgcd90
  92. xor edx, edx ; initialize return data length
  93. mov ecx, ByteCount
  94. or ecx, ecx ; validate requested byte count
  95. jz HalpGetCmosDataExit ; if no work to do, exit
  96. mov edx, SourceAddress
  97. mov edi, ReturnBuffer
  98. mov eax, SourceLocation ; cmos or extended cmos?
  99. cmp eax, 1
  100. je ECmosReadByte
  101. cmp eax, 0
  102. jne HalpGetCmosDataExit
  103. align 4
  104. CmosReadByte:
  105. cmp edx, 0ffH ; validate cmos source address
  106. ja HalpGetCmosDataExit ; if out of range, exit
  107. mov al, dl
  108. out CmosAddressPort, al
  109. in al, CmosDataPort
  110. mov [edi], al
  111. inc edx
  112. inc edi
  113. dec ecx
  114. jnz CmosReadByte
  115. jmp SHORT HalpGetCmosDataExit
  116. align 4
  117. ECmosReadByte:
  118. cmp edx,0ffffH ; validate ecmos source address
  119. ja HalpGetCmosDataExit ; if out of range, exit
  120. mov al, dl
  121. out ECmosAddressLsbPort, al
  122. mov al, dh
  123. out ECmosAddressMsbPort, al
  124. in al, ECmosDataPort
  125. mov [edi], al
  126. inc edx
  127. inc edi
  128. dec ecx
  129. jnz ECmosReadByte
  130. HalpGetCmosDataExit:
  131. ; lea eax, _HalpSystemHardwareLock
  132. ; RELEASE_SPINLOCK eax
  133. mov eax, edx ; return bytes read
  134. pop edi
  135. pop ebx
  136. pop ebp
  137. stdRET _HalpGetCmosData
  138. ;Hgcd90:
  139. ; sti
  140. ; SPIN_ON_SPINLOCK eax, <Hgcd01>
  141. stdENDP _HalpGetCmosData
  142. _TEXT ends
  143. end