A
download movc.S
Language: NonCode
LOC: 0
Project Info
Hurd on Mach on PowerPC(hurdppc)
Server: Savannah NonGNU
Type: cvs
...pc\hurdppc\gnu‑osfmach\ppc\
   _setjmp.S
   alignment.c
   asm.h
   ast.h
   ast_types.h
   bcopy.S
   bits.S
   boot.h
   bzero.S
   cache.S
   clock.h
   console_feed.c
   console_feed_entries.h
   cpu_number.h
   cswtch.S
   db_disasm.c
   db_interface.c
   db_low_trace.c
   db_low_trace.h
   db_machdep.h
   db_trace.c
   endian.h
   exception.h
   Firmware.h
   Firmware.S
   FirmwareCalls.h
   fpu_protos.h
   gdb_defs.h
   genassym.c
   go.c
   hardclock_entries.h
   hw_exception.S
   hw_lock.S
   interrupt.c
   io_map.c
   io_map_entries.h
   iobus.h
   iso_font.h
   kgdb_defs.h
   kgdb_interface.c
   kgdb_setjmp.h
   klglue.S
   lock.h
   low_trace.h
   lowmem_vectors.S
   mach_param.h
   machine_routines.h
   machine_rpc.h
   machlimits.h
   machparam.h
   mem.c
   mem.h
   misc.c
   misc_asm.S
   misc_protos.h
   model_dep.c
   movc.S
   mp.h
   MPinterfaces.S
   ndr_def.h
   net_filter.c
   new_screen.h
   pcb.c
   pmap.c
   pmap.c-broken
   pmap.h
   pmap_internals.h
   ppc_disasm.i
   ppc_init.c
   ppc_rpc.c
   proc_reg.h
   screen.h
   screen_defs.h
   screen_switch.h
   serial_console.c
   serial_defs.h
   setjmp.h
   spl.h
   start.S
   status.c
   strlen.c
   stubs.c
   syscall_subr.h
   task.h
   testjump.c
   thread.h
   thread_act.h
   trap.c
   trap.h
   vm_tuning.h
   xpr.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
/*
 * Copyright 1991-1998 by Open Software Foundation, Inc. 
 *              All Rights Reserved 
 *  
 * Permission to use, copy, modify, and distribute this software and 
 * its documentation for any purpose and without fee is hereby granted, 
 * provided that the above copyright notice appears in all copies and 
 * that both the copyright notice and this permission notice appear in 
 * supporting documentation. 
 *  
 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 * FOR A PARTICULAR PURPOSE. 
 *  
 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 
 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
 */
/*
 * MkLinux
 */

#include <debug.h>
#include <ppc/asm.h>
#include <ppc/proc_reg.h>
#include <mach/ppc/vm_param.h>
#include <assym.S>



/* Change this when we get an assembler that understands a DCBA */

#define dcba dcbz




/*
 * void pmap_zero_page(vm_offset_t pa)
 *
 * zero a page of physical memory.
 */

#if DEBUG
	/* C debug stub in pmap.c calls this */
ENTRY(pmap_zero_page_assembler, TAG_NO_FRAME_USED)
#else
ENTRY(pmap_zero_page, TAG_NO_FRAME_USED)
#endif /* DEBUG */

		li		r0,	0						/* Ensure r0 is 0 before first sync */

		mfmsr	r6								/* Get the MSR */
		rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1	/* Turn off DR */
		li		r4,PPC_PGBYTES-CACHE_LINE_SIZE	/* Point to the end of the page */
		mtmsr	r7								/* Set MSR to DR off */
		isync									/* Ensure data translations are off */


.L_phys_zero_loop:	
		subic.	r5,r4,CACHE_LINE_SIZE			/* Point to the next one */
		dcbz	r4, r3							/* Clear the whole thing to 0s */
		subi	r4,r5,CACHE_LINE_SIZE			/* Point to the next one */
		dcbz	r5, r3							/* Clear the next to zeros */
		bgt+	.L_phys_zero_loop				/* Keep going until we do the page... */

		sync									/* Make sure they're all done */
		li		r4,PPC_PGBYTES-CACHE_LINE_SIZE	/* Point to the end of the page */

