VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/tstInstrEmul.cpp@ 14806

Last change on this file since 14806 was 13567, checked in by vboxsync, 16 years ago

tstInstrEmul: unbusted the darwin build and straigthened up the testcase output a bit.

File size: 3.3 KB
Line 
1/* $Id: tstMicro.cpp 37408 2008-10-03 22:22:37Z bird $ */
2/** @file
3 * Micro Testcase, checking emulation of certain instructions
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#include <stdio.h>
26#include <VBox/vm.h>
27#include <VBox/err.h>
28#include <VBox/em.h>
29
30#include <VBox/log.h>
31#include <iprt/assert.h>
32#include <iprt/runtime.h>
33#include <iprt/stream.h>
34#include <iprt/string.h>
35#include <iprt/semaphore.h>
36
37
38int main(int argc, char **argv)
39{
40 int rcRet = 0; /* error count. */
41
42 RTR3Init();
43 RTPrintf("tstInstrEmul: TESTING...\n");
44
45 uint32_t eax, edx, ebx, ecx, eflags;
46 uint64_t val;
47
48 val = UINT64_C(0xffffffffffff);
49 eax = 0xffffffff;
50 edx = 0xffff;
51 ebx = 0x1;
52 ecx = 0x2;
53 eflags = EMEmulateLockCmpXchg8b(&val, &eax, &edx, ebx, ecx);
54 if ( !(eflags & X86_EFL_ZF)
55 || val != UINT64_C(0x200000001))
56 {
57 RTPrintf("tstInstrEmul: FAILURE - Lock cmpxchg8b failed the equal case! (val=%x%x)\n", val);
58 return 1;
59 }
60 val = UINT64_C(0x123456789);
61 eflags = EMEmulateLockCmpXchg8b(&val, &eax, &edx, ebx, ecx);
62 if ( (eflags & X86_EFL_ZF)
63 || eax != 0x23456789
64 || edx != 0x1)
65 {
66 RTPrintf("tstInstrEmul: FAILURE - Lock cmpxchg8b failed the non-equal case! (val=%x%x)\n", val);
67 return 1;
68 }
69 RTPrintf("tstInstrEmul: Testing lock cmpxchg instruction emulation - SUCCESS\n");
70
71 val = UINT64_C(0xffffffffffff);
72 eax = 0xffffffff;
73 edx = 0xffff;
74 ebx = 0x1;
75 ecx = 0x2;
76 eflags = EMEmulateCmpXchg8b(&val, &eax, &edx, ebx, ecx);
77 if ( !(eflags & X86_EFL_ZF)
78 || val != UINT64_C(0x200000001))
79 {
80 RTPrintf("tstInstrEmul: FAILURE - Cmpxchg8b failed the equal case! (val=%x%x)\n", val);
81 return 1;
82 }
83 val = UINT64_C(0x123456789);
84 eflags = EMEmulateCmpXchg8b(&val, &eax, &edx, ebx, ecx);
85 if ( (eflags & X86_EFL_ZF)
86 || eax != 0x23456789
87 || edx != 0x1)
88 {
89 RTPrintf("tstInstrEmul: FAILURE - Cmpxchg8b failed the non-equal case! (val=%x%x)\n", val);
90 return 1;
91 }
92 RTPrintf("tstInstrEmul: Testing cmpxchg instruction emulation - SUCCESS\n");
93
94
95 /*
96 * Summary.
97 */
98 if (!rcRet)
99 RTPrintf("tstInstrEmul: SUCCESS\n");
100 else
101 RTPrintf("tstInstrEmul: FAILURE - %d errors\n", rcRet);
102 return rcRet ? 1 : 0;
103}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette