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.

115 lines
3.0 KiB

  1. // TITLE("Byte and Short Emulation")
  2. //++
  3. //
  4. //
  5. // Copyright (c) 1995 Digital Equipment Corporation
  6. //
  7. // Module Name:
  8. //
  9. // byteme.s
  10. //
  11. // Abstract:
  12. //
  13. // This module implements the code to perform atomic store operations
  14. // on bytes and shorts (words).
  15. //
  16. // Atomic byte and short opcodes have been added into the Alpha
  17. // architecture as of Alpha 21164A or EV56. In chips 21164 and prior,
  18. // an illegal instruction will occur and an exception will lead them here.
  19. //
  20. // Author:
  21. //
  22. // Wim Colgate, May 18th, 1995
  23. // Tom Van Baak, May 18th, 1995
  24. //
  25. // Environment:
  26. //
  27. // Kernel mode only.
  28. //
  29. // Revision History:
  30. //
  31. //--
  32. #include "ksalpha.h"
  33. //++
  34. //
  35. // VOID
  36. // KiInterlockedStoreByte(
  37. // IN PUCHAR Address,
  38. // IN UCHAR Data
  39. // )
  40. //
  41. // Routine Description:
  42. //
  43. // This routine stores the data byte specified by Data to the location
  44. // specified by Address. The architecture requires byte granularity,
  45. // so locking is necessary.
  46. //
  47. // Arguments:
  48. //
  49. // Address(a0) - Supplies a pointer to byte data value.
  50. // Data(a1) - Supplied the byte data value to store.
  51. //
  52. // Return Value:
  53. //
  54. // None
  55. //
  56. //--
  57. LEAF_ENTRY(KiInterlockedStoreByte)
  58. bic a0, 3, t0 // clear low 2 bits
  59. and a0, 3, t1 // mask of three low bits
  60. 10: ldl_l t2, 0(t0) // load locked full longword
  61. insbl a1, t1, t3 // insert byte low
  62. mskbl t2, t1, t2 // mask byte low
  63. bis t2, t3, t2 // merge data
  64. stl_c t2, 0(t0) // store conditional
  65. beq t2, 20f // failed to store, retry, forward
  66. ret zero, (ra), 1 // return
  67. 20: br zero, 10b // try again
  68. .end KiInterlockedStoreByte
  69. //++
  70. //
  71. // VOID
  72. // KiInterlockedStoreWord(
  73. // IN PUSHORT Address,
  74. // IN USHORT Data
  75. // )
  76. //
  77. // Routine Description:
  78. //
  79. // This routine stores the short data specified by Data to the aligned
  80. // location specified by Address. The architecture requires word granularity,
  81. // so locking is necessary.
  82. //
  83. // Arguments:
  84. //
  85. // Address(a0) - Supplies a pointer to an aligned short data value.
  86. // Data(a1) - Supplied the short data value to store.
  87. //
  88. // Return Value:
  89. //
  90. // None
  91. //
  92. //--
  93. LEAF_ENTRY(KiInterlockedStoreWord)
  94. bic a0, 2, t0 // clear low short address bit
  95. and a0, 2, t1 // mask of low short address bit
  96. 10: ldl_l t2, 0(t0) // load locked full longword
  97. inswl a1, t1, t3 // insert word low
  98. mskwl t2, t1, t2 // mask word low
  99. bis t2, t3, t2 // merge data
  100. stl_c t2, 0(t0) // store conditional
  101. beq t2, 20f // failed to store, retry, forward
  102. ret zero, (ra), 1 // return
  103. 20: br zero, 10b // try again
  104. .end KiInterlockedStoreWord
  105.