.L_inst_inval_loop:	
		subic.	r5,r4,CACHE_LINE_SIZE			/* Point to the next one */
		icbi	r4, r3							/* Clear the whole thing to 0s */
		subi	r4,r5,CACHE_LINE_SIZE			/* Point to the next one */
		icbi	r5, r3							/* Clear the next to zeros */
		bgt+	.L_inst_inval_loop				/* Keep going until we do the page... */

		sync									/* Make sure they're all done */

		mtmsr	r6		/* Restore original translations */
		isync			/* Ensure data translations are on */

		blr

/* void
 * phys_copy(src, dst, bytecount)
 *      vm_offset_t     src;
 *      vm_offset_t     dst;
 *      int             bytecount
 *
 * This routine will copy bytecount bytes from physical address src to physical
 * address dst. 
 */

ENTRY(phys_copy, TAG_NO_FRAME_USED)

	li		r0,	0						/* Ensure r0 is 0 before first sync */

	/* Switch off data translations */
	mfmsr	r6
	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
	mtmsr	r7
	isync			/* Ensure data translations are off */

	subi	ARG0,	ARG0,	4
	subi	ARG1,	ARG1,	4

	cmpwi	ARG2,	3
	ble-	.L_phys_copy_bytes
.L_phys_copy_loop:
	lwz	r0,	4(ARG0)
	addi	ARG0,	ARG0,	4
	subi	ARG2,	ARG2,	4
	stw	r0,	4(ARG1)
	addi	ARG1,	ARG1,	4
	cmpwi	ARG2,	3
	bgt+	.L_phys_copy_loop

	/* If no leftover bytes, we're done now */
	cmpwi	ARG2,	0
	beq+	.L_phys_copy_done
	
.L_phys_copy_bytes:
	addi	ARG0,	ARG0,	3
	addi	ARG1,	ARG1,	3
.L_phys_copy_byte_loop:	
	lbz	r0,	1(ARG0)
	addi	ARG0,	ARG0,	1
	subi	ARG2,	ARG2,	1
	stb	r0,	1(ARG1)
	addi	ARG1,	ARG1,	1
	cmpwi	ARG2,	0
	bne+	.L_phys_copy_loop

.L_phys_copy_done:
	mtmsr	r6		/* Restore original translations */
	isync			/* Ensure data translations are off */

	blr

/* void
 * pmap_copy_page(src, dst)
 *      vm_offset_t     src;
 *      vm_offset_t     dst;
 *
 * This routine will copy the physical page src to physical page dst
 * 
 * This routine assumes that the src and dst are page aligned and that the
 * destination is cached.
 *
 * We also must assume that noone will be executing within the destination
 * page.  We also assume that this will be used for paging
 *
 */

#if DEBUG
	/* if debug, we have a little piece of C around this
	 * in pmap.c that gives some trace ability
	 */
ENTRY(pmap_copy_page_assembler, TAG_NO_FRAME_USED)
#else
ENTRY(pmap_copy_page, TAG_NO_FRAME_USED)
#endif /* DEBUG */

	/* Save off the link register, we want to call fpu_save. We assume
	 * that fpu_save leaves ARG0-5 intact and that it doesn't need
	 * a frame, otherwise we'd need one too.
	 */
	
		mflr	r7
		bl		fpu_save
		mtlr	r7

		li		r0,	0						/* Ensure r0 is 0 before first sync */

		/* Switch off data translations */
		mfmsr	r9
		rlwinm	r7,	r9,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
		mtmsr	r7
		isync			/* Ensure data translations are off */


		dcbt	0, r3						/* Start in first input line */
		addi	r6,r3,PPC_PGBYTES			/* Point to the start of the next page */
		
		mr		r8,r4						/* Save the destination */

		li		r5,	CACHE_LINE_SIZE			/* Get the line size */

.L_pmap_copy_page_loop:
		dcba	0, r4						/* Allocate a line for the output */
		lfd		f0, 0(r3)					/* Get first 8 */
		lfd		f1, 8(r3)					/* Get second 8 */
		lfd		f2, 16(r3)					/* Get third 8 */
		stfd	f0, 0(r4)					/* Put first 8 */
		dcbt	r5, r3						/* Start next line coming in */
		lfd		f3, 24(r3)					/* Get fourth 8 */
		stfd	f1,	8(r4)					/* Put second 8 */
		addi	r3,r3,CACHE_LINE_SIZE		/* Point to the next line in */
		stfd	f2,	16(r4)					/* Put third 8 */
		cmplw	cr0,r3,r6					/* See if we're finished yet */
		stfd	f3,	24(r4)					/* Put fourth 8 */
		dcbst	0,r4						/* Force it out */
		addi	r4,r4,CACHE_LINE_SIZE		/* Point to the next line out */
		blt+	.L_pmap_copy_page_loop		/* Copy the whole page */
		
		sync									/* Make sure they're all done */
		li		r4,PPC_PGBYTES-CACHE_LINE_SIZE	/* Point to the end of the page */

