dosasm.s 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "asm_i386.h"
  2. .data
  3. fpenv: .long 0, 0, 0, 0, 0, 0, 0, 0
  4. .text
  5. .globl C(StartMSRInterval)
  6. C(StartMSRInterval):
  7. movl $0x11,%ecx // read the CESR
  8. .byte 0x0F
  9. .byte 0x32 // RDMSR
  10. andl $0xFE3FFE3F,%eax // stop both counters
  11. .byte 0x0F
  12. .byte 0x30 // WRMSR
  13. movl 4(%esp),%eax // point counter 0 to desired event, with counters
  14. andl $0x3F,%eax // still stopped
  15. movl $0x11,%ecx
  16. .byte 0x0F
  17. .byte 0x30 // WRMSR
  18. movl $0x12,%ecx // set counter 0 to the value 0
  19. subl %eax,%eax
  20. subl %edx,%edx
  21. .byte 0x0F
  22. .byte 0x30 // WRMSR
  23. movl 4(%esp),%eax // restart counter 0 with selected event
  24. andl $0x3F,%eax
  25. subl %edx,%edx
  26. orl $0xC0,%eax
  27. movl $0x11,%ecx // control and event select
  28. .byte 0x0F
  29. .byte 0x30 // WRMSR
  30. ret
  31. .globl C(EndMSRInterval)
  32. C(EndMSRInterval):
  33. movl $0x12,%ecx // counter 0
  34. .byte 0x0F
  35. .byte 0x32 // RDMSR
  36. ret // lower 32 bits of count in %eax
  37. #if 0
  38. .data
  39. Lxxx: .long 0
  40. .text
  41. .globl C(setstackcheck)
  42. C(setstackcheck):
  43. movl %esp,%eax
  44. subl $0x38000,%eax
  45. movl $0x5A5A5A5A,(%eax)
  46. movl %eax,Lxxx
  47. ret
  48. .globl C(dostackcheck)
  49. C(dostackcheck):
  50. movl Lxxx,%edx
  51. movl $0,%eax
  52. cmpl $0x5A5A5A5A,(%edx)
  53. jz qqq
  54. incl %eax
  55. qqq:
  56. ret
  57. #endif