Subversion Repositories HelenOS-historic

Rev

Rev 1278 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1278 Rev 1288
Line 35... Line 35...
35
.text
35
.text
36
 
36
 
37
.global paging_on
37
.global paging_on
38
.global enable_l_apic_in_msr
38
.global enable_l_apic_in_msr
39
.global interrupt_handlers
39
.global interrupt_handlers
-
 
40
.global memcpy
-
 
41
.global memcpy_from_uspace
-
 
42
.global memcpy_from_uspace_failover_address
-
 
43
.global memcpy_to_uspace
-
 
44
.global memcpy_to_uspace_failover_address
-
 
45
 
-
 
46
 
-
 
47
#define MEMCPY_DST	4
-
 
48
#define MEMCPY_SRC	8
-
 
49
#define MEMCPY_SIZE	12
-
 
50
 
-
 
51
/** Copy memory to/from userspace.
-
 
52
 *
-
 
53
 * This is almost conventional memcpy().
-
 
54
 * The difference is that there is a failover part
-
 
55
 * to where control is returned from a page fault
-
 
56
 * if the page fault occurs during copy_from_uspace()
-
 
57
 * or copy_to_uspace().
-
 
58
 *
-
 
59
 * @param MEMCPY_DST(%esp)	Destination address.
-
 
60
 * @param MEMCPY_SRC(%esp)	Source address.
-
 
61
 * @param MEMCPY_SIZE(%esp)	Size.
-
 
62
 *
-
 
63
 * @return MEMCPY_SRC(%esp) on success and 0 on failure.
-
 
64
 */
-
 
65
memcpy:
-
 
66
memcpy_from_uspace:
-
 
67
memcpy_to_uspace:
-
 
68
	movl %edi, %edx				/* save %edi */
-
 
69
	movl %esi, %eax				/* save %esi */
-
 
70
	
-
 
71
	movl MEMCPY_SIZE(%esp), %ecx
-
 
72
	shrl $2, %ecx				/* size / 4 */
-
 
73
	
-
 
74
	movl MEMCPY_DST(%esp), %edi
-
 
75
	movl MEMCPY_SRC(%esp), %esi
-
 
76
	
-
 
77
	rep movsl				/* copy as much as possible word by word */
-
 
78
 
-
 
79
	movl MEMCPY_SIZE(%esp), %ecx
-
 
80
	andl $3, %ecx				/* size % 4 */
-
 
81
	jz 0f
-
 
82
	
-
 
83
	rep movsb				/* copy the rest byte by byte */
-
 
84
 
-
 
85
0:
-
 
86
	movl %edx, %edi
-
 
87
	movl %eax, %esi
-
 
88
	movl MEMCPY_SRC(%esp), %eax		/* MEMCPY_SRC(%esp), success */
-
 
89
	ret
-
 
90
	
-
 
91
/*
-
 
92
 * We got here from as_page_fault() after the memory operations
-
 
93
 * above had caused a page fault.
-
 
94
 */
-
 
95
memcpy_from_uspace_failover_address:
-
 
96
memcpy_to_uspace_failover_address:
-
 
97
	movl %edx, %edi
-
 
98
	movl %eax, %esi
-
 
99
	xorl %eax, %eax				/* return 0, failure */
-
 
100
	ret
40
 
101
 
41
## Turn paging on
102
## Turn paging on
42
#
103
#
43
# Enable paging and write-back caching in CR0.
104
# Enable paging and write-back caching in CR0.
44
#
105
#