Changeset e762b43 in mainline for kernel/arch/arm32/src


Ignore:
Timestamp:
2009-03-03T16:12:43Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
02fd705
Parents:
f24d300
Message:

better inline assembler readability using the new symbolic syntax

Location:
kernel/arch/arm32/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/cpu/cpu.c

    rf24d300 re762b43  
    3737#include <cpu.h>
    3838#include <arch.h>
    39 #include <print.h>     
     39#include <print.h>
    4040
    4141/** Number of indexes left out in the #imp_data array */
     
    8383        uint32_t ident;
    8484        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)
    8787        );
    88 
     88       
    8989        cpu->imp_num = ident >> 24;
    9090        cpu->variant_num = (ident << 8) >> 28;
  • kernel/arch/arm32/src/exception.c

    rf24d300 re762b43  
    6464 * Temporary exception stack is used to save a few registers
    6565 * before stack switch takes place.
     66 *
    6667 */
    6768inline static void setup_stack_and_save_regs()
    6869{
    69         asm volatile(
    70                 "ldr r13, =exc_stack            \n"
    71                 "stmfd r13!, {r0}               \n"
    72                 "mrs r0, spsr                   \n"
    73                 "and r0, r0, #0x1f              \n"
    74                 "cmp r0, #0x10                  \n"
    75                 "bne 1f                         \n"
    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               
    7778                /* prev mode was usermode */
    78                 "ldmfd r13!, {r0}               \n"
    79                 "ldr r13, =supervisor_sp        \n"
    80                 "ldr r13, [r13]                 \n"
    81                 "stmfd r13!, {lr}               \n"
    82                 "stmfd r13!, {r0-r12}           \n"
    83                 "stmfd r13!, {r13, lr}^         \n"
    84                 "mrs r0, spsr                   \n"
    85                 "stmfd r13!, {r0}               \n"
    86                 "b 2f                           \n"
    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               
    8889                /* 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"
    117120        );
    118121}
     
    190193
    191194/** 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        );\
    196202
    197203/** General exception handler.
     
    202208 *  @param exception Exception number.
    203209 */
    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) \
    207213        load_regs();
    208214
     
    334340        uint32_t control_reg;
    335341       
    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        );
    337346       
    338347        /* switch on the high vectors bit */
    339348        control_reg |= CP15_R1_HIGH_VECTORS_BIT;
    340349       
    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        );
    342354}
    343355#endif
    344356
    345357/** Initializes exception handling.
    346  * 
     358 *
    347359 * Installs low-level exception handlers and then registers
    348360 * exceptions and their handlers to kernel exception dispatcher.
  • kernel/arch/arm32/src/mm/page_fault.c

    rf24d300 re762b43  
    5050{
    5151        fault_status_union_t fsu;
    52 
     52       
    5353        /* fault status is stored in CP15 register 5 */
    5454        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)
    5757        );
     58       
    5859        return fsu.fs;
    5960}
     
    6263 *
    6364 * @return FAR (fault address register) content (address that caused a page
    64  *         fault)
     65 *         fault)
    6566 */
    6667static inline uintptr_t read_fault_address_register(void)
    6768{
    6869        uintptr_t ret;
    69 
     70       
    7071        /* fault adress is stored in CP15 register 6 */
    7172        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)
    7475        );
     76       
    7577        return ret;
    7678}
     
    8183 *
    8284 * @return true when instruction is load/store, false otherwise
     85 *
    8386 */
    8487static inline bool is_load_store_instruction(instruction_t instr)
    8588{
    8689        /* load store immediate offset */
    87         if (instr.type == 0x2) {
    88                 return true;
    89         }
    90 
     90        if (instr.type == 0x2)
     91                return true;
     92       
    9193        /* 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       
    9697        /* load store multiple */
    97         if (instr.type == 0x4) {
    98                 return true;
    99         }
    100 
     98        if (instr.type == 0x4)
     99                return true;
     100       
    101101        /* oprocessor load/store */
    102         if (instr.type == 0x6) {
    103                 return true;
    104         }
    105 
     102        if (instr.type == 0x6)
     103                return true;
     104       
    106105        return false;
    107106}
     
    116115{
    117116        /* 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       
    124122        return false;
    125123}
  • kernel/arch/arm32/src/mm/tlb.c

    rf24d300 re762b43  
    4949                "eor r1, r1\n"
    5050                "mcr p15, 0, r1, c8, c7, 0\n"
    51                 : : : "r1"
     51                ::: "r1"
    5252        );
    5353}
     
    6969{
    7070        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)
    7473        );
    7574}
  • kernel/arch/arm32/src/userspace.c

    rf24d300 re762b43  
    9191        /* set user mode, set registers, jump */
    9292        asm volatile (
    93                 "mov sp, %0                     \n"
    94                 "msr spsr_c, %1                 \n"
    95                 "ldmfd sp!, {r0-r12, sp, lr}^   \n"
     93                "mov sp, %[ustate]\n"
     94                "msr spsr_c, %[user_mode]\n"
     95                "ldmfd sp!, {r0-r12, sp, lr}^\n"
    9696                "ldmfd sp!, {pc}^\n"
    97                 :
    98                 : "r" (&ustate), "r" (user_mode)
     97                :: [ustate] "r" (&ustate), [user_mode] "r" (user_mode)
    9998        );
    10099
Note: See TracChangeset for help on using the changeset viewer.