invalinst:	
		subic.	r5,r4,CACHE_LINE_SIZE		/* Point to the next one */
		icbi	r4, r8						/* Trash the i-cache */
		subi	r4,r5,CACHE_LINE_SIZE		/* Point to the next one */
		icbi	r5, r8						/* Trash the i-cache */
		bgt+	invalinst					/* Keep going until we do the page... */

		sync								/* Make sure all invalidates done */		
	
		mtmsr	r9							/* Restore original translations */
		isync								/* Ensure data translations are on */

		blr

/*
 * int
 * copyin(src, dst, count)
 *	vm_offset_t	src;
 *	vm_offset_t	dst;
 *	int		count;
 *
 * We can't generate alignment exceptions here - so use bcopy which
 * is guaranteed not to do this. That means we need to be able to call
 * a sub-function. We USE r10 and assume that bcopy won't need or trash it!
 */

ENTRY2(copyin, copyinmsg, TAG_NO_FRAME_USED)
	/* Preamble allowing us to call a sub-function */
	mflr	r0
	stw	r0,	FM_LR_SAVE(r1)
	stwu	r1,	-FM_SIZE(r1)

	lwz	r6,	PP_CPU_DATA(r2)
	lwz	r10,	CPU_ACTIVE_THREAD(r6)
	cmpli	CR0,	ARG2,	0
	ble-	CR0,	.L_copyinout_trivial
	/* we know we have a valid copyin to do now */

	/* Set up thread_recover in case we hit an illegal address */
	addis	r7,	0,	.L_copyinout_error@ha
	addi	r7,	r7,	.L_copyinout_error@l
	stw	r7,	THREAD_RECOVER(r10)

	lwz	r8,	THREAD_TOP_ACT(r10)
	lwz	r8,	ACT_VMMAP(r8)
	lwz	r8,	VMMAP_PMAP(r8)
	lwz	r8,	PMAP_SPACE(r8)

	lis	r7,	SEG_REG_PROT>>16	/* Top byte of SR value */
	rlwimi	r7,	r8,	4,	4,	31 /* Insert space<<4   */
	rlwimi	r7,	ARG0,	4,	28,	31 /* Insert seg number */

	mtsr	SR_COPYIN,	r7
	isync

	/* ARG0 = adjusted user pointer mapping into SR_COPYIN */
	rlwinm	ARG0,	ARG0,	0,	4,	31
	oris	ARG0,	ARG0,	(SR_COPYIN << (28-16))

	/* For optimisation, we check if the copyin lies on a segment
	 * boundary. If it doesn't, we can use a simple copy. If it
	 * does, we split it into two separate copies in some C code.
	 */
	/* see if (start+size-1) is in same segment */
	add	r7,	ARG0,	ARG2
	subi	r7,	r7,	1

	rlwinm	r7,	r7,	0,	0,	3
	rlwinm	r0,	ARG0,	0,	0,	3
	cmpw	CR0,	r0,	r7
	bne-	.L_call_copyin_multiple

	/* Call bcopy, but need to keep r10 contents (thread ptr) safe */

	bl	bcopy
	
	/* Now that copyin is done, we don't need a recovery point */
	li	r7,	0
	stw	r7,	THREAD_RECOVER(r10)

	li	ARG0,	0	/* Indicate success */

	/* unwind the stack */
	addi	r1,	r1,	FM_SIZE
	lwz	r0,	FM_LR_SAVE(r1)
	mtlr	r0
	blr

.L_copyinout_error:
	/* we get here via the exception handler if an illegal
	 * user memory reference was made.
	 */

	/* Now that copyin is done, we don't need a recovery point */
	li	r7,	0
	stw	r7,	THREAD_RECOVER(r10)

	li	ARG0,	1	/* Indicate error */

	/* unwind the stack */
	addi	r1,	r1,	FM_SIZE
	lwz	r0,	FM_LR_SAVE(r1)
	mtlr	r0

	blr

