Changeset 11508 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Aug 20, 2008 9:46:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/EMAllA.asm
r9984 r11508 50 50 ; EMDECL(uint32_t) EMEmulateCmp(uint32_t u32Param1, uint64_t u64Param2, size_t cb); 51 51 ; 52 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.52 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 53 53 ; @param [esp + 04h] rdi rcx Param 1 - First parameter (Dst). 54 54 ; @param [esp + 08h] rsi edx Param 2 - Second parameter (Src). … … 114 114 ; EMDECL(uint32_t) EMEmulateAnd(void *pvParam1, uint64_t u64Param2, size_t cb); 115 115 ; 116 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.116 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 117 117 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 118 118 ; @param [esp + 08h] Param 2 - Second parameter. … … 179 179 ; EMDECL(uint32_t) EMEmulateOr(void *pvParam1, uint64_t u64Param2, size_t cb); 180 180 ; 181 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.181 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 182 182 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 183 183 ; @param [esp + 08h] Param 2 - Second parameter. … … 326 326 ; EMDECL(uint32_t) EMEmulateXor(void *pvParam1, uint64_t u64Param2, size_t cb); 327 327 ; 328 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.328 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 329 329 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 330 330 ; @param [esp + 08h] Param 2 - Second parameter. … … 515 515 ; EMDECL(uint32_t) EMEmulateAdd(void *pvParam1, uint64_t u64Param2, size_t cb); 516 516 ; 517 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.517 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 518 518 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 519 519 ; @param [esp + 08h] Param 2 - Second parameter. … … 579 579 ; EMDECL(uint32_t) EMEmulateAdcWithCarrySet(void *pvParam1, uint64_t u64Param2, size_t cb); 580 580 ; 581 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.581 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 582 582 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 583 583 ; @param [esp + 08h] Param 2 - Second parameter. … … 647 647 ; EMDECL(uint32_t) EMEmulateSub(void *pvParam1, uint64_t u64Param2, size_t cb); 648 648 ; 649 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.649 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 650 650 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 651 651 ; @param [esp + 08h] Param 2 - Second parameter. … … 712 712 ; EMDECL(uint32_t) EMEmulateBtr(void *pvParam1, uint64_t u64Param2); 713 713 ; 714 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.714 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 715 715 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 716 716 ; @param [esp + 08h] Param 2 - Second parameter. … … 785 785 ; EMDECL(uint32_t) EMEmulateBtc(void *pvParam1, uint64_t u64Param2); 786 786 ; 787 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.787 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 788 788 ; @param [esp + 04h] Param 1 - First parameter - pointer to data item. 789 789 ; @param [esp + 08h] Param 2 - Second parameter. … … 842 842 843 843 844 %if 0845 ;; untested code!!846 847 844 ;; 848 845 ; Emulate LOCK CMPXCHG instruction, CDECL calling conv. 849 ; EMDECL(uint32_t) EMEmulateLockCmpXchg 32(RTHCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize);850 ; 851 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.846 ; EMDECL(uint32_t) EMEmulateLockCmpXchg(void *pvParam1, uint64_t *pu64Param2, uint64_t u64Param3, size_t cbSize); 847 ; 848 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 852 849 ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to first parameter 853 850 ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - pointer to second parameter (eax) 854 851 ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - third parameter 855 ; @param [esp + 10h] gcc:rcx msc:r9 Param 4 - Size of parameters, only 1/2/4 is valid 856 ; @uses eax, ecx, edx 857 ; 858 align 16 859 BEGINPROC EMEmulateLockCmpXchg32 860 push ebx 852 ; @param [esp + 14h] gcc:rcx msc:r9 Param 4 - Size of parameters, only 1/2/4/8 is valid 853 ; @uses eax, ecx, edx 854 ; 855 align 16 856 BEGINPROC EMEmulateLockCmpXchg 857 push xBX 858 %ifdef RT_ARCH_AMD64 859 %ifdef RT_OS_WINDOWS 860 ; rcx contains the first parameter already 861 mov rbx, rdx ; rdx = 2nd parameter 862 mov rdx, r8 ; r8 = 3rd parameter 863 mov rax, r9 ; r9 = size of parameters 864 %else 865 mov rax, rcx ; rcx = size of parameters (4th) 866 mov rcx, rdi ; rdi = 1st parameter 867 mov rbx, rsi ; rsi = second parameter 868 ;rdx contains the 3rd parameter already 869 %endif ; !RT_OS_WINDOWS 870 %else ; !RT_ARCH_AMD64 861 871 mov ecx, [esp + 04h + 4] ; ecx = first parameter 862 872 mov ebx, [esp + 08h + 4] ; ebx = 2nd parameter (eax) 863 873 mov edx, [esp + 0ch + 4] ; edx = third parameter 864 mov eax, [esp + 10h + 4] ; eax = size of parameters 865 874 mov eax, [esp + 14h + 4] ; eax = size of parameters 875 %endif 876 877 %ifdef RT_ARCH_AMD64 878 cmp al, 8 879 je short .do_qword ; 4 bytes variant 880 %endif 866 881 cmp al, 4 867 882 je short .do_dword ; 4 bytes variant … … 872 887 int3 873 888 889 %ifdef RT_ARCH_AMD64 890 .do_qword: 891 ; load 2nd parameter's value 892 mov rax, qword [rbx] 893 894 lock cmpxchg qword [rcx], rdx ; do 8 bytes CMPXCHG 895 mov qword [rbx], rax 896 jmp short .done 897 %endif 898 874 899 .do_dword: 875 900 ; load 2nd parameter's value 876 mov eax, dword [ ebx]877 878 lock cmpxchg dword [ ecx], edx ; do 4 bytes CMPXCHG879 mov dword [ ebx], eax901 mov eax, dword [xBX] 902 903 lock cmpxchg dword [xCX], edx ; do 4 bytes CMPXCHG 904 mov dword [xBX], eax 880 905 jmp short .done 881 906 882 907 .do_word: 883 908 ; load 2nd parameter's value 884 mov eax, dword [ ebx]885 886 lock cmpxchg word [ ecx], dx ; do 2 bytes CMPXCHG887 mov word [ ebx], ax909 mov eax, dword [xBX] 910 911 lock cmpxchg word [xCX], dx ; do 2 bytes CMPXCHG 912 mov word [xBX], ax 888 913 jmp short .done 889 914 890 915 .do_byte: 891 916 ; load 2nd parameter's value 892 mov eax, dword [ ebx]893 894 lock cmpxchg byte [ ecx], dl ; do 1 bytesCMPXCHG895 mov byte [ ebx], al917 mov eax, dword [xBX] 918 919 lock cmpxchg byte [xCX], dl ; do 1 byte CMPXCHG 920 mov byte [xBX], al 896 921 897 922 .done: 898 923 ; collect flags and return. 899 924 pushf 900 pop eax 901 902 pop ebx 903 retn 904 905 ENDPROC EMEmulateLockCmpXchg32 925 pop MY_RET_REG 926 927 pop xBX 928 retn 929 ENDPROC EMEmulateLockCmpXchg 906 930 907 931 ;; 908 932 ; Emulate CMPXCHG instruction, CDECL calling conv. 909 ; EMDECL(uint32_t) EMEmulateCmpXchg 32(RTHCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize);910 ; 911 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.933 ; EMDECL(uint32_t) EMEmulateCmpXchg(void *pvParam1, uint64_t *pu32Param2, uint64_t u32Param3, size_t cbSize); 934 ; 935 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 912 936 ; @param [esp + 04h] gcc:rdi msc:rcx Param 1 - First parameter - pointer to first parameter 913 937 ; @param [esp + 08h] gcc:rsi msc:rdx Param 2 - pointer to second parameter (eax) 914 938 ; @param [esp + 0ch] gcc:rdx msc:r8 Param 3 - third parameter 915 ; @param [esp + 10h] gcc:rcx msc:r9 Param 4 - Size of parameters, only 1/2/4 is valid. 916 ; @uses eax, ecx, edx 917 ; 918 align 16 919 BEGINPROC EMEmulateCmpXchg32 920 push ebx 939 ; @param [esp + 14h] gcc:rcx msc:r9 Param 4 - Size of parameters, only 1/2/4 is valid. 940 ; @uses eax, ecx, edx 941 ; 942 align 16 943 BEGINPROC EMEmulateCmpXchg 944 push xBX 945 %ifdef RT_ARCH_AMD64 946 %ifdef RT_OS_WINDOWS 947 ; rcx contains the first parameter already 948 mov rbx, rdx ; rdx = 2nd parameter 949 mov rdx, r8 ; r8 = 3rd parameter 950 mov rax, r9 ; r9 = size of parameters 951 %else 952 mov rax, rcx ; rcx = size of parameters (4th) 953 mov rcx, rdi ; rdi = 1st parameter 954 mov rbx, rsi ; rsi = second parameter 955 ;rdx contains the 3rd parameter already 956 %endif ; !RT_OS_WINDOWS 957 %else ; !RT_ARCH_AMD64 921 958 mov ecx, [esp + 04h + 4] ; ecx = first parameter 922 959 mov ebx, [esp + 08h + 4] ; ebx = 2nd parameter (eax) 923 960 mov edx, [esp + 0ch + 4] ; edx = third parameter 924 mov eax, [esp + 10h + 4] ; eax = size of parameters 925 961 mov eax, [esp + 14h + 4] ; eax = size of parameters 962 %endif 963 964 %ifdef RT_ARCH_AMD64 965 cmp al, 8 966 je short .do_qword ; 4 bytes variant 967 %endif 926 968 cmp al, 4 927 969 je short .do_dword ; 4 bytes variant … … 932 974 int3 933 975 976 %ifdef RT_ARCH_AMD64 977 .do_qword: 978 ; load 2nd parameter's value 979 mov rax, qword [rbx] 980 981 cmpxchg qword [rcx], rdx ; do 8 bytes CMPXCHG 982 mov qword [rbx], rax 983 jmp short .done 984 %endif 985 934 986 .do_dword: 935 987 ; load 2nd parameter's value 936 mov eax, dword [ ebx]937 938 cmpxchg dword [ ecx], edx ; do 4 bytes CMPXCHG939 mov dword [ ebx], eax988 mov eax, dword [xBX] 989 990 cmpxchg dword [xCX], edx ; do 4 bytes CMPXCHG 991 mov dword [xBX], eax 940 992 jmp short .done 941 993 942 994 .do_word: 943 995 ; load 2nd parameter's value 944 mov eax, dword [ ebx]945 946 cmpxchg word [ ecx], dx ; do 2 bytes CMPXCHG947 mov word [ ebx], ax996 mov eax, dword [xBX] 997 998 cmpxchg word [xCX], dx ; do 2 bytes CMPXCHG 999 mov word [xBX], ax 948 1000 jmp short .done 949 1001 950 1002 .do_byte: 951 1003 ; load 2nd parameter's value 952 mov eax, dword [ ebx]953 954 cmpxchg byte [ ecx], dl ; do 1 bytesCMPXCHG955 mov byte [ ebx], al1004 mov eax, dword [xBX] 1005 1006 cmpxchg byte [xCX], dl ; do 1 byte CMPXCHG 1007 mov byte [xBX], al 956 1008 957 1009 .done: 958 1010 ; collect flags and return. 959 1011 pushf 960 pop eax 961 962 pop ebx 963 retn 964 965 ENDPROC EMEmulateCmpXchg32 1012 pop MY_RET_REG 1013 1014 pop xBX 1015 retn 1016 ENDPROC EMEmulateCmpXchg 1017 1018 %if 0 1019 ;; not tested!! 966 1020 967 1021 ;; … … 969 1023 ; EMDECL(uint32_t) EMEmulateLockCmpXchg8b(RTHCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX); 970 1024 ; 971 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.1025 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 972 1026 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter 973 1027 ; @param [esp + 08h] Param 2 - Address of the eax register … … 978 1032 ; 979 1033 align 16 980 BEGINPROC EMEmulateLockCmpXchg8b 321034 BEGINPROC EMEmulateLockCmpXchg8b 981 1035 push ebp 982 1036 push ebx … … 1003 1057 retn 1004 1058 1005 ENDPROC EMEmulateLockCmpXchg8b 321059 ENDPROC EMEmulateLockCmpXchg8b 1006 1060 1007 1061 ;; 1008 1062 ; Emulate CMPXCHG8B instruction, CDECL calling conv. 1009 ; EMDECL(uint32_t) EMEmulateCmpXchg8b 32(RTHCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);1010 ; 1011 ; @returns EFLAGS after the operation, only arithmetic flags isvalid.1063 ; EMDECL(uint32_t) EMEmulateCmpXchg8b(RTHCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX); 1064 ; 1065 ; @returns EFLAGS after the operation, only arithmetic flags are valid. 1012 1066 ; @param [esp + 04h] Param 1 - First parameter - pointer to first parameter 1013 1067 ; @param [esp + 08h] Param 2 - Address of the eax register … … 1018 1072 ; 1019 1073 align 16 1020 BEGINPROC EMEmulateCmpXchg8b 321074 BEGINPROC EMEmulateCmpXchg8b 1021 1075 push ebp 1022 1076 push ebx … … 1042 1096 pop ebp 1043 1097 retn 1044 ENDPROC EMEmulateCmpXchg8b 321045 1046 %endif 1098 ENDPROC EMEmulateCmpXchg8b 1099 1100 %endif
Note:
See TracChangeset
for help on using the changeset viewer.