]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Bugfix for installing ISRs
authormahi <devnull@localhost>
Wed, 22 Jun 2011 19:15:38 +0000 (21:15 +0200)
committermahi <devnull@localhost>
Wed, 22 Jun 2011 19:15:38 +0000 (21:15 +0200)
arch/ppc/mpc55xx/kernel/irq_types.h
common/msl_port.c
include/Os.h
include/isr.h
system/kernel/isr.c

index 7a057312c57740541062958b7de78170e6ae8f60..9ccef9f9a3ed69df17523d97e184d23e9d57fc83 100644 (file)
@@ -888,6 +888,7 @@ typedef enum
        CPU_CORE1\r
 } Cpu_t;\r
 \r
+/* Offset from exceptions to interrupts */\r
 #define IRQ_INTERRUPT_OFFSET           0\r
 \r
 #endif /* IRQ_H_ */\r
index d88feb0def94ab8ad79b69bf36356f1a606b6975..da5fe48c158b693bf9cb4bd3e2b1a1c34390ef13 100644 (file)
@@ -9,6 +9,7 @@
 Methods called by MW MSL libraries to perform console IO:\r
 */\r
 \r
+#include "Os.h"\r
 #include "stddef.h"\r
 \r
 #ifdef USE_TTY_WINIDEA\r
@@ -108,6 +109,8 @@ void __init_user(void)
 \r
 void exit(int exit ) {\r
        (void)exit;\r
+       DisableAllInterrupts();\r
+       while(1);\r
 }\r
 \r
 \r
index be09514c579e2625bdbbddedd009e33e7339bdea..eb6ef358dce8c989b31e56f90555a43ad314d557 100644 (file)
 \r
 typedef uint8 StatusType;\r
 \r
+#if (OS_ISR_CNT > OS_ISR_MAX_CNT)\r
+#error OS configuration error. OS_ISR_MAX_CNT must be bigger or equal to OS_ISR_CNT\r
+#endif\r
+\r
 #define E_OS_ACCESS (StatusType)1               /**< STD OSEK */\r
 #define        E_OS_CALLEVEL (StatusType)2             /**< STD OSEK */\r
 #define        E_OS_ID (StatusType)3                   /**< STD OSEK */\r
index a9ad168a468fef9ba9a5b3455f633dcc63eb214d..3371a61abfc88d263dd7b109f91f18d388ca715b 100644 (file)
@@ -190,7 +190,7 @@ typedef struct OsIsrConst {
 /*\r
  *\r
  */\r
-typedef struct {\r
+typedef struct OsIsrVar{\r
        ISRType id;\r
 //     OsIsrStackType          stack;\r
        int                                     state;\r
index 12fb916e976cbe382ae018bf901d17d93b032255..f4201b0fce6e97f7df21d12b81fa64ab2e6a0fd9 100644 (file)
@@ -27,6 +27,7 @@
 #include "isr.h"\r
 #include "irq.h"\r
 \r
+#define ILL_VECTOR     0xff\r
 \r
 extern uint8_t Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
 #if OS_ISR_CNT!=0\r
@@ -75,6 +76,9 @@ void Os_IsrInit( void ) {
 \r
        Irq_Init();\r
 \r
+       /* Probably something smarter, but I cant figure out what */\r
+       memset(&Os_VectorToIsr[OS_ISR_CNT],ILL_VECTOR,OS_ISR_MAX_CNT-OS_ISR_CNT);\r
+\r
 #if OS_ISR_CNT != 0\r
        /* Attach the interrupts */\r
        for (int i = 0; i < Os_Sys.isrCnt; i++) {\r
@@ -83,7 +87,6 @@ void Os_IsrInit( void ) {
 #endif\r
 }\r
 \r
-\r
 /**\r
  * Adds an ISR to a list of Isr's. The ISRType (id) is returned\r
  * for the "created" ISR.\r
@@ -93,13 +96,28 @@ void Os_IsrInit( void ) {
  */\r
 ISRType Os_IsrAdd( const OsIsrConstType * restrict isrPtr ) {\r
        ISRType id;\r
+       ISRType installedId;\r
 \r
        assert( isrPtr != NULL );\r
+       assert( (isrPtr->vector + IRQ_INTERRUPT_OFFSET) < NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS );\r
 \r
-       id = Os_Sys.isrCnt++;\r
-       Os_IsrVarList[id].constPtr = isrPtr;\r
-       Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ] = id;\r
-       Irq_EnableVector( isrPtr->vector, isrPtr->priority, Os_ApplGetCore(isrPtr->appOwner )  );\r
+       /* Check if we already have installed it */\r
+       installedId = Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ];\r
+\r
+       if( installedId != ILL_VECTOR ) {\r
+               /* The vector is already installed */\r
+               id = installedId;\r
+       } else {\r
+               /* It a new vector */\r
+               id = Os_Sys.isrCnt++;\r
+               /* Since OS_ISR_MAX_CNT defines the allocation limit for Os_IsrVarList,\r
+                * we must not allocate more IDs than that */\r
+               assert(id<OS_ISR_MAX_CNT);\r
+\r
+               Os_IsrVarList[id].constPtr = isrPtr;\r
+               Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ] = id;\r
+               Irq_EnableVector( isrPtr->vector, isrPtr->priority, Os_ApplGetCore(isrPtr->appOwner )  );\r
+       }\r
 \r
        return id;\r
 }\r