From 42b9bf02bafed0054566c8526601d557d6917d79 Mon Sep 17 00:00:00 2001 From: mahi Date: Tue, 3 Jan 2012 12:13:51 +0100 Subject: [PATCH] Added support for diab5.6. Corrected build config for mpc5516it --- boards/mpc5516it/build_config.mk | 1 - include/ppc/Cpu.h | 59 ++++++++++++++++++++++---------- system/EcuM/EcuM.c | 10 ++++-- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/boards/mpc5516it/build_config.mk b/boards/mpc5516it/build_config.mk index 526c2f5c..f3e9149c 100644 --- a/boards/mpc5516it/build_config.mk +++ b/boards/mpc5516it/build_config.mk @@ -6,7 +6,6 @@ ARCH_MCU=mpc5516 # CFG (y/n) macros CFG=PPC BOOKE E200Z1 MPC55XX MPC5516 BRD_MPC5516IT -CFG+=VLE # What buildable modules does this board have, # default or private diff --git a/include/ppc/Cpu.h b/include/ppc/Cpu.h index ed2f0ae1..be91bfde 100644 --- a/include/ppc/Cpu.h +++ b/include/ppc/Cpu.h @@ -14,21 +14,15 @@ * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - #ifndef CPU_H #define CPU_H #include "Std_Types.h" typedef uint32_t imask_t; -#if defined(__DCC__) -#include -#endif + +//#if defined(__DCC__) +//#include +//#endif // Used if we are running a T32 instruction set simulator #define SIMULATOR() (SIU.MIDR.R==0) @@ -144,9 +138,13 @@ typedef uint32_t imask_t; * Sets a value to a specific SPR register */ #if defined(__DCC__) -#define set_spr(spr_nr, val) (__mtspr(spr_nr,val)) +asm void set_spr(uint32 spr_nr, uint32 val) +{ +%reg val; con spr_nr + mtspr spr_nr, val +} #else -#define set_spr(spr_nr, val) \ +# define set_spr(spr_nr, val) \ asm volatile (" mtspr " STRINGIFY__(spr_nr) ",%[_val]" : : [_val] "r" (val)) #endif /** @@ -156,7 +154,11 @@ typedef uint32_t imask_t; */ #if defined(__DCC__) -#define get_spr(spr_nr) (__mfspr(spr_nr)) +asm uint32 get_spr(uint32 spr_nr) +{ +% con spr_nr + mfspr r3, spr_nr +} #else #define get_spr(spr_nr) CC_EXTENSION \ ({\ @@ -171,7 +173,10 @@ typedef uint32_t imask_t; * @return */ #if defined(__DCC__) -#define get_msr() (__mfmsr()) +asm volatile unsigned long get_msr() +{ + mfmsr r3 +} #else static inline unsigned long get_msr() { uint32_t msr; @@ -186,9 +191,12 @@ static inline unsigned long get_msr() { * @param msr */ #if defined(__DCC__) -#define set_msr(msr)\ - (__mtmsr(msr));\ - (__isync()); +asm volatile void set_msr(unsigned long msr) +{ +% reg msr + mtmsr msr + isync +} #else static inline void set_msr(unsigned long msr) { asm volatile ("mtmsr %0" : : "r" (msr) ); @@ -201,7 +209,11 @@ static inline void set_msr(unsigned long msr) { /* Count the number of consecutive zero bits starting at ppc-bit 0 */ #if defined(__DCC__) -#define cntlzw(val) (__cntlzw(val)) +asm volatile unsigned int cntlzw(unsigned int val) +{ +% reg val + cntlzw r3, val +} #else static inline unsigned int cntlzw(unsigned int val) { @@ -230,14 +242,23 @@ static inline unsigned long _Irq_Disable_save(void) } /*-----------------------------------------------------------------*/ + +static inline void _Irq_Disable_restore(unsigned long flags) +{ + set_msr(flags); +} + +#if 0 #if defined(__DCC__) -#define _Irq_Disable_restore(flags) (__mtmsr(flags)) +#define _Irq_Disable_restore(flags) (set_msr(flags)) #else static inline void _Irq_Disable_restore(unsigned long flags) { + set_msr(flags); asm volatile ("mtmsr %0" : : "r" (flags) ); } #endif +#endif /*-----------------------------------------------------------------*/ #if defined(__DCC__) #else diff --git a/system/EcuM/EcuM.c b/system/EcuM/EcuM.c index 009ed5d4..d1f7856b 100644 --- a/system/EcuM/EcuM.c +++ b/system/EcuM/EcuM.c @@ -22,7 +22,9 @@ #include "EcuM_Internals.h" #include "EcuM_Cbk.h" #include "Mcu.h" +#if defined(USE_DET) #include "Det.h" +#endif #include "isr.h" #if defined(USE_NVM) #include "NvM.h" @@ -33,6 +35,10 @@ EcuM_GlobalType internal_data; +#if !defined(USE_DET) && defined(ECUM_DEV_ERROR_DETECT) +#error EcuM configuration error. DET is not enabled when ECUM_DEV_ERROR_DETECT is set +#endif + void EcuM_Init( void ) { Std_ReturnType status; @@ -111,7 +117,7 @@ void EcuM_StartupTwo(void) // Start timer to wait for NVM job to complete tickTimerStatus = GetCounterValue(Os_Arc_OsTickCounter , &tickTimerStart); if (tickTimerStatus != E_OK) { - Det_ReportError(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR); + DET_REPORTERROR(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR); } #endif @@ -128,7 +134,7 @@ void EcuM_StartupTwo(void) tickTimer = tickTimerStart; // Save this because the GetElapsedCounterValue() will destroy it. tickTimerStatus = GetElapsedCounterValue(Os_Arc_OsTickCounter, &tickTimer, &tickTimerElapsed); if (tickTimerStatus != E_OK) { - Det_ReportError(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR); + DET_REPORTERROR(MODULE_ID_ECUM, 0, ECUM_ARC_STARTUPTWO_ID, ECUM_E_ARC_TIMERERROR); } } while( (readAllResult == NVM_REQ_PENDING) && (tickTimerElapsed < internal_data.config->EcuMNvramReadAllTimeout) ); #endif -- 2.39.2