Changeset 4bd4c9e in rtems


Ignore:
Timestamp:
Nov 23, 2012, 8:32:52 AM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
f665f13
Parents:
4263155
git-author:
Sebastian Huber <sebastian.huber@…> (11/23/12 08:32:52)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/03/12 12:17:08)
Message:

bsps/powerpc: Add PPC_EXC_CONFIG_USE_FIXED_HANDLER

In case a BSP enables this option, then fixed high level exception
handler will be used. For normal asynchronous exceptions this is
bsp_interrupt_dispatch() and for other exceptions this is the handler
from the read-only ppc_exc_handler_table. The global handler is
C_exception_handler(). This avoids some dependencies on valid
read-write data.

Location:
c/src/lib
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_asm_macros.h

    r4263155 r4bd4c9e  
    44 * Modified and partially rewritten by Till Straumann, 2007-2008
    55 *
    6  * Modified by Sebastian Huber <sebastian.huber@embedded-brains.de>, 2008.
     6 * Modified by Sebastian Huber <sebastian.huber@embedded-brains.de>, 2008-2012.
    77 *
    88 * Low-level assembly code for PPC exceptions (macros).
     
    826826        addi    r3, FRAME_REGISTER, FRAME_LINK_SPACE
    827827
     828#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
     829
    828830        /* Load global handler address */
    829831        LW      SCRATCH_REGISTER_0, globalExceptHdl
     
    837839        bctrl
    838840
     841#else /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     842
     843        /* Call fixed global handler */
     844        bl      C_exception_handler
     845
     846#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     847
    839848        b       wrap_handler_done_\_FLVR
    840849
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_async_normal.S

    r4263155 r4bd4c9e  
    11/*
    2  * Copyright (c) 2011 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2011-2012 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    4747#define FRAME_OFFSET(reg) GPR2_OFFSET(reg)
    4848
     49#ifdef PPC_EXC_CONFIG_USE_FIXED_HANDLER
     50        .global bsp_interrupt_dispatch
     51#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     52
    4953        .global ppc_exc_min_prolog_async_tmpl_normal
    5054        .global ppc_exc_wrap_async_normal
     
    5357
    5458        stwu    r1, -PPC_EXC_MINIMAL_FRAME_SIZE(r1)
     59
     60#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
    5561        stw     VECTOR_REGISTER, PPC_EXC_VECTOR_PROLOGUE_OFFSET(r1)
    5662        li      VECTOR_REGISTER, 0xffff8000
     63#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    5764
    5865        /*
     
    8895        PPC_GPR_STORE   SCRATCH_0_REGISTER, SCRATCH_0_OFFSET(r1)
    8996
     97#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
    9098#ifdef __SPE__
    9199        /*
     
    96104        stw     SCRATCH_0_REGISTER, VECTOR_OFFSET(r1)
    97105#endif
     106#else /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     107        /* The vector register has no special purpose in this case */
     108        PPC_GPR_STORE   VECTOR_REGISTER, VECTOR_OFFSET(r1)
     109#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    98110
    99111        PPC_GPR_STORE   HANDLER_REGISTER, HANDLER_OFFSET(r1)
    100112
     113#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
    101114        /*
    102115         * Load the handler address.  Get the handler table index from the
     
    109122        ori     HANDLER_REGISTER, HANDLER_REGISTER, ppc_exc_handler_table@l
    110123        lwzx    HANDLER_REGISTER, HANDLER_REGISTER, SCRATCH_0_REGISTER
     124#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    111125
    112126        PPC_GPR_STORE   SCRATCH_1_REGISTER, SCRATCH_1_OFFSET(r1)
     
    150164        iselgt  r1, r1, SCRATCH_0_REGISTER
    151165
     166#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
    152167        /*
    153168         * Call high level exception handler.
     
    160175        mtctr   HANDLER_REGISTER
    161176        bctrl
     177#else /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     178        /* Call fixed high level handler */
     179        bl      bsp_interrupt_dispatch
     180#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    162181
    163182        /* Load ISR nest level and thread dispatch disable level */
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_global_handler.c

    r4263155 r4bd4c9e  
    2020#include <bsp/vectors.h>
    2121
    22 exception_handler_t globalExceptHdl = C_exception_handler;
    23 
    2422void C_exception_handler(BSP_Exception_frame *excPtr)
    2523{
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_hdl.c

    r4263155 r4bd4c9e  
    4040uint32_t ppc_exc_msr_bits = MSR_IR | MSR_DR | MSR_RI;
    4141
    42 static int ppc_exc_handler_default(BSP_Exception_frame *f, unsigned int vector)
     42int ppc_exc_handler_default(BSP_Exception_frame *f, unsigned int vector)
    4343{
    4444  return -1;
    4545}
     46
     47#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
     48
     49exception_handler_t globalExceptHdl = C_exception_handler;
    4650
    4751/* Table of C-handlers */
     
    4953  [0 ... LAST_VALID_EXC] = ppc_exc_handler_default
    5054};
     55
     56#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    5157
    5258ppc_exc_handler_t ppc_exc_get_handler(unsigned vector)
     
    6672  if (vector <= LAST_VALID_EXC) {
    6773    if (handler == NULL) {
    68       ppc_exc_handler_table [vector] = ppc_exc_handler_default;
    69     } else {
     74      handler = ppc_exc_handler_default;
     75    }
     76
     77    if (ppc_exc_handler_table [vector] != handler) {
     78#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
    7079      ppc_exc_handler_table [vector] = handler;
     80#else /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     81      return RTEMS_RESOURCE_IN_USE;
     82#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    7183    }
    7284
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_prologue.c

    r4263155 r4bd4c9e  
    1010 * Copyright (C) 2007 Till Straumann <strauman@slac.stanford.edu>
    1111 *
    12  * Copyright (C) 2009 embedded brains GmbH.
     12 * Copyright (C) 2009-2012 embedded brains GmbH.
    1313 *
    1414 * The license and distribution terms for this file may be
     
    136136  ) {
    137137    prologue_template = ppc_exc_min_prolog_async_tmpl_normal;
     138#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
    138139    prologue_template_size = (size_t) ppc_exc_min_prolog_size;
    139140    fixup_vector = true;
     141#else /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     142    prologue_template_size = 8;
     143#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    140144  } else {
    141145    prologue_template = ppc_exc_prologue_templates [category];
  • c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors.h

    r4263155 r4bd4c9e  
    3535#ifndef LIBCPU_VECTORS_H
    3636#define LIBCPU_VECTORS_H
     37
     38#include <bspopts.h>
    3739
    3840#include <libcpu/powerpc-utility.h>
     
    263265
    264266/**
    265  * @brief Global exception handler.
    266  */
    267 extern exception_handler_t globalExceptHdl;
    268 
    269 /**
    270267 * @brief Default global exception handler.
    271268 */
     
    400397 * @brief High-level exception handler type.
    401398 *
    402  * Exception handlers should return zero if the exception was handled and
    403  * normal execution may resume.
    404  *
    405  * They should return minus one to reject the exception resulting in the
    406  * globalExcHdl() being called.
    407  *
    408  * Other return values are reserved.
     399 * @retval 0 The exception was handled and normal execution may resume.
     400 * @retval -1 Reject the exception resulting in a call of the global exception
     401 * handler.
     402 * @retval other Reserved, do not use.
    409403 */
    410404typedef int (*ppc_exc_handler_t)(BSP_Exception_frame *f, unsigned vector);
     405
     406/**
     407 * @brief Default high-level exception handler.
     408 *
     409 * @retval -1 Always.
     410 */
     411int ppc_exc_handler_default(BSP_Exception_frame *f, unsigned int vector);
    411412
    412413/**
     
    437438extern uint32_t ppc_exc_cache_wb_check;
    438439
    439 /**
    440  * @brief High-level exception handler table.
    441  */
    442 extern ppc_exc_handler_t ppc_exc_handler_table [LAST_VALID_EXC + 1];
     440#ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
     441  /**
     442   * @brief High-level exception handler table.
     443   */
     444  extern ppc_exc_handler_t ppc_exc_handler_table [LAST_VALID_EXC + 1];
     445
     446  /**
     447   * @brief Global exception handler.
     448   */
     449  extern exception_handler_t globalExceptHdl;
     450#else /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
     451  /**
     452   * @brief High-level exception handler table.
     453   */
     454  extern const ppc_exc_handler_t ppc_exc_handler_table [LAST_VALID_EXC + 1];
     455
     456  /**
     457   * @brief Interrupt dispatch routine provided by BSP.
     458   */
     459  void bsp_interrupt_dispatch(void);
     460#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
    443461
    444462/**
     
    458476 * It is legal to set a NULL handler. This leads to the globalExcHdl
    459477 * being called if an exception for 'vector' occurs.
     478 *
     479 * @retval RTEMS_SUCCESSFUL Successful operation.
     480 * @retval RTEMS_INVALID_ID Invalid vector number.
     481 * @retval RTEMS_RESOURCE_IN_USE Handler table is read-only and handler does
     482 * not match.
    460483 */
    461484rtems_status_code ppc_exc_set_handler(unsigned vector, ppc_exc_handler_t hdl);
Note: See TracChangeset for help on using the changeset viewer.