Re: [pok-devel] ARINC - partition

[ Thread Index | Date Index | More lists.tuxfamily.org/pok-devel Archives ]


Hi,

You are right for the SET_PARTITION_MODE. it's only used to set the current mode to normal after the initialization or to set the partition back to idle or warm/cold start mode when a fault is detected and processed.

I attach a little patch at this mail:
- Add the GET_PARTITION_STATUS function (without period, lock_level and start_condition values for the moment) :
	- Add a struct in the kernel for ARINC compliance
	- Add a syscall
- Little modification in SET_PARTITION_MODE:
	- Add check in libpok function
	- Modification on the kernel to to permit some new transition between the mode.

I will complete GET_PARTITION_STATUS gradually. For now I must concentrate on other arinc function for the PARSEC project.

I look forward to hearing from you about the patch,
Thanks,
Matias
Index: kernel/include/core/partition.h
===================================================================
--- kernel/include/core/partition.h	(révision 26)
+++ kernel/include/core/partition.h	(copie de travail)
@@ -107,6 +107,17 @@
 #endif
 } pok_partition_t;
 
+typedef struct
+{
+  uint64_t		period;
+  uint64_t		duration;
+  uint8_t		identifier;
+  uint32_t		lock_level;
+  pok_partition_mode_t	operating_mode;
+  uint32_t		start_condition;
+} pok_arinc_partition_status_t;
+
+
 extern pok_partition_t pok_partitions[POK_CONFIG_NB_PARTITIONS];
 
 /**
@@ -144,6 +155,8 @@
 
 pok_ret_t pok_partition_restart_thread (const uint32_t tid);
 
+pok_ret_t pok_partition_get_status (pok_arinc_partition_status_t *status);
+
 #endif /* __POK_NEEDS_PARTITIONS */
 
 #endif /* __POK_PARTITION_H__ */
Index: kernel/include/core/syscall.h
===================================================================
--- kernel/include/core/syscall.h	(révision 26)
+++ kernel/include/core/syscall.h	(copie de travail)
@@ -66,6 +66,7 @@
 #endif
 #ifdef POK_NEEDS_PARTITIONS
    POK_SYSCALL_PARTITION_SET_MODE                  = 404,
+   POK_SYSCALL_PARTITION_GET_STATUS                = 405,
 #endif
 #ifdef POK_NEEDS_IO
    POK_SYSCALL_INB                                 = 501,
Index: kernel/core/partition.c
===================================================================
--- kernel/core/partition.c	(révision 26)
+++ kernel/core/partition.c	(copie de travail)
@@ -48,7 +48,9 @@
 
 uint8_t			 pok_partitions_index = 0;
 
+extern uint64_t		pok_sched_slots[];
 
+
 /**
  **\brief Setup the scheduler used in partition pid
  */
@@ -256,7 +258,7 @@
           * to the NORMAL mode is currently in the INIT mode
           */
 
-         if (pok_partitions[pid].mode != POK_PARTITION_MODE_INIT_WARM)
+         if (pok_partitions[pid].mode == POK_PARTITION_MODE_IDLE)
          {
             return POK_ERRNO_PARTITION_MODE;
          }
@@ -285,16 +287,8 @@
 
 #ifdef POK_NEEDS_ERROR_HANDLING
       case POK_PARTITION_MODE_STOPPED:
-
+ 
          /*
-          * The partition can be stopped once it was in the normal mode
-          */
-         if (pok_partitions[pid].mode != POK_PARTITION_MODE_NORMAL)
-         {
-            return POK_ERRNO_PARTITION_MODE;
-         }
-
-         /*
           * Only the error thread can stop the partition
           */
          if ((POK_CURRENT_PARTITION.thread_error == 0 ) ||
@@ -308,10 +302,11 @@
          break;
 
       case POK_PARTITION_MODE_INIT_WARM:
-         if (pok_partitions[pid].mode != POK_PARTITION_MODE_NORMAL)
-         {
-            return POK_ERRNO_PARTITION_MODE;
-         }
+      case POK_PARTITION_MODE_INIT_COLD:
+	if (pok_partitions[pid].mode == POK_PARTITION_MODE_INIT_COLD && mode == POK_PARTITION_MODE_INIT_WARM)
+          { 
+             return POK_ERRNO_PARTITION_MODE;
+          }
 
          /*
           * Check that only the error thread can restart the partition
@@ -327,7 +322,7 @@
           * was in the NORMAL mode. So, we check the previous mode
           */
 
-         pok_partitions[pid].mode = POK_PARTITION_MODE_INIT_WARM;  /* Here, we change the mode */
+         pok_partitions[pid].mode = mode;  /* Here, we change the mode */
 
          pok_partition_reinit (pid);
 
@@ -367,6 +362,20 @@
    return (pok_partition_set_mode (POK_SCHED_CURRENT_PARTITION, mode));
 }
 
