Changeset d8cfebb in rtems


Ignore:
Timestamp:
Jun 21, 2007, 6:33:22 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
218b070b
Parents:
ff089035
Message:

2007-06-21 Joel Sherrill <joel.sherrill@…>

  • cpu.c: Merge patch from Till Straumann which would work except gcc core dumps with an ICE when may_alias is used in this code. I filed a GCC PR and reduced optimization to -O0 and it does run again.
Location:
cpukit/score/cpu/unix
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/cpu/unix/ChangeLog

    rff089035 rd8cfebb  
     12007-06-21      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * cpu.c: Merge patch from Till Straumann which would work except gcc
     4        core dumps with an ICE when may_alias is used in this code. I filed a
     5        GCC PR and reduced optimization to -O0 and it does run again.
     6
    172007-05-09      Ralf Corsépius <ralf.corsepius@rtems.org>
    28
  • cpukit/score/cpu/unix/cpu.c

    rff089035 rd8cfebb  
    454454}
    455455
     456
     457typedef struct AuxFrame_ {
     458        /* stack builds down from here */
     459        uint32_t        ebx, esi, edi;
     460        void       (*eip)();
     461        jmp_buf    *pjb;
     462        uint32_t   old_esp;
     463} AuxFrame __attribute__((may_alias));
     464
     465/* MUST make sure this is called in a new frame so it
     466 * uses the new stack
     467 */
     468static void trampo(void (*pc)(), jmp_buf *pjb)
     469__attribute__((noinline));
     470
     471static void trampo(void (*pc)(), jmp_buf *pjb)
     472{
     473        if ( setjmp( *pjb ) )
     474                pc();
     475}
     476
     477/* Same as above; this should probably be entirely coded in assembly
     478 * to avoid problems
     479 */
     480static void cpy_jmpbuf(AuxFrame *new_sp) __attribute__((noinline));
     481
     482/*
     483 * NOTE: this routine relies on the layout of 'AuxFrame' above
     484 *
     485 * INPUT: pointer to a AuxFrame on new stack;
     486 *
     487 * What it does:
     488 *      1) save current SP in new stack frame
     489 *      2) switch stack to new_sp
     490 *      3) load registers with desired values (except for PC)
     491 *      4) call setjmp() to store context
     492 *      4a) setjmp returns 0: restore SP and leave
     493 *      4b) setjmp returns 1 (got here from longjmp):
     494 *          call code at PC
     495 */
     496static void cpy_jmpbuf(AuxFrame *new_sp)
     497{
     498asm volatile(
     499        /* Save current ESP in AuxFrame       */
     500        "       movl %%esp,0x14(%0)   \n"
     501        /* Switch ESP to new stack (AuxFrame) */
     502        "       movl %0, %%esp        \n"
     503        /* Pop off / load EBX                 */
     504        "       popl %%ebx            \n"
     505        /* Pop off / load ESI                 */
     506        "       popl %%esi            \n"
     507        /* Pop off / load EDI                 */
     508        "       popl %%edi            \n"
     509        /* Pop off EBP; this should never be
     510         * used - 'trampo' is a C routine and
     511         * saves-restores the 'deadcafe' value.
     512         */
     513        "   movl $0xdeadcafe,%%ebp\n"
     514        /* Call trampoline                    */
     515        "       call trampo           \n"
     516        /* If we return (setjmp returned 0)
     517         * then we restore the old SP
     518         */
     519        "       movl 8(%%esp),%%esp   \n"
     520        ::"r"(new_sp):"ebx","esi","edi");
     521
     522        /* When leaving this routine, the original EBP is restored */
     523}
     524
    456525/*PAGE
    457526 *
     
    540609     */
    541610
    542     {
    543       uint32_t   stack_ptr;
    544 
    545       stack_ptr = _stack_high - CPU_FRAME_SIZE;
    546 
    547       *(addr + EBX_OFF) = 0xFEEDFEED;
    548       *(addr + ESI_OFF) = 0xDEADDEAD;
    549       *(addr + EDI_OFF) = 0xDEAFDEAF;
    550       *(addr + EBP_OFF) = stack_ptr;
    551       *(addr + ESP_OFF) = stack_ptr;
    552       *(addr + RET_OFF) = jmp_addr;
    553 
    554       addr = (uint32_t   *) stack_ptr;
    555 
    556       addr[ 0 ] = jmp_addr;
    557       addr[ 1 ] = (uint32_t  ) stack_ptr;
    558       addr[ 2 ] = (uint32_t  ) stack_ptr;
    559     }
     611        {
     612      AuxFrame *stack_ptr;
     613
     614      stack_ptr = (AuxFrame*)( _stack_high - sizeof(AuxFrame));
     615          stack_ptr->ebx = 0xFEEDFEED;
     616      stack_ptr->esi = 0xDEADDEAD;
     617      stack_ptr->edi = 0xDEAFDEAF;
     618          stack_ptr->eip = (void (*)())jmp_addr;
     619          stack_ptr->pjb = &((Context_Control_overlay *)_the_context)->regs;
     620
     621          cpy_jmpbuf(stack_ptr);
     622
     623        }
    560624
    561625#else
Note: See TracChangeset for help on using the changeset viewer.