.L_copyinout_trivial:
	/* The copyin/out was for either 0 bytes or a negative
	 * number of bytes, return an appropriate value (0 == SUCCESS).
	 * CR0 still contains result of comparison of len with 0.
	 */
	li	ARG0,	0
	beq+	CR0,	.L_copyinout_negative
	li	ARG0,	1
.L_copyinout_negative:

	/* unwind the stack */
	addi	r1,	r1,	FM_SIZE
	lwz	r0,	FM_LR_SAVE(r1)
	mtlr	r0

	blr

.L_call_copyin_multiple:

	/* unwind the stack */
	addi	r1,	r1,	FM_SIZE
	lwz	r0,	FM_LR_SAVE(r1)
	mtlr	r0

	b	copyin_multiple		/* not a call - a jump! */

/*
 * int
 * copyout(src, dst, count)
 *	vm_offset_t	src;
 *	vm_offset_t	dst;
 *	int		count;
 *
 * We can't generate alignment exceptions here - so use bcopy which
 * is guaranteed not to do this. That means we need to be able to call
 * a sub-function. We USE r10 and assume that bcopy won't need or trash r10!
 */

ENTRY2(copyout, copyoutmsg, TAG_NO_FRAME_USED)
	/* Preamble allowing us to call a sub-function */
	mflr	r0
	stw	r0,	FM_LR_SAVE(r1)
	stwu	r1,	-FM_SIZE(r1)

	lwz	r6,	PP_CPU_DATA(r2)
	lwz	r10,	CPU_ACTIVE_THREAD(r6)
	cmpli	CR0,	ARG2,	0
	ble-	CR0,	.L_copyinout_trivial
	/* we know we have a valid copyout to do now */

	/* Set up thread_recover in case we hit an illegal address */
	addis	r7,	0,	.L_copyinout_error@ha
	addi	r7,	r7,	.L_copyinout_error@l
	stw	r7,	THREAD_RECOVER(r10)

	lwz	r8,	THREAD_TOP_ACT(r10)
	lwz	r8,	ACT_VMMAP(r8)
	lwz	r8,	VMMAP_PMAP(r8)
	lwz	r8,	PMAP_SPACE(r8)

	lis	r7,	SEG_REG_PROT>>16	/* Top byte of SR value */
	rlwimi	r7,	r8,	4,	4,	31 /* Insert space<<4   */
	rlwimi	r7,	ARG1,	4,	28,	31 /* Insert seg number */

	mtsr	SR_COPYIN,	r7
	isync

	/* ARG1 = adjusted user pointer mapping into SR_COPYIN */
	rlwinm	ARG1,	ARG1,	0,	4,	31
	oris	ARG1,	ARG1,	(SR_COPYIN << (28-16))

	/* For optimisation, we check if the copyout lies on a segment
	 * boundary. If it doesn't, we can use a simple copy. If it
	 * does, we split it into two separate copies in some C code.
	 */
	/* see if (start+size-1) is in same segment */
	add	r7,	ARG1,	ARG2
	subi	r7,	r7,	1

	rlwinm	r7,	r7,	0,	0,	3
	rlwinm	r0,	ARG1,	0,	0,	3
	cmpw	CR0,	r0,	r7
	bne-	.L_call_copyout_multiple

	/* Call bcopy, but need to keep r10 contents (thread ptr) safe */

	bl	bcopy
	
	/* Now that copyout is done, we don't need a recovery point */
	li	r7,	0
	stw	r7,	THREAD_RECOVER(r10)

	li	ARG0,	0	/* Indicate success */

	/* unwind the stack */
	addi	r1,	r1,	FM_SIZE
	lwz	r0,	FM_LR_SAVE(r1)
	mtlr	r0

	blr

.L_call_copyout_multiple:
	/* unwind the stack */
	addi	r1,	r1,	FM_SIZE
	lwz	r0,	FM_LR_SAVE(r1)
	mtlr	r0

	b	copyout_multiple	/* not a call - a jump! */

/*
 * boolean_t
 * copyinstr(src, dst, count, maxcount)
 *	vm_offset_t	src;
 *	vm_offset_t	dst;
 *	vm_size_t	maxcount; 
 *	vm_size_t*	count;
 *
 * Set *count to the number of bytes copied
 * 
 * If dst == NULL, don't copy, just count bytes.
 * Only currently called from klcopyinstr. 
 */

