Changeset e762b43 in mainline
- Timestamp:
- 2009-03-03T16:12:43Z (16 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
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/include/asm.h
rf24d300 re762b43 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file 33 33 * @brief Declarations of functions implemented in assembly. 34 34 */ … … 78 78 79 79 /** Return base address of current stack. 80 * 80 * 81 81 * Return the base address of the current stack. 82 82 * The stack is assumed to be STACK_SIZE bytes long. 83 83 * The stack must start on page boundary. 84 * 84 85 */ 85 86 static inline uintptr_t get_stack_base(void) … … 87 88 uintptr_t v; 88 89 asm volatile ( 89 "and % 0, sp, %1\n"90 : "=r" (v)91 : "r" (~(STACK_SIZE - 1))90 "and %[v], sp, %[size]\n" 91 : [v] "=r" (v) 92 : [size] "r" (~(STACK_SIZE - 1)) 92 93 ); 93 94 return v; -
kernel/arch/arm32/include/atomic.h
rf24d300 re762b43 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file 33 33 * @brief Atomic operations. 34 34 */ … … 43 43 * 44 44 * @return Value after addition. 45 * 45 46 */ 46 47 static inline long atomic_add(atomic_t *val, int i) … … 48 49 int ret; 49 50 volatile long *mem = &(val->count); 50 51 51 52 asm volatile ( 52 "1:\n" 53 "ldr r2, [%1] \n" 54 "add r3, r2, %2 \n" 55 "str r3, %0 \n" 56 "swp r3, r3, [%1] \n" 57 "cmp r3, r2 \n" 58 "bne 1b \n" 59 60 : "=m" (ret) 61 : "r" (mem), "r" (i) 53 "1:\n" 54 "ldr r2, [%[mem]]\n" 55 "add r3, r2, %[i]\n" 56 "str r3, %[ret]\n" 57 "swp r3, r3, [%[mem]]\n" 58 "cmp r3, r2\n" 59 "bne 1b\n" 60 : [ret] "=m" (ret) 61 : [mem] "r" (mem), [i] "r" (i) 62 62 : "r3", "r2" 63 63 ); 64 64 65 65 return ret; 66 66 } -
kernel/arch/arm32/include/barrier.h
rf24d300 re762b43 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ … … 40 40 * TODO: implement true ARM memory barriers for macros below. 41 41 */ 42 #define CS_ENTER_BARRIER() 43 #define CS_LEAVE_BARRIER() 42 #define CS_ENTER_BARRIER() asm volatile ("" ::: "memory") 43 #define CS_LEAVE_BARRIER() asm volatile ("" ::: "memory") 44 44 45 #define memory_barrier() 46 #define read_barrier() 47 #define write_barrier() 45 #define memory_barrier() asm volatile ("" ::: "memory") 46 #define read_barrier() asm volatile ("" ::: "memory") 47 #define write_barrier() asm volatile ("" ::: "memory") 48 48 49 49 #define smc_coherence(a) -
kernel/arch/arm32/include/mm/page.h
rf24d300 re762b43 194 194 { 195 195 asm volatile ( 196 "mcr p15, 0, %0, c2, c0, 0 \n" 197 : 198 : "r"(pt) 196 "mcr p15, 0, %[pt], c2, c0, 0\n" 197 :: [pt] "r" (pt) 199 198 ); 200 199 } -
kernel/arch/arm32/include/regutils.h
rf24d300 re762b43 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ … … 58 58 { \ 59 59 uint32_t retval; \ 60 asm volatile("mrs %0, " #reg : "=r" (retval)); \ 60 asm volatile( \ 61 "mrs %[retval], " #reg \ 62 : [retval] "=r" (retval) \ 63 ); \ 61 64 return retval; \ 62 65 } … … 65 68 static inline void nm## _status_reg_ ##fieldname## _write(uint32_t value) \ 66 69 { \ 67 asm volatile("msr " #reg "_" #field ", %0" : : "r" (value)); \ 70 asm volatile( \ 71 "msr " #reg "_" #field ", %[value]" \ 72 :: [value] "r" (value) \ 73 ); \ 68 74 } 69 75 -
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.