Changeset 0cb47cf in mainline


Ignore:
Timestamp:
2010-05-22T22:48:43Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
86a3f89b
Parents:
ba7371f9
Message:

replace shebang comments with C comments to avoid conflicts with the C preprocessor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/src/start.S

    rba7371f9 r0cb47cf  
    4545.global userspace_asm
    4646
    47 # Which status bits should are thread-local
    48 #define REG_SAVE_MASK 0x1f # KSU(UM), EXL, ERL, IE
    49 
    50 # Save registers to space defined by \r
    51 # We will change status: Disable ERL, EXL, UM, IE
    52 # These changes will be automatically reversed in REGISTER_LOAD
    53 # %sp is NOT saved as part of these registers
     47/*
     48 * Which status bits should are thread-local:
     49 * KSU(UM), EXL, ERL, IE
     50 */
     51#define REG_SAVE_MASK 0x1f
     52
     53/*
     54 * Save registers to space defined by \r
     55 * We will change status: Disable ERL, EXL, UM, IE
     56 * These changes will be automatically reversed in REGISTER_LOAD
     57 * %sp is NOT saved as part of these registers
     58 */
    5459.macro REGISTERS_STORE_AND_EXC_RESET r
    5560        sw $at, EOFFSET_AT(\r)
     
    8388        mfc0 $t1, $epc
    8489       
    85         # save only KSU, EXL, ERL, IE
     90        /* save only KSU, EXL, ERL, IE */
    8691        and $t2, $t0, REG_SAVE_MASK
    8792       
    88         # clear KSU, EXL, ERL, IE
     93        /* clear KSU, EXL, ERL, IE */
    8994        li $t3, ~(REG_SAVE_MASK)
    9095        and $t0, $t0, $t3
     
    96101
    97102.macro REGISTERS_LOAD r
    98         # Update only UM, EXR, IE from status, the rest
    99         # is controlled by OS and not bound to task
     103        /*
     104         * Update only UM, EXR, IE from status, the rest
     105         * is controlled by OS and not bound to task.
     106         */
    100107        mfc0 $t0, $status
    101108        lw $t1,EOFFSET_STATUS(\r)
    102109       
    103         # Mask UM, EXL, ERL, IE
     110        /* mask UM, EXL, ERL, IE */
    104111        li $t2, ~REG_SAVE_MASK
    105112        and $t0, $t0, $t2
    106113       
    107         # Copy UM, EXL, ERL, IE from saved status
     114        /* copy UM, EXL, ERL, IE from saved status */
    108115        or $t0, $t0, $t1
    109116        mtc0 $t0, $status
     
    142149.endm
    143150
    144 # Move kernel stack pointer address to register K0
    145 # - if we are in user mode, load the appropriate stack address
     151/*
     152 * Move kernel stack pointer address to register $k0.
     153 * If we are in user mode, load the appropriate stack address.
     154 */
    146155.macro KERNEL_STACK_TO_K0
    147         # if we are in user mode
     156        /* if we are in user mode */
    148157        mfc0 $k0, $status
    149158        andi $k0, 0x10
     
    152161        add $k0, $sp, 0
    153162       
    154         # move $k0 pointer to kernel stack
     163        /* move $k0 pointer to kernel stack */
    155164        lui $k0, %hi(supervisor_sp)
    156165        ori $k0, $k0, %lo(supervisor_sp)
    157166       
    158         # move $k0 (supervisor_sp)
     167        /* move $k0 (supervisor_sp) */
    159168        lw $k0, 0($k0)
    160169       
     
    164173.org 0x0
    165174kernel_image_start:
    166         # load temporary stack
     175        /* load temporary stack */
    167176        lui $sp, %hi(end_stack)
    168177        ori $sp, $sp, %lo(end_stack)
    169178       
    170         # Not sure about this, but might
    171         # be needed for PIC code
     179        /* not sure about this, but might be needed for PIC code */
    172180        lui $gp, 0x8000
    173181       
    174         # $a1 contains physical address of bootinfo_t
     182        /* $a1 contains physical address of bootinfo_t */
    175183        jal arch_pre_main
    176184        nop
     
    203211        mfc0 $k0, $cause
    204212       
    205         sra $k0, $k0, 0x2    # cp0_exc_cause() part 1
    206         andi $k0, $k0, 0x1f  # cp0_exc_cause() part 2
    207         sub $k0, 8           # 8 = SYSCALL
     213        sra $k0, $k0, 0x2    /* cp0_exc_cause() part 1 */
     214        andi $k0, $k0, 0x1f  /* cp0_exc_cause() part 2 */
     215        sub $k0, 8           /* 8 = SYSCALL */
    208216       
    209217        beqz $k0, syscall_shortcut
    210         add $k0, 8           # Revert $k0 back to correct exc number
     218        add $k0, 8           /* revert $k0 back to correct exc number */
    211219       
    212220        REGISTERS_STORE_AND_EXC_RESET $sp
    213221       
    214222        move $a1, $sp
    215         jal exc_dispatch     # exc_dispatch(excno, register_space)
     223        jal exc_dispatch     /* exc_dispatch(excno, register_space) */
    216224        move $a0, $k0
    217225       
    218226        REGISTERS_LOAD $sp
    219         # The $sp is automatically restored to former value
    220         eret
    221 
    222 ## Syscall entry
    223 #
    224 # Registers:
    225 #
    226 # @param v0             Syscall number.
    227 # @param a0             1st argument.
    228 # @param a1             2nd argument.
    229 # @param a2             3rd argument.
    230 # @param a3             4th argument.
    231 # @param t0             5th argument.
    232 # @param t1             6th argument.
    233 #
    234 # @return               The return value will be stored in v0.
    235 #
    236 #define SS_SP           EOFFSET_SP
    237 #define SS_STATUS       EOFFSET_STATUS
    238 #define SS_EPC          EOFFSET_EPC
    239 #define SS_K1           EOFFSET_K1
     227        /* the $sp is automatically restored to former value */
     228        eret
     229
     230#define SS_SP      EOFFSET_SP
     231#define SS_STATUS  EOFFSET_STATUS
     232#define SS_EPC     EOFFSET_EPC
     233#define SS_K1      EOFFSET_K1
     234
     235/** Syscall entry
     236 *
     237 * Registers:
     238 *
     239 * @param $v0 Syscall number.
     240 * @param $a0 1st argument.
     241 * @param $a1 2nd argument.
     242 * @param $a2 3rd argument.
     243 * @param $a3 4th argument.
     244 * @param $t0 5th argument.
     245 * @param $t1 6th argument.
     246 *
     247 * @return The return value will be stored in $v0.
     248 *
     249 */
    240250syscall_shortcut:
    241         # We have a lot of space on the stack, with free use
     251        /* we have a lot of space on the stack, with free use */
    242252        mfc0 $t3, $epc
    243253        mfc0 $t2, $status
    244         sw $t3, SS_EPC($sp)             # Save EPC
    245         sw $k1, SS_K1($sp)              # Save k1 not saved on context switch
    246        
    247         and $t4, $t2, REG_SAVE_MASK     # Save only KSU, EXL, ERL, IE
     254        sw $t3, SS_EPC($sp)  /* save EPC */
     255        sw $k1, SS_K1($sp)   /* save $k1 not saved on context switch */
     256       
     257        and $t4, $t2, REG_SAVE_MASK  /* save only KSU, EXL, ERL, IE */
    248258        li $t5, ~(0x1f)
    249         and $t2, $t2, $t5               # Clear KSU, EXL, ERL
    250         ori $t2, $t2, 0x1               # Set IE
    251 
     259        and $t2, $t2, $t5  /* clear KSU, EXL, ERL */
     260        ori $t2, $t2, 0x1  /* set IE */
     261       
    252262        sw $t4, SS_STATUS($sp)
    253263        mtc0 $t2, $status
    254 
    255         #
    256         # Call the higher level system call handler
    257         # We are going to reuse part of the unused exception stack frame
    258         #
    259         sw $t0, STACK_ARG4($sp)         # save the 5th argument on the stack
    260         sw $t1, STACK_ARG5($sp)         # save the 6th argument on the stack
     264       
     265        /*
     266         * Call the higher level system call handler.
     267         * We are going to reuse part of the unused exception stack frame.
     268         *
     269         */
     270        sw $t0, STACK_ARG4($sp)  /* save the 5th argument on the stack */
     271        sw $t1, STACK_ARG5($sp)  /* save the 6th argument on the stack */
    261272        jal syscall_handler
    262         sw $v0, STACK_ARG6($sp)         # save the syscall number on the stack
    263 
    264         # restore status
     273        sw $v0, STACK_ARG6($sp)  /* save the syscall number on the stack */
     274       
     275        /* restore status */
    265276        mfc0 $t2, $status
    266277        lw $t3, SS_STATUS($sp)
    267 
    268         # Change back to EXL = 1 (from last exception), otherwise
    269         # an interrupt could rewrite the CP0 - EPC
    270         li $t4, ~REG_SAVE_MASK          # Mask UM, EXL, ERL, IE
     278       
     279        /*
     280         * Change back to EXL = 1 (from last exception), otherwise
     281         * an interrupt could rewrite the CP0 - EPC.
     282         *
     283         */
     284        li $t4, ~REG_SAVE_MASK  /* mask UM, EXL, ERL, IE */
    271285        and $t2, $t2, $t4
    272         or $t2, $t2, $t3                # Copy saved UM, EXL, ERL, IE
     286        or $t2, $t2, $t3  /* copy saved UM, EXL, ERL, IE */
    273287        mtc0 $t2, $status
    274                        
    275         # restore epc + 4
     288       
     289        /* restore epc + 4 */
    276290        lw $t2, SS_EPC($sp)
    277291        lw $k1, SS_K1($sp)
     
    279293        mtc0 $t2, $epc
    280294       
    281         lw $sp, SS_SP($sp)              # restore sp
    282        
     295        lw $sp, SS_SP($sp)  /* restore $sp */
    283296        eret
    284297
     
    289302        sw $sp,EOFFSET_SP($k0)
    290303        add $sp, $k0, 0
    291 
     304       
    292305        jal tlb_refill
    293306        add $a0, $sp, 0
    294 
     307       
    295308        REGISTERS_LOAD $sp
    296 
    297309        eret
    298310
     
    303315        sw $sp,EOFFSET_SP($k0)
    304316        add $sp, $k0, 0
    305 
     317       
    306318        jal cache_error
    307         add $a0, $sp, 0 
    308 
     319        add $a0, $sp, 0
     320       
    309321        REGISTERS_LOAD $sp
    310 
    311322        eret
    312323
    313324userspace_asm:
    314325        add $sp, $a0, 0
    315         add $v0, $a1, 0 
    316         add $t9, $a2, 0                 # Set up correct entry into PIC code
    317         xor $a0, $a0, $a0               # $a0 is defined to hold pcb_ptr
    318                                         # set it to 0
    319         eret
     326        add $v0, $a1, 0
     327        add $t9, $a2, 0    /* set up correct entry into PIC code */
     328        xor $a0, $a0, $a0  /* $a0 is defined to hold pcb_ptr */
     329                           /* set it to 0 */
     330        eret
Note: See TracChangeset for help on using the changeset viewer.