Subversion Repositories HelenOS

Rev

Rev 3022 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3022 Rev 4055
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 memsetb
-
 
41
.global memsetw
40
.global memcpy
42
.global memcpy
41
.global memcpy_from_uspace
43
.global memcpy_from_uspace
42
.global memcpy_from_uspace_failover_address
44
.global memcpy_from_uspace_failover_address
43
.global memcpy_to_uspace
45
.global memcpy_to_uspace
44
.global memcpy_to_uspace_failover_address
46
.global memcpy_to_uspace_failover_address
45
 
47
 
46
 
48
 
-
 
49
# Wrapper for generic memsetb
-
 
50
memsetb:
-
 
51
	jmp _memsetb
-
 
52
 
-
 
53
# Wrapper for generic memsetw
-
 
54
memsetw:
-
 
55
	jmp _memsetw
-
 
56
 
-
 
57
 
47
#define MEMCPY_DST	4
58
#define MEMCPY_DST	4
48
#define MEMCPY_SRC	8
59
#define MEMCPY_SRC	8
49
#define MEMCPY_SIZE	12
60
#define MEMCPY_SIZE	12
50
 
61
 
51
/** Copy memory to/from userspace.
62
/** Copy memory to/from userspace.
Line 58... Line 69...
58
 *
69
 *
59
 * @param MEMCPY_DST(%esp)	Destination address.
70
 * @param MEMCPY_DST(%esp)	Destination address.
60
 * @param MEMCPY_SRC(%esp)	Source address.
71
 * @param MEMCPY_SRC(%esp)	Source address.
61
 * @param MEMCPY_SIZE(%esp)	Size.
72
 * @param MEMCPY_SIZE(%esp)	Size.
62
 *
73
 *
63
 * @return MEMCPY_SRC(%esp) on success and 0 on failure.
74
 * @return MEMCPY_DST(%esp) on success and 0 on failure.
64
 */
75
 */
65
memcpy:
76
memcpy:
66
memcpy_from_uspace:
77
memcpy_from_uspace:
67
memcpy_to_uspace:
78
memcpy_to_uspace:
68
	movl %edi, %edx			/* save %edi */
79
	movl %edi, %edx			/* save %edi */
Line 83... Line 94...
83
	rep movsb			/* copy the rest byte by byte */
94
	rep movsb			/* copy the rest byte by byte */
84
 
95
 
85
0:
96
0:
86
	movl %edx, %edi
97
	movl %edx, %edi
87
	movl %eax, %esi
98
	movl %eax, %esi
88
	movl MEMCPY_SRC(%esp), %eax	/* MEMCPY_SRC(%esp), success */
99
	movl MEMCPY_DST(%esp), %eax	/* MEMCPY_DST(%esp), success */
89
	ret
100
	ret
90
	
101
	
91
/*
102
/*
92
 * We got here from as_page_fault() after the memory operations
103
 * We got here from as_page_fault() after the memory operations
93
 * above had caused a page fault.
104
 * above had caused a page fault.
Line 134... Line 145...
134
	and $0xffffbfff, %ecx
145
	and $0xffffbfff, %ecx
135
	push %ecx
146
	push %ecx
136
	popfl
147
	popfl
137
.endm	
148
.endm	
138
 
149
 
-
 
150
/*
-
 
151
 * The SYSENTER syscall mechanism can be used for syscalls with
-
 
152
 * four or fewer arguments. To pass these four arguments, we
-
 
153
 * use four registers: EDX, ECX, EBX, ESI. The syscall number
-
 
154
 * is passed in EAX. We use EDI to remember the return address
-
 
155
 * and EBP to remember the stack. The INT-based syscall mechanism
-
 
156
 * can actually handle six arguments plus the syscall number
-
 
157
 * entirely in registers.
-
 
158
 */
-
 
159
.global sysenter_handler
-
 
160
sysenter_handler:
-
 
161
	sti
-
 
162
	pushl %ebp	# remember user stack
-
 
163
	pushl %edi	# remember return user address
-
 
164
 
-
 
165
	pushl %gs	# remember TLS
-
 
166
 
-
 
167
	pushl %eax	# syscall number
-
 
168
	subl $8, %esp	# unused sixth and fifth argument
-
 
169
	pushl %esi	# fourth argument
-
 
170
	pushl %ebx	# third argument
-
 
171
	pushl %ecx	# second argument
-
 
172
	pushl %edx	# first argument
-
 
173
 
-
 
174
	movw $16, %ax
-
 
175
	movw %ax, %ds
-
 
176
	movw %ax, %es
-
 
177
 
-
 
178
	cld
-
 
179
	call syscall_handler
-
 
180
	addl $28, %esp	# remove arguments from stack
-
 
181
 
-
 
182
	pop %gs		# restore TLS
-
 
183
 
-
 
184
	pop %edx	# prepare return EIP for SYSEXIT
-
 
185
	pop %ecx	# prepare userspace ESP for SYSEXIT
-
 
186
 
-
 
187
	sysexit		# return to userspace
-
 
188
 
-
 
189
 
139
## Declare interrupt handlers
190
## Declare interrupt handlers
140
#
191
#
141
# Declare interrupt handlers for n interrupt
192
# Declare interrupt handlers for n interrupt
142
# vectors starting at vector i.
193
# vectors starting at vector i.
143
#
194
#
Line 215... Line 266...
215
	pushl %ds
266
	pushl %ds
216
	pushl %es
267
	pushl %es
217
	pushl %fs
268
	pushl %fs
218
	pushl %gs
269
	pushl %gs
219
 
270
 
220
#ifdef CONFIG_DEBUG_ALLREGS
-
 
221
	pushl %ebx
-
 
222
	pushl %ebp
-
 
223
	pushl %edi
-
 
224
	pushl %esi
-
 
225
#else
-
 
226
	subl $16, %esp
-
 
227
#endif
-
 
228
	pushl %edx
271
	pushl %edx
229
	pushl %ecx
272
	pushl %ecx
230
	pushl %eax
273
	pushl %eax
231
	
274
	
232
	# we must fill the data segment registers
275
	# we must fill the data segment registers
Line 244... Line 287...
244
	CLEAR_NT_FLAG # Modifies %ecx
287
	CLEAR_NT_FLAG # Modifies %ecx
245
	
288
	
246
	popl %eax
289
	popl %eax
247
	popl %ecx
290
	popl %ecx
248
	popl %edx
291
	popl %edx
249
#ifdef CONFIG_DEBUG_ALLREGS
-
 
250
	popl %esi
-
 
251
	popl %edi
-
 
252
	popl %ebp
-
 
253
	popl %ebx
-
 
254
#else
-
 
255
	addl $16, %esp
-
 
256
#endif	
-
 
257
	
292
	
258
	popl %gs
293
	popl %gs
259
	popl %fs
294
	popl %fs
260
	popl %es
295
	popl %es
261
	popl %ds
296
	popl %ds