cpuswitch.S revision 1.19 1 /* $NetBSD: cpuswitch.S,v 1.19 2002/10/05 13:46:59 bjh21 Exp $ */
2
3 /*
4 * Copyright (c) 1994-1998 Mark Brinicombe.
5 * Copyright (c) 1994 Brini.
6 * All rights reserved.
7 *
8 * This code is derived from software written for Brini by Mark Brinicombe
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by Brini.
21 * 4. The name of the company nor the name of the author may be used to
22 * endorse or promote products derived from this software without specific
23 * prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * RiscBSD kernel project
38 *
39 * cpuswitch.S
40 *
41 * cpu switching functions
42 *
43 * Created : 15/10/94
44 */
45
46 #include "opt_armfpe.h"
47 #include "opt_multiprocessor.h"
48
49 #include "assym.h"
50 #include <machine/param.h>
51 #include <machine/cpu.h>
52 #include <machine/frame.h>
53 #include <machine/asm.h>
54
55 #undef IRQdisable
56 #undef IRQenable
57
58 /*
59 * New experimental definitions of IRQdisable and IRQenable
60 * These keep FIQ's enabled since FIQ's are special.
61 */
62
63 #define IRQdisable \
64 mrs r14, cpsr ; \
65 orr r14, r14, #(I32_bit) ; \
66 msr cpsr_c, r14 ; \
67
68 #define IRQenable \
69 mrs r14, cpsr ; \
70 bic r14, r14, #(I32_bit) ; \
71 msr cpsr_c, r14 ; \
72
73 /*
74 * setrunqueue() and remrunqueue()
75 *
76 * Functions to add and remove a process for the run queue.
77 */
78
79 .text
80
81 .Lwhichqs:
82 .word _C_LABEL(sched_whichqs)
83
84 .Lqs:
85 .word _C_LABEL(sched_qs)
86
87 /*
88 * On entry
89 * r0 = process
90 */
91
92 ENTRY(setrunqueue)
93 /*
94 * Local register usage
95 * r0 = process
96 * r1 = queue
97 * r2 = &qs[queue] and temp
98 * r3 = temp
99 * r12 = whichqs
100 */
101 #ifdef DIAGNOSTIC
102 ldr r1, [r0, #(P_BACK)]
103 teq r1, #0x00000000
104 bne .Lsetrunqueue_erg
105
106 ldr r1, [r0, #(P_WCHAN)]
107 teq r1, #0x00000000
108 bne .Lsetrunqueue_erg
109 #endif
110
111 /* Get the priority of the queue */
112 ldrb r1, [r0, #(P_PRIORITY)]
113
114 /* Indicate that there is a process on this queue */
115 ldr r12, .Lwhichqs
116 mov r1, r1, lsr #2
117 ldr r2, [r12]
118 mov r3, #0x00000001
119 mov r3, r3, lsl r1
120 orr r2, r2, r3
121 str r2, [r12]
122
123 /* Get the address of the queue */
124 ldr r2, .Lqs
125 add r1, r2, r1, lsl # 3
126
127 /* Hook the process in */
128 str r1, [r0, #(P_FORW)]
129 ldr r2, [r1, #(P_BACK)]
130
131 str r0, [r1, #(P_BACK)]
132 #ifdef DIAGNOSTIC
133 teq r2, #0x00000000
134 beq .Lsetrunqueue_erg
135 #endif
136 str r0, [r2, #(P_FORW)]
137 str r2, [r0, #(P_BACK)]
138
139 mov pc, lr
140
141 #ifdef DIAGNOSTIC
142 .Lsetrunqueue_erg:
143 mov r2, r1
144 mov r1, r0
145 add r0, pc, #.Ltext1 - . - 8
146 bl _C_LABEL(printf)
147
148 ldr r2, .Lqs
149 ldr r1, [r2]
150 add r0, pc, #.Ltext2 - . - 8
151 b _C_LABEL(panic)
152
153 .Ltext1:
154 .asciz "setrunqueue : %08x %08x\n"
155 .Ltext2:
156 .asciz "setrunqueue : [qs]=%08x qs=%08x\n"
157 .align 0
158 #endif
159
160 /*
161 * On entry
162 * r0 = process
163 */
164
165 ENTRY(remrunqueue)
166 /*
167 * Local register usage
168 * r0 = oldproc
169 * r1 = queue
170 * r2 = &qs[queue] and scratch
171 * r3 = scratch
172 * r12 = whichqs
173 */
174
175 /* Get the priority of the queue */
176 ldrb r1, [r0, #(P_PRIORITY)]
177 mov r1, r1, lsr #2
178
179 /* Unhook the process */
180 ldr r2, [r0, #(P_FORW)]
181 ldr r3, [r0, #(P_BACK)]
182
183 str r3, [r2, #(P_BACK)]
184 str r2, [r3, #(P_FORW)]
185
186 /* If the queue is now empty clear the queue not empty flag */
187 teq r2, r3
188
189 /* This could be reworked to avoid the use of r4 */
190 ldreq r12, .Lwhichqs
191 moveq r3, #0x00000001
192 ldreq r2, [r12]
193 moveq r3, r3, lsl r1
194 biceq r2, r2, r3
195 streq r2, [r12]
196
197 /* Remove the back pointer for the process */
198 mov r1, #0x00000000
199 str r1, [r0, #(P_BACK)]
200
201 mov pc, lr
202
203
204 /*
205 * cpuswitch()
206 *
207 * preforms a process context switch.
208 * This function has several entry points
209 */
210
211 #ifdef MULTIPROCESSOR
212 .Lcpu_info_store:
213 .word _C_LABEL(cpu_info_store)
214 .Lcurproc:
215 /* FIXME: This is bogus in the general case. */
216 .word _C_LABEL(cpu_info_store) + CI_CURPROC
217 #else
218 .Lcurproc:
219 .word _C_LABEL(curproc)
220 #endif
221
222 .Lcurpcb:
223 .word _C_LABEL(curpcb)
224
225 .Lwant_resched:
226 .word _C_LABEL(want_resched)
227
228 .Lcpufuncs:
229 .word _C_LABEL(cpufuncs)
230
231 .data
232 .global _C_LABEL(curpcb)
233 _C_LABEL(curpcb):
234 .word 0x00000000
235 .text
236
237 .Lblock_userspace_access:
238 .word _C_LABEL(block_userspace_access)
239
240 .Lcpu_do_powersave:
241 .word _C_LABEL(cpu_do_powersave)
242
243 /*
244 * Idle loop, exercised while waiting for a process to wake up.
245 *
246 * NOTE: When we jump back to .Lswitch_search, we must have a
247 * pointer to whichqs in r7, which is what it is when we arrive
248 * here.
249 */
250 /* LINTSTUB: Ignore */
251 ASENTRY_NP(idle)
252 #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
253 bl _C_LABEL(sched_unlock_idle)
254 #endif
255 ldr r3, .Lcpu_do_powersave
256
257 /* Enable interrupts */
258 IRQenable
259
260 /* If we don't want to sleep, use a simpler loop. */
261 ldr r3, [r3] /* r3 = cpu_do_powersave */
262 teq r3, #0
263 bne 2f
264
265 /* Non-powersave idle. */
266 1: /* should maybe do uvm pageidlezero stuff here */
267 ldr r3, [r7] /* r3 = whichqs */
268 teq r3, #0x00000000
269 bne .Lswitch_search
270 b 1b
271
272 2: /* Powersave idle. */
273 ldr r4, .Lcpufuncs
274 3: ldr r3, [r7] /* r3 = whichqs */
275 teq r3, #0x00000000
276 bne .Lswitch_search
277
278 /* if saving power, don't want to pageidlezero */
279 mov r0, #0
280 add lr, pc, #3b - . - 8
281 ldr pc, [r4, #(CF_SLEEP)]
282 /* loops back around */
283
284
285 /*
286 * Find a new process to run, save the current context and
287 * load the new context
288 */
289
290 ENTRY(cpu_switch)
291 /*
292 * Local register usage. Some of these registers are out of date.
293 * r1 = oldproc
294 * r2 = spl level
295 * r3 = whichqs
296 * r4 = queue
297 * r5 = &qs[queue]
298 * r6 = newproc
299 * r7 = scratch
300 */
301 stmfd sp!, {r4-r7, lr}
302
303 /*
304 * Get the current process and indicate that there is no longer
305 * a valid process (curproc = 0). Zero the current PCB pointer
306 * while we're at it.
307 */
308 ldr r7, .Lcurproc
309 ldr r6, .Lcurpcb
310 mov r0, #0x00000000
311 ldr r1, [r7] /* r1 = curproc */
312 str r0, [r7] /* curproc = NULL */
313 str r0, [r6] /* curpcb = NULL */
314
315 /* stash the old proc while we call functions */
316 mov r5, r1
317
318 #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
319 /* release the sched_lock before handling interrupts */
320 bl _C_LABEL(sched_unlock_idle)
321 #endif
322
323 /* Lower the spl level to spl0 and get the current spl level. */
324 #ifdef __NEWINTR
325 mov r0, #(IPL_NONE)
326 bl _C_LABEL(_spllower)
327 #else /* ! __NEWINTR */
328 #ifdef spl0
329 mov r0, #(_SPL_0)
330 bl _C_LABEL(splx)
331 #else
332 bl _C_LABEL(spl0)
333 #endif /* spl0 */
334 #endif /* __NEWINTR */
335
336 /* Push the old spl level onto the stack */
337 str r0, [sp, #-0x0004]!
338
339 /* First phase : find a new process */
340
341 ldr r7, .Lwhichqs
342
343 /* rem: r5 = old proc */
344 /* rem: r7 = &whichqs */
345
346 .Lswitch_search:
347 IRQdisable
348 #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
349 bl _C_LABEL(sched_lock_idle)
350 #endif
351
352 /* Do we have any active queues */
353 ldr r3, [r7]
354
355 /* If not we must idle until we do. */
356 teq r3, #0x00000000
357 beq _ASM_LABEL(idle)
358
359 /* put old proc back in r1 */
360 mov r1, r5
361
362 /* rem: r1 = old proc */
363 /* rem: r3 = whichqs */
364 /* rem: interrupts are disabled */
365
366 /*
367 * We have found an active queue. Currently we do not know which queue
368 * is active just that one of them is.
369 */
370 /* this is the ffs algorithm devised by d.seal and posted to
371 * comp.sys.arm on 16 Feb 1994.
372 */
373 rsb r5, r3, #0
374 ands r0, r3, r5
375
376 adr r5, .Lcpu_switch_ffs_table
377
378 /* X = R0 */
379 orr r4, r0, r0, lsl #4 /* r4 = X * 0x11 */
380 orr r4, r4, r4, lsl #6 /* r4 = X * 0x451 */
381 rsb r4, r4, r4, lsl #16 /* r4 = X * 0x0450fbaf */
382
383 /* used further down, saves SA stall */
384 ldr r6, .Lqs
385
386 /* now lookup in table indexed on top 6 bits of a4 */
387 ldrb r4, [ r5, r4, lsr #26 ]
388
389 /* rem: r0 = bit mask of chosen queue (1 << r4) */
390 /* rem: r1 = old proc */
391 /* rem: r3 = whichqs */
392 /* rem: r4 = queue number */
393 /* rem: interrupts are disabled */
394
395 /* Get the address of the queue (&qs[queue]) */
396 add r5, r6, r4, lsl #3
397
398 /*
399 * Get the process from the queue and place the next process in
400 * the queue at the head. This basically unlinks the process at
401 * the head of the queue.
402 */
403 ldr r6, [r5, #(P_FORW)]
404
405 /* rem: r6 = new process */
406 ldr r7, [r6, #(P_FORW)]
407 str r7, [r5, #(P_FORW)]
408
409 /*
410 * Test to see if the queue is now empty. If the head of the queue
411 * points to the queue itself then there are no more processes in
412 * the queue. We can therefore clear the queue not empty flag held
413 * in r3.
414 */
415
416 teq r5, r7
417 biceq r3, r3, r0
418
419 /* rem: r0 = bit mask of chosen queue (1 << r4) - NOT NEEDED AN MORE */
420
421 /* Fix the back pointer for the process now at the head of the queue. */
422 ldr r0, [r6, #(P_BACK)]
423 str r0, [r7, #(P_BACK)]
424
425 /* Update the RAM copy of the queue not empty flags word. */
426 ldr r7, .Lwhichqs
427 str r3, [r7]
428
429 /* rem: r1 = old proc */
430 /* rem: r3 = whichqs - NOT NEEDED ANY MORE */
431 /* rem: r4 = queue number - NOT NEEDED ANY MORE */
432 /* rem: r6 = new process */
433 /* rem: interrupts are disabled */
434
435 /* Clear the want_resched flag */
436 ldr r7, .Lwant_resched
437 mov r0, #0x00000000
438 str r0, [r7]
439
440 /*
441 * Clear the back pointer of the process we have removed from
442 * the head of the queue. The new process is isolated now.
443 */
444 str r0, [r6, #(P_BACK)]
445
446 #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
447 /*
448 * unlock the sched_lock, but leave interrupts off, for now.
449 */
450 mov r7, r1
451 bl _C_LABEL(sched_unlock_idle)
452 mov r1, r7
453 #endif
454
455 #ifdef MULTIPROCESSOR
456 /* XXX use curcpu() */
457 ldr r0, .Lcpu_info_store
458 str r0, [r6, #(P_CPU)]
459 #else
460 /* p->p_cpu initialized in fork1() for single-processor */
461 #endif
462
463 /* Process is now on a processor. */
464 mov r0, #SONPROC /* p->p_stat = SONPROC */
465 strb r0, [r6, #(P_STAT)]
466
467 /* We have a new curproc now so make a note it */
468 ldr r7, .Lcurproc
469 str r6, [r7]
470
471 /* Hook in a new pcb */
472 ldr r7, .Lcurpcb
473 ldr r0, [r6, #(P_ADDR)]
474 str r0, [r7]
475
476 /* At this point we can allow IRQ's again. */
477 IRQenable
478
479 /* rem: r1 = old proc */
480 /* rem: r6 = new process */
481 /* rem: interrupts are enabled */
482
483 /*
484 * If the new process is the same as the process that called
485 * cpu_switch() then we do not need to save and restore any
486 * contexts. This means we can make a quick exit.
487 * The test is simple if curproc on entry (now in r1) is the
488 * same as the proc removed from the queue we can jump to the exit.
489 */
490 teq r1, r6
491 beq .Lswitch_return
492
493 /* Remember the old process in r0 */
494 mov r0, r1
495
496 /*
497 * If the curproc on entry to cpu_switch was zero then the
498 * process that called it was exiting. This means that we do
499 * not need to save the current context. Instead we can jump
500 * straight to restoring the context for the new process.
501 */
502 teq r0, #0x00000000
503 beq .Lswitch_exited
504
505 /* rem: r0 = old proc */
506 /* rem: r6 = new process */
507 /* rem: interrupts are enabled */
508
509 /* Stage two : Save old context */
510
511 /* Get the user structure for the old process. */
512 ldr r1, [r0, #(P_ADDR)]
513
514 /* Save all the registers in the old process's pcb */
515 add r7, r1, #(PCB_R8)
516 stmia r7, {r8-r13}
517
518 /*
519 * This can be optimised... We know we want to go from SVC32
520 * mode to UND32 mode
521 */
522 mrs r3, cpsr
523 bic r2, r3, #(PSR_MODE)
524 orr r2, r2, #(PSR_UND32_MODE | I32_bit)
525 msr cpsr_c, r2
526
527 str sp, [r1, #(PCB_UND_SP)]
528
529 msr cpsr_c, r3 /* Restore the old mode */
530
531 /* rem: r0 = old proc */
532 /* rem: r1 = old pcb */
533 /* rem: r6 = new process */
534 /* rem: interrupts are enabled */
535
536 /* What else needs to be saved Only FPA stuff when that is supported */
537
538 /* r1 now free! */
539
540 /* Third phase : restore saved context */
541
542 /* rem: r0 = old proc */
543 /* rem: r6 = new process */
544 /* rem: interrupts are enabled */
545
546 /*
547 * Don't allow user space access between the purge and the switch.
548 */
549 ldr r3, .Lblock_userspace_access
550 mov r1, #0x00000001
551 mov r2, #0x00000000
552 str r1, [r3]
553
554 stmfd sp!, {r0-r3}
555 ldr r1, .Lcpufuncs
556 add lr, pc, #.Lcs_cache_purged - . - 8
557 ldr pc, [r1, #CF_IDCACHE_WBINV_ALL]
558
559 .Lcs_cache_purged:
560 ldmfd sp!, {r0-r3}
561
562 .Lcs_cache_purge_skipped:
563 /* At this point we need to kill IRQ's again. */
564 IRQdisable
565
566 /*
567 * Interrupts are disabled so we can allow user space accesses again
568 * as none will occur until interrupts are re-enabled after the
569 * switch.
570 */
571 str r2, [r3]
572
573 /* Get the user structure for the new process in r1 */
574 ldr r1, [r6, #(P_ADDR)]
575
576 /* Get the pagedir physical address for the process. */
577 ldr r0, [r1, #(PCB_PAGEDIR)]
578
579 /* Switch the memory to the new process */
580 ldr r3, .Lcpufuncs
581 add lr, pc, #.Lcs_context_switched - . - 8
582 ldr pc, [r3, #CF_CONTEXT_SWITCH]
583
584 .Lcs_context_switched:
585 /*
586 * This can be optimised... We know we want to go from SVC32
587 * mode to UND32 mode
588 */
589 mrs r3, cpsr
590 bic r2, r3, #(PSR_MODE)
591 orr r2, r2, #(PSR_UND32_MODE)
592 msr cpsr_c, r2
593
594 ldr sp, [r1, #(PCB_UND_SP)]
595
596 msr cpsr_c, r3 /* Restore the old mode */
597
598 /* Restore all the save registers */
599 add r7, r1, #PCB_R8
600 ldmia r7, {r8-r13}
601
602 mov r7, r1 /* preserve PCB pointer */
603
604 #ifdef ARMFPE
605 add r0, r1, #(USER_SIZE) & 0x00ff
606 add r0, r0, #(USER_SIZE) & 0xff00
607 bl _C_LABEL(arm_fpe_core_changecontext)
608 #endif
609
610 /* We can enable interrupts again */
611 IRQenable
612
613 /* rem: r6 = new proc */
614 /* rem: r7 = new PCB */
615
616 /*
617 * Check for restartable atomic sequences (RAS).
618 */
619
620 ldr r2, [r6, #(P_NRAS)]
621 ldr r4, [r7, #(PCB_TF)] /* r4 = trapframe (used below) */
622 teq r2, #0 /* p->p_nras == 0? */
623 bne .Lswitch_do_ras /* no, check for one */
624
625 .Lswitch_return:
626
627 /* Get the spl level from the stack and update the current spl level */
628 ldr r0, [sp], #0x0004
629 bl _C_LABEL(splx)
630
631 /* cpu_switch returns the proc it switched to. */
632 mov r0, r6
633
634 /*
635 * Pull the registers that got pushed when either savectx() or
636 * cpu_switch() was called and return.
637 */
638 ldmfd sp!, {r4-r7, pc}
639
640 .Lswitch_do_ras:
641 ldr r1, [r4, #(TF_PC)] /* second ras_lookup() arg */
642 mov r0, r6 /* first ras_lookup() arg */
643 bl _C_LABEL(ras_lookup)
644 cmn r0, #1 /* -1 means "not in a RAS" */
645 strne r0, [r4, #(TF_PC)]
646 b .Lswitch_return
647
648 .Lswitch_exited:
649 /*
650 * We skip the cache purge because switch_exit() already did
651 * it. Load up registers the way Lcs_cache_purge_skipped
652 * expects. Userspace access already blocked in switch_exit().
653 */
654 ldr r3, .Lblock_userspace_access
655 mov r2, #0x00000000
656 b .Lcs_cache_purge_skipped
657
658 /*
659 * void switch_exit(struct proc *p, struct proc *p0);
660 * Switch to proc0's saved context and deallocate the address space and kernel
661 * stack for p. Then jump into cpu_switch(), as if we were in proc0 all along.
662 */
663
664 /* LINTSTUB: Func: void switch_exit(struct proc *p, struct proc *p0) */
665 ENTRY(switch_exit)
666 /*
667 * r0 = proc
668 * r1 = proc0
669 */
670
671 mov r3, r0
672
673 /* In case we fault */
674 ldr r0, .Lcurproc
675 mov r2, #0x00000000
676 str r2, [r0]
677
678 /* ldr r0, .Lcurpcb
679 str r2, [r0]*/
680
681 /*
682 * Don't allow user space access between the purge and the switch.
683 */
684 ldr r0, .Lblock_userspace_access
685 mov r2, #0x00000001
686 str r2, [r0]
687
688 /* Switch to proc0 context */
689
690 stmfd sp!, {r0-r3}
691
692 ldr r0, .Lcpufuncs
693 add lr, pc, #.Lse_cache_purged - . - 8
694 ldr pc, [r0, #CF_IDCACHE_WBINV_ALL]
695
696 .Lse_cache_purged:
697 ldmfd sp!, {r0-r3}
698
699 IRQdisable
700
701 ldr r2, [r1, #(P_ADDR)]
702 ldr r0, [r2, #(PCB_PAGEDIR)]
703
704 /* Switch the memory to the new process */
705 ldr r4, .Lcpufuncs
706 add lr, pc, #.Lse_context_switched - . - 8
707 ldr pc, [r4, #CF_CONTEXT_SWITCH]
708
709 .Lse_context_switched:
710 /* Restore all the save registers */
711 add r7, r2, #PCB_R8
712 ldmia r7, {r8-r13}
713
714 /* This is not really needed ! */
715 /* Yes it is for the su and fu routines */
716 ldr r0, .Lcurpcb
717 str r2, [r0]
718
719 IRQenable
720
721 /* str r3, [sp, #-0x0004]!*/
722
723 /*
724 * Schedule the vmspace and stack to be freed.
725 */
726 mov r0, r3 /* exit2(p) */
727 bl _C_LABEL(exit2)
728
729 /* Paranoia */
730 ldr r1, .Lcurproc
731 mov r0, #0x00000000
732 str r0, [r1]
733
734 ldr r7, .Lwhichqs /* r7 = &whichqs */
735 mov r5, #0x00000000 /* r5 = old proc = NULL */
736 b .Lswitch_search
737
738 /* LINTSTUB: Func: void savectx(struct pcb *pcb) */
739 ENTRY(savectx)
740 /*
741 * r0 = pcb
742 */
743
744 /* Push registers.*/
745 stmfd sp!, {r4-r7, lr}
746
747 /* Store all the registers in the process's pcb */
748 add r2, r0, #(PCB_R8)
749 stmia r2, {r8-r13}
750
751 /* Pull the regs of the stack */
752 ldmfd sp!, {r4-r7, pc}
753
754 ENTRY(proc_trampoline)
755 #ifdef MULTIPROCESSOR
756 bl _C_LABEL(proc_trampoline_mp)
757 #endif
758 add lr, pc, #(.Ltrampoline_return - . - 8)
759 mov r0, r5
760 mov r1, sp
761 mov pc, r4
762
763 .Ltrampoline_return:
764 /* Kill irq's */
765 mrs r0, cpsr
766 orr r0, r0, #(I32_bit)
767 msr cpsr_c, r0
768
769 PULLFRAME
770
771 movs pc, lr /* Exit */
772
773 .type .Lcpu_switch_ffs_table, _ASM_TYPE_OBJECT;
774 .Lcpu_switch_ffs_table:
775 /* same as ffs table but all nums are -1 from that */
776 /* 0 1 2 3 4 5 6 7 */
777 .byte 0, 0, 1, 12, 2, 6, 0, 13 /* 0- 7 */
778 .byte 3, 0, 7, 0, 0, 0, 0, 14 /* 8-15 */
779 .byte 10, 4, 0, 0, 8, 0, 0, 25 /* 16-23 */
780 .byte 0, 0, 0, 0, 0, 21, 27, 15 /* 24-31 */
781 .byte 31, 11, 5, 0, 0, 0, 0, 0 /* 32-39 */
782 .byte 9, 0, 0, 24, 0, 0, 20, 26 /* 40-47 */
783 .byte 30, 0, 0, 0, 0, 23, 0, 19 /* 48-55 */
784 .byte 29, 0, 22, 18, 28, 17, 16, 0 /* 56-63 */
785
786 /* End of cpuswitch.S */
787