+/**
+ * Get partition information. Used for ARINC GET_PARTITION_STATUS function.
+ */
+pok_ret_t pok_partition_get_status (pok_arinc_partition_status_t *status)
+{
+  status->identifier = POK_SCHED_CURRENT_PARTITION;
+  status->period = 0;
+  status->duration = pok_sched_slots[POK_SCHED_CURRENT_PARTITION];
+  status->lock_level = 0;
+  status->operating_mode = POK_CURRENT_PARTITION.mode;
+  status->start_condition = 0;
+  return POK_ERRNO_OK;
+}
+
 #ifdef POK_NEEDS_ERROR_HANDLING
 
 /**
Index: kernel/core/syscall.c
===================================================================
--- kernel/core/syscall.c	(révision 26)
+++ kernel/core/syscall.c	(copie de travail)
@@ -150,6 +150,9 @@
       case POK_SYSCALL_PARTITION_SET_MODE:
          return pok_partition_set_mode_current ((pok_partition_mode_t)args->arg1);
          break;
+      case POK_SYSCALL_PARTITION_GET_STATUS:
+	return pok_partition_get_status ((pok_arinc_partition_status_t*)(args->arg1 + infos->base_addr));
+         break;
 #endif
 
 #ifdef POK_NEEDS_ERROR_HANDLING
Index: libpok/include/core/partition.h
===================================================================
--- libpok/include/core/partition.h	(révision 26)
+++ libpok/include/core/partition.h	(copie de travail)
@@ -32,6 +32,9 @@
    POK_PARTITION_MODE_STOPPED   = 6,
 }pok_partition_mode_t;
 
+
 #define pok_partition_set_mode(mode) pok_syscall2(POK_SYSCALL_PARTITION_SET_MODE,(uint32_t)mode,0)
 
+#define pok_partition_get_status(status) pok_syscall2(POK_SYSCALL_PARTITION_GET_STATUS,(uint32_t)status,0)
+
 #endif
Index: libpok/include/core/syscall.h
===================================================================
--- libpok/include/core/syscall.h	(révision 26)
+++ libpok/include/core/syscall.h	(copie de travail)
@@ -66,6 +66,7 @@
 #endif
 #ifdef POK_NEEDS_PARTITIONS
    POK_SYSCALL_PARTITION_SET_MODE                  = 404,
+   POK_SYSCALL_PARTITION_GET_STATUS                  = 405,
 #endif
 #ifdef POK_NEEDS_IO
    POK_SYSCALL_INB                                 = 501,
Index: libpok/arinc653/partition.c
===================================================================
--- libpok/arinc653/partition.c	(révision 26)
+++ libpok/arinc653/partition.c	(copie de travail)
@@ -27,16 +27,18 @@
 void GET_PARTITION_STATUS (PARTITION_STATUS_TYPE *partition_status,
                            RETURN_CODE_TYPE      *return_code)
 {
-   (void) partition_status;
-   *return_code = NOT_AVAILABLE;
+  pok_partition_get_status (partition_status);
+  *return_code = NO_ERROR;
 }
 
 void SET_PARTITION_MODE (OPERATING_MODE_TYPE operating_mode,
                          RETURN_CODE_TYPE *return_code)
 {
-   pok_partition_mode_t core_mode = POK_PARTITION_MODE_NORMAL;
+  pok_partition_mode_t core_mode;
    pok_ret_t            core_ret;
+   PARTITION_STATUS_TYPE curent_mode;
 
+   pok_partition_get_status (&curent_mode);
    switch (operating_mode)
    {
       case IDLE:
@@ -49,17 +51,29 @@
 
       case COLD_START:
          core_mode = POK_PARTITION_MODE_INIT_COLD;
-         break;
+         *return_code = NOT_AVAILABLE;
+	 return;
 
       case WARM_START:
          core_mode = POK_PARTITION_MODE_INIT_WARM;
          break;
 
       default:
-         *return_code = INVALID_MODE;
+         *return_code = INVALID_PARAM;
          return;
    }
 
+   if (curent_mode.OPERATING_MODE == core_mode)
+     {
+       *return_code = NO_ACTION;
+       return ;
+     }
+   if (curent_mode.OPERATING_MODE == POK_PARTITION_MODE_INIT_COLD &&
+       core_mode == POK_PARTITION_MODE_INIT_WARM)
+     {
+       *return_code = INVALID_MODE;
+       return ;
+     }
    core_ret = pok_partition_set_mode (core_mode);
    *return_code = core_ret;
 }
Index: doc/develguide/pok-devel.tex
===================================================================
--- doc/develguide/pok-devel.tex	(révision 26)
+++ doc/develguide/pok-devel.tex	(copie de travail)
@@ -247,7 +247,7 @@
 needs all functions of \texttt{libc/stdio}.
 
 Then, each function of libpok is surrounded with a \texttt{POK\_CONFIG\_NEEDS\_FUNC*}
-or \texttt{POK\_CONFIG\_NEEDS\_*}. \LARGE{You have to introduce that in your code when
+or \texttt{POK\_CONFIG\_NEEDS\_*}. {\LARGE You have to introduce that in your code when
 you introduce new services in POK}.
 
 Then, the file in \texttt{include/core/dependencies.h} specifies which functions


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/