Update for exception support changes.

This commit is contained in:
Thomas Doerfler
2009-10-23 07:32:46 +00:00
parent cc1e864dfe
commit 2d2de4eba1
103 changed files with 1609 additions and 1588 deletions

View File

@@ -1,3 +1,29 @@
2009-10-22 Sebastian Huber <sebastian.huber@embedded-brains.de>
* new-exceptions/bspsupport/ppc-code-copy.c,
new-exceptions/bspsupport/ppc_exc_address.c,
new-exceptions/bspsupport/ppc_exc_categories.c,
new-exceptions/bspsupport/ppc_exc_global_handler.c,
new-exceptions/bspsupport/ppc_exc_initialize.c,
new-exceptions/bspsupport/ppc_exc_naked.S,
new-exceptions/bspsupport/ppc_exc_prologue.c: New files.
* new-exceptions/bspsupport/irq.c,
new-exceptions/bspsupport/irq_supp.h,
new-exceptions/bspsupport/ppc_exc_asm_macros.h: Changed exception
header file includes. Fixes for type changes.
* new-exceptions/bspsupport/vectors.h: Reformatted. Documentation.
Removed parts that belong to the raw exception API. Added
declarations from files "new-exceptions/raw_exception.h" and
"bspsupport/ppc_exc_bspsupp.h".
* new-exceptions/bspsupport/ppc_exc_hdl.c: Reformatted. Removed parts
that belong to the raw exception API.
* new-exceptions/bspsupport/ppc_exc_bspsupp.h: Added prologue template.
* new-exceptions/bspsupport/ppc_exc.S: Fixed
ppc_exc_tgpr_clr_prolog_size.
* shared/include/powerpc-utility.h: Reformatted. Include more files
for ASM.
* shared/include/cpuIdent.h: Added ppc_cpu_current() and ppc_cpu_is().
2009-10-22 Ralf Corsépius <ralf.corsepius@rtems.org>
* new-exceptions/bspsupport/vectors_init.c: Remove duplicate

View File

@@ -15,6 +15,10 @@ include_libcpudir = $(includedir)/libcpu
include_libcpu_HEADERS = shared/include/powerpc-utility.h
include_bspdir = $(includedir)/bsp
include_bsp_HEADERS =
EXTRA_DIST =
noinst_PROGRAMS = new-exceptions/rtems-cpu.rel
@@ -25,19 +29,20 @@ new_exceptions_rtems_cpu_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
if !mpc5xx
include_libcpu_HEADERS += new-exceptions/raw_exception.h
noinst_PROGRAMS += new-exceptions/raw_exception.rel
new_exceptions_raw_exception_rel_SOURCES = new-exceptions/raw_exception.c \
new-exceptions/asm_utils.S \
new-exceptions/e500_raw_exc_init.c
new_exceptions_raw_exception_rel_CPPFLAGS = $(AM_CPPFLAGS)
new_exceptions_raw_exception_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
include_bsp_HEADERS += new-exceptions/bspsupport/vectors.h
noinst_PROGRAMS += new-exceptions/exc_bspsupport.rel
new_exceptions_exc_bspsupport_rel_SOURCES = \
new-exceptions/bspsupport/ppc-code-copy.c \
new-exceptions/bspsupport/ppc_exc.S \
new-exceptions/bspsupport/ppc_exc_naked.S \
new-exceptions/bspsupport/ppc_exc_hdl.c \
new-exceptions/bspsupport/vectors_init.c
new-exceptions/bspsupport/ppc_exc_initialize.c \
new-exceptions/bspsupport/ppc_exc_global_handler.c \
new-exceptions/bspsupport/ppc_exc_categories.c \
new-exceptions/bspsupport/ppc_exc_address.c \
new-exceptions/bspsupport/ppc_exc_prologue.c
new_exceptions_exc_bspsupport_rel_CPPFLAGS = $(AM_CPPFLAGS)
new_exceptions_exc_bspsupport_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
@@ -50,7 +55,6 @@ endif
EXTRA_DIST += new-exceptions/bspsupport/vectors.h
EXTRA_DIST += new-exceptions/bspsupport/irq_supp.h
EXTRA_DIST += new-exceptions/bspsupport/ppc_exc_bspsupp.h
EXTRA_DIST += new-exceptions/bspsupport/README
EXTRA_DIST += new-exceptions/bspsupport/nest_irq_test.c
EXTRA_DIST += new-exceptions/bspsupport/ppc_exc_test.c
@@ -357,11 +361,6 @@ endif
if mpc83xx
# Includes
include_bspdir = $(includedir)/bsp
include_bsp_HEADERS = new-exceptions/bspsupport/vectors.h \
new-exceptions/bspsupport/ppc_exc_bspsupp.h
include_mpc83xxdir = $(includedir)/mpc83xx
include_mpc83xx_HEADERS = mpc83xx/include/mpc83xx.h
@@ -407,12 +406,6 @@ endif
if mpc55xx
# Includes
include_bspdir = $(includedir)/bsp
include_bsp_HEADERS = new-exceptions/bspsupport/vectors.h \
new-exceptions/bspsupport/ppc_exc_bspsupp.h \
mpc55xx/include/irq.h
include_mpc55xxdir = $(includedir)/mpc55xx
include_mpc55xx_HEADERS = mpc55xx/include/regs.h \
@@ -424,6 +417,8 @@ include_mpc55xx_HEADERS = mpc55xx/include/regs.h \
mpc55xx/include/esci.h \
mpc55xx/include/watchdog.h
include_bsp_HEADERS += mpc55xx/include/irq.h
# IRQ
noinst_PROGRAMS += mpc55xx/irq.rel
mpc55xx_irq_rel_SOURCES = mpc55xx/irq/irq.c

View File

@@ -20,12 +20,11 @@
#include <mpc55xx/regs.h>
#include <libcpu/raw_exception.h>
#include <libcpu/powerpc-utility.h>
#include <bsp/irq.h>
#include <bsp/vectors.h>
#include <bsp/irq-generic.h>
#include <bsp/ppc_exc_bspsupp.h>
#define RTEMS_STATUS_CHECKS_USE_PRINTK

View File

@@ -69,7 +69,6 @@
#ifdef DEBUG_EXC
#include <bsp.h>
#include <bsp/vectors.h>
#include <libcpu/raw_exception.h>
#endif
#endif

View File

@@ -16,10 +16,7 @@
#include <rtems.h>
#include "irq_supp.h"
#include <rtems/score/apiext.h> /* for post ISR signal processing */
#include <libcpu/raw_exception.h>
#include <libcpu/cpuIdent.h>
#include "vectors.h"
#include "ppc_exc_bspsupp.h"
#include <bsp/vectors.h>
#include <stdlib.h>
#include <rtems/bspIo.h> /* for printk */
#include <libcpu/spr.h>

View File

