Changeset 10df690 in rtems


Ignore:
Timestamp:
Jan 31, 2011, 4:12:24 PM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
0e867af1
Parents:
58dac48
Message:

2011-01-31 Sebastian Huber <sebastian.huber@…>

  • new-exceptions/bspsupport/ppc_exc.S, new-exceptions/bspsupport/ppc_exc_asm_macros.h, new-exceptions/bspsupport/ppc_exc_naked.S, new-exceptions/bspsupport/ppc_exc_prologue.c: Branch targets are now global for all minimal prologues. Generate branch instruction in minimal prologues.
Location:
c/src/lib/libcpu/powerpc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/ChangeLog

    r58dac48 r10df690  
     12011-01-31      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * new-exceptions/bspsupport/ppc_exc.S,
     4        new-exceptions/bspsupport/ppc_exc_asm_macros.h,
     5        new-exceptions/bspsupport/ppc_exc_naked.S,
     6        new-exceptions/bspsupport/ppc_exc_prologue.c: Branch targets are now
     7        global for all minimal prologues.  Generate branch instruction in
     8        minimal prologues.
     9
    1102011-01-31      Sebastian Huber <sebastian.huber@embedded-brains.de>
    211
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc.S

    r58dac48 r10df690  
    6767        stw     VECTOR_REGISTER, VECTOR_OFFSET(r1)
    6868        mflr    VECTOR_REGISTER
    69         bla     wrap_auto
     69
     70        /*
     71         * We store the absolute branch target address here.  It will be used
     72         * to generate the branch operation in ppc_exc_make_prologue().
     73         *
     74         * We add one to request the link in the generated branch instruction.
     75         */
     76        .int    ppc_exc_wrap_auto + 1
    7077
    7178        .global ppc_exc_tgpr_clr_prolog_size
     
    8895        stw     VECTOR_REGISTER, ppc_exc_vector_register_std@sdarel(r13)
    8996        mflr    VECTOR_REGISTER
    90         bla     wrap_auto_async
     97
     98        /*
     99         * We store the absolute branch target address here.  It will be used
     100         * to generate the branch operation in ppc_exc_make_prologue().
     101         *
     102         * We add one to request the link in the generated branch instruction.
     103         */
     104        .int    ppc_exc_wrap_auto_async + 1
    91105
    92106/******************************************************/
     
    120134
    121135        /* LR holds vector, VECTOR_REGISTER holds orig. LR */
    122 wrap_auto:
     136        .global ppc_exc_wrap_auto
     137ppc_exc_wrap_auto:
    123138        stw     FRAME_REGISTER, FRAME_OFFSET(r1)
    124139
     
    139154        b       wrap_no_save_frame_register_std
    140155
    141 wrap_auto_async:
     156        .global ppc_exc_wrap_auto_async
     157ppc_exc_wrap_auto_async:
    142158        stwu    r1, -EXCEPTION_FRAME_END(r1)
    143159        stw     FRAME_REGISTER, FRAME_OFFSET(r1)
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_asm_macros.h

    r58dac48 r10df690  
    107107         */
    108108        li      VECTOR_REGISTER, ( \_VEC | 0xffff8000 )
    109         /*      Branch (must be within 32MB)
    110          */
    111         ba      wrap_\_FLVR
     109
     110        /*
     111         * We store the absolute branch target address here.  It will be used
     112         * to generate the branch operation in ppc_exc_make_prologue().
     113         */
     114        .int    ppc_exc_wrap_\_FLVR
    112115
    113116        .endm
     
    130133        stw     VECTOR_REGISTER, VECTOR_OFFSET(r1)
    131134        li      VECTOR_REGISTER, \_VEC
    132         ba      wrap_nopush_\_FLVR
     135
     136        /*
     137         * We store the absolute branch target address here.  It will be used
     138         * to generate the branch operation in ppc_exc_make_prologue().
     139         */
     140        .int    ppc_exc_wrap_nopush_\_FLVR
    133141
    134142        .endm
     
    375383        .macro  WRAP _FLVR _PRI _SRR0 _SRR1 _RFI
    376384
    377 wrap_\_FLVR:
     385        .global ppc_exc_wrap_\_FLVR
     386ppc_exc_wrap_\_FLVR:
    378387
    379388        /* Push exception frame */
    380389        stwu    r1, -EXCEPTION_FRAME_END(r1)
    381390
    382 wrap_nopush_\_FLVR:
     391        .global ppc_exc_wrap_nopush_\_FLVR
     392ppc_exc_wrap_nopush_\_FLVR:
    383393
    384394        /* Save frame register */
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_naked.S

    r58dac48 r10df690  
    2929        stw     VECTOR_REGISTER, VECTOR_OFFSET(r1)
    3030        li      VECTOR_REGISTER, 0
    31         ba      wrap_naked
    3231
    33 wrap_naked:
     32        /*
     33         * We store the absolute branch target address here.  It will be used
     34         * to generate the branch operation in ppc_exc_make_prologue().
     35         */
     36        .int    ppc_exc_wrap_naked
     37
     38        .global ppc_exc_wrap_naked
     39ppc_exc_wrap_naked:
    3440
    3541        /* Save scratch registers */
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_prologue.c

    r58dac48 r10df690  
    6363};
    6464
     65static bool ppc_exc_create_branch_op(
     66  unsigned vector,
     67  uint32_t *prologue,
     68  size_t prologue_size
     69)
     70{
     71  static const uintptr_t BRANCH_OP_CODE = 18 << 26;
     72  static const uintptr_t BRANCH_OP_LINK = 0x1;
     73  static const uintptr_t BRANCH_OP_ABS = 0x2;
     74  static const uintptr_t BRANCH_OP_MSK = 0x3ffffff;
     75  size_t branch_op_index = prologue_size / 4 - 1;
     76  uintptr_t vector_address = (uintptr_t) ppc_exc_vector_address(vector);
     77  uintptr_t branch_op_address = vector_address + 4 * branch_op_index;
     78
     79  /* This value may have BRANCH_OP_LINK set */
     80  uintptr_t target_address = prologue [branch_op_index];
     81
     82  uintptr_t branch_target_address = target_address - branch_op_address;
     83
     84  /*
     85   * We prefer to use a relative branch.  This has the benefit that custom
     86   * minimal prologues in a read-only area are relocatable.
     87   */
     88  if ((branch_target_address & ~BRANCH_OP_MSK) != 0) {
     89    /* Target to far for relative branch (PC ± 32M) */
     90    if (target_address >= 0xfe000001 || target_address < 0x01fffffd) {
     91      /* Can use an absolute branch */
     92      branch_target_address = (target_address | BRANCH_OP_ABS) & BRANCH_OP_MSK;
     93    } else {
     94      return false;
     95    }
     96  }
     97
     98  prologue [branch_op_index] = BRANCH_OP_CODE | branch_target_address;
     99
     100  return true;
     101}
     102
    65103rtems_status_code ppc_exc_make_prologue(
    66104  unsigned vector,
     
    72110  const uint32_t *prologue_template = NULL;
    73111  size_t prologue_template_size = 0;
    74   uintptr_t vector_address = (uintptr_t) ppc_exc_vector_address(vector);
    75112  bool fixup_vector = false;
    76113
     
    105142    memcpy(prologue, prologue_template, prologue_template_size);
    106143
     144    if (!ppc_exc_create_branch_op(vector, prologue, prologue_template_size)) {
     145      return RTEMS_INVALID_ADDRESS;
     146    }
     147
    107148    if (fixup_vector) {
    108149      if (vector <= 0x7fffU) {
Note: See TracChangeset for help on using the changeset viewer.