ENTRY(copyinstr, TAG_NO_FRAME_USED)
	/* Preamble allowing us to call a sub-function */
	mflr	r0
	stw	r0,	FM_LR_SAVE(r1)
	stwu	r1,	-FM_SIZE(r1)

	lwz	ARG4,	PP_CPU_DATA(r2)
	lwz	r10,	CPU_ACTIVE_THREAD(ARG4)

	/* Say that we copy no bytes until we say something different... */
	li	r0,	0
	stw	r0,	0(ARG3)

	cmpli	CR0,	ARG2,	0
	ble-	CR0,	.L_copyinout_trivial
	/* we know we have a valid copyinstr to do now */

	/* Set up thread_recover in case we hit an illegal address */
	addis	ARG5,	0,	.L_copyinout_error@ha
	addi	ARG5,	ARG5,	.L_copyinout_error@l
	stw	ARG5,	THREAD_RECOVER(r10)

	lwz	ARG6,	THREAD_TOP_ACT(r10)
	lwz	ARG6,	ACT_VMMAP(ARG6)
	lwz	ARG6,	VMMAP_PMAP(ARG6)
	lwz	ARG6,	PMAP_SPACE(ARG6)

	lis	ARG5,	SEG_REG_PROT>>16	/* Top byte of SR value */
	rlwimi	ARG5,	ARG6,	4,	4,	31 /* Insert space<<4   */
	rlwimi	ARG5,	ARG0,	4,	28,	31 /* Insert seg number */

	mtsr	SR_COPYIN,	ARG5
	isync

	/* ARG0 = adjusted user pointer mapping into SR_COPYIN */
	rlwinm	ARG0,	ARG0,	0,	4,	31
	oris	ARG0,	ARG0,	(SR_COPYIN << (28-16))

	/* Copy byte by byte for now - TODO NMGS speed this up with
	 * some clever (but fairly standard) logic for word copies.
	 * We don't use a copyinstr_multiple since copyinstr is called
	 * with INT_MAX in the linux server. Eugh.
	 */

	li	ARG6,	0

	/* If the destination is NULL, don't do writes,
	 * just count bytes. We set CR7 outside the loop to save time
	 */
	cmpwi	CR7,	ARG1,	0
	
	/* if we _do_ store, we do load/store with updates on ARG1*/
	
	subi	ARG1,	ARG1,	1

.L_copyinstr_loop:
	lbz	r0,	0(ARG0)

	addic.	ARG2,	ARG2,	-1

	cmpwi	CR1,	r0,	0

	addi	ARG0,	ARG0,	1

	/* Jump over store if dest == NULL */
	beq	CR7,	.L_copyinstr_no_store
	
	stb	r0,	1(ARG1)
	addi	ARG1,	ARG1,	1

.L_copyinstr_no_store:

	addi	ARG6,	ARG6,	1

	/* Did we find the zero byte? */
	beq-	CR1,	.L_copyinstr_done

	/* did we get to MAXLEN? */
	beq-	CR0,	.L_copyinstr_done
	
	/* Check to see if the copyin pointer has moved out of the
	 * copyin segment, if it has we must remap.
	 */

	rlwinm.	r0,	ARG0,	0,	4,	31
	bne+	CR0,	.L_copyinstr_loop

	/* We have gone beyond the segment boundary, remap */

	addi	ARG5,	ARG5,	1
	li		r0,	0				/* Ensure R0 is 0 before sync */
	cmpwi	r0, 0
	bne+	0f
	sync
0:
	mtsr	SR_COPYIN,	ARG5
	isync

	/* and change the pointer back to the start of the segment */

	rlwinm	ARG0,	ARG0,	0,	4,	31
	oris	ARG0,	ARG0,	(SR_COPYIN << (28-16))
	
	b	.L_copyinstr_loop
	
.L_copyinstr_done:
	/* set *count to the number of bytes copied */
	stw	ARG6,	0(ARG3)

	/* we return success */
	li	ARG0,	0
			
	/* Now that copyinstr is done, we don't need a recovery point */
	li	ARG5,	0
	stw	ARG5,	THREAD_RECOVER(r10)

	/* unwind the stack */
	addi	r1,	r1,	FM_SIZE
	lwz	r0,	FM_LR_SAVE(r1)
	mtlr	r0
	blr

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us