1 | ; $Id: bs3-mode-MemCopyFlat.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3MemCopyFlat
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2023-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 | ;*********************************************************************************************************************************
|
---|
38 | ;* Header Files *
|
---|
39 | ;*********************************************************************************************************************************
|
---|
40 | %include "bs3kit-template-header.mac"
|
---|
41 |
|
---|
42 |
|
---|
43 | ;*********************************************************************************************************************************
|
---|
44 | ;* External symbols *
|
---|
45 | ;*********************************************************************************************************************************
|
---|
46 | TMPL_BEGIN_TEXT
|
---|
47 | extern TMPL_NM(Bs3SwitchToRM)
|
---|
48 | BS3_BEGIN_TEXT16
|
---|
49 | extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_rm)
|
---|
50 |
|
---|
51 | BS3_EXTERN_DATA16 g_aBs3RmIvtOriginal
|
---|
52 | %ifdef TMPL_16BIT
|
---|
53 | extern NAME(Bs3SwitchTo32BitAndCallC_rm_far)
|
---|
54 | %else
|
---|
55 | BS3_EXTERN_CMN Bs3MemCpy
|
---|
56 | %endif
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | ;;
|
---|
61 | ; Copies memory from/to real mode.
|
---|
62 | ;
|
---|
63 | ; ASSUMES 386+.
|
---|
64 | ;
|
---|
65 | ; @cproto BS3_MODE_PROTO_STUB(void BS3_FAR *, Bs3MemCopyFlat,(uint32_t uFlatDst, uint32_t uFlatSrc, uint32_t cbToCopy));
|
---|
66 | ;
|
---|
67 | TMPL_BEGIN_TEXT
|
---|
68 | BS3_PROC_BEGIN_MODE Bs3MemCopyFlat, BS3_PBC_HYBRID
|
---|
69 | %ifdef TMPL_64BIT
|
---|
70 | mov ecx, ecx
|
---|
71 | mov edx, edx
|
---|
72 | mov r8d, r8d
|
---|
73 | jmp Bs3MemCpy
|
---|
74 | %elifdef TMPL_32BIT
|
---|
75 | jmp Bs3MemCpy
|
---|
76 | %else
|
---|
77 | push xBP
|
---|
78 | mov xBP, xSP
|
---|
79 |
|
---|
80 | ; Just call Bs3SwitchTo32BitAndCallC w/ Bs3MemCpy_c32
|
---|
81 | push dword [xBP + xCB + cbCurRetAddr + 4 + 4]
|
---|
82 | push dword [xBP + xCB + cbCurRetAddr + 4]
|
---|
83 | push dword [xBP + xCB + cbCurRetAddr]
|
---|
84 | push word 4 * 3
|
---|
85 | push seg .copy32_bit_worker
|
---|
86 | push word .copy32_bit_worker
|
---|
87 | call far NAME(Bs3SwitchTo32BitAndCallC_rm_far)
|
---|
88 |
|
---|
89 | leave
|
---|
90 | BS3_HYBRID_RET
|
---|
91 |
|
---|
92 | BITS 32
|
---|
93 | .copy32_bit_worker:
|
---|
94 | push ebp
|
---|
95 | mov ebp, esp
|
---|
96 | push edi
|
---|
97 | push esi
|
---|
98 | push ecx
|
---|
99 |
|
---|
100 | mov edi, [ebp + 8]
|
---|
101 | mov esi, [ebp + 12]
|
---|
102 | mov ecx, [ebp + 16]
|
---|
103 | cld
|
---|
104 | rep movsb
|
---|
105 |
|
---|
106 | pop ecx
|
---|
107 | pop esi
|
---|
108 | pop edi
|
---|
109 | leave
|
---|
110 | ret
|
---|
111 | BITS 16
|
---|
112 | %endif
|
---|
113 | BS3_PROC_END_MODE Bs3MemCopyFlat
|
---|
114 |
|
---|