Mercurial > ecos
annotate packages/hal/arm/arch/current/src/context.S @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children | 435cced73e2f |
| rev | line source |
|---|---|
| 2 | 1 // #============================================================================= |
| 2 // # | |
| 3 // # context.S | |
| 4 // # | |
| 5 // # PowerPC context switch code | |
| 6 // # | |
| 7 // #============================================================================= | |
| 8 // ####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
12 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
15 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
29 // |
| 2 | 30 // ####COPYRIGHTEND#### |
| 31 // #============================================================================= | |
| 32 // ######DESCRIPTIONBEGIN#### | |
| 33 // # | |
| 34 // # Author(s): nickg, gthomas | |
| 35 // # Contributors: nickg, gthomas | |
| 36 // # Date: 1998-09-15 | |
| 37 // # Purpose: ARM context switch code | |
| 38 // # Description: This file contains implementations of the thread context | |
| 39 // # switch routines. It also contains the longjmp() and setjmp() | |
| 40 // # routines. | |
| 41 // # | |
| 42 // #####DESCRIPTIONEND#### | |
| 43 // # | |
| 44 // #============================================================================= | |
| 45 | |
| 46 #include <pkgconf/hal.h> | |
| 47 | |
| 48 #include "arm.inc" | |
| 49 | |
| 50 .text | |
| 51 | |
| 52 // ------------------------------------------------------------------------------ | |
| 53 // function declaration macro | |
| 54 | |
| 55 #define FUNC_START(name) \ | |
| 56 .globl name; \ | |
| 57 name: | |
| 58 | |
| 59 // ------------------------------------------------------------------------------ | |
| 60 // hal_thread_switch_context | |
| 61 // Switch thread contexts | |
| 62 // R0 = address of sp of next thread to execute | |
| 63 // R1 = address of sp save location of current thread | |
| 64 | |
| 65 // Need to save/restore R4..R12, R13 (sp), R14 (lr) | |
| 66 | |
| 67 // Note: this is a little wasteful since r0..r3 don't need to be saved. | |
| 68 // They are saved here though so that the information can match the HAL_SavedRegisters | |
| 69 | |
| 70 FUNC_START(hal_thread_switch_context) | |
| 71 mov ip,sp // saved stack pointer | |
|
38
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
20
diff
changeset
|
72 stmfd sp!,{fp,ip,lr,pc} // filler |
|
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
20
diff
changeset
|
73 stmfd sp!,{r0-r10,fp,ip,lr,pc} |
| 2 | 74 mrs r2,cpsr |
| 75 str r2,[sp,#armreg_cpsr] | |
| 76 str sp,[r1] // return new stack pointer | |
| 77 | |
| 78 # Now load the destination thread by dropping through | |
| 79 # to hal_thread_load_context | |
| 80 | |
| 81 // ------------------------------------------------------------------------------ | |
| 82 // hal_thread_load_context | |
| 83 // Load thread context | |
| 84 // R0 = address of sp of next thread to execute | |
| 85 // Note that this function is also the second half of hal_thread_switch_context | |
| 86 // and is simply dropped into from it. | |
| 87 | |
| 88 FUNC_START(hal_thread_load_context) | |
| 89 ldr fp,[r0] // get context to restore | |
| 90 mrs r0,cpsr // disable IRQ's | |
|
20
5f5102441818
Merge from eCos master repository on 1999-07-02-23:17:07-BST
jlarmour
parents:
2
diff
changeset
|
91 orr r0,r0,#CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE |
| 2 | 92 msr cpsr,r0 |
| 93 ldr r0,[fp,#armreg_cpsr] | |
| 94 msr spsr,r0 | |
|
38
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
20
diff
changeset
|
95 ldmfd fp,{r0-r10,fp,sp,lr} |
|
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
20
diff
changeset
|
96 movs pc,lr // also restores saved PSR |
| 2 | 97 |
| 98 // ------------------------------------------------------------------------------ | |
| 99 // HAL longjmp, setjmp implementations | |
| 100 // hal_setjmp saves only to callee save registers 4-14 | |
| 101 // and lr into buffer supplied in r0[arg0] | |
| 102 | |
| 103 FUNC_START(hal_setjmp) | |
| 104 stmea r0,{r4-r14} | |
| 105 mov r0,#0 | |
| 106 mov pc,lr; # return | |
| 107 | |
| 108 // hal_longjmp loads state from r0[arg0] and returns | |
| 109 | |
| 110 FUNC_START(hal_longjmp) | |
| 111 ldmfd r0,{r4-r14} | |
| 112 mov r0,r1; # return [arg1] | |
| 113 mov pc,lr | |
| 114 | |
| 115 // ------------------------------------------------------------------------------ | |
| 116 // end of context.S | |
| 117 | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
38
diff
changeset
|
118 |
