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.

152 lines
4.9 KiB

  1. title "Profile Interrupt"
  2. ;++
  3. ;
  4. ; Copyright (c) 2000 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; profint.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements the architecture dependent code necessary to
  13. ; process the profile interrupt.
  14. ;
  15. ; Author:
  16. ;
  17. ; David N. Cutler (davec) 12-Sep-2000
  18. ;
  19. ; Environment:
  20. ;
  21. ; Kernel mode only.
  22. ;
  23. ;--
  24. include ksamd64.inc
  25. extern KiProfileListHead:qword
  26. extern KiProfileLock:qword
  27. subttl "Profile Interrupt"
  28. ;++
  29. ;
  30. ; VOID
  31. ; KeProfileInterruptWithSource (
  32. ; IN KPROFILE_SOURCE ProfileSource
  33. ; )
  34. ;
  35. ; Routine Description:
  36. ;
  37. ; This routine is executed is response to an interrupt generated by one
  38. ; of the profile sources. Its function is to process the system and process
  39. ; profile lists and update bucket hit counters.
  40. ;
  41. ; Arguments:
  42. ;
  43. ; TrapFrame (rcx) - Supplies the address of a trap frame.
  44. ;
  45. ; ProfileSource (rdx) - Supplies the source of profile interrupt.
  46. ;
  47. ; Return Value:
  48. ;
  49. ; None.
  50. ;
  51. ;--
  52. PiFrame struct
  53. Source dq ? ; profile interrupt source
  54. Fill dq ? ; fill to 8 mod 16
  55. SavedRbp dq ? ; saved register RBP
  56. PiFrame ends
  57. NESTED_ENTRY KeProfileInterruptWithSource, _TEXT$00
  58. push_reg rbp ; save nonvolatile register
  59. alloc_stack (sizeof PiFrame - (1 * 8)) ; allocate stack frame
  60. END_PROLOGUE
  61. mov PiFrame.Source[rsp], rdx ; save interrupt source
  62. lea r11, KiProfileLock ; get address of spin lock
  63. AcquireSpinLock r11 ; acquire profile spin lock
  64. mov rcx, PiFrame.Source[rsp] ; set interrupt source
  65. mov rdx, gs:[PcCurrentThread] ; get current thread address
  66. mov rdx, ThApcState + AsProcess[rdx] ; get current process address
  67. add rdx, PrProfileListHead ; compute profile listhead address
  68. call KiProcessProfileList ; process profile list
  69. mov rcx, PiFrame.Source[rsp] ; set interrupt source
  70. lea rdx, KiProfileListHead ; get system profile listhead address
  71. call KiProcessProfileList ; process profile list
  72. lea r11, KiProfileLock ; get address of spin lock
  73. ReleaseSpinLock r11 ; release spin lock
  74. add rsp, sizeof PiFrame - (1 * 8) ; deallocate stack frame
  75. pop rbp ; restore nonvolatile register
  76. ret ; return
  77. NESTED_END KeProfileInterruptWithSource, _TEXT$00
  78. subttl "Process Profile List"
  79. ;++
  80. ;
  81. ; VOID
  82. ; KiProcessProfileList (
  83. ; IN KPROFILE_SOURCE Source,
  84. ; IN PLIST_ENTRY ListHead
  85. ; )
  86. ;
  87. ; Routine Description:
  88. ;
  89. ; This routine processes a profile list.
  90. ;
  91. ; Arguments:
  92. ;
  93. ; Source (cx) - Supplies the source of profile interrupt.
  94. ;
  95. ; ListHead (rdx) - Supplies a pointer to a profile list.
  96. ;
  97. ; Implicit Arguments:
  98. ;
  99. ; rbp - Supplies a pointer to a trap frame.
  100. ;
  101. ; Return Value:
  102. ;
  103. ; None.
  104. ;
  105. ;--
  106. LEAF_ENTRY KiProcessProfileList, _TEXT$00
  107. mov r8, LsFlink[rdx] ; get first entry address
  108. cmp r8, rdx ; check if list is empty
  109. je short KiPP30 ; if e, list is empty
  110. mov r9, gs:[PcSetMember] ; get procecessor set member
  111. mov r10, TrRip[rbp] ; get profile interrupt address
  112. mov ax, cx ; save profile source
  113. ;
  114. ; Process list entry.
  115. ;
  116. KiPP10: cmp ax, (PfSource - PfProfileListEntry)[r8] ; check for source match
  117. jne short KiPP20 ; if ne, source mismatch
  118. cmp r10, (PfRangeBase - PfProfileListEntry)[r8] ; check if below base
  119. jb short KiPP20 ; if b, address below base
  120. cmp r10, (PfRangeLimit - PfProfileListEntry)[r8] ; check if above limit
  121. jae short KiPP20 ; if ae, address above limit
  122. test r9, (PfAffinity - PfProfileListEntry)[r8] ; check if in set
  123. jz short KiPP20 ; if z, processor not in set
  124. mov cl, (PfBucketShift - PfProfileListEntry)[r8] ; get shift count
  125. mov r11, r10 ; compute offset into profile buffer
  126. sub r11, (PfRangeBase - PfProfileListEntry)[r8] ;
  127. shr r11, cl ;
  128. and r11, NOT 3 ;
  129. mov rcx, (PfBuffer - PfProfileListEntry)[r8] ; get profile buffer address
  130. inc dword ptr [r11][rcx] ; increment profile bucket
  131. KiPP20: mov r8, LsFlink[r8] ; get next entry address
  132. cmp r8, rdx ; check if end of list
  133. jne short KiPP10 ; if ne, not end of list
  134. KiPP30: ret ; return
  135. LEAF_END KiProcessProfileList, _TEXT$00
  136. end