VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMGC/MMRamGCA.asm@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1;; @file
2;
3; MMRamGCA - Guest Context Ram access Assembly Routines.
4
5; Copyright (C) 2006 InnoTek Systemberatung GmbH
6;
7; This file is part of VirtualBox Open Source Edition (OSE), as
8; available from http://www.virtualbox.org. This file is free software;
9; you can redistribute it and/or modify it under the terms of the GNU
10; General Public License as published by the Free Software Foundation,
11; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
12; distribution. VirtualBox OSE is distributed in the hope that it will
13; be useful, but WITHOUT ANY WARRANTY of any kind.
14;
15; If you received this file as part of a commercial VirtualBox
16; distribution, then only the terms of your commercial VirtualBox
17; license agreement apply instead of the previous paragraph.
18
19;*******************************************************************************
20;* Header Files *
21;*******************************************************************************
22%include "VBox/nasm.mac"
23%include "VBox/err.mac"
24%include "iprt/err.mac"
25%include "VBox/x86.mac"
26
27
28BEGINCODE
29
30
31;;
32; Read data in guest context, CDECL calling conv.
33; MMGCDECL(int) MMGCRamRead(void *pDst, void *pSrc, size_t cb);
34; MMRamGC page fault handler must be installed prior this call for safe operation.
35;
36; @returns eax=0 if data read, other code - invalid access, #PF was generated.
37; @param [esp + 04h] Param 1 - Pointer where to store result data (pDst).
38; @param [esp + 08h] Param 2 - Pointer of data to read (pSrc).
39; @param [esp + 0ch] Param 3 - Size of data to read, only 1/2/4/8 is valid.
40; @uses eax, ecx, edx
41;
42; @remark Data is saved to destination (Param 1) even if read error occurred!
43;
44align 16
45BEGINPROC MMGCRamReadNoTrapHandler
46 mov eax, [esp + 0ch] ; eax = size of data to read
47 cmp eax, byte 8 ; yes, it's slow, validate input
48 ja ramread_InvalidSize
49 mov edx, [esp + 04h] ; edx = result address
50 mov ecx, [esp + 08h] ; ecx = data address
51 jmp [ramread_table + eax*4]
52
53ramread_byte:
54 xor eax, eax ; rc = VINF_SUCCESS by default
55 mov cl, [ecx] ; read data
56 mov [edx], cl ; save data
57 ret
58
59ramread_word:
60 xor eax, eax ; rc = VINF_SUCCESS by default
61 mov cx, [ecx] ; read data
62 mov [edx], cx ; save data
63 ret
64
65ramread_dword:
66 xor eax, eax ; rc = VINF_SUCCESS by default
67 mov ecx, [ecx] ; read data
68 mov [edx], ecx ; save data
69 ret
70
71ramread_qword:
72 mov eax, [ecx] ; read data
73 mov [edx], eax ; save data
74 mov eax, [ecx+4] ; read data
75 mov [edx+4], eax ; save data
76 xor eax, eax ; rc = VINF_SUCCESS by default
77 ret
78
79; Read error - we will be here after our page fault handler.
80GLOBALNAME MMGCRamRead_Error
81 mov eax, VERR_ACCESS_DENIED
82 ret
83
84; Invalid data size
85ramread_InvalidSize:
86 mov eax, VERR_INVALID_PARAMETER
87 ret
88
89; Jump table
90ramread_table:
91 DD ramread_InvalidSize
92 DD ramread_byte
93 DD ramread_word
94 DD ramread_InvalidSize
95 DD ramread_dword
96 DD ramread_InvalidSize
97 DD ramread_InvalidSize
98 DD ramread_InvalidSize
99 DD ramread_qword
100ENDPROC MMGCRamReadNoTrapHandler
101
102
103;;
104; Write data in guest context, CDECL calling conv.
105; MMGCDECL(int) MMGCRamWrite(void *pDst, void *pSrc, size_t cb);
106;
107; @returns eax=0 if data written, other code - invalid access, #PF was generated.
108; @param [esp + 04h] Param 1 - Pointer where to write data (pDst).
109; @param [esp + 08h] Param 2 - Pointer of data to write (pSrc).
110; @param [esp + 0ch] Param 3 - Size of data to write, only 1/2/4 is valid.
111; @uses eax, ecx, edx
112;
113align 16
114BEGINPROC MMGCRamWriteNoTrapHandler
115 mov eax, [esp + 0ch] ; eax = size of data to write
116 cmp eax, byte 4 ; yes, it's slow, validate input
117 ja ramwrite_InvalidSize
118 mov edx, [esp + 04h] ; edx = write address
119 mov ecx, [esp + 08h] ; ecx = data address
120 jmp [ramwrite_table + eax*4]
121
122ramwrite_byte:
123 xor eax, eax ; rc = VINF_SUCCESS by default
124 mov cl, [ecx] ; read data
125 mov [edx], cl ; write data
126 ret
127
128ramwrite_word:
129 xor eax, eax ; rc = VINF_SUCCESS by default
130 mov cx, [ecx] ; read data
131 mov [edx], cx ; write data
132 ret
133
134ramwrite_dword:
135 xor eax, eax ; rc = VINF_SUCCESS by default
136 mov ecx, [ecx] ; read data
137 mov [edx], ecx ; write data
138 ret
139
140; Write error - we will be here after our page fault handler.
141GLOBALNAME MMGCRamWrite_Error
142 mov eax, VERR_ACCESS_DENIED
143 ret
144
145; Invalid data size
146ramwrite_InvalidSize:
147 mov eax, VERR_INVALID_PARAMETER
148 ret
149
150; Jump table
151ramwrite_table:
152 DD ramwrite_InvalidSize
153 DD ramwrite_byte
154 DD ramwrite_word
155 DD ramwrite_InvalidSize
156 DD ramwrite_dword
157ENDPROC MMGCRamWriteNoTrapHandler
158
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