cpuidamd64.S 633 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * The CPUID instruction is always supported on the amd64.
  3. */
  4. .globl cpuid
  5. cpuid:
  6. pushq %rbx
  7. pushq %rcx
  8. pushq %rdx
  9. movq %rdi, %rax
  10. movq %rsi, %rcx
  11. pushq %r15
  12. movq %rdx, %r15
  13. cpuid /* Argument in %rax */
  14. // Plan 9 just moves them as a,b,c,d. Weird.
  15. movl %eax, 0(%r15)
  16. movl %ebx, 4(%r15)
  17. movl %ecx, 8(%r15)
  18. movl %edx, 12(%r15)
  19. popq %r15
  20. popq %rdx
  21. popq %rcx
  22. pop %rbx
  23. ret
  24. /*
  25. * Basic timing loop to determine CPU frequency.
  26. * The AAM instruction is not available in 64-bit mode.
  27. */
  28. .globl aamloop
  29. aamloop:
  30. pushq %rcx
  31. movq %rdi, %rcx
  32. aaml1:
  33. xorq %rax, %rax /* close enough */
  34. loop aaml1
  35. popq %rcx
  36. ret