env-common.mac revision 08fc4eb537ed24136b05660d0aa038b336516961
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; Instruction Test Environment - Common Bits.
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; Copyright (C) 2006-2013 Oracle Corporation
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; available from http://www.virtualbox.org. This file is free software;
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; you can redistribute it and/or modify it under the terms of the GNU
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; General Public License (GPL) as published by the Free Software
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync%ifndef ___env_common_mac
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync%define ___env_common_mac
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync;*******************************************************************************
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync;* Defined Constants And Macros *
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync;*******************************************************************************
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync%ifdef RT_ARCH_AMD64
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %define MY_PUSH_FLAGS pushfq
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %define MY_POP_FLAGS popfq
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %define MY_PUSH_FLAGS_SIZE 8
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %macro MY_PUSH_ALL 0
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov rbp, rsp
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %macro MY_POP_ALL 0
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %define MY_PUSH_FLAGS pushfd
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %define MY_POP_FLAGS popfd
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %define MY_PUSH_FLAGS_SIZE 4
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %macro MY_PUSH_ALL 0
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov xBP, xSP
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync %macro MY_POP_ALL 0
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync;*******************************************************************************
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync;* Internal Functions *
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync;*******************************************************************************
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsyncVBINSTST_BEGINCODE
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; Report bad register value.
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; Primary purpose is save all registers and convert from our stack-based to
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; the correct calling convention for the environment.
72e9ef1022a910facbd4a232500026befd944d95vboxsync; This function will clean up the stack upon return (to save space in the caller).
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; @param uExpected
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; @param uActual
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync; @param uRegisterNo
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsyncVBINSTST_BEGINPROC Common_BadValue
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync MY_PUSH_ALL
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov xAX, xSP ; 16-byte align the stack and reserve space for arguments and stuff.
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync sub xSP, 40h
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync and xSP, ~15
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov [xSP + 38h], xAX
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync%ifdef ASM_CALL64_GCC
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov r8d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov rcx, [rbp + 10h] ; expected
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov rdx, [rbp + 18h] ; actual
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov rsi, [rbp + 20h] ; reg#
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync lea rdi, [.szFmt wrt rip]
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync VBINSTST_CALL_FN_FAILURE_4
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync%elifdef ASM_CALL64_MSC
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov r10d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov [rsp + 20h], r10
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov r9, [rbp + 10h] ; expected
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov r8, [rbp + 18h] ; actual
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov rdx, [rbp + 20h] ; reg#
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync lea rcx, [.szFmt wrt rip]
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync VBINSTST_CALL_FN_FAILURE_4
08fc4eb537ed24136b05660d0aa038b336516961vboxsync%elifdef ASM_CALL64_BS2
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) xWrtRIP]
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov sCX, [xBP + xCB + xCB] ; expected
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov sAX, [xBP + xCB + xCB + sCB*1] ; actual
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov sDX, [xBP + xCB + xCB + sCB*2] ; reg#
08fc4eb537ed24136b05660d0aa038b336516961vboxsync lea sSI, [.szFmt xWrtRIP]
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov qword [xSP + xCB + 3*sCB], sBX
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov qword [xSP + xCB + 2*sCB], sCX
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov qword [xSP + xCB + 1*sCB], sAX
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov qword [xSP + xCB], sDX
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov [xSP], sSI
08fc4eb537ed24136b05660d0aa038b336516961vboxsync VBINSTST_CALL_FN_FAILURE_4
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator)]
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov sCX, [xBP + xCB + xCB] ; expected
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov sAX, [xBP + xCB + xCB + sCB*1] ; actual
08fc4eb537ed24136b05660d0aa038b336516961vboxsync mov sDX, [xBP + xCB + xCB + sCB*2] ; reg#
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov [xSP + xCB + 3*sCB], sBX
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov [xSP + xCB + 2*sCB], sCX
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov [xSP + xCB + 1*sCB], sAX
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov [xSP + xCB], sDX
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov [xSP], RTCCPTR_PRE .szFmt
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync VBINSTST_CALL_FN_FAILURE_4
c4b8dd273d2becff4145cf4c634b566e2dd633e6vboxsync mov xSP, [xSP + 38h]
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsync%if ARCH_BITS == 64
08fc4eb537ed24136b05660d0aa038b336516961vboxsync.szFmt: db 'Bad register 0x%RX32 value 0x%RX64, expected 0x%RX64 (line %RU64)', 13, 0
08fc4eb537ed24136b05660d0aa038b336516961vboxsync.szFmt: db 'Bad register 0x%RX32 value 0x%RX32, expected 0x%RX32 (line %RU32)', 13, 0
917f4ee9f101c9786cf09ea0fe7923a7f6dfe40cvboxsyncVBINSTST_ENDPROC Common_BadValue
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; Global data variables used by Common_SetupMemReadUxx.
8541678784dbe432feebe6d9c1528525e1771397vboxsync; For address calculation reasons, these must be qword aligned.
08fc4eb537ed24136b05660d0aa038b336516961vboxsyncVBINSTST_BEGINDATA
8541678784dbe432feebe6d9c1528525e1771397vboxsync dd 09d8af498h, 09ab3e5f8h
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_GLOBALNAME_EX g_u64Data, data hidden
8541678784dbe432feebe6d9c1528525e1771397vboxsync dd 07d7af797h, 096b36562h
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_GLOBALNAME_EX g_u32Data, data hidden
8541678784dbe432feebe6d9c1528525e1771397vboxsync dd 012305987h
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_GLOBALNAME_EX g_u16Data, data hidden
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_GLOBALNAME_EX g_u8Data, data hidden
8541678784dbe432feebe6d9c1528525e1771397vboxsync dd 058daffe2h
08fc4eb537ed24136b05660d0aa038b336516961vboxsyncVBINSTST_BEGINCODE
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; Sets up g_u8Data.
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; @param uValue
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_BEGINPROC Common_SetupMemReadU8
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync mov ax, [xSP + sCB + xCB]
c6383709c15c809f8cfb09b5cfe670760f06e2b9vboxsync mov [VBINSTST_NAME(g_u8Data) xWrtRIP], ax
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_ENDPROC Common_SetupMemReadU8
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; Sets up g_u16Data.
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; @param uValue
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_BEGINPROC Common_SetupMemReadU16
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync mov ax, [xSP + sCB + xCB]
c6383709c15c809f8cfb09b5cfe670760f06e2b9vboxsync mov [VBINSTST_NAME(g_u16Data) xWrtRIP], ax
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_ENDPROC Common_SetupMemReadU16
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; Sets up g_u32Data.
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; @param uValue
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_BEGINPROC Common_SetupMemReadU32
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync mov eax, [xSP + sCB + xCB]
c6383709c15c809f8cfb09b5cfe670760f06e2b9vboxsync mov [VBINSTST_NAME(g_u32Data) xWrtRIP], eax
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_ENDPROC Common_SetupMemReadU32
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; Sets up g_u64Data.
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync; @param uValue
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_BEGINPROC Common_SetupMemReadU64
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync%ifdef RT_ARCH_AMD64
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync mov rax, [xSP + sCB + xCB]
c6383709c15c809f8cfb09b5cfe670760f06e2b9vboxsync mov [VBINSTST_NAME(g_u64Data) xWrtRIP], rax
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync mov eax, [xSP + sCB + xCB]
c6383709c15c809f8cfb09b5cfe670760f06e2b9vboxsync mov [VBINSTST_NAME(g_u64Data) xWrtRIP], eax
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsync mov eax, [xSP + sCB + xCB + 4]
c6383709c15c809f8cfb09b5cfe670760f06e2b9vboxsync mov [VBINSTST_NAME(g_u64Data) + 4 xWrtRIP], eax
f372af8e6ee2a011213b11cc69f4a29530ff7ce5vboxsyncVBINSTST_ENDPROC Common_SetupMemReadU64