Fix the indenting of the comments in this file.
This commit is contained in:
parent
7c57681a0b
commit
ad8c2a5654
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpuswitch.S,v 1.20 1998/01/20 01:18:24 mark Exp $ */
|
||||
/* $NetBSD: cpuswitch.S,v 1.21 1998/04/19 23:37:22 mark Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994-1997 Mark Brinicombe.
|
||||
@ -49,10 +49,6 @@
|
||||
#include <machine/frame.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
sp .req r13
|
||||
lr .req r14
|
||||
pc .req r15
|
||||
|
||||
#undef IRQdisable
|
||||
#undef IRQenable
|
||||
|
||||
@ -95,14 +91,14 @@ Lqs:
|
||||
*/
|
||||
|
||||
ENTRY(setrunqueue)
|
||||
/*
|
||||
* Local register usage
|
||||
* r0 = process
|
||||
* r1 = queue
|
||||
* r2 = &qs[queue]
|
||||
* r3 = temp
|
||||
* r4 = whichqs
|
||||
*/
|
||||
/*
|
||||
* Local register usage
|
||||
* r0 = process
|
||||
* r1 = queue
|
||||
* r2 = &qs[queue] and temp
|
||||
* r3 = temp
|
||||
* r4 = whichqs
|
||||
*/
|
||||
stmfd sp!, {r4}
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -115,13 +111,11 @@ ENTRY(setrunqueue)
|
||||
bne Lsetrunqueue_erg
|
||||
#endif
|
||||
|
||||
/* Get the priority of the queue */
|
||||
|
||||
/* Get the priority of the queue */
|
||||
ldrb r1, [r0, #(P_PRIORITY)]
|
||||
mov r1, r1, lsr #2
|
||||
|
||||
/* Indicate that there is a process on this queue */
|
||||
|
||||
/* Indicate that there is a process on this queue */
|
||||
ldr r4, Lwhichqs
|
||||
ldr r2, [r4]
|
||||
mov r3, #0x00000001
|
||||
@ -129,12 +123,11 @@ ENTRY(setrunqueue)
|
||||
orr r2, r2, r3
|
||||
str r2, [r4]
|
||||
|
||||
/* Get the address of the queue */
|
||||
|
||||
/* Get the address of the queue */
|
||||
ldr r2, Lqs
|
||||
add r1, r2, r1, lsl # 3
|
||||
|
||||
/* Hook the process in */
|
||||
/* Hook the process in */
|
||||
str r1, [r0, #(P_FORW)]
|
||||
ldr r2, [r1, #(P_BACK)]
|
||||
|
||||
@ -175,36 +168,31 @@ Ltext2:
|
||||
*/
|
||||
|
||||
ENTRY(remrunqueue)
|
||||
|
||||
/*
|
||||
* Local register usage
|
||||
* r0 = oldproc
|
||||
* r1 = queue
|
||||
* r2 = &qs[queue]
|
||||
* r3 = scratch
|
||||
* r4 = whichqs
|
||||
*/
|
||||
/*
|
||||
* Local register usage
|
||||
* r0 = oldproc
|
||||
* r1 = queue
|
||||
* r2 = &qs[queue] and scratch
|
||||
* r3 = scratch
|
||||
* r4 = whichqs
|
||||
*/
|
||||
stmfd sp!, {r4}
|
||||
|
||||
/* Get the priority of the queue */
|
||||
|
||||
/* Get the priority of the queue */
|
||||
ldrb r1, [r0, #(P_PRIORITY)]
|
||||
mov r1, r1, lsr #2
|
||||
|
||||
/* Unhook the process */
|
||||
|
||||
/* Unhook the process */
|
||||
ldr r2, [r0, #(P_FORW)]
|
||||
ldr r3, [r0, #(P_BACK)]
|
||||
|
||||
str r3, [r2, #(P_BACK)]
|
||||
str r2, [r3, #(P_FORW)]
|
||||
|
||||
/* If the queue is now empty clear the queue not empty flag */
|
||||
|
||||
/* If the queue is now empty clear the queue not empty flag */
|
||||
teq r2, r3
|
||||
|
||||
/* This could be reworked to avoid the use of r4 */
|
||||
|
||||
/* This could be reworked to avoid the use of r4 */
|
||||
ldreq r4, Lwhichqs
|
||||
ldreq r2, [r4]
|
||||
moveq r3, #0x00000001
|
||||
@ -212,8 +200,7 @@ ENTRY(remrunqueue)
|
||||
biceq r2, r2, r3
|
||||
streq r2, [r4]
|
||||
|
||||
/* Remove the back pointer for the process */
|
||||
|
||||
/* Remove the back pointer for the process */
|
||||
mov r1, #0x00000000
|
||||
str r1, [r0, #(P_BACK)]
|
||||
|
||||
@ -229,16 +216,9 @@ ENTRY(remrunqueue)
|
||||
* This function has several entry points
|
||||
*/
|
||||
|
||||
|
||||
Lcurproc:
|
||||
.word _curproc
|
||||
|
||||
.data
|
||||
.global _curpcb
|
||||
_curpcb:
|
||||
.word 0x00000000
|
||||
|
||||
.text
|
||||
Lcurpcb:
|
||||
.word _curpcb
|
||||
|
||||
@ -247,18 +227,23 @@ Lwant_resched:
|
||||
|
||||
Lcpufuncs:
|
||||
.word _cpufuncs
|
||||
|
||||
.data
|
||||
.global _curpcb
|
||||
_curpcb:
|
||||
.word 0x00000000
|
||||
.text
|
||||
|
||||
|
||||
/*
|
||||
* Idle loop, exercised while waiting for a process to wake up.
|
||||
*/
|
||||
|
||||
idle:
|
||||
/* Enable interrupts */
|
||||
|
||||
/* Enable interrupts */
|
||||
IRQenable
|
||||
|
||||
/* XXX - r1 needs to be preserved for cpu_switch */
|
||||
|
||||
mov r7, r1
|
||||
ldr r3, Lcpufuncs
|
||||
mov r0, #0
|
||||
@ -268,16 +253,14 @@ idle:
|
||||
Lidle_slept:
|
||||
mov r1, r7
|
||||
|
||||
/* Disable interrupts while we check for an active queue */
|
||||
|
||||
/* Disable interrupts while we check for an active queue */
|
||||
IRQdisable
|
||||
ldr r7, Lwhichqs
|
||||
ldr r3, [r7]
|
||||
teq r3, #0x00000000
|
||||
bne sw1
|
||||
|
||||
/* All processes are still asleep so idle a while longer */
|
||||
|
||||
/* All processes are still asleep so idle a while longer */
|
||||
b idle
|
||||
|
||||
|
||||
@ -299,23 +282,20 @@ ENTRY(cpu_switch)
|
||||
*/
|
||||
stmfd sp!, {r4-r7, lr}
|
||||
|
||||
/*
|
||||
* Get the current process and indicate that there is no longer a valid
|
||||
* process (curproc = 0)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get the current process and indicate that there is no longer
|
||||
* a valid process (curproc = 0)
|
||||
*/
|
||||
ldr r7, Lcurproc
|
||||
ldr r1, [r7]
|
||||
mov r0, #0x00000000
|
||||
str r0, [r7]
|
||||
|
||||
/* Zero the pcb */
|
||||
|
||||
/* Zero the pcb */
|
||||
ldr r7, Lcurpcb
|
||||
str r0, [r7]
|
||||
|
||||
/* Lower the spl level to spl0 and get the current spl level. */
|
||||
|
||||
/* Lower the spl level to spl0 and get the current spl level. */
|
||||
mov r7, r1
|
||||
|
||||
#ifdef spl0
|
||||
@ -325,40 +305,36 @@ ENTRY(cpu_switch)
|
||||
bl _spl0
|
||||
#endif
|
||||
|
||||
/* Push the old spl level onto the stack */
|
||||
|
||||
/* Push the old spl level onto the stack */
|
||||
str r0, [sp, #-0x0004]!
|
||||
|
||||
mov r1, r7
|
||||
|
||||
/* First phase : find a new process */
|
||||
/* First phase : find a new process */
|
||||
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r1 = old proc */
|
||||
|
||||
switch_search:
|
||||
IRQdisable
|
||||
|
||||
/* Do we have any active queues */
|
||||
|
||||
/* Do we have any active queues */
|
||||
ldr r7, Lwhichqs
|
||||
ldr r3, [r7]
|
||||
|
||||
/* If not we must idle until we do. */
|
||||
|
||||
/* If not we must idle until we do. */
|
||||
teq r3, #0x00000000
|
||||
beq idle
|
||||
|
||||
sw1:
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r3 = whichqs */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/*
|
||||
* Paranoid debug time ....
|
||||
* Is this overkill ? If we are not in SVC mode then things are
|
||||
* very sick and will probably have already died.
|
||||
*/
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r3 = whichqs */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/*
|
||||
* Paranoid debug time ....
|
||||
* Is this overkill ? If we are not in SVC mode then things are
|
||||
* very sick and will probably have already died.
|
||||
*/
|
||||
#ifdef DIAGNOSTIC
|
||||
mrs r4, cpsr_all
|
||||
and r4, r4, #(PSR_MODE)
|
||||
@ -376,16 +352,15 @@ switchpanic:
|
||||
switchmodeok:
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We have found an active queue. Currently we do not know which queue
|
||||
* is active just that one of them is.
|
||||
* We must check each queue to find the active one.
|
||||
* r3 contains a bit for each of the 32 queues. A one indicates that
|
||||
* that the queue has something in it.
|
||||
*/
|
||||
|
||||
/* This ffs() type routine could be optimised */
|
||||
/*
|
||||
* We have found an active queue. Currently we do not know which queue
|
||||
* is active just that one of them is.
|
||||
* We must check each queue to find the active one.
|
||||
* r3 contains a bit for each of the 32 queues. A one indicates that
|
||||
* that the queue has something in it.
|
||||
*/
|
||||
|
||||
/* This ffs() type routine could be optimised */
|
||||
mov r4, #0x00000000
|
||||
|
||||
findqueue:
|
||||
@ -396,141 +371,130 @@ findqueue:
|
||||
addeq r4, r4, #0x00000001
|
||||
beq findqueue
|
||||
|
||||
/*
|
||||
* Ok we have found the active queue. The above code can never fail as
|
||||
* we only get to it if r3 != 0
|
||||
* r4 contains the number of the first queue found with a process in it.
|
||||
*/
|
||||
/*
|
||||
* Ok we have found the active queue. The above code can never fail as
|
||||
* we only get to it if r3 != 0
|
||||
* r4 contains the number of the first queue found with a process in it.
|
||||
*/
|
||||
|
||||
/* rem: r0 = bit mask of chosen queue (1 << r4) */
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r3 = whichqs */
|
||||
/* rem: r4 = queue number */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/* Get the address of the queue (&qs[queue]) */
|
||||
/* rem: r0 = bit mask of chosen queue (1 << r4) */
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r3 = whichqs */
|
||||
/* rem: r4 = queue number */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/* Get the address of the queue (&qs[queue]) */
|
||||
ldr r5, Lqs
|
||||
add r5, r5, r4, lsl #3
|
||||
|
||||
/*
|
||||
* Get the process from the queue and place the next process in the queue
|
||||
* at the head. This basically unlinks the process at the head of the queue.
|
||||
*/
|
||||
/*
|
||||
* Get the process from the queue and place the next process in
|
||||
* the queue at the head. This basically unlinks the process at
|
||||
* the head of the queue.
|
||||
*/
|
||||
ldr r6, [r5, #(P_FORW)]
|
||||
|
||||
/* rem: r6 = new process */
|
||||
|
||||
/* rem: r6 = new process */
|
||||
ldr r7, [r6, #(P_FORW)]
|
||||
str r7, [r5, #(P_FORW)]
|
||||
|
||||
/*
|
||||
* Test to see if the queue is now empty. If the head of the queue points
|
||||
* to the queue itself then there are no more processes in the queue.
|
||||
* We can therefore clear the queue not empty flag held in r3.
|
||||
*/
|
||||
/*
|
||||
* Test to see if the queue is now empty. If the head of the queue
|
||||
* points to the queue itself then there are no more processes in
|
||||
* the queue. We can therefore clear the queue not empty flag held
|
||||
* in r3.
|
||||
*/
|
||||
|
||||
teq r5, r7
|
||||
biceq r3, r3, r0
|
||||
|
||||
/* rem: r0 = bit mask of chosen queue (1 << r4) - NOT NEEDED AN MORE */
|
||||
|
||||
/* Fix the back pointer for the process now at the head of the queue. */
|
||||
/* rem: r0 = bit mask of chosen queue (1 << r4) - NOT NEEDED AN MORE */
|
||||
|
||||
/* Fix the back pointer for the process now at the head of the queue. */
|
||||
ldr r0, [r6, #(P_BACK)]
|
||||
str r0, [r7, #(P_BACK)]
|
||||
|
||||
/* Update the RAM copy of the queue not empty flags word. */
|
||||
|
||||
/* Update the RAM copy of the queue not empty flags word. */
|
||||
ldr r7, Lwhichqs
|
||||
str r3, [r7]
|
||||
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r3 = whichqs - NOT NEEDED ANY MORE */
|
||||
/* rem: r4 = queue number - NOT NEEDED ANY MORE */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/* Clear the want_resched flag */
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r3 = whichqs - NOT NEEDED ANY MORE */
|
||||
/* rem: r4 = queue number - NOT NEEDED ANY MORE */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/* Clear the want_resched flag */
|
||||
mov r0, #0x00000000
|
||||
ldr r7, Lwant_resched
|
||||
str r0, [r7]
|
||||
|
||||
/*
|
||||
* Clear the back pointer of the process we have removed from the head
|
||||
* of the queue. The new process is isolated now.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Clear the back pointer of the process we have removed from
|
||||
* the head of the queue. The new process is isolated now.
|
||||
*/
|
||||
mov r0, #0x00000000
|
||||
str r0, [r6, #(P_BACK)]
|
||||
|
||||
/* We have a new curproc now so make a note it */
|
||||
|
||||
/* We have a new curproc now so make a note it */
|
||||
ldr r7, Lcurproc
|
||||
str r6, [r7]
|
||||
|
||||
/* Hook in a new pcb */
|
||||
|
||||
/* Hook in a new pcb */
|
||||
ldr r7, Lcurpcb
|
||||
ldr r0, [r6, #(P_ADDR)]
|
||||
str r0, [r7]
|
||||
|
||||
/* At this point we can allow IRQ's again. */
|
||||
|
||||
/* At this point we can allow IRQ's again. */
|
||||
/*
|
||||
IRQenable
|
||||
IRQdisable
|
||||
*/
|
||||
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/*
|
||||
* If the new process is the same as the process that called cpu_switch
|
||||
* Then we do not need to save and restore any contexts. This means
|
||||
* we can make a quick exit.
|
||||
* The test is simple if curproc on entry (now in r1) is the same as the
|
||||
* proc removed from the queue we can jump to the exit.
|
||||
*/
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/*
|
||||
* If the new process is the same as the process that called
|
||||
* cpu_switch() then we do not need to save and restore any
|
||||
* contexts. This means we can make a quick exit.
|
||||
* The test is simple if curproc on entry (now in r1) is the
|
||||
* same as the proc removed from the queue we can jump to the exit.
|
||||
*/
|
||||
teq r1, r6
|
||||
beq switch_return
|
||||
|
||||
/*
|
||||
* If the curproc on entry to cpu_switch was zero then the process that
|
||||
* called it was exiting. This means that we do not need to save the current
|
||||
* context. Instead we can jump straight to restoring the context for
|
||||
* the new process.
|
||||
*/
|
||||
/*
|
||||
* If the curproc on entry to cpu_switch was zero then the
|
||||
* process that called it was exiting. This means that we do
|
||||
* not need to save the current context. Instead we can jump
|
||||
* straight to restoring the context for the new process.
|
||||
*/
|
||||
|
||||
teq r1, #0x00000000
|
||||
beq switch_exited
|
||||
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
/* rem: r1 = old proc */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/* Stage two : Save old context */
|
||||
|
||||
/* Remember the old process in r0 */
|
||||
/* Stage two : Save old context */
|
||||
|
||||
/* Remember the old process in r0 */
|
||||
mov r0, r1
|
||||
|
||||
/* Get the user structure for the old process. */
|
||||
|
||||
/* Get the user structure for the old process. */
|
||||
ldr r1, [r1, #(P_ADDR)]
|
||||
|
||||
/* Save all the registers in the old process's pcb */
|
||||
|
||||
/* Save all the registers in the old process's pcb */
|
||||
add r7, r1, #(PCB_R8)
|
||||
stmia r7, {r8-r13}
|
||||
|
||||
/*
|
||||
* This can be optimised... We know we want to go from SVC32 mode to UND32
|
||||
* mode
|
||||
*/
|
||||
/*
|
||||
* This can be optimised... We know we want to go from SVC32
|
||||
* mode to UND32 mode
|
||||
*/
|
||||
|
||||
mrs r3, cpsr_all
|
||||
bic r2, r3, #(PSR_MODE)
|
||||
@ -541,19 +505,17 @@ findqueue:
|
||||
|
||||
msr cpsr_all, r3 /* Restore the old mode */
|
||||
|
||||
/* rem: r0 = old proc */
|
||||
/* rem: r0 = old pcb */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
/* rem: r0 = old proc */
|
||||
/* rem: r0 = old pcb */
|
||||
/* rem: r6 = new process */
|
||||
/* rem: interrupts are disabled */
|
||||
|
||||
/* What else needs to be saved Only FPA stuff when that is supported */
|
||||
/* What else needs to be saved Only FPA stuff when that is supported */
|
||||
|
||||
/* Third phase : restore saved context */
|
||||
/* Third phase : restore saved context */
|
||||
|
||||
switch_exited:
|
||||
|
||||
/* At this point we need to kill IRQ's again. */
|
||||
|
||||
/* At this point we need to kill IRQ's again. */
|
||||
mrs r0, cpsr_all
|
||||
orr r0, r0, #(I32_bit)
|
||||
msr cpsr_all , r0
|
||||
@ -568,26 +530,22 @@ switch_exited:
|
||||
Lcs_cache_purged:
|
||||
ldmfd sp!, {r0-r3}
|
||||
|
||||
/* Get the user structure for the new process in r1 */
|
||||
|
||||
/* Get the user structure for the new process in r1 */
|
||||
ldr r1, [r6, #(P_ADDR)]
|
||||
|
||||
/* Get the pagedir physical address for the process. */
|
||||
|
||||
/* Get the pagedir physical address for the process. */
|
||||
ldr r0, [r1, #(PCB_PAGEDIR)]
|
||||
|
||||
/* Switch the memory to the new process */
|
||||
/* Switch the memory to the new process */
|
||||
ldr r3, Lcpufuncs
|
||||
add lr, pc, #Lcs_context_switched - . - 8
|
||||
ldr pc, [r3, #CF_CONTEXT_SWITCH]
|
||||
|
||||
Lcs_context_switched:
|
||||
|
||||
/*
|
||||
* This can be optimised... We know we want to go from SVC32 mode to UND32
|
||||
* mode
|
||||
*/
|
||||
|
||||
/*
|
||||
* This can be optimised... We know we want to go from SVC32
|
||||
* mode to UND32 mode
|
||||
*/
|
||||
mrs r3, cpsr_all
|
||||
bic r2, r3, #(PSR_MODE)
|
||||
orr r2, r2, #(PSR_UND32_MODE)
|
||||
@ -597,18 +555,15 @@ Lcs_context_switched:
|
||||
|
||||
msr cpsr_all, r3 /* Restore the old mode */
|
||||
|
||||
/* Restore all the save registers */
|
||||
|
||||
/* Restore all the save registers */
|
||||
add r7, r1, #PCB_R8
|
||||
ldmia r7, {r8-r13}
|
||||
|
||||
/* Remember the pcb currently in use */
|
||||
|
||||
/* Remember the pcb currently in use */
|
||||
ldr r7, Lcurpcb
|
||||
str r1, [r7]
|
||||
|
||||
/* We can enable interrupts again */
|
||||
|
||||
/* We can enable interrupts again */
|
||||
/*
|
||||
IRQenable
|
||||
*/
|
||||
@ -620,29 +575,25 @@ Lcs_context_switched:
|
||||
#endif
|
||||
|
||||
switch_return:
|
||||
|
||||
/* We have a new curproc now so make a note it */
|
||||
|
||||
/* We have a new curproc now so make a note it */
|
||||
/*
|
||||
ldr r7, Lcurproc
|
||||
str r6, [r7]
|
||||
*/
|
||||
|
||||
/* Get the spl level from the stack and update the current spl level */
|
||||
|
||||
/* Get the spl level from the stack and update the current spl level */
|
||||
ldr r0, [sp], #0x0004
|
||||
bl _splx
|
||||
|
||||
IRQenable /*** just changed this ***/
|
||||
|
||||
/* cpu_switch returns the proc it switched to. */
|
||||
|
||||
/* cpu_switch returns the proc it switched to. */
|
||||
mov r0, r6
|
||||
|
||||
/*
|
||||
* Pull the registers that got pushed when either savectx or cpu_switch
|
||||
* was called and return.
|
||||
*/
|
||||
/*
|
||||
* Pull the registers that got pushed when either savectx() or
|
||||
* cpu_switch() was called and return.
|
||||
*/
|
||||
ldmfd sp!, {r4-r7, pc}
|
||||
|
||||
Lproc0:
|
||||
@ -653,17 +604,15 @@ Lkernel_map:
|
||||
|
||||
|
||||
ENTRY(switch_exit)
|
||||
|
||||
/*
|
||||
* r0 = proc
|
||||
* r1 = proc0
|
||||
*/
|
||||
/*
|
||||
* r0 = proc
|
||||
* r1 = proc0
|
||||
*/
|
||||
|
||||
mov r3, r0
|
||||
ldr r1, Lproc0
|
||||
|
||||
/* In case we fault */
|
||||
|
||||
/* In case we fault */
|
||||
mov r2, #0x00000000
|
||||
ldr r0, Lcurproc
|
||||
str r2, [r0]
|
||||
@ -671,8 +620,7 @@ ENTRY(switch_exit)
|
||||
/* ldr r0, Lcurpcb
|
||||
str r2, [r0]*/
|
||||
|
||||
/* Switch to proc0 context */
|
||||
|
||||
/* Switch to proc0 context */
|
||||
IRQdisable
|
||||
|
||||
stmfd sp!, {r0-r3}
|
||||
@ -687,21 +635,18 @@ Lse_cache_purged:
|
||||
ldr r2, [r1, #(P_ADDR)]
|
||||
ldr r0, [r2, #(PCB_PAGEDIR)]
|
||||
|
||||
/* Switch the memory to the new process */
|
||||
/* Switch the memory to the new process */
|
||||
ldr r4, Lcpufuncs
|
||||
add lr, pc, #Lse_context_switched - . - 8
|
||||
ldr pc, [r4, #CF_CONTEXT_SWITCH]
|
||||
|
||||
Lse_context_switched:
|
||||
|
||||
/* Restore all the save registers */
|
||||
|
||||
/* Restore all the save registers */
|
||||
add r7, r2, #PCB_R8
|
||||
ldmia r7, {r8-r13}
|
||||
|
||||
/* This is not really needed ! */
|
||||
/* Yes it is for the su and fu routines */
|
||||
|
||||
/* This is not really needed ! */
|
||||
/* Yes it is for the su and fu routines */
|
||||
ldr r0, Lcurpcb
|
||||
str r2, [r0]
|
||||
|
||||
@ -709,10 +654,8 @@ Lse_context_switched:
|
||||
|
||||
str r3, [sp, #-0x0004]!
|
||||
|
||||
/* Thoroughly nuke the old process's resources. */
|
||||
|
||||
/* This has to be done here, before we lose the pmap */
|
||||
|
||||
/* Thoroughly nuke the old process's resources. */
|
||||
/* This has to be done here, before we lose the pmap */
|
||||
mov r1, #0x00000000
|
||||
add r2, r1, #NBPG
|
||||
ldr r0, [r3, #(P_VMSPACE)]
|
||||
@ -720,16 +663,14 @@ Lse_context_switched:
|
||||
bl _pmap_remove
|
||||
ldr r0, [sp]
|
||||
|
||||
/*
|
||||
* Have to wait until we have switched to proc0 as the pmap gets released
|
||||
* in vmspace_free()
|
||||
*/
|
||||
|
||||
/*
|
||||
* Have to wait until we have switched to proc0 as the
|
||||
* pmap gets released in vmspace_free()
|
||||
*/
|
||||
ldr r0, [r0, #(P_VMSPACE)]
|
||||
bl _vmspace_free
|
||||
|
||||
/* This has to be done here */
|
||||
|
||||
/* This has to be done here */
|
||||
mov r2, #(UPAGES << PGSHIFT)
|
||||
ldr r0, [sp], #0x0004
|
||||
ldr r1, [r0, #(P_ADDR)]
|
||||
@ -737,8 +678,7 @@ Lse_context_switched:
|
||||
ldr r0, [r0]
|
||||
bl _kmem_free
|
||||
|
||||
/* Paranoia */
|
||||
|
||||
/* Paranoia */
|
||||
mov r0, #0x00000000
|
||||
ldr r1, Lcurproc
|
||||
str r0, [r1]
|
||||
@ -746,29 +686,24 @@ Lse_context_switched:
|
||||
ldr r1, Lproc0
|
||||
b switch_search
|
||||
|
||||
|
||||
Lcurrent_spl_level:
|
||||
.word _current_spl_level
|
||||
|
||||
ENTRY(savectx)
|
||||
/*
|
||||
* r0 = pcb
|
||||
*/
|
||||
|
||||
/* Push registers.*/
|
||||
/*
|
||||
* r0 = pcb
|
||||
*/
|
||||
|
||||
/* Push registers.*/
|
||||
stmfd sp!, {r4-r7, lr}
|
||||
|
||||
/* Store all the registers in the process's pcb */
|
||||
|
||||
/* Store all the registers in the process's pcb */
|
||||
add r2, r0, #(PCB_R8)
|
||||
stmia r2, {r8-r13}
|
||||
|
||||
/* Pull the regs of the stack */
|
||||
|
||||
/* Pull the regs of the stack */
|
||||
ldmfd sp!, {r4-r7, pc}
|
||||
|
||||
|
||||
ENTRY(proc_trampoline)
|
||||
add lr, pc, #(trampoline_return - . - 8)
|
||||
mov r0, r5
|
||||
@ -776,8 +711,7 @@ ENTRY(proc_trampoline)
|
||||
mov pc, r4
|
||||
|
||||
trampoline_return:
|
||||
/* Kill irq's */
|
||||
|
||||
/* Kill irq's */
|
||||
mrs r0, cpsr_all
|
||||
orr r0, r0, #(I32_bit)
|
||||
msr cpsr_all, r0
|
||||
|
Loading…
Reference in New Issue
Block a user