@@ -24,9 +24,10 @@
#endif
#include <rtems.h>
#include <stdint.h>
#include <rtems/irq.h>
#include <bsp/vectors.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -51,8 +52,6 @@ extern int BSP_disable_irq_at_pic(const rtems_irq_number irqLine);
*/
extern int BSP_setup_the_pic(rtems_irq_global_settings* config);
struct _BSP_Exception_frame;
/* IRQ dispatcher to be defined by the PIC driver; note that it MUST
* implement shared interrupts.
* Note also that the exception frame passed to this handler is not very
@@ -64,7 +63,7 @@ struct _BSP_Exception_frame;
* uncaught exception.
*******************************************************************
*/
int C_dispatch_irq_handler (struct _BSP_Exception_frame *frame, unsigned int excNum);
int C_dispatch_irq_handler (BSP_Exception_frame *frame, unsigned int excNum);
/*
* Snippet to be used by PIC drivers and by bsp_irq_dispatch_list

View File

@@ -64,6 +64,9 @@ ppc_exc_min_prolog_auto:
mflr VECTOR_REGISTER
bla wrap_auto
.global ppc_exc_tgpr_clr_prolog_size
ppc_exc_tgpr_clr_prolog_size = . - ppc_exc_tgpr_clr_prolog
/**
* @brief Use vector offsets with 16 byte boundaries.
*
@@ -76,9 +79,6 @@ ppc_exc_min_prolog_auto_packed:
mflr VECTOR_REGISTER
bla wrap_auto_packed
.global ppc_exc_tgpr_clr_prolog_size
ppc_exc_tgpr_clr_prolog_size = . - ppc_exc_tgpr_clr_prolog
/*
* Automatic vector, asynchronous exception; however,
* automatic vector calculation is less efficient than

View File

@@ -12,10 +12,7 @@
* reintroduce such statements.
*/
#include <libcpu/powerpc-utility.h>
#include <libcpu/raw_exception.h>
#include "vectors.h"
#include <bsp/vectors.h>
#define LT(cr) ((cr)*4+0)
#define GT(cr) ((cr)*4+1)

View File

@@ -117,6 +117,7 @@ extern void ppc_exc_min_prolog_async_tmpl_bookE_crit(void);
extern void ppc_exc_min_prolog_sync_tmpl_bookE_crit(void);
extern void ppc_exc_min_prolog_sync_tmpl_e500_mchk(void);
extern void ppc_exc_min_prolog_async_tmpl_e500_mchk(void);
extern void ppc_exc_min_prolog_tmpl_naked(void);
/* Special prologue for handling register shadowing on 603-style CPUs */
extern void ppc_exc_tgpr_clr_prolog(void);

View File

@@ -10,20 +10,10 @@
* $Id$
*/
#include <stdint.h>
#include <string.h>
#include <rtems.h>
#include <rtems/score/apiext.h>
#include <rtems.h>
#include <rtems/score/cpu.h>
#include <libcpu/raw_exception.h>
#include <libcpu/spr.h>
#include <rtems/score/apiext.h>
#include "vectors.h"
#include "ppc_exc_bspsupp.h"
/* offset into min-prolog where vector # is hardcoded */
#define PPC_EXC_PROLOG_VEC_OFFSET 2
#include <bsp/vectors.h>
/* Provide temp. storage space for a few registers.
* This is used by the assembly code prior to setting up
@@ -39,9 +29,9 @@ uint32_t ppc_exc_lock_std = 0;
uint32_t ppc_exc_lock_crit = 0;
uint32_t ppc_exc_lock_mchk = 0;
uint32_t ppc_exc_vector_register_std = 0;
uint32_t ppc_exc_vector_register_crit = 0;
uint32_t ppc_exc_vector_register_mchk = 0;
uint32_t ppc_exc_vector_register_std = 0;
uint32_t ppc_exc_vector_register_crit = 0;
uint32_t ppc_exc_vector_register_mchk = 0;
/* MSR bits to enable once critical status info is saved and the stack
* is switched; must be set depending on CPU type
@@ -49,105 +39,65 @@ uint32_t ppc_exc_vector_register_mchk = 0;
* Default is set here for classic PPC CPUs with a MMU
* but is overridden from vectors_init.c
*/
uint32_t ppc_exc_msr_bits = MSR_IR | MSR_DR | MSR_RI;
uint32_t ppc_exc_msr_bits = MSR_IR | MSR_DR | MSR_RI;
int ppc_exc_handler_default( BSP_Exception_frame *f, unsigned int vector)
static int ppc_exc_handler_default(BSP_Exception_frame *f, unsigned int vector)
{
return 1;
return -1;
}
/* Table of C-handlers */
ppc_exc_handler_t ppc_exc_handler_table [LAST_VALID_EXC + 1] = {
[0 ... LAST_VALID_EXC] = ppc_exc_handler_default
[0 ... LAST_VALID_EXC] = ppc_exc_handler_default
};
ppc_exc_handler_t ppc_exc_get_handler( unsigned vector)
ppc_exc_handler_t ppc_exc_get_handler(unsigned vector)
{
ppc_exc_handler_t handler = NULL;
if (vector > LAST_VALID_EXC) {
return 0;
}
if (ppc_exc_handler_table [vector] != ppc_exc_handler_default) {
handler = ppc_exc_handler_table [vector];
}
return handler;
if (
vector <= LAST_VALID_EXC
&& ppc_exc_handler_table [vector] != ppc_exc_handler_default
) {
return ppc_exc_handler_table [vector];
} else {
return NULL;
}
}
int ppc_exc_set_handler( unsigned vector, ppc_exc_handler_t handler)
rtems_status_code ppc_exc_set_handler(unsigned vector, ppc_exc_handler_t handler)
{
if (vector > LAST_VALID_EXC) {
return -1;
}
if (handler == NULL) {
ppc_exc_handler_table [vector] = ppc_exc_handler_default;
} else {
ppc_exc_handler_table [vector] = handler;
}
return 0;
if (vector <= LAST_VALID_EXC) {
if (handler == NULL) {
ppc_exc_handler_table [vector] = ppc_exc_handler_default;
} else {
ppc_exc_handler_table [vector] = handler;
}
return RTEMS_SUCCESSFUL;
} else {
return RTEMS_INVALID_ID;
}
}
void
ppc_exc_wrapup( BSP_Exception_frame *f)
void ppc_exc_wrapup(BSP_Exception_frame *frame)
{
/* dispatch_disable level is decremented from assembly code. */
if ( _Context_Switch_necessary ) {
/* FIXME: I believe it should be OK to re-enable
* interrupts around the execution of _Thread_Dispatch();
*/
_Thread_Dispatch();
} else if ( _ISR_Signals_to_thread_executing ) {
_ISR_Signals_to_thread_executing = 0;
/*
* Process pending signals that have not already been
* processed by _Thread_Dispatch. This happens quite
* unfrequently : the ISR must have posted an action
* to the current running thread.
*/
if ( _Thread_Do_post_task_switch_extension ||
_Thread_Executing->do_post_task_switch_extension ) {
_Thread_Executing->do_post_task_switch_extension = false;
_API_extensions_Run_postswitch();
}
}
/* dispatch_disable level is decremented from assembly code. */
if ( _Context_Switch_necessary ) {
/* FIXME: I believe it should be OK to re-enable
* interrupts around the execution of _Thread_Dispatch();
*/
_Thread_Dispatch();
} else if ( _ISR_Signals_to_thread_executing ) {
_ISR_Signals_to_thread_executing = 0;
/*
* Process pending signals that have not already been
* processed by _Thread_Dispatch. This happens quite
* unfrequently : the ISR must have posted an action
* to the current running thread.
*/
if ( _Thread_Do_post_task_switch_extension ||
_Thread_Executing->do_post_task_switch_extension ) {
_Thread_Executing->do_post_task_switch_extension = false;
_API_extensions_Run_postswitch();
}
}
}
void
ppc_exc_min_prolog_expand(ppc_exc_min_prolog_t buf, ppc_exc_min_prolog_template_t templ, uint16_t vec)
{
memcpy(&buf[0], templ, sizeof(ppc_exc_min_prolog_t));
/* fixup the vector */
buf[PPC_EXC_PROLOG_VEC_OFFSET] = (buf[PPC_EXC_PROLOG_VEC_OFFSET] & 0xffff8000) | (vec & 0x7fff);
}
#undef TESTING
#ifdef TESTING
static void noop(const struct __rtems_raw_except_connect_data__*x) {}
rtems_raw_except_connect_data exc_conn = {
exceptIndex: ASM_SYS_VECTOR,
hdl : {
vector: ASM_SYS_VECTOR,
raw_hdl: 0,
raw_hdl_size: 0
},
on : noop,
off : noop,
isOn : 0 /* never used AFAIK */
};
void
ppc_exc_raise()
{
asm volatile("li 3, 0xffffdead; sc");
}
int
exc_conn_do()
{
exc_conn.hdl.raw_hdl = ppc_exc_min_prolog_auto;
exc_conn.hdl.raw_hdl_size = 16;
return ppc_set_exception(&exc_conn);
}
#endif

View File

@@ -1,21 +1,147 @@
/*
* vectors.h Exception frame related contant and API.
/**
* @file
*
* This include file describe the data structure and the functions implemented
* by rtems to handle exceptions.
* @ingroup ppc_exc
* @ingroup ppc_exc_frame
*
* CopyRight (C) 1999 valette@crf.canon.fr
*
* The license and distribution terms for this file may be
* found in found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
* @brief PowerPC Exceptions API.
*/
#ifndef LIBCPU_POWERPC_BSPSUPP_VECTORS_H
#define LIBCPU_POWERPC_BSPSUPP_VECTORS_H
#include <libcpu/raw_exception.h>
/*
* Copyright (C) 1999 Eric Valette (valette@crf.canon.fr)
* Canon Centre Recherche France.
*
* Copyright (C) 2007 Till Straumann <strauman@slac.stanford.edu>
*
* Copyright (C) 2009 embedded brains GmbH.
*
* Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com>
* to support 603, 603e, 604, 604e exceptions
*
* Moved to "libcpu/powerpc/new-exceptions" and consolidated
* by Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
* to be common for all PPCs with new exceptions.
*
* Derived from file "libcpu/powerpc/new-exceptions/raw_exception.h".
* Derived from file "libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_bspsupp.h".
*
* The license and distribution terms for this file may be
* found in found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/* DO NOT INTRODUCE #ifdef <cpu_flavor> in this file */
#ifndef LIBCPU_VECTORS_H
#define LIBCPU_VECTORS_H
#include <libcpu/powerpc-utility.h>
/**
* @defgroup ppc_exc PowerPC Exceptions
*
* @brief XXX
*
* @{
*/
#define ASM_RESET_VECTOR 0x01
#define ASM_MACH_VECTOR 0x02
#define ASM_PROT_VECTOR 0x03
#define ASM_ISI_VECTOR 0x04
#define ASM_EXT_VECTOR 0x05
#define ASM_ALIGN_VECTOR 0x06
#define ASM_PROG_VECTOR 0x07
#define ASM_FLOAT_VECTOR 0x08
#define ASM_DEC_VECTOR 0x09
#define ASM_SYS_VECTOR 0x0C
#define ASM_TRACE_VECTOR 0x0D
#define ASM_BOOKE_CRIT_VECTOR 0x01
/* We could use the std. decrementer vector # on bookE, too,
* but the bookE decrementer has slightly different semantics
* so we use a different vector (which happens to be
* the PIT vector on the 405 which is like the booke decrementer)
*/
#define ASM_BOOKE_DEC_VECTOR 0x10
#define ASM_BOOKE_ITLBMISS_VECTOR 0x11
#define ASM_BOOKE_DTLBMISS_VECTOR 0x12
#define ASM_BOOKE_FIT_VECTOR 0x13
#define ASM_BOOKE_WDOG_VECTOR 0x14
#define ASM_PPC405_APU_UNAVAIL_VECTOR ASM_60X_VEC_ASSIST_VECTOR
#define ASM_8XX_FLOATASSIST_VECTOR 0x0E
#define ASM_8XX_SOFTEMUL_VECTOR 0x10
#define ASM_8XX_ITLBMISS_VECTOR 0x11
#define ASM_8XX_DTLBMISS_VECTOR 0x12
#define ASM_8XX_ITLBERROR_VECTOR 0x13
#define ASM_8XX_DTLBERROR_VECTOR 0x14
#define ASM_8XX_DBREAK_VECTOR 0x1C
#define ASM_8XX_IBREAK_VECTOR 0x1D
#define ASM_8XX_PERIFBREAK_VECTOR 0x1E
#define ASM_8XX_DEVPORT_VECTOR 0x1F
#define ASM_5XX_FLOATASSIST_VECTOR 0x0E
#define ASM_5XX_SOFTEMUL_VECTOR 0x10
#define ASM_5XX_IPROT_VECTOR 0x13
#define ASM_5XX_DPROT_VECTOR 0x14
#define ASM_5XX_DBREAK_VECTOR 0x1C
#define ASM_5XX_IBREAK_VECTOR 0x1D
#define ASM_5XX_MEBREAK_VECTOR 0x1E
#define ASM_5XX_NMEBREAK_VECTOR 0x1F
#define ASM_60X_VEC_VECTOR 0x0A
#define ASM_60X_PERFMON_VECTOR 0x0F
#define ASM_60X_IMISS_VECTOR 0x10
#define ASM_60X_DLMISS_VECTOR 0x11
#define ASM_60X_DSMISS_VECTOR 0x12
#define ASM_60X_ADDR_VECTOR 0x13
#define ASM_60X_SYSMGMT_VECTOR 0x14
#define ASM_60X_VEC_ASSIST_VECTOR 0x16
#define ASM_60X_ITM_VECTOR 0x17
/* e200 */
#define ASM_E200_SPE_UNAVAILABLE_VECTOR 0x15
#define ASM_E200_SPE_DATA_VECTOR 0x16
#define ASM_E200_SPE_ROUND_VECTOR 0x17
/* e300 */
#define ASM_E300_CRIT_VECTOR 0x0A
#define ASM_E300_PERFMON_VECTOR 0x0F
#define ASM_E300_IMISS_VECTOR ASM_60X_IMISS_VECTOR /* Special case: Shadowed GPRs */
#define ASM_E300_DLMISS_VECTOR ASM_60X_DLMISS_VECTOR /* Special case: Shadowed GPRs */
#define ASM_E300_DSMISS_VECTOR ASM_60X_DSMISS_VECTOR /* Special case: Shadowed GPRs */
#define ASM_E300_ADDR_VECTOR 0x13
#define ASM_E300_SYSMGMT_VECTOR 0x14
/*
* If you change that number make sure to adjust the wrapper code in ppc_exc.S
* and that ppc_exc_handler_table will be correctly initialized.
*/
#define LAST_VALID_EXC 0x1F
/* DO NOT USE -- this symbol is DEPRECATED
* (only used by libbsp/shared/vectors/vectors.S
* which should not be used by new BSPs).
*/
#define ASM_60X_VEC_VECTOR_OFFSET 0xf20
#define ASM_PPC405_FIT_VECTOR_OFFSET 0x1010
#define ASM_PPC405_WDOG_VECTOR_OFFSET 0x1020
#define ASM_PPC405_TRACE_VECTOR_OFFSET 0x2000
/** @} */
/**
* @defgroup ppc_exc_frame PowerPC Exception Frame
*
* @brief XXX
*
* @{
*/
/*
* The callee (high level exception code written in C)
@@ -73,85 +199,291 @@
*/
#define EXCEPTION_FRAME_END 176
/** @} */
#ifndef ASM
#include <stdint.h>
/* codemove is like memmove, but it also gets the cache line size
* as 4th parameter to synchronize them. If this last parameter is
* zero, it performs more or less like memmove. No copy is performed if
* source and destination addresses are equal. However the caches
* are synchronized. Note that the size is always rounded up to the
* next mutiple of 4.
/**
* @ingroup ppc_exc_frame
*
* @{
*/
extern void * codemove(void *, const void *, unsigned int, unsigned long);
extern void exception_nop_enable(const rtems_raw_except_connect_data* ptr);
extern int exception_always_enabled(const rtems_raw_except_connect_data* ptr);
void ppc_exc_initialize(
uint32_t interrupt_disable_mask,
uint32_t interrupt_stack_start,
uint32_t interrupt_stack_size
);
typedef struct _BSP_Exception_frame {
unsigned EXC_SRR0;
unsigned EXC_SRR1;
unsigned _EXC_number;
unsigned GPR0;
unsigned GPR1;
unsigned GPR2;
unsigned GPR3;
unsigned GPR4;
unsigned GPR5;
unsigned GPR6;
unsigned GPR7;
unsigned GPR8;
unsigned GPR9;
unsigned GPR10;
unsigned GPR11;
unsigned GPR12;
unsigned GPR13;
unsigned GPR14;
unsigned GPR15;
unsigned GPR16;
unsigned GPR17;
unsigned GPR18;
unsigned GPR19;
unsigned GPR20;
unsigned GPR21;
unsigned GPR22;
unsigned GPR23;
unsigned GPR24;
unsigned GPR25;
unsigned GPR26;
unsigned GPR27;
unsigned GPR28;
unsigned GPR29;
unsigned GPR30;
unsigned GPR31;
unsigned EXC_CR;
unsigned EXC_CTR;
unsigned EXC_XER;
unsigned EXC_LR;
unsigned EXC_MSR;
unsigned EXC_DAR;
typedef struct {
unsigned EXC_SRR0;
unsigned EXC_SRR1;
unsigned _EXC_number;
unsigned GPR0;
unsigned GPR1;
unsigned GPR2;
unsigned GPR3;
unsigned GPR4;
unsigned GPR5;
unsigned GPR6;
unsigned GPR7;
unsigned GPR8;
unsigned GPR9;
unsigned GPR10;
unsigned GPR11;
unsigned GPR12;
unsigned GPR13;
unsigned GPR14;
unsigned GPR15;
unsigned GPR16;
unsigned GPR17;
unsigned GPR18;
unsigned GPR19;
unsigned GPR20;
unsigned GPR21;
unsigned GPR22;
unsigned GPR23;
unsigned GPR24;
unsigned GPR25;
unsigned GPR26;
unsigned GPR27;
unsigned GPR28;
unsigned GPR29;
unsigned GPR30;
unsigned GPR31;
unsigned EXC_CR;
unsigned EXC_CTR;
unsigned EXC_XER;
unsigned EXC_LR;
unsigned EXC_MSR;
unsigned EXC_DAR;
} BSP_Exception_frame;
typedef void (*exception_handler_t) (BSP_Exception_frame* excPtr);
/** @} */
/**
* @ingroup ppc_exc
*
* @{
*/
/**
* @brief Global exception handler type.
*/
typedef void (*exception_handler_t)(BSP_Exception_frame*);
/**
* @brief Global exception handler.
*/
extern exception_handler_t globalExceptHdl;
/**
* @brief Default global exception handler.
*/
void C_exception_handler(BSP_Exception_frame* excPtr);
void BSP_printStackTrace(BSP_Exception_frame *excPtr);
/**
* @brief Exception categories.
*
* Exceptions of different categories use different SRR registers to save the
* machine state and do different things in the prologue and epilogue.
*
* For now, the CPU descriptions assume this fits into 8 bits.
*/
typedef enum {
PPC_EXC_INVALID = 0,
PPC_EXC_ASYNC = 1,
PPC_EXC_CLASSIC = 2,
PPC_EXC_CLASSIC_ASYNC = PPC_EXC_CLASSIC | PPC_EXC_ASYNC,
PPC_EXC_405_CRITICAL = 4,
PPC_EXC_405_CRITICAL_ASYNC = PPC_EXC_405_CRITICAL | PPC_EXC_ASYNC,
PPC_EXC_BOOKE_CRITICAL = 6,
PPC_EXC_BOOKE_CRITICAL_ASYNC = PPC_EXC_BOOKE_CRITICAL | PPC_EXC_ASYNC,
PPC_EXC_E500_MACHCHK = 8,
PPC_EXC_E500_MACHCHK_ASYNC = PPC_EXC_E500_MACHCHK | PPC_EXC_ASYNC,
PPC_EXC_NAKED = 10
} ppc_exc_category;
/**
* @brief Categorie set type.
*/
typedef uint8_t ppc_exc_categories [LAST_VALID_EXC + 1];
static inline bool ppc_exc_is_valid_category(ppc_exc_category category)
{
return (unsigned) category <= (unsigned) PPC_EXC_NAKED;
}
/**
* @brief Indicates if exception entry table resides in a writable memory.
*
* This variable is initialized to 'TRUE' by default;
* BSPs which have their vectors in ROM should set it
* to FALSE prior to initializing raw exceptions.
*
* I suspect the only candidate is the simulator.
* After all, the value of this variable is used to
* determine where to install the prologue code and
* installing to ROM on anyting that's real ROM
* will fail anyways.
*
* This should probably go away... (T.S. 2007/11/30)
*/
extern bool bsp_exceptions_in_RAM;
/**
* @brief Vector base address for CPUs (for example e200 and e500) with IVPR
* and IVOR registers.
*/
extern uint32_t ppc_exc_vector_base;
/**
* @brief Returns the entry address of the vector @a vector.
*/
void *ppc_exc_vector_address(unsigned vector);
/**
* @brief Returns the category set for a CPU of type @a cpu, or @c NULL if
* there is no category set available for this CPU.
*/
const ppc_exc_categories *ppc_exc_categories_for_cpu(ppc_cpu_id_t cpu);
/**
* @brief Returns the category set for the current CPU, or @c NULL if there is
* no category set available for this CPU.
*/
static inline const ppc_exc_categories *ppc_exc_current_categories(void)
{
return ppc_exc_categories_for_cpu(ppc_cpu_current());
}
/**
* @brief Returns the category for the vector @a vector using the category set
* @a categories.
*/
ppc_exc_category ppc_exc_category_for_vector(
const ppc_exc_categories *categories,
unsigned vector
);
/**
* @brief Makes a minimal prologue for the vector @a vector with the category
* @a category.
*
* The minimal prologue will be copied to @a prologue. Not more than @a
* prologue_size bytes will be copied. Returns the actual minimal prologue
* size in bytes in @a prologue_size.
*
* @retval RTEMS_SUCCESSFUL Minimal prologue successfully made.
* @retval RTEMS_INVALID_ID Invalid vector number.
* @retval RTEMS_INVALID_NUMBER Invalid category.
* @retval RTEMS_INVALID_SIZE Prologue size to small.
*/
rtems_status_code ppc_exc_make_prologue(
unsigned vector,
ppc_exc_category category,
uint32_t *prologue,
size_t *prologue_size
);
/**
* @brief Initializes the exception handling.
*
* @retval RTEMS_SUCCESSFUL Successful initialization.
* @retval RTEMS_NOT_IMPLEMENTED No category set available for the current CPU.
* @retval RTEMS_NOT_CONFIGURED Register r13 does not point to the small data
* area anchor required by SVR4/EABI.
* @retval RTEMS_INTERNAL_ERROR Minimal prologue creation failed.
*/
rtems_status_code ppc_exc_initialize(
uint32_t interrupt_disable_mask,
uintptr_t interrupt_stack_begin,
uintptr_t interrupt_stack_size
);
/**
* @brief High-level exception handler type.
*
* Exception handlers should return zero if the exception was handled and
* normal execution may resume.
*
* They should return minus one to reject the exception resulting in the
* globalExcHdl() being called.
*
* Other return values are reserved.
*/
typedef int (*ppc_exc_handler_t)(BSP_Exception_frame *f, unsigned vector);
/**
* @brief Bits for MSR update.
*
* Bits in MSR that are enabled during execution of exception handlers / ISRs
* (on classic PPC these are DR/IR/RI [default], on bookE-style CPUs they should
* be set to 0 during initialization)
*
* By default, the setting of these bits that is in effect when exception
* handling is initialized is used.
*/
extern uint32_t ppc_exc_msr_bits;
/**
* @brief Cache write back check flag.
*
* (See README under CAVEATS). During initialization
* a check is performed to assert that write-back
* caching is enabled for memory accesses. If a BSP
* runs entirely without any caching then it should
* set this variable to zero prior to initializing
* exceptions in order to skip the test.
* NOTE: The code does NOT support mapping memory
* with cache-attributes other than write-back
* (unless the entire cache is physically disabled)
*/
extern uint32_t ppc_exc_cache_wb_check;
/**
* @brief Set high-level exception handler.
*
* Hook C exception handlers.
* - handlers for asynchronous exceptions run on the ISR stack
* with thread-dispatching disabled.
* - handlers for synchronous exceptions run on the task stack
* with thread-dispatching enabled.
*
* If a particular slot is NULL then the traditional 'globalExcHdl' is used.
*
* ppc_exc_set_handler() registers a handler (returning 0 on success,
* -1 if the vector argument is too big).
*
* It is legal to set a NULL handler. This leads to the globalExcHdl
* being called if an exception for 'vector' occurs.
*/
rtems_status_code ppc_exc_set_handler(unsigned vector, ppc_exc_handler_t hdl);
/**
* @brief Returns the currently active high-level exception handler.
*/
ppc_exc_handler_t ppc_exc_get_handler(unsigned vector);
/**
* @brief Function for DAR access.
*
* CPU support may store the address of a function here
* that can be used by the default exception handler to
* obtain fault-address info which is helpful. Unfortunately,
* the SPR holding this information is not uniform
* across PPC families so we need assistance from
* CPU support
*/
extern uint32_t (*ppc_exc_get_DAR)(void);
void
ppc_exc_wrapup(BSP_Exception_frame *f);
/** @} */
/*
* Compatibility with pc386
*/
typedef BSP_Exception_frame CPU_Exception_frame;
typedef exception_handler_t cpuExcHandlerType;
/*
* dummy functions for exception interface
*/
void exception_nop_enable(const rtems_raw_except_connect_data* ptr);
int exception_always_enabled(const rtems_raw_except_connect_data* ptr);
#endif /* ASM */
#endif /* LIBCPU_POWERPC_BSPSUPP_VECTORS_H */
#endif /* LIBCPU_VECTORS_H */

View File

@@ -51,9 +51,7 @@
#include <bsp.h>
#ifdef BSP_PPC403_CLOCK_HOOK_EXCEPTION
#include <libcpu/raw_exception.h>
#include <bsp/vectors.h>
#include <bsp/ppc_exc_bspsupp.h>
#define PPC_HAS_CLASSIC_EXCEPTIONS FALSE
#else
#if !defined(ppc405)

View File

@@ -49,10 +49,15 @@ $(PROJECT_INCLUDE)/libcpu/powerpc-utility.h: shared/include/powerpc-utility.h $(
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/powerpc-utility.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/powerpc-utility.h
$(PROJECT_INCLUDE)/bsp/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
if !mpc5xx
$(PROJECT_INCLUDE)/libcpu/raw_exception.h: new-exceptions/raw_exception.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/raw_exception.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/raw_exception.h
$(PROJECT_INCLUDE)/bsp/vectors.h: new-exceptions/bspsupport/vectors.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/vectors.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/vectors.h
endif
if shared
$(PROJECT_INCLUDE)/libcpu/io.h: shared/include/io.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
@@ -210,19 +215,6 @@ $(PROJECT_INCLUDE)/mpc8260/mmu.h: mpc8260/include/mmu.h $(PROJECT_INCLUDE)/mpc82
PREINSTALL_FILES += $(PROJECT_INCLUDE)/mpc8260/mmu.h
endif
if mpc83xx
$(PROJECT_INCLUDE)/bsp/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(PROJECT_INCLUDE)/bsp/vectors.h: new-exceptions/bspsupport/vectors.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/vectors.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/vectors.h
$(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h: new-exceptions/bspsupport/ppc_exc_bspsupp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h
$(PROJECT_INCLUDE)/mpc83xx/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/mpc83xx
@: > $(PROJECT_INCLUDE)/mpc83xx/$(dirstamp)
@@ -249,23 +241,6 @@ $(PROJECT_INCLUDE)/mpc83xx/gtm.h: mpc83xx/include/gtm.h $(PROJECT_INCLUDE)/mpc83
PREINSTALL_FILES += $(PROJECT_INCLUDE)/mpc83xx/gtm.h
endif
if mpc55xx
$(PROJECT_INCLUDE)/bsp/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(PROJECT_INCLUDE)/bsp/vectors.h: new-exceptions/bspsupport/vectors.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/vectors.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/vectors.h
$(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h: new-exceptions/bspsupport/ppc_exc_bspsupp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h
$(PROJECT_INCLUDE)/bsp/irq.h: mpc55xx/include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
$(PROJECT_INCLUDE)/mpc55xx/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/mpc55xx
@: > $(PROJECT_INCLUDE)/mpc55xx/$(dirstamp)
@@ -302,4 +277,8 @@ PREINSTALL_FILES += $(PROJECT_INCLUDE)/mpc55xx/esci.h
$(PROJECT_INCLUDE)/mpc55xx/watchdog.h: mpc55xx/include/watchdog.h $(PROJECT_INCLUDE)/mpc55xx/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/mpc55xx/watchdog.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/mpc55xx/watchdog.h
$(PROJECT_INCLUDE)/bsp/irq.h: mpc55xx/include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
endif

View File

@@ -106,17 +106,28 @@ _PPC_FEAT_DECL(has_epic)
_PPC_FEAT_DECL(has_shadowed_gprs)
_PPC_FEAT_DECL(has_ivpr_and_ivor)
static inline bool ppc_cpu_is_e300()
#undef _PPC_FEAT_DECL
static inline ppc_cpu_id_t ppc_cpu_current(void)
{
if (current_ppc_cpu == PPC_UNKNOWN) {
get_ppc_cpu_type();
}
return current_ppc_cpu == PPC_e300c1
|| current_ppc_cpu == PPC_e300c2
|| current_ppc_cpu == PPC_e300c3;
return current_ppc_cpu;
}
static inline bool ppc_cpu_is_e300()
{
if (ppc_cpu_current() == PPC_UNKNOWN) {
get_ppc_cpu_type();
}
return ppc_cpu_current() == PPC_e300c1
|| ppc_cpu_current() == PPC_e300c2
|| ppc_cpu_current() == PPC_e300c3;
}
static inline bool ppc_cpu_is(ppc_cpu_id_t cpu)
{
return ppc_cpu_current() == cpu;
}
#undef _PPC_FEAT_DECL
#endif /* ASM */
#endif

View File

@@ -29,165 +29,182 @@
#ifndef LIBCPU_POWERPC_UTILITY_H
#define LIBCPU_POWERPC_UTILITY_H
#ifndef ASM
#include <rtems.h>
#endif
#include <rtems/score/cpu.h>
#include <rtems/powerpc/registers.h>
#include <rtems/powerpc/powerpc.h>
#ifndef ASM
#include <stdint.h>
#include <rtems/bspIo.h>
#include <rtems/system.h>
#include <rtems/score/cpu.h>
#include <libcpu/cpuIdent.h>
#define LINKER_SYMBOL( sym) extern char sym []
#define LINKER_SYMBOL(sym) extern char sym []
/**
* @brief Read one byte from @a src.
*/
static inline uint8_t ppc_read_byte( const volatile void *src)
static inline uint8_t ppc_read_byte(const volatile void *src)
{
uint8_t value;
uint8_t value;
asm volatile (
"lbz %0, 0(%1)"
: "=r" (value)
: "b" (src)
);
asm volatile (
"lbz %0, 0(%1)"
: "=r" (value)
: "b" (src)
);
return value;
return value;
}
/**
* @brief Read one half word from @a src.
*/
static inline uint16_t ppc_read_half_word( const volatile void *src)
static inline uint16_t ppc_read_half_word(const volatile void *src)
{
uint16_t value;
uint16_t value;
asm volatile (
"lhz %0, 0(%1)"
: "=r" (value)
: "b" (src)
);
asm volatile (
"lhz %0, 0(%1)"
: "=r" (value)
: "b" (src)
);
return value;
return value;
}
/**
* @brief Read one word from @a src.
*/
static inline uint32_t ppc_read_word( const volatile void *src)
static inline uint32_t ppc_read_word(const volatile void *src)
{
uint32_t value;
uint32_t value;
asm volatile (
"lwz %0, 0(%1)"
: "=r" (value)
: "b" (src)
);
asm volatile (
"lwz %0, 0(%1)"
: "=r" (value)
: "b" (src)
);
return value;
return value;
}
/**
* @brief Write one byte @a value to @a dest.
*/
static inline void ppc_write_byte( uint8_t value, volatile void *dest)
static inline void ppc_write_byte(uint8_t value, volatile void *dest)
{
asm volatile (
"stb %0, 0(%1)"
:
: "r" (value), "b" (dest)
);
asm volatile (
"stb %0, 0(%1)"
:
: "r" (value), "b" (dest)
);
}
/**
* @brief Write one half word @a value to @a dest.
*/
static inline void ppc_write_half_word( uint16_t value, volatile void *dest)
static inline void ppc_write_half_word(uint16_t value, volatile void *dest)
{
asm volatile (
"sth %0, 0(%1)"
:
: "r" (value), "b" (dest)
);
asm volatile (
"sth %0, 0(%1)"
:
: "r" (value), "b" (dest)
);
}
/**
* @brief Write one word @a value to @a dest.
*/
static inline void ppc_write_word( uint32_t value, volatile void *dest)
static inline void ppc_write_word(uint32_t value, volatile void *dest)
{
asm volatile (
"stw %0, 0(%1)" :
: "r" (value), "b" (dest)
);
asm volatile (
"stw %0, 0(%1)" :
: "r" (value), "b" (dest)
);
}
static inline void *ppc_stack_pointer()
static inline void *ppc_stack_pointer(void)
{
void *sp;
void *sp;
asm volatile (
"mr %0, 1"
: "=r" (sp)
);
asm volatile (
"mr %0, 1"
: "=r" (sp)
);
return sp;
return sp;
}
static inline void ppc_set_stack_pointer( void *sp)
static inline void ppc_set_stack_pointer(void *sp)
{
asm volatile (
"mr 1, %0"
:
: "r" (sp)
);
asm volatile (
"mr 1, %0"
:
: "r" (sp)
);
}
static inline void *ppc_link_register()
static inline void *ppc_link_register(void)
{
void *lr;
void *lr;
asm volatile (
"mflr %0"
: "=r" (lr)
);
asm volatile (
"mflr %0"
: "=r" (lr)
);
return lr;
return lr;
}
static inline void ppc_set_link_register( void *lr)
static inline void ppc_set_link_register(void *lr)
{
asm volatile (
"mtlr %0"
:
: "r" (lr)
);
asm volatile (
"mtlr %0"
:
: "r" (lr)
);
}
static inline uint32_t ppc_machine_state_register()
static inline uint32_t ppc_machine_state_register(void)
{
uint32_t msr;
uint32_t msr;
asm volatile (
"mfmsr %0"
: "=r" (msr)
);
asm volatile (
"mfmsr %0"
: "=r" (msr)
);
return msr;
return msr;
}
static inline void ppc_set_machine_state_register( uint32_t msr)
static inline void ppc_set_machine_state_register(uint32_t msr)
{
asm volatile (
"mtmsr %0"
:
: "r" (msr)
);
asm volatile (
"mtmsr %0"
:
: "r" (msr)
);
}
static inline void ppc_synchronize_data(void)
{
RTEMS_COMPILER_MEMORY_BARRIER();
asm volatile ("sync");
}
static inline void ppc_synchronize_instructions(void)
{
RTEMS_COMPILER_MEMORY_BARRIER();
asm volatile ("isync");
}
/**
@@ -196,21 +213,21 @@ static inline void ppc_set_machine_state_register( uint32_t msr)
* You can use this function to enable the external exceptions and restore the
* machine state with ppc_external_exceptions_disable() later.
*/
static inline uint32_t ppc_external_exceptions_enable()
static inline uint32_t ppc_external_exceptions_enable(void)
{
uint32_t current_msr;
uint32_t new_msr;
uint32_t current_msr;
uint32_t new_msr;
RTEMS_COMPILER_MEMORY_BARRIER();
RTEMS_COMPILER_MEMORY_BARRIER();
asm volatile (
"mfmsr %0;"
"ori %1, %0, 0x8000;"
"mtmsr %1"
: "=r" (current_msr), "=r" (new_msr)
);
asm volatile (
"mfmsr %0;"
"ori %1, %0, 0x8000;"
"mtmsr %1"
: "=r" (current_msr), "=r" (new_msr)
);
return current_msr;
return current_msr;
}
/**
@@ -218,59 +235,59 @@ static inline uint32_t ppc_external_exceptions_enable()
*
* @see ppc_external_exceptions_enable()
*/
static inline void ppc_external_exceptions_disable( uint32_t msr)
static inline void ppc_external_exceptions_disable(uint32_t msr)
{
ppc_set_machine_state_register( msr);
ppc_set_machine_state_register(msr);
RTEMS_COMPILER_MEMORY_BARRIER();
RTEMS_COMPILER_MEMORY_BARRIER();
}
static inline uint32_t ppc_decrementer_register()
static inline uint32_t ppc_decrementer_register(void)
{
uint32_t dec;
uint32_t dec;
PPC_Get_decrementer( dec);
PPC_Get_decrementer(dec);
return dec;
return dec;
}
static inline void ppc_set_decrementer_register( uint32_t dec)
static inline void ppc_set_decrementer_register(uint32_t dec)
{
PPC_Set_decrementer( dec);
PPC_Set_decrementer(dec);
}
/**
* @brief Preprocessor magic for stringification of @a x.
*/
#define PPC_STRINGOF( x) #x
#define PPC_STRINGOF(x) #x
/**
* @brief Returns the value of the Special Purpose Register with number @a spr.
*
* @note This macro uses a GNU C extension.
*/
#define PPC_SPECIAL_PURPOSE_REGISTER( spr) \
( { \
uint32_t val; \
asm volatile ( \
"mfspr %0, " PPC_STRINGOF( spr) \
: "=r" (val) \
); \
val;\
} )
#define PPC_SPECIAL_PURPOSE_REGISTER(spr) \
({ \
uint32_t val; \
asm volatile (\
"mfspr %0, " PPC_STRINGOF(spr) \
: "=r" (val) \
); \
val;\
} )
/**
* @brief Sets the Special Purpose Register with number @a spr to the value in
* @a val.
*/
#define PPC_SET_SPECIAL_PURPOSE_REGISTER( spr, val) \
do { \
asm volatile ( \
"mtspr " PPC_STRINGOF( spr) ", %0" \
: \
: "r" (val) \
); \
} while (0)
#define PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val) \
do { \
asm volatile (\
"mtspr " PPC_STRINGOF(spr) ", %0" \
: \
: "r" (val) \
); \
} while (0)
/**
* @brief Sets in the Special Purpose Register with number @a spr all bits
@@ -278,17 +295,17 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* Interrupts are disabled throughout this operation.
*/
#define PPC_SET_SPECIAL_PURPOSE_REGISTER_BITS( spr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable( level); \
val = PPC_SPECIAL_PURPOSE_REGISTER( spr); \
val |= mybits; \
PPC_SET_SPECIAL_PURPOSE_REGISTER( spr, val); \
rtems_interrupt_enable( level); \
} while (0)
#define PPC_SET_SPECIAL_PURPOSE_REGISTER_BITS(spr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable(level); \
val = PPC_SPECIAL_PURPOSE_REGISTER(spr); \
val |= mybits; \
PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val); \
rtems_interrupt_enable(level); \
} while (0)
/**
* @brief Sets in the Special Purpose Register with number @a spr all bits
@@ -297,19 +314,19 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* Interrupts are disabled throughout this operation.
*/
#define PPC_SET_SPECIAL_PURPOSE_REGISTER_BITS_MASKED( spr, bits, mask) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
uint32_t mymask = mask; \
rtems_interrupt_disable( level); \
val = PPC_SPECIAL_PURPOSE_REGISTER( spr); \
val &= ~mymask; \
val |= mybits; \
PPC_SET_SPECIAL_PURPOSE_REGISTER( spr, val); \
rtems_interrupt_enable( level); \
} while (0)
#define PPC_SET_SPECIAL_PURPOSE_REGISTER_BITS_MASKED(spr, bits, mask) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
uint32_t mymask = mask; \
rtems_interrupt_disable(level); \
val = PPC_SPECIAL_PURPOSE_REGISTER(spr); \
val &= ~mymask; \
val |= mybits; \
PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val); \
rtems_interrupt_enable(level); \
} while (0)
/**
* @brief Clears in the Special Purpose Register with number @a spr all bits
@@ -317,17 +334,17 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* Interrupts are disabled throughout this operation.
*/
#define PPC_CLEAR_SPECIAL_PURPOSE_REGISTER_BITS( spr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable( level); \
val = PPC_SPECIAL_PURPOSE_REGISTER( spr); \
val &= ~mybits; \
PPC_SET_SPECIAL_PURPOSE_REGISTER( spr, val); \
rtems_interrupt_enable( level); \
} while (0)
#define PPC_CLEAR_SPECIAL_PURPOSE_REGISTER_BITS(spr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable(level); \
val = PPC_SPECIAL_PURPOSE_REGISTER(spr); \
val &= ~mybits; \
PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val); \
rtems_interrupt_enable(level); \
} while (0)
/**
* @brief Returns the value of the Device Control Register with number @a dcr.
@@ -336,15 +353,15 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* @note This macro uses a GNU C extension.
*/
#define PPC_DEVICE_CONTROL_REGISTER( dcr) \
( { \
uint32_t val; \
asm volatile ( \
"mfdcr %0, " PPC_STRINGOF( dcr) \
: "=r" (val) \
); \
val;\
} )
#define PPC_DEVICE_CONTROL_REGISTER(dcr) \
({ \
uint32_t val; \
asm volatile (\
"mfdcr %0, " PPC_STRINGOF(dcr) \
: "=r" (val) \
); \
val;\
} )
/**
* @brief Sets the Device Control Register with number @a dcr to the value in
@@ -352,14 +369,14 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* The PowerPC 4XX family has Device Control Registers.
*/
#define PPC_SET_DEVICE_CONTROL_REGISTER( dcr, val) \
do { \
asm volatile ( \
"mtdcr " PPC_STRINGOF( dcr) ", %0" \
: \
: "r" (val) \
); \
} while (0)
#define PPC_SET_DEVICE_CONTROL_REGISTER(dcr, val) \
do { \
asm volatile (\
"mtdcr " PPC_STRINGOF(dcr) ", %0" \
: \
: "r" (val) \
); \
} while (0)
/**
* @brief Sets in the Device Control Register with number @a dcr all bits
@@ -367,17 +384,17 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* Interrupts are disabled throughout this operation.
*/
#define PPC_SET_DEVICE_CONTROL_REGISTER_BITS( dcr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable( level); \
val = PPC_DEVICE_CONTROL_REGISTER( dcr); \
val |= mybits; \
PPC_SET_DEVICE_CONTROL_REGISTER( dcr, val); \
rtems_interrupt_enable( level); \
} while (0)
#define PPC_SET_DEVICE_CONTROL_REGISTER_BITS(dcr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable(level); \
val = PPC_DEVICE_CONTROL_REGISTER(dcr); \
val |= mybits; \
PPC_SET_DEVICE_CONTROL_REGISTER(dcr, val); \
rtems_interrupt_enable(level); \
} while (0)
/**
* @brief Sets in the Device Control Register with number @a dcr all bits
@@ -386,19 +403,19 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* Interrupts are disabled throughout this operation.
*/
#define PPC_SET_DEVICE_CONTROL_REGISTER_BITS_MASKED( dcr, bits, mask) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
uint32_t mymask = mask; \
rtems_interrupt_disable( level); \
val = PPC_DEVICE_CONTROL_REGISTER( dcr); \
val &= ~mymask; \
val |= mybits; \
PPC_SET_DEVICE_CONTROL_REGISTER( dcr, val); \
rtems_interrupt_enable( level); \
} while (0)
#define PPC_SET_DEVICE_CONTROL_REGISTER_BITS_MASKED(dcr, bits, mask) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
uint32_t mymask = mask; \
rtems_interrupt_disable(level); \
val = PPC_DEVICE_CONTROL_REGISTER(dcr); \
val &= ~mymask; \
val |= mybits; \
PPC_SET_DEVICE_CONTROL_REGISTER(dcr, val); \
rtems_interrupt_enable(level); \
} while (0)
/**
* @brief Clears in the Device Control Register with number @a dcr all bits
@@ -406,52 +423,54 @@ static inline void ppc_set_decrementer_register( uint32_t dec)
*
* Interrupts are disabled throughout this operation.
*/
#define PPC_CLEAR_DEVICE_CONTROL_REGISTER_BITS( dcr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable( level); \
val = PPC_DEVICE_CONTROL_REGISTER( dcr); \
val &= ~mybits; \
PPC_SET_DEVICE_CONTROL_REGISTER( dcr, val); \
rtems_interrupt_enable( level); \
} while (0)
#define PPC_CLEAR_DEVICE_CONTROL_REGISTER_BITS(dcr, bits) \
do { \
rtems_interrupt_level level; \
uint32_t val; \
uint32_t mybits = bits; \
rtems_interrupt_disable(level); \
val = PPC_DEVICE_CONTROL_REGISTER(dcr); \
val &= ~mybits; \
PPC_SET_DEVICE_CONTROL_REGISTER(dcr, val); \
rtems_interrupt_enable(level); \
} while (0)
static inline uint32_t ppc_time_base()
static inline uint32_t ppc_time_base(void)
{
uint32_t val;
uint32_t val;
CPU_Get_timebase_low( val);
CPU_Get_timebase_low(val);
return val;
return val;
}
static inline void ppc_set_time_base( uint32_t val)
static inline void ppc_set_time_base(uint32_t val)
{
PPC_SET_SPECIAL_PURPOSE_REGISTER( TBWL, val);
PPC_SET_SPECIAL_PURPOSE_REGISTER(TBWL, val);
}
static inline uint32_t ppc_time_base_upper()
static inline uint32_t ppc_time_base_upper(void)
{
return PPC_SPECIAL_PURPOSE_REGISTER( TBRU);
return PPC_SPECIAL_PURPOSE_REGISTER(TBRU);
}
static inline void ppc_set_time_base_upper( uint32_t val)
static inline void ppc_set_time_base_upper(uint32_t val)
{
PPC_SET_SPECIAL_PURPOSE_REGISTER( TBWU, val);
PPC_SET_SPECIAL_PURPOSE_REGISTER(TBWU, val);
}
static inline uint64_t ppc_time_base_64()
static inline uint64_t ppc_time_base_64(void)
{
return PPC_Get_timebase_register();
return PPC_Get_timebase_register();
}
static inline void ppc_set_time_base_64( uint64_t val)
static inline void ppc_set_time_base_64(uint64_t val)
{
PPC_Set_timebase_register( val);
PPC_Set_timebase_register(val);
}
void ppc_code_copy(void *dest, const void *src, size_t n);
#else /* ASM */
#include <rtems/asm.h>
@@ -523,7 +542,7 @@ static inline void ppc_set_time_base_64( uint64_t val)
mtmsr \level
.endm
#define LINKER_SYMBOL( sym) .extern sym
#define LINKER_SYMBOL(sym) .extern sym
#endif /* ASM */