1 | ; $Id: bs3-cmn-TestNow.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3TestNow.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox base platform packages, as
|
---|
10 | ; available from https://www.virtualbox.org.
|
---|
11 | ;
|
---|
12 | ; This program is free software; you can redistribute it and/or
|
---|
13 | ; modify it under the terms of the GNU General Public License
|
---|
14 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
15 | ; License.
|
---|
16 | ;
|
---|
17 | ; This program is distributed in the hope that it will be useful, but
|
---|
18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | ; General Public License for more details.
|
---|
21 | ;
|
---|
22 | ; You should have received a copy of the GNU General Public License
|
---|
23 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | ;
|
---|
25 | ; The contents of this file may alternatively be used under the terms
|
---|
26 | ; of the Common Development and Distribution License Version 1.0
|
---|
27 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | ; CDDL are applicable instead of those of the GPL.
|
---|
30 | ;
|
---|
31 | ; You may elect to license modified versions of this file under the
|
---|
32 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | ;
|
---|
34 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | ;
|
---|
36 |
|
---|
37 | %include "bs3kit-template-header.mac"
|
---|
38 | %include "VBox/VMMDevTesting.mac"
|
---|
39 |
|
---|
40 | BS3_EXTERN_DATA16 g_fbBs3VMMDevTesting
|
---|
41 | TMPL_BEGIN_TEXT
|
---|
42 |
|
---|
43 | ;;
|
---|
44 | ; @cproto BS3_DECL(uint64_t) Bs3TestNow(void);
|
---|
45 | ;
|
---|
46 | ; @uses eflags, return register(s)
|
---|
47 | ;
|
---|
48 | BS3_PROC_BEGIN_CMN Bs3TestNow, BS3_PBC_HYBRID
|
---|
49 | BS3_CALL_CONV_PROLOG 0
|
---|
50 | push xBP
|
---|
51 | mov xBP, xSP
|
---|
52 | %if __BITS__ == 16
|
---|
53 | BONLY16 push sAX
|
---|
54 | %else
|
---|
55 | push xCX
|
---|
56 | BONLY64 push xDX
|
---|
57 | %endif
|
---|
58 |
|
---|
59 | cmp byte [BS3_DATA16_WRT(g_fbBs3VMMDevTesting)], 0
|
---|
60 | je .no_vmmdev
|
---|
61 |
|
---|
62 | ; Read the lower timestamp.
|
---|
63 | mov dx, VMMDEV_TESTING_IOPORT_TS_LOW
|
---|
64 | in eax, dx
|
---|
65 | %if __BITS__ == 16
|
---|
66 | mov bx, ax ; Save the first word in BX (returned in DX).
|
---|
67 | shr eax, 16
|
---|
68 | mov cx, ax ; The second word is returned in CX.
|
---|
69 | %else
|
---|
70 | mov ecx, eax
|
---|
71 | %endif
|
---|
72 |
|
---|
73 | ; Read the high timestamp (latached in above read).
|
---|
74 | mov dx, VMMDEV_TESTING_IOPORT_TS_HIGH
|
---|
75 | in eax, dx
|
---|
76 | %if __BITS__ == 16
|
---|
77 | mov dx, bx ; The first word is returned in DX.
|
---|
78 | mov bx, ax ; The third word is returned in BX.
|
---|
79 | shr eax, 16 ; The fourth word is returned in AX.
|
---|
80 | %elif __BITS__ == 32
|
---|
81 | mov edx, eax
|
---|
82 | mov eax, ecx
|
---|
83 | %else
|
---|
84 | shl rax, 32
|
---|
85 | or rax, rcx
|
---|
86 | %endif
|
---|
87 |
|
---|
88 | .return:
|
---|
89 | %if __BITS__ == 16
|
---|
90 | mov [bp - sCB], ax ; Update the AX part of the saved EAX.
|
---|
91 | pop sAX
|
---|
92 | %else
|
---|
93 | pop xCX
|
---|
94 | BONLY64 pop xDX
|
---|
95 | %endif
|
---|
96 | pop xBP
|
---|
97 | BS3_CALL_CONV_EPILOG 0
|
---|
98 | BS3_HYBRID_RET
|
---|
99 |
|
---|
100 | .no_vmmdev:
|
---|
101 | ; No fallback, just zero the result.
|
---|
102 | %if __BITS__ == 16
|
---|
103 | xor ax, ax
|
---|
104 | xor bx, bx
|
---|
105 | xor cx, cx
|
---|
106 | xor dx, dx
|
---|
107 | %else
|
---|
108 | xor eax, eax
|
---|
109 | BONLY32 xor edx, edx
|
---|
110 | %endif
|
---|
111 | jmp .return
|
---|
112 | BS3_PROC_END_CMN Bs3TestNow
|
---|
113 |
|
---|