f1c610f9c83bd9b8f3152798fce6dee4bc2a7ee4
[reactos.git] / ntoskrnl / mm / i386 / memsafe.s
1 .globl _MmSafeCopyFromUser
2 .globl _MmSafeCopyFromUserUnsafeStart
3 .globl _MmSafeCopyFromUserRestart
4 .globl _MmSafeCopyToUser
5 .globl _MmSafeCopyToUserUnsafeStart
6 .globl _MmSafeCopyToUserRestart
7
8         /*
9          * NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, 
10          *                             ULONG NumberOfBytes)
11          */
12 _MmSafeCopyFromUser:
13         pushl   %ebp
14         movl    %esp,%ebp
15
16         pushl   %esi
17         pushl   %edi
18         pushl   %ecx
19         
20         movl    8(%ebp),%edi
21         movl    12(%ebp),%esi
22         movl    16(%ebp),%ecx
23
24         /*
25          * Default return code
26          */ 
27         movl    $0,%eax
28
29 _MmSafeCopyFromUserUnsafeStart:         
30         /*
31          * This is really a synthetic instruction since if we incur a
32          * pagefault then eax will be set to an appropiate STATUS code
33          */ 
34         rep movsb
35
36 _MmSafeCopyFromUserRestart:
37
38         popl    %ecx
39         popl    %edi
40         popl    %esi
41
42         popl    %ebp
43         ret
44
45 /*****************************************************************************/
46
47         /*
48          * NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, 
49          *                      ULONG NumberOfBytes)
50          */ 
51 _MmSafeCopyToUser:
52         pushl   %ebp
53         movl    %esp,%ebp
54
55         pushl   %esi
56         pushl   %edi
57         pushl   %ecx
58         
59         movl    8(%ebp),%edi
60         movl    12(%ebp),%esi
61         movl    16(%ebp),%ecx
62
63         /*
64          * Default return code
65          */ 
66         movl    $0,%eax
67
68 _MmSafeCopyToUserUnsafeStart:            
69         /*
70          * This is really a synthetic instruction since if we incur a
71          * pagefault then eax will be set to an appropiate STATUS code
72          */ 
73         rep movsb
74
75 _MmSafeCopyToUserRestart:
76
77         popl    %ecx
78         popl    %edi
79         popl    %esi
80         
81         popl    %ebp
82         ret
83