Home | History | Annotate | Line # | Download | only in arm32
cpuswitch.S revision 1.1
      1 /*	$NetBSD: cpuswitch.S,v 1.1 2001/07/28 13:28:03 chris 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 
     48 #include "assym.h"
     49 #include <machine/param.h>
     50 #include <machine/cpu.h>
     51 #include <machine/frame.h>
     52 #include <machine/asm.h>
     53 
     54 #undef IRQdisable
     55 #undef IRQenable
     56 
     57 /*
     58  * New experimental definitions of IRQdisable and IRQenable
     59  * These keep FIQ's enabled since FIQ's are special.
     60  */
     61 
     62 #define IRQdisable \
     63 	mrs	r14, cpsr_all ; \
     64 	orr	r14, r14, #(I32_bit) ; \
     65 	msr	cpsr_all, r14 ; \
     66 
     67 #define IRQenable \
     68 	mrs	r14, cpsr_all ; \
     69 	bic	r14, r14, #(I32_bit) ; \
     70 	msr	cpsr_all, r14 ; \
     71 
     72 /*
     73  * setrunqueue() and remrunqueue()
     74  *
     75  * Functions to add and remove a process for the run queue.
     76  */
     77 
     78 	.text
     79 
     80 Lwhichqs:
     81 	.word	_C_LABEL(sched_whichqs)
     82 
     83 Lqs:
     84 	.word	_C_LABEL(sched_qs)
     85 
     86 /*
     87  * On entry
     88  *	r0 = process
     89  */
     90 
     91 ENTRY(setrunqueue)
     92 	/*
     93 	 * Local register usage
     94 	 * 	r0 = process
     95 	 * 	r1 = queue
     96 	 * 	r2 = &qs[queue] and temp
     97 	 * 	r3 = temp
     98 	 *	r12 = whichqs
     99 	 */
    100 #ifdef DIAGNOSTIC
    101 	ldr	r1, [r0, #(P_BACK)]
    102 	teq	r1, #0x00000000
    103 	bne	Lsetrunqueue_erg
    104 
    105 	ldr	r1, [r0, #(P_WCHAN)]
    106 	teq	r1, #0x00000000
    107 	bne	Lsetrunqueue_erg
    108 #endif
    109 
    110 	/* Get the priority of the queue */
    111 	ldrb	r1, [r0, #(P_PRIORITY)]
    112 	mov	r1, r1, lsr #2
    113 
    114 	/* Indicate that there is a process on this queue */
    115 	ldr	r12, Lwhichqs
    116 	ldr	r2, [r12]
    117 	mov	r3, #0x00000001
    118 	mov	r3, r3, lsl r1
    119 	orr	r2, r2, r3
    120 	str	r2, [r12]
    121 
    122 	/* Get the address of the queue */
    123 	ldr	r2, Lqs
    124 	add	r1, r2, r1, lsl # 3
    125 
    126 	/* Hook the process in */
    127 	str	r1, [r0, #(P_FORW)]
    128 	ldr	r2, [r1, #(P_BACK)]
    129 
    130 	str	r0, [r1, #(P_BACK)]
    131 #ifdef DIAGNOSTIC
    132 	teq	r2, #0x00000000
    133 	beq	Lsetrunqueue_erg
    134 #endif
    135 	str	r0, [r2, #(P_FORW)]
    136 	str	r2, [r0, #(P_BACK)]
    137 
    138 	mov	pc, lr
    139 
    140 #ifdef DIAGNOSTIC
    141 Lsetrunqueue_erg:
    142 	mov	r2, r1
    143 	mov	r1, r0
    144 	add	r0, pc, #Ltext1 - . - 8
    145 	bl	_C_LABEL(printf)
    146 
    147 	ldr	r2, Lqs
    148 	ldr	r1, [r2]
    149 	add	r0, pc, #Ltext2 - . - 8
    150 	b	_C_LABEL(panic)
    151 
    152 Ltext1:
    153 	.asciz	"setrunqueue : %08x %08x\n"
    154 Ltext2:
    155 	.asciz	"setrunqueue : [qs]=%08x qs=%08x\n"
    156 	.align	0
    157 #endif
    158 
    159 /*
    160  * On entry
    161  *	r0 = process
    162  */
    163 
    164 ENTRY(remrunqueue)
    165 	/*
    166 	 * Local register usage
    167 	 *	r0 = oldproc
    168 	 * 	r1 = queue
    169 	 * 	r2 = &qs[queue] and scratch
    170 	 *	r3 = scratch
    171 	 *	r12 = whichqs
    172 	 */
    173 
    174 	/* Get the priority of the queue */
    175 	ldrb	r1, [r0, #(P_PRIORITY)]
    176 	mov	r1, r1, lsr #2
    177 
    178 	/* Unhook the process */
    179 	ldr	r2, [r0, #(P_FORW)]
    180 	ldr	r3, [r0, #(P_BACK)]
    181 
    182 	str	r3, [r2, #(P_BACK)]
    183 	str	r2, [r3, #(P_FORW)]
    184 
    185 	/* If the queue is now empty clear the queue not empty flag */
    186 	teq	r2, r3
    187 
    188 	/* This could be reworked to avoid the use of r4 */
    189 	ldreq	r12, Lwhichqs
    190 	ldreq	r2, [r12]
    191 	moveq	r3, #0x00000001
    192 	moveq	r3, r3, lsl r1
    193 	biceq	r2, r2, r3
    194 	streq	r2, [r12]
    195 
    196 	/* Remove the back pointer for the process */
    197 	mov	r1, #0x00000000
    198 	str	r1, [r0, #(P_BACK)]
    199 
    200 	mov	pc, lr
    201 
    202 
    203 /*
    204  * cpuswitch()
    205  *
    206  * preforms a process context switch.
    207  * This function has several entry points
    208  */
    209 
    210 Lcurproc:
    211 	.word	_C_LABEL(curproc)
    212 
    213 Lcurpcb:
    214 	.word	_C_LABEL(curpcb)
    215 
    216 Lwant_resched:
    217 	.word	_C_LABEL(want_resched)
    218 
    219 Lcpufuncs:
    220 	.word	_C_LABEL(cpufuncs)
    221 
    222 	.data
    223 	.global	_C_LABEL(curpcb)
    224 _C_LABEL(curpcb):
    225 	.word	0x00000000
    226 	.text
    227 
    228 Lblock_userspace_access:
    229 	.word	_C_LABEL(block_userspace_access)
    230 
    231 /*
    232  * Idle loop, exercised while waiting for a process to wake up.
    233  */
    234 
    235 idle:
    236 	/* Enable interrupts */
    237 	IRQenable
    238 
    239 	/* XXX - r1 needs to be preserved for cpu_switch */
    240 	mov	r7, r1
    241 	ldr	r3, Lcpufuncs
    242 	mov	r0, #0
    243 	add	lr, pc, #Lidle_slept - . - 8
    244 	ldr	pc, [r3, #CF_SLEEP]
    245 
    246 Lidle_slept:
    247 	mov	r1, r7
    248 
    249 	/* Disable interrupts while we check for an active queue */
    250 	IRQdisable
    251 	ldr	r7, Lwhichqs
    252 	ldr	r3, [r7]
    253 	teq	r3, #0x00000000
    254 	bne	sw1
    255 
    256 	/* All processes are still asleep so idle a while longer */
    257 	b	idle
    258 
    259 
    260 /*
    261  * Find a new process to run, save the current context and
    262  * load the new context
    263  */
    264 
    265 ENTRY(cpu_switch)
    266 /*
    267  * Local register usage. Some of these registers are out of date.
    268  * r1 = oldproc
    269  * r2 = spl level
    270  * r3 = whichqs
    271  * r4 = queue
    272  * r5 = &qs[queue]
    273  * r6 = newproc
    274  * r7 = scratch
    275  */
    276 	stmfd	sp!, {r4-r7, lr}
    277 
    278 	/*
    279 	 * Get the current process and indicate that there is no longer
    280 	 * a valid process (curproc = 0)
    281 	 */
    282 	ldr	r7, Lcurproc
    283 	ldr	r1, [r7]
    284 	mov	r0, #0x00000000
    285 	str	r0, [r7]
    286 
    287 	/* Zero the pcb */
    288 	ldr	r7, Lcurpcb
    289 	str	r0, [r7]
    290 
    291 	/* Lower the spl level to spl0 and get the current spl level. */
    292 	mov	r7, r1
    293 
    294 #ifdef spl0
    295 	mov	r0, #(_SPL_0)
    296 	bl	_C_LABEL(splx)
    297 #else
    298 	bl	_C_LABEL(spl0)
    299 #endif
    300 
    301 	/* Push the old spl level onto the stack */
    302 	str	r0, [sp, #-0x0004]!
    303 
    304 	mov	r1, r7
    305 
    306 	/* First phase : find a new process */
    307 
    308 	/* rem: r1 = old proc */
    309 
    310 switch_search:
    311 	IRQdisable
    312 
    313 	/* Do we have any active queues  */
    314 	ldr	r7, Lwhichqs
    315 	ldr	r3, [r7]
    316 
    317 	/* If not we must idle until we do. */
    318 	teq	r3, #0x00000000
    319 	beq	idle
    320 
    321 sw1:
    322 	/* rem: r1 = old proc */
    323 	/* rem: r3 = whichqs */
    324 	/* rem: interrupts are disabled */
    325 
    326 	/*
    327 	 * Paranoid debug time ....
    328 	 * Is this overkill ? If we are not in SVC mode then things are
    329 	 * very sick and will probably have already died.
    330 	 */
    331 #ifdef DIAGNOSTIC
    332 	mrs	r4, cpsr_all
    333 	and	r4, r4, #(PSR_MODE)
    334 	teq	r4, #(PSR_SVC32_MODE)
    335 	beq	switchmodeok
    336 
    337 	add	r0, pc, #switchpanic - . - 8
    338 	mrs	r1, cpsr_all
    339 	bl	_C_LABEL(panic)
    340 
    341 switchpanic:
    342 	.asciz	"Yikes! In cpu_switch() but not in SVC mode (%08x)\n"
    343 	.align	0
    344 
    345 switchmodeok:
    346 #endif
    347 
    348 	/*
    349 	 * We have found an active queue. Currently we do not know which queue
    350 	 * is active just that one of them is.
    351 	 */
    352 	/* this is the ffs algorithm devised by d.seal and posted to
    353 	 * comp.sys.arm on 16 Feb 1994.
    354 	 */
    355  	rsb	r5, r3, #0
    356  	ands	r0, r3, r5
    357 
    358 	adr	r5, Lcpu_switch_ffs_table
    359 
    360 	orr	r4, r0, r0, lsl #4  /* r0 = X * 0x11 */
    361 	orr	r4, r4, r4, lsl #6  /* r0 = X * 0x451 */
    362 	rsb	r4, r4, r4, lsl #16 /* r0 = X * 0x0450fbaf */
    363 
    364 	/* used further down, saves SA stall */
    365 	ldr	r6, Lqs
    366 
    367 	/* now lookup in table indexed on top 6 bits of a0 */
    368 	ldrb	r4, [ r5, r4, lsr #26 ]
    369 
    370 	/* rem: r0 = bit mask of chosen queue (1 << r4) */
    371 	/* rem: r1 = old proc */
    372 	/* rem: r3 = whichqs */
    373 	/* rem: r4 = queue number */
    374 	/* rem: interrupts are disabled */
    375 
    376 	/* Get the address of the queue (&qs[queue]) */
    377 	add	r5, r6, r4, lsl #3
    378 
    379 	/*
    380 	 * Get the process from the queue and place the next process in
    381 	 * the queue at the head. This basically unlinks the process at
    382 	 * the head of the queue.
    383 	 */
    384 	ldr	r6, [r5, #(P_FORW)]
    385 
    386 	/* rem: r6 = new process */
    387 	ldr	r7, [r6, #(P_FORW)]
    388 	str	r7, [r5, #(P_FORW)]
    389 
    390 	/*
    391 	 * Test to see if the queue is now empty. If the head of the queue
    392 	 * points to the queue itself then there are no more processes in
    393 	 * the queue. We can therefore clear the queue not empty flag held
    394 	 * in r3.
    395 	 */
    396 
    397 	teq	r5, r7
    398 	biceq	r3, r3, r0
    399 
    400 	/* rem: r0 = bit mask of chosen queue (1 << r4) - NOT NEEDED AN MORE */
    401 
    402 	/* Fix the back pointer for the process now at the head of the queue. */
    403 	ldr	r0, [r6, #(P_BACK)]
    404 	str	r0, [r7, #(P_BACK)]
    405 
    406 	/* Update the RAM copy of the queue not empty flags word. */
    407 	ldr	r7, Lwhichqs
    408 	str	r3, [r7]
    409 
    410 	/* rem: r1 = old proc */
    411 	/* rem: r3 = whichqs - NOT NEEDED ANY MORE */
    412 	/* rem: r4 = queue number - NOT NEEDED ANY MORE */
    413 	/* rem: r6 = new process */
    414 	/* rem: interrupts are disabled */
    415 
    416 	/* Clear the want_resched flag */
    417 	mov	r0, #0x00000000
    418 	ldr	r7, Lwant_resched
    419 	str	r0, [r7]
    420 
    421 	/*
    422 	 * Clear the back pointer of the process we have removed from
    423 	 * the head of the queue. The new process is isolated now.
    424 	 */
    425 	mov	r0, #0x00000000
    426 	str	r0, [r6, #(P_BACK)]
    427 
    428 	/* p->p_cpu initialized in fork1() for single-processor */
    429 
    430 	/* Process is now on a processor. */
    431 	mov	r0, #SONPROC			/* p->p_stat = SONPROC */
    432 	strb	r0, [r6, #(P_STAT)]
    433 
    434 	/* We have a new curproc now so make a note it */
    435 	ldr	r7, Lcurproc
    436 	str	r6, [r7]
    437 
    438 	/* Hook in a new pcb */
    439 	ldr	r7, Lcurpcb
    440 	ldr	r0, [r6, #(P_ADDR)]
    441 	str	r0, [r7]
    442 
    443 	/* At this point we can allow IRQ's again. */
    444 	IRQenable
    445 
    446 	/* rem: r1 = old proc */
    447 	/* rem: r6 = new process */
    448 	/* rem: interrupts are disabled */
    449 
    450 	/*
    451 	 * If the new process is the same as the process that called
    452 	 * cpu_switch() then we do not need to save and restore any
    453 	 * contexts. This means we can make a quick exit.
    454 	 * The test is simple if curproc on entry (now in r1) is the
    455 	 * same as the proc removed from the queue we can jump to the exit.
    456 	 */
    457 	teq	r1, r6
    458 	beq	switch_return
    459 
    460 	/*
    461 	 * If the curproc on entry to cpu_switch was zero then the
    462 	 * process that called it was exiting. This means that we do
    463 	 * not need to save the current context. Instead we can jump
    464 	 * straight to restoring the context for the new process.
    465 	 */
    466 	teq	r1, #0x00000000
    467 	beq	switch_exited
    468 
    469 	/* rem: r1 = old proc */
    470 	/* rem: r6 = new process */
    471 	/* rem: interrupts are disabled */
    472 
    473 	/* Stage two : Save old context */
    474 
    475 	/* Remember the old process in r0 */
    476 	mov	r0, r1
    477 
    478 	/* Get the user structure for the old process. */
    479 	ldr	r1, [r1, #(P_ADDR)]
    480 
    481 	/* Save all the registers in the old process's pcb */
    482 	add	r7, r1, #(PCB_R8)
    483 	stmia	r7, {r8-r13}
    484 
    485 	/*
    486 	 * This can be optimised... We know we want to go from SVC32
    487 	 * mode to UND32 mode
    488 	 */
    489         mrs	r3, cpsr_all
    490 	bic	r2, r3, #(PSR_MODE)
    491 	orr	r2, r2, #(PSR_UND32_MODE | I32_bit)
    492         msr	cpsr_all, r2
    493 
    494 	str	sp, [r1, #(PCB_UND_SP)]
    495 
    496         msr	cpsr_all, r3		/* Restore the old mode */
    497 
    498 	/* rem: r0 = old proc */
    499 	/* rem: r0 = old pcb */
    500 	/* rem: r6 = new process */
    501 	/* rem: interrupts are disabled */
    502 
    503 	/* What else needs to be saved  Only FPA stuff when that is supported */
    504 
    505 	/* Third phase : restore saved context */
    506 
    507 switch_exited:
    508 	/* Don't allow user space access beween the purge and the switch */
    509 	ldr	r3, Lblock_userspace_access
    510 	ldr	r2, [r3]
    511 	orr	r0, r2, #1
    512 	str	r0, [r3]
    513 
    514 	stmfd	sp!, {r0-r3}
    515 	ldr	r0, Lcpufuncs
    516 	add	lr, pc, #Lcs_cache_purged - . - 8
    517 	ldr	pc, [r0, #CF_CACHE_PURGE_ID]
    518 
    519 Lcs_cache_purged:
    520 	ldmfd	sp!, {r0-r3}
    521 
    522 	/* At this point we need to kill IRQ's again. */
    523 	IRQdisable
    524 
    525 	/* Interrupts are disabled so we can allow user space accesses again
    526 	 * as none will occur until interrupts are re-enabled after the
    527 	 * switch.
    528 	 */
    529 	str	r2, [r3]
    530 
    531 	/* Get the user structure for the new process in r1 */
    532 	ldr	r1, [r6, #(P_ADDR)]
    533 
    534 	/* Get the pagedir physical address for the process. */
    535 	ldr	r0, [r1, #(PCB_PAGEDIR)]
    536 
    537 	/* Switch the memory to the new process */
    538 	ldr	r3, Lcpufuncs
    539 	add	lr, pc, #Lcs_context_switched - . - 8
    540 	ldr	pc, [r3, #CF_CONTEXT_SWITCH]
    541 
    542 Lcs_context_switched:
    543 	/*
    544 	 * This can be optimised... We know we want to go from SVC32
    545 	 * mode to UND32 mode
    546 	 */
    547         mrs	r3, cpsr_all
    548 	bic	r2, r3, #(PSR_MODE)
    549 	orr	r2, r2, #(PSR_UND32_MODE)
    550         msr	cpsr_all, r2
    551 
    552 	ldr	sp, [r1, #(PCB_UND_SP)]
    553 
    554         msr	cpsr_all, r3		/* Restore the old mode */
    555 
    556 	/* Restore all the save registers */
    557 	add	r7, r1, #PCB_R8
    558 	ldmia	r7, {r8-r13}
    559 
    560 	/* Remember the pcb currently in use */
    561 	ldr	r7, Lcurpcb
    562 	str	r1, [r7]
    563 
    564 #ifdef ARMFPE
    565 	add	r0, r1, #(USER_SIZE) & 0x00ff
    566 	add	r0, r0, #(USER_SIZE) & 0xff00
    567 	bl	_C_LABEL(arm_fpe_core_changecontext)
    568 #endif
    569 
    570 	/* We can enable interrupts again */
    571 	IRQenable
    572 
    573 switch_return:
    574 	/* We have a new curproc now so make a note it */
    575 /*
    576 	ldr	r7, Lcurproc
    577 	str	r6, [r7]
    578 */
    579 
    580 	/* Get the spl level from the stack and update the current spl level */
    581 	ldr	r0, [sp], #0x0004
    582 	bl	_C_LABEL(splx)
    583 
    584 	/* cpu_switch returns the proc it switched to. */
    585 	mov	r0, r6
    586 
    587 	/*
    588 	 * Pull the registers that got pushed when either savectx() or
    589 	 * cpu_switch() was called and return.
    590 	 */
    591 	ldmfd	sp!, {r4-r7, pc}
    592 
    593 Lproc0:
    594 	.word	_C_LABEL(proc0)
    595 
    596 Lkernel_map:
    597 	.word	_C_LABEL(kernel_map)
    598 
    599 
    600 ENTRY(switch_exit)
    601 	/*
    602 	 * r0 = proc
    603 	 * r1 = proc0
    604 	 */
    605 
    606 	mov	r3, r0
    607  	ldr	r1, Lproc0
    608 
    609 	/* In case we fault */
    610 	mov	r2, #0x00000000
    611 	ldr	r0, Lcurproc
    612 	str	r2, [r0]
    613 
    614 /*	ldr	r0, Lcurpcb
    615 	str	r2, [r0]*/
    616 
    617 	/* Switch to proc0 context */
    618 
    619 	stmfd	sp!, {r0-r3}
    620 
    621 	ldr	r0, Lcpufuncs
    622 	add	lr, pc, #Lse_cache_purged - . - 8
    623 	ldr	pc, [r0, #CF_CACHE_PURGE_ID]
    624 
    625 Lse_cache_purged:
    626 	ldmfd	sp!, {r0-r3}
    627 
    628 	IRQdisable
    629 
    630 	ldr	r2, [r1, #(P_ADDR)]
    631 	ldr	r0, [r2, #(PCB_PAGEDIR)]
    632 
    633 	/* Switch the memory to the new process */
    634 	ldr	r4, Lcpufuncs
    635 	add	lr, pc, #Lse_context_switched - . - 8
    636 	ldr	pc, [r4, #CF_CONTEXT_SWITCH]
    637 
    638 Lse_context_switched:
    639 	/* Restore all the save registers */
    640 	add	r7, r2, #PCB_R8
    641 	ldmia	r7, {r8-r13}
    642 
    643 	/* This is not really needed ! */
    644 	/* Yes it is for the su and fu routines */
    645 	ldr	r0, Lcurpcb
    646 	str	r2, [r0]
    647 
    648 	IRQenable
    649 
    650 /*	str	r3, [sp, #-0x0004]!*/
    651 
    652 	/*
    653 	 * Schedule the vmspace and stack to be freed.
    654 	 */
    655 	mov	r0, r3			/* exit2(p) */
    656 	bl	_C_LABEL(exit2)
    657 
    658 	/* Paranoia */
    659 	mov	r0, #0x00000000
    660 	ldr	r1, Lcurproc
    661 	str	r0, [r1]
    662 
    663         ldr     r1, Lproc0
    664 	b	switch_search
    665 
    666 Lcurrent_spl_level:
    667 	.word	_C_LABEL(current_spl_level)
    668 
    669 ENTRY(savectx)
    670 	/*
    671 	 * r0 = pcb
    672 	 */
    673 
    674 	/* Push registers.*/
    675 	stmfd	sp!, {r4-r7, lr}
    676 
    677 	/* Store all the registers in the process's pcb */
    678 	add	r2, r0, #(PCB_R8)
    679 	stmia	r2, {r8-r13}
    680 
    681 	/* Pull the regs of the stack */
    682 	ldmfd	sp!, {r4-r7, pc}
    683 
    684 ENTRY(proc_trampoline)
    685 	add	lr, pc, #(trampoline_return - . - 8)
    686 	mov	r0, r5
    687 	mov	r1, sp
    688 	mov	pc, r4
    689 
    690 trampoline_return:
    691 	/* Kill irq's */
    692         mrs     r0, cpsr_all
    693         orr     r0, r0, #(I32_bit)
    694         msr     cpsr_all, r0
    695 
    696 	PULLFRAME
    697 
    698 	movs	pc, lr			/* Exit */
    699 
    700 .type Lffs_table, _ASM_TYPE_OBJECT;
    701 Lcpu_switch_ffs_table:
    702 /* same as ffs table but all nums are -1 from that */
    703 /*               0   1   2   3   4   5   6   7           */
    704 	.byte	 0,  0,  1, 12,  2,  6,  0, 13  /*  0- 7 */
    705 	.byte	 3,  0,  7,  0,  0,  0,  0, 14  /*  8-15 */
    706 	.byte	10,  4,  0,  0,  8,  0,  0, 25  /* 16-23 */
    707 	.byte	 0,  0,  0,  0,  0, 21, 27, 15  /* 24-31 */
    708 	.byte	31, 11,  5,  0,  0,  0,  0,  0	/* 32-39 */
    709 	.byte	 9,  0,  0, 24,  0,  0, 20, 26  /* 40-47 */
    710 	.byte	30,  0,  0,  0,  0, 23,  0, 19  /* 48-55 */
    711 	.byte   29,  0, 22, 18, 28, 17, 16,  0  /* 56-63 */
    712 
    713 /* End of cpuswitch.S */
    714