cpuid_amd64.s 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // The MIT License (MIT)
  2. //
  3. // Copyright (c) 2015 Klaus Post
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in all
  13. // copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. // SOFTWARE.
  22. // +build amd64,!gccgo
  23. // func cpuid(op uint32) (eax, ebx, ecx, edx uint32)
  24. TEXT ·cpuid(SB), 7, $0
  25. XORQ CX, CX
  26. MOVL op+0(FP), AX
  27. CPUID
  28. MOVL AX, eax+8(FP)
  29. MOVL BX, ebx+12(FP)
  30. MOVL CX, ecx+16(FP)
  31. MOVL DX, edx+20(FP)
  32. RET
  33. // func cpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32)
  34. TEXT ·cpuidex(SB), 7, $0
  35. MOVL op+0(FP), AX
  36. MOVL op2+4(FP), CX
  37. CPUID
  38. MOVL AX, eax+8(FP)
  39. MOVL BX, ebx+12(FP)
  40. MOVL CX, ecx+16(FP)
  41. MOVL DX, edx+20(FP)
  42. RET
  43. // func xgetbv(index uint32) (eax, edx uint32)
  44. TEXT ·xgetbv(SB), 7, $0
  45. MOVL index+0(FP), CX
  46. BYTE $0x0f; BYTE $0x01; BYTE $0xd0 // XGETBV
  47. MOVL AX, eax+8(FP)
  48. MOVL DX, edx+12(FP)
  49. RET