Changeset 6175 in vbox for trunk/include/iprt
- Timestamp:
- Dec 21, 2007 9:34:13 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r5999 r6175 588 588 589 589 /** 590 * Performs the cpuid instruction returning all registers. 591 * Some subfunctions of cpuid take ECX as additional parameter (currently known for EAX=4) 592 * 593 * @param uOperator CPUID operation (eax). 594 * @param uIdxECX ecx index 595 * @param pvEAX Where to store eax. 596 * @param pvEBX Where to store ebx. 597 * @param pvECX Where to store ecx. 598 * @param pvEDX Where to store edx. 599 * @remark We're using void pointers to ease the use of special bitfield structures and such. 600 */ 601 #if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN 602 DECLASM(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX); 603 #else 604 DECLINLINE(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX) 605 { 606 # if RT_INLINE_ASM_GNU_STYLE 607 # ifdef RT_ARCH_AMD64 608 RTCCUINTREG uRAX, uRBX, uRCX, uRDX; 609 __asm__ ("cpuid\n\t" 610 : "=a" (uRAX), 611 "=b" (uRBX), 612 "=c" (uRCX), 613 "=d" (uRDX) 614 : "0" (uOperator), 615 "2" (uIdxECX)); 616 *(uint32_t *)pvEAX = (uint32_t)uRAX; 617 *(uint32_t *)pvEBX = (uint32_t)uRBX; 618 *(uint32_t *)pvECX = (uint32_t)uRCX; 619 *(uint32_t *)pvEDX = (uint32_t)uRDX; 620 # else 621 __asm__ ("xchgl %%ebx, %1\n\t" 622 "cpuid\n\t" 623 "xchgl %%ebx, %1\n\t" 624 : "=a" (*(uint32_t *)pvEAX), 625 "=r" (*(uint32_t *)pvEBX), 626 "=c" (*(uint32_t *)pvECX), 627 "=d" (*(uint32_t *)pvEDX) 628 : "0" (uOperator), 629 "2" (uIdxECX)); 630 # endif 631 632 # elif RT_INLINE_ASM_USES_INTRIN 633 int aInfo[4]; 634 /* ??? another intrinsic ??? */ 635 __cpuid(aInfo, uOperator); 636 *(uint32_t *)pvEAX = aInfo[0]; 637 *(uint32_t *)pvEBX = aInfo[1]; 638 *(uint32_t *)pvECX = aInfo[2]; 639 *(uint32_t *)pvEDX = aInfo[3]; 640 641 # else 642 uint32_t uEAX; 643 uint32_t uEBX; 644 uint32_t uECX; 645 uint32_t uEDX; 646 __asm 647 { 648 push ebx 649 mov eax, [uOperator] 650 mov ecx, [uIdxECX] 651 cpuid 652 mov [uEAX], eax 653 mov [uEBX], ebx 654 mov [uECX], ecx 655 mov [uEDX], edx 656 pop ebx 657 } 658 *(uint32_t *)pvEAX = uEAX; 659 *(uint32_t *)pvEBX = uEBX; 660 *(uint32_t *)pvECX = uECX; 661 *(uint32_t *)pvEDX = uEDX; 662 # endif 663 } 664 #endif 665 666 667 /** 590 668 * Performs the cpuid instruction returning ecx and edx. 591 669 *
Note:
See TracChangeset
for help on using the changeset viewer.