Changeset 6d123b3 in mainline for kernel


Ignore:
Timestamp:
2012-03-13T15:23:11Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
145d16f8
Parents:
df366b5e
Message:

respect the o32 ABI when calling C functions from assembler and creating contexts
(thx Adam Hraska)

Location:
kernel/arch
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/include/context.h

    rdf366b5e r6d123b3  
    4242 * Put one item onto the stack to support get_stack_base() and align it up.
    4343 */
    44 #define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
     44#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4545
    4646#ifndef __ASM__
  • kernel/arch/mips32/include/stack.h

    rdf366b5e r6d123b3  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
     
    3636#define KERN_mips32_STACK_H_
    3737
    38 #define STACK_ITEM_SIZE         4
    39 #define STACK_ALIGNMENT         8
     38#define STACK_ITEM_SIZE  4
     39#define STACK_ALIGNMENT  8
     40#define ABI_STACK_FRAME  32
    4041
    4142#endif
  • kernel/arch/mips32/src/start.S

    rdf366b5e r6d123b3  
    241241        /* $a1 contains physical address of bootinfo_t */
    242242        jal arch_pre_main
    243         nop
     243        addiu $sp, -ABI_STACK_FRAME
    244244       
    245245        j main_bsp
     
    281281       
    282282        move $a1, $sp
     283        move $a0, $k0
    283284        jal exc_dispatch     /* exc_dispatch(excno, register_space) */
    284         move $a0, $k0
     285        addiu $sp, -ABI_STACK_FRAME
     286        addiu $sp, ABI_STACK_FRAME
    285287       
    286288        REGISTERS_LOAD $sp
     
    323325        sw $t0, ISTATE_OFFSET_T0($sp)  /* save the 5th argument on the stack */
    324326        sw $t1, ISTATE_OFFSET_T1($sp)  /* save the 6th argument on the stack */
     327       
    325328        jal syscall_handler
    326329        sw $v0, ISTATE_OFFSET_V0($sp)  /* save the syscall number on the stack */
     
    357360        move $sp, $k0
    358361       
     362        move $a0, $sp
    359363        jal tlb_refill
    360         move $a0, $sp
     364        addiu $sp, -ABI_STACK_FRAME
     365        addiu $sp, ABI_STACK_FRAME
    361366       
    362367        REGISTERS_LOAD $sp
     
    366371cache_error_handler:
    367372        KERNEL_STACK_TO_K0
    368         sub $k0, ISTATE_SOFT_SIZE 
     373        sub $k0, ISTATE_SOFT_SIZE
    369374        REGISTERS_STORE_AND_EXC_RESET $k0
    370375        sw $sp, ISTATE_OFFSET_SP($k0)
    371376        move $sp, $k0
    372377       
     378        move $a0, $sp
    373379        jal cache_error
    374         move $a0, $sp
     380        addiu $sp, -ABI_STACK_FRAME
     381        addiu $sp, ABI_STACK_FRAME
    375382       
    376383        REGISTERS_LOAD $sp
  • kernel/arch/mips64/include/context.h

    rdf366b5e r6d123b3  
    4242 * Put one item onto the stack to support get_stack_base() and align it up.
    4343 */
    44 #define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
     44#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4545
    4646#ifndef __ASM__
  • kernel/arch/mips64/include/stack.h

    rdf366b5e r6d123b3  
    3838#define STACK_ITEM_SIZE  8
    3939#define STACK_ALIGNMENT  8
     40#define ABI_STACK_FRAME  64
    4041
    4142#endif
  • kernel/arch/mips64/src/start.S

    rdf366b5e r6d123b3  
    241241        /* $a1 contains physical address of bootinfo_t */
    242242        jal arch_pre_main
    243         nop
     243        addiu $sp, -ABI_STACK_FRAME
    244244       
    245245        j main_bsp
     
    281281       
    282282        move $a1, $sp
     283        move $a0, $k0
    283284        jal exc_dispatch     /* exc_dispatch(excno, register_space) */
    284         move $a0, $k0
     285        addiu $sp, -ABI_STACK_FRAME
     286        addiu $sp, ABI_STACK_FRAME
    285287       
    286288        REGISTERS_LOAD $sp
     
    323325        sw $t0, ISTATE_OFFSET_T0($sp)  /* save the 5th argument on the stack */
    324326        sw $t1, ISTATE_OFFSET_T1($sp)  /* save the 6th argument on the stack */
     327       
    325328        jal syscall_handler
    326329        sw $v0, ISTATE_OFFSET_V0($sp)  /* save the syscall number on the stack */
     
    357360        move $sp, $k0
    358361       
     362        move $a0, $sp
    359363        jal tlb_refill
    360         move $a0, $sp
     364        addiu $sp, -ABI_STACK_FRAME
     365        addiu $sp, ABI_STACK_FRAME
    361366       
    362367        REGISTERS_LOAD $sp
     
    366371cache_error_handler:
    367372        KERNEL_STACK_TO_K0
    368         sub $k0, ISTATE_SOFT_SIZE 
     373        sub $k0, ISTATE_SOFT_SIZE
    369374        REGISTERS_STORE_AND_EXC_RESET $k0
    370375        sw $sp, ISTATE_OFFSET_SP($k0)
    371376        move $sp, $k0
    372377       
     378        move $a0, $sp
    373379        jal cache_error
    374         move $a0, $sp
     380        addiu $sp, -ABI_STACK_FRAME
     381        addiu $sp, ABI_STACK_FRAME
    375382       
    376383        REGISTERS_LOAD $sp
Note: See TracChangeset for help on using the changeset viewer.