Mercurial > flash_v2
comparison packages/hal/arm/arch/current/src/context.S @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | bf00f99aec69 |
| children | 2085233a121a |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 // #============================================================================= | 1 // #============================================================================= |
| 2 // # | 2 // # |
| 3 // # context.S | 3 // # context.S |
| 4 // # | 4 // # |
| 5 // # PowerPC context switch code | 5 // # ARM context switch code |
| 6 // # | 6 // # |
| 7 // #============================================================================= | 7 // #============================================================================= |
| 8 // ####COPYRIGHTBEGIN#### | 8 // ####COPYRIGHTBEGIN#### |
| 9 // | 9 // |
| 10 // ------------------------------------------- | 10 // ------------------------------------------- |
| 65 // Need to save/restore R4..R12, R13 (sp), R14 (lr) | 65 // Need to save/restore R4..R12, R13 (sp), R14 (lr) |
| 66 | 66 |
| 67 // Note: this is a little wasteful since r0..r3 don't need to be saved. | 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 | 68 // They are saved here though so that the information can match the HAL_SavedRegisters |
| 69 | 69 |
| 70 #ifdef __thumb__ | |
| 71 .code 16 | |
| 72 .thumb_func | |
| 73 #endif | |
| 70 FUNC_START(hal_thread_switch_context) | 74 FUNC_START(hal_thread_switch_context) |
| 75 #ifdef __thumb__ | |
| 76 ldr r2,=hal_thread_switch_context_ARM | |
| 77 bx r2 | |
| 78 .code 32 | |
| 79 FUNC_START(hal_thread_switch_context_ARM) | |
| 80 #endif | |
| 71 mov ip,sp // saved stack pointer | 81 mov ip,sp // saved stack pointer |
| 72 stmfd sp!,{fp,ip,lr,pc} // filler | 82 stmfd sp!,{fp,ip,lr,pc} // filler |
| 73 stmfd sp!,{r0-r10,fp,ip,lr,pc} | 83 stmfd sp!,{r0-r10,fp,ip,lr,pc} |
| 74 mrs r2,cpsr | 84 mrs r2,cpsr |
| 75 str r2,[sp,#armreg_cpsr] | 85 str r2,[sp,#armreg_cpsr] |
| 76 str sp,[r1] // return new stack pointer | 86 str sp,[r1] // return new stack pointer |
| 87 #ifdef __thumb__ | |
| 88 b hal_thread_load_context_ARM // skip mode switch stuff | |
| 89 #endif | |
| 77 | 90 |
| 78 # Now load the destination thread by dropping through | 91 # Now load the destination thread by dropping through |
| 79 # to hal_thread_load_context | 92 # to hal_thread_load_context |
| 80 | 93 |
| 81 // ------------------------------------------------------------------------------ | 94 // ------------------------------------------------------------------------------ |
| 83 // Load thread context | 96 // Load thread context |
| 84 // R0 = address of sp of next thread to execute | 97 // R0 = address of sp of next thread to execute |
| 85 // Note that this function is also the second half of hal_thread_switch_context | 98 // Note that this function is also the second half of hal_thread_switch_context |
| 86 // and is simply dropped into from it. | 99 // and is simply dropped into from it. |
| 87 | 100 |
| 101 #ifdef __thumb__ | |
| 102 .code 16 | |
| 103 .thumb_func | |
| 104 #endif | |
| 88 FUNC_START(hal_thread_load_context) | 105 FUNC_START(hal_thread_load_context) |
| 106 #ifdef __thumb__ | |
| 107 ldr r2,=hal_thread_load_context_ARM | |
| 108 bx r2 | |
| 109 .code 32 | |
| 110 FUNC_START(hal_thread_load_context_ARM) | |
| 111 #endif | |
| 89 ldr fp,[r0] // get context to restore | 112 ldr fp,[r0] // get context to restore |
| 90 mrs r0,cpsr // disable IRQ's | 113 mrs r0,cpsr // disable IRQ's |
| 91 orr r0,r0,#CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE | 114 orr r0,r0,#CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE |
| 92 msr cpsr,r0 | 115 msr cpsr,r0 |
| 93 ldr r0,[fp,#armreg_cpsr] | 116 ldr r0,[fp,#armreg_cpsr] |
| 94 msr spsr,r0 | 117 msr spsr,r0 |
| 95 ldmfd fp,{r0-r10,fp,sp,lr} | 118 ldmfd fp,{r0-r10,fp,sp,lr} |
| 119 #ifdef __thumb__ | |
| 120 mrs r1,spsr // r1 is scratch | |
| 121 // [r0 holds initial thread arg] | |
| 122 msr cpsr,r1 // hopefully no mode switch here! | |
| 123 bx lr | |
| 124 #else | |
| 96 movs pc,lr // also restores saved PSR | 125 movs pc,lr // also restores saved PSR |
| 126 #endif | |
| 97 | 127 |
| 98 // ------------------------------------------------------------------------------ | 128 // ------------------------------------------------------------------------------ |
| 99 // HAL longjmp, setjmp implementations | 129 // HAL longjmp, setjmp implementations |
| 100 // hal_setjmp saves only to callee save registers 4-14 | 130 // hal_setjmp saves only to callee save registers 4-14 |
| 101 // and lr into buffer supplied in r0[arg0] | 131 // and lr into buffer supplied in r0[arg0] |
| 102 | 132 |
| 133 #ifdef __thumb__ | |
| 134 .code 16 | |
| 135 .thumb_func | |
| 136 #endif | |
| 103 FUNC_START(hal_setjmp) | 137 FUNC_START(hal_setjmp) |
| 138 #ifdef __thumb__ | |
| 139 ldr r2,=hal_setjmp_ARM | |
| 140 bx r2 | |
| 141 .code 32 | |
| 142 FUNC_START(hal_setjmp_ARM) | |
| 143 #endif | |
| 104 stmea r0,{r4-r14} | 144 stmea r0,{r4-r14} |
| 105 mov r0,#0 | 145 mov r0,#0 |
| 146 #ifdef __thumb__ | |
| 147 bx lr | |
| 148 #else | |
| 106 mov pc,lr; # return | 149 mov pc,lr; # return |
| 150 #endif | |
| 107 | 151 |
| 108 // hal_longjmp loads state from r0[arg0] and returns | 152 // hal_longjmp loads state from r0[arg0] and returns |
| 109 | 153 |
| 154 #ifdef __thumb__ | |
| 155 .code 16 | |
| 156 .thumb_func | |
| 157 #endif | |
| 110 FUNC_START(hal_longjmp) | 158 FUNC_START(hal_longjmp) |
| 159 #ifdef __thumb__ | |
| 160 ldr r2,=hal_longjmp_ARM | |
| 161 bx r2 | |
| 162 .code 32 | |
| 163 FUNC_START(hal_longjmp_ARM) | |
| 164 #endif | |
| 111 ldmfd r0,{r4-r14} | 165 ldmfd r0,{r4-r14} |
| 112 mov r0,r1; # return [arg1] | 166 mov r0,r1; # return [arg1] |
| 167 #ifdef __thumb__ | |
| 168 bx lr | |
| 169 #else | |
| 113 mov pc,lr | 170 mov pc,lr |
| 171 #endif | |
| 114 | 172 |
| 115 // ------------------------------------------------------------------------------ | 173 // ------------------------------------------------------------------------------ |
| 116 // end of context.S | 174 // end of context.S |
| 117 | 175 |
| 118 | 176 |
