Changeset e762b43 in mainline for kernel/arch/arm32/src
- Timestamp:
- 2009-03-03T16:12:43Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 02fd705
- Parents:
- f24d300
- Location:
- kernel/arch/arm32/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/cpu/cpu.c
rf24d300 re762b43 37 37 #include <cpu.h> 38 38 #include <arch.h> 39 #include <print.h> 39 #include <print.h> 40 40 41 41 /** Number of indexes left out in the #imp_data array */ … … 83 83 uint32_t ident; 84 84 asm volatile ( 85 "mrc p15, 0, % 0, c0, c0, 0\n"86 : "=r" (ident)85 "mrc p15, 0, %[ident], c0, c0, 0\n" 86 : [ident] "=r" (ident) 87 87 ); 88 88 89 89 cpu->imp_num = ident >> 24; 90 90 cpu->variant_num = (ident << 8) >> 28; -
kernel/arch/arm32/src/exception.c
rf24d300 re762b43 64 64 * Temporary exception stack is used to save a few registers 65 65 * before stack switch takes place. 66 * 66 67 */ 67 68 inline static void setup_stack_and_save_regs() 68 69 { 69 asm volatile (70 "ldr r13, =exc_stack 71 "stmfd r13!, {r0} 72 "mrs r0, spsr 73 "and r0, r0, #0x1f 74 "cmp r0, #0x10 75 "bne 1f 76 70 asm volatile ( 71 "ldr r13, =exc_stack\n" 72 "stmfd r13!, {r0}\n" 73 "mrs r0, spsr\n" 74 "and r0, r0, #0x1f\n" 75 "cmp r0, #0x10\n" 76 "bne 1f\n" 77 77 78 /* prev mode was usermode */ 78 "ldmfd r13!, {r0} 79 "ldr r13, =supervisor_sp 80 "ldr r13, [r13] 81 "stmfd r13!, {lr} 82 "stmfd r13!, {r0-r12} 83 "stmfd r13!, {r13, lr}^ 84 "mrs r0, spsr 85 "stmfd r13!, {r0} 86 "b 2f 87 79 "ldmfd r13!, {r0}\n" 80 "ldr r13, =supervisor_sp\n" 81 "ldr r13, [r13]\n" 82 "stmfd r13!, {lr}\n" 83 "stmfd r13!, {r0-r12}\n" 84 "stmfd r13!, {r13, lr}^\n" 85 "mrs r0, spsr\n" 86 "stmfd r13!, {r0}\n" 87 "b 2f\n" 88 88 89 /* mode was not usermode */ 89 "1:\n" 90 "stmfd r13!, {r1, r2, r3} \n" 91 "mrs r1, cpsr \n" 92 "mov r2, lr \n" 93 "bic r1, r1, #0x1f \n" 94 "orr r1, r1, r0 \n" 95 "mrs r0, cpsr \n" 96 "msr cpsr_c, r1 \n" 97 98 "mov r3, r13 \n" 99 "stmfd r13!, {r2} \n" 100 "mov r2, lr \n" 101 "stmfd r13!, {r4-r12} \n" 102 "mov r1, r13 \n" 103 /* the following two lines are for debugging */ 104 "mov sp, #0 \n" 105 "mov lr, #0 \n" 106 "msr cpsr_c, r0 \n" 107 108 "ldmfd r13!, {r4, r5, r6, r7} \n" 109 "stmfd r1!, {r4, r5, r6} \n" 110 "stmfd r1!, {r7} \n" 111 "stmfd r1!, {r2} \n" 112 "stmfd r1!, {r3} \n" 113 "mrs r0, spsr \n" 114 "stmfd r1!, {r0} \n" 115 "mov r13, r1 \n" 116 "2:\n" 90 "1:\n" 91 "stmfd r13!, {r1, r2, r3}\n" 92 "mrs r1, cpsr\n" 93 "mov r2, lr\n" 94 "bic r1, r1, #0x1f\n" 95 "orr r1, r1, r0\n" 96 "mrs r0, cpsr\n" 97 "msr cpsr_c, r1\n" 98 99 "mov r3, r13\n" 100 "stmfd r13!, {r2}\n" 101 "mov r2, lr\n" 102 "stmfd r13!, {r4-r12}\n" 103 "mov r1, r13\n" 104 105 /* the following two lines are for debugging */ 106 "mov sp, #0\n" 107 "mov lr, #0\n" 108 "msr cpsr_c, r0\n" 109 110 "ldmfd r13!, {r4, r5, r6, r7}\n" 111 "stmfd r1!, {r4, r5, r6}\n" 112 "stmfd r1!, {r7}\n" 113 "stmfd r1!, {r2}\n" 114 "stmfd r1!, {r3}\n" 115 "mrs r0, spsr\n" 116 "stmfd r1!, {r0}\n" 117 "mov r13, r1\n" 118 119 "2:\n" 117 120 ); 118 121 } … … 190 193 191 194 /** Calls exception dispatch routine. */ 192 #define CALL_EXC_DISPATCH(exception) \ 193 asm("mov r0, %0" : : "i" (exception)); \ 194 asm("mov r1, r13"); \ 195 asm("bl exc_dispatch"); 195 #define CALL_EXC_DISPATCH(exception) \ 196 asm volatile ( \ 197 "mov r0, %[exc]\n" \ 198 "mov r1, r13\n" \ 199 "bl exc_dispatch\n" \ 200 :: [exc] "i" (exception) \ 201 );\ 196 202 197 203 /** General exception handler. … … 202 208 * @param exception Exception number. 203 209 */ 204 #define PROCESS_EXCEPTION(exception) 205 setup_stack_and_save_regs(); 206 CALL_EXC_DISPATCH(exception) 210 #define PROCESS_EXCEPTION(exception) \ 211 setup_stack_and_save_regs(); \ 212 CALL_EXC_DISPATCH(exception) \ 207 213 load_regs(); 208 214 … … 334 340 uint32_t control_reg; 335 341 336 asm volatile("mrc p15, 0, %0, c1, c1" : "=r" (control_reg)); 342 asm volatile ( 343 "mrc p15, 0, %[control_reg], c1, c1" 344 : [control_reg] "=r" (control_reg) 345 ); 337 346 338 347 /* switch on the high vectors bit */ 339 348 control_reg |= CP15_R1_HIGH_VECTORS_BIT; 340 349 341 asm volatile("mcr p15, 0, %0, c1, c1" : : "r" (control_reg)); 350 asm volatile ( 351 "mcr p15, 0, %[control_reg], c1, c1" 352 :: [control_reg] "r" (control_reg) 353 ); 342 354 } 343 355 #endif 344 356 345 357 /** Initializes exception handling. 346 * 358 * 347 359 * Installs low-level exception handlers and then registers 348 360 * exceptions and their handlers to kernel exception dispatcher. -
kernel/arch/arm32/src/mm/page_fault.c
rf24d300 re762b43 50 50 { 51 51 fault_status_union_t fsu; 52 52 53 53 /* fault status is stored in CP15 register 5 */ 54 54 asm volatile ( 55 "mrc p15, 0, % 0, c5, c0, 0"56 : "=r"(fsu.dummy)55 "mrc p15, 0, %[dummy], c5, c0, 0" 56 : [dummy] "=r" (fsu.dummy) 57 57 ); 58 58 59 return fsu.fs; 59 60 } … … 62 63 * 63 64 * @return FAR (fault address register) content (address that caused a page 64 * 65 * fault) 65 66 */ 66 67 static inline uintptr_t read_fault_address_register(void) 67 68 { 68 69 uintptr_t ret; 69 70 70 71 /* fault adress is stored in CP15 register 6 */ 71 72 asm volatile ( 72 "mrc p15, 0, % 0, c6, c0, 0"73 : "=r"(ret)73 "mrc p15, 0, %[ret], c6, c0, 0" 74 : [ret] "=r" (ret) 74 75 ); 76 75 77 return ret; 76 78 } … … 81 83 * 82 84 * @return true when instruction is load/store, false otherwise 85 * 83 86 */ 84 87 static inline bool is_load_store_instruction(instruction_t instr) 85 88 { 86 89 /* load store immediate offset */ 87 if (instr.type == 0x2) { 88 return true; 89 } 90 90 if (instr.type == 0x2) 91 return true; 92 91 93 /* load store register offset */ 92 if (instr.type == 0x3 && instr.bit4 == 0) { 93 return true; 94 } 95 94 if ((instr.type == 0x3) && (instr.bit4 == 0)) 95 return true; 96 96 97 /* load store multiple */ 97 if (instr.type == 0x4) { 98 return true; 99 } 100 98 if (instr.type == 0x4) 99 return true; 100 101 101 /* oprocessor load/store */ 102 if (instr.type == 0x6) { 103 return true; 104 } 105 102 if (instr.type == 0x6) 103 return true; 104 106 105 return false; 107 106 } … … 116 115 { 117 116 /* swap, swapb instruction */ 118 if (instr.type == 0x0 && 119 (instr.opcode == 0x8 || instr.opcode == 0xa) && 120 instr.access == 0x0 && instr.bits567 == 0x4 && instr.bit4 == 1) { 121 return true; 122 } 123 117 if ((instr.type == 0x0) && 118 ((instr.opcode == 0x8) || (instr.opcode == 0xa)) && 119 (instr.access == 0x0) && (instr.bits567 == 0x4) && (instr.bit4 == 1)) 120 return true; 121 124 122 return false; 125 123 } -
kernel/arch/arm32/src/mm/tlb.c
rf24d300 re762b43 49 49 "eor r1, r1\n" 50 50 "mcr p15, 0, r1, c8, c7, 0\n" 51 : :: "r1"51 ::: "r1" 52 52 ); 53 53 } … … 69 69 { 70 70 asm volatile ( 71 "mcr p15, 0, %0, c8, c7, 1" 72 : 73 : "r" (page) 71 "mcr p15, 0, %[page], c8, c7, 1\n" 72 :: [page] "r" (page) 74 73 ); 75 74 } -
kernel/arch/arm32/src/userspace.c
rf24d300 re762b43 91 91 /* set user mode, set registers, jump */ 92 92 asm volatile ( 93 "mov sp, % 0\n"94 "msr spsr_c, % 1\n"95 "ldmfd sp!, {r0-r12, sp, lr}^ 93 "mov sp, %[ustate]\n" 94 "msr spsr_c, %[user_mode]\n" 95 "ldmfd sp!, {r0-r12, sp, lr}^\n" 96 96 "ldmfd sp!, {pc}^\n" 97 : 98 : "r" (&ustate), "r" (user_mode) 97 :: [ustate] "r" (&ustate), [user_mode] "r" (user_mode) 99 98 ); 100 99
Note:
See TracChangeset
for help on using the changeset viewer.