Re: [pok-devel] ARINC - partition

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


Hi,

The v2 :D

I look forward to hearing from you about the v2,
Matias


----- Mail original -----
> De: "Julien Delange" <julien@xxxxxxxxx>
> À: pok-devel@xxxxxxxxxxxxxxxxxxx
> Envoyé: Lundi 13 Février 2012 21:56:32
> Objet: Re: [pok-devel] ARINC - partition
>
> Le Mon, Feb 13, 2012 at 01:57:33PM +0100, Matias Hastaran :
> > I look forward to hearing from you about the patch,
>
> Dear Mathias,
>
> Thanks for submitting this patch, this is a good step to ensure the
> ARINC653 compatibility, especially because we support just a subset
> of
> the standard. However, I have some comments :
> 1. The kernel would not be specific to any existing partitioning
>    standard. Instead, we should keep the kernel generic and as small
>    as
>    possible.
> 2. We should not duplicate structures and especially members between
>    different functions. This would make difficult to keep system
>    consistency (the same requirement/property in two structures could
>    be
>    quite confusing and difficult to ensure that parameters have the
>    same
>    value everytime). In particular, the period/duration/identifier
>    can be retrieved from the existing pok_partition_t structure.
> 3. Instead of making a new structure in the kernel, it would be
> better
>    to extend the pok_partition_t structure by:
>      a. Adding a start condition
> 	 b. Adding the lock level
> 4. One these parameters are added, you can add new syscall to get
>    atomically the period, duration, lock_level, operating_mode and
>    start
>    condition. Then, the arinc653 layer in libpok can fill the
>    ARINC653-dedicated  structure by performing appropriate syscall to
>    the kernel.
>
> But we have to keep in mind that we have to be standard-agnostic on
> the
> kernel-side and avoid any specific function against a standard. As a
> result, all ARINC653 functions should be kept in the libpok/ library,
> and nothing related to arinc should reside in the kernel.
>
> Sorry for this long list of comments and this first shot is quite
> promising and it could be useful to keep the initial guidelines,
> especially for potential regular committers :-)
>
> Best,
>
>
>
>
Index: kernel/include/core/partition.h
===================================================================
--- kernel/include/core/partition.h	(révision 26)
+++ kernel/include/core/partition.h	(copie de travail)
@@ -51,6 +51,15 @@
    POK_PARTITION_MODE_STOPPED   = 6, /**< Partition is stopped, it will no longer be executed */
 }pok_partition_mode_t;
 
+typedef enum
+{
+  NORMAL_START          = 0,
+  PARTITION_RESTART     = 1,
+  HM_MODULE_RESTART     = 2,
+  HM_PARTITION_RESTART  = 3
+}pok_start_condition_t;
+
+
 /*!
  * \struct pok_partition_t
  * \brief This structure contains all needed information for partition management
@@ -105,6 +114,9 @@
   uint16_t		io_min;                        /**< If the partition is allowed to perform I/O, the lower bound of the I/O */
   uint16_t		io_max;                        /**< If the partition is allowed to perform I/O, the uppder bound of the I/O */
 #endif
+
+  uint32_t		lock_level;
+  pok_start_condition_t	start_condition;
 } pok_partition_t;
 
 extern pok_partition_t pok_partitions[POK_CONFIG_NB_PARTITIONS];
@@ -144,6 +156,18 @@
 
 pok_ret_t pok_partition_restart_thread (const uint32_t tid);
 
+pok_ret_t pok_current_partition_get_id (uint8_t *id);
+
+pok_ret_t pok_current_partition_get_period (uint64_t *period);
+
+pok_ret_t pok_current_partition_get_duration (uint64_t *duration);
+
+pok_ret_t pok_current_partition_get_operating_mode (pok_partition_mode_t *op_mode);
+
+pok_ret_t pok_current_partition_get_lock_level (uint32_t *lock_level);
+
+pok_ret_t pok_current_partition_get_start_condition (pok_start_condition_t *start_condition);
+
 #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,12 @@
 #endif
 #ifdef POK_NEEDS_PARTITIONS
    POK_SYSCALL_PARTITION_SET_MODE                  = 404,
+   POK_SYSCALL_PARTITION_GET_ID                    = 405,
+   POK_SYSCALL_PARTITION_GET_PERIOD                = 406,
+   POK_SYSCALL_PARTITION_GET_DURATION              = 407,
+   POK_SYSCALL_PARTITION_GET_LOCK_LEVEL            = 408,
+   POK_SYSCALL_PARTITION_GET_OPERATING_MODE        = 409,
+   POK_SYSCALL_PARTITION_GET_START_CONDITION       = 410,
 #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
  */
@@ -229,6 +231,9 @@
        * Load the partition in its address space
        */
       pok_partitions[i].thread_main_entry = program_entry;
+      
+      pok_partitions[i].lock_level = 0;
+      pok_partitions[i].start_condition = NORMAL_START;
 
 #ifdef POK_NEEDS_INSTRUMENTATION
       pok_instrumentation_partition_archi (i);
@@ -256,7 +261,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 +290,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 +305,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 +325,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 +365,45 @@
    return (pok_partition_set_mode (POK_SCHED_CURRENT_PARTITION, mode));
 }
 
+/**
+ * Get partition information. Used for ARINC GET_PARTITION_STATUS function.
+ */
+pok_ret_t pok_current_partition_get_id (uint8_t *id)
+{
+  *id = POK_SCHED_CURRENT_PARTITION;
+  return POK_ERRNO_OK;
+}
+
+pok_ret_t pok_current_partition_get_period (uint64_t *period)
+{
+  *period = POK_CURRENT_PARTITION.period;
+  return POK_ERRNO_OK;
+}
+
+pok_ret_t pok_current_partition_get_duration (uint64_t *duration)
+{
+  *duration = pok_sched_slots[POK_SCHED_CURRENT_PARTITION];
+  return POK_ERRNO_OK;
+}
+
+pok_ret_t pok_current_partition_get_operating_mode (pok_partition_mode_t *op_mode)
+{
+  *op_mode = POK_CURRENT_PARTITION.mode;
+  return POK_ERRNO_OK;
+}
+
+pok_ret_t pok_current_partition_get_lock_level (uint32_t *lock_level)
+{
+  *lock_level = POK_CURRENT_PARTITION.lock_level;
+  return POK_ERRNO_OK;
+}
+
+pok_ret_t pok_current_partition_get_start_condition (pok_start_condition_t *start_condition)
+{
+  *start_condition = POK_CURRENT_PARTITION.start_condition;
+  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,24 @@
       case POK_SYSCALL_PARTITION_SET_MODE:
          return pok_partition_set_mode_current ((pok_partition_mode_t)args->arg1);
          break;
+      case POK_SYSCALL_PARTITION_GET_ID:
+	return pok_current_partition_get_id ((uint8_t*)(args->arg1 + infos->base_addr));
+         break;
+      case POK_SYSCALL_PARTITION_GET_PERIOD:
+	return pok_current_partition_get_period ((uint64_t*)(args->arg1 + infos->base_addr));
+	 break;
+      case POK_SYSCALL_PARTITION_GET_DURATION:
+	return pok_current_partition_get_duration ((uint64_t*)(args->arg1 + infos->base_addr));
+	 break;
+      case POK_SYSCALL_PARTITION_GET_LOCK_LEVEL:
+	return pok_current_partition_get_lock_level ((uint32_t*)(args->arg1 + infos->base_addr));
+         break;
+      case POK_SYSCALL_PARTITION_GET_OPERATING_MODE:
+	return pok_current_partition_get_operating_mode ((pok_partition_mode_t*)(args->arg1 + infos->base_addr));
+         break;
+      case POK_SYSCALL_PARTITION_GET_START_CONDITION:
+	return pok_current_partition_get_start_condition ((pok_start_condition_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,18 @@
    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_current_partition_get_id(id) pok_syscall2(POK_SYSCALL_PARTITION_GET_ID,(uint32_t)id,0)
+
+#define pok_current_partition_get_period(period) pok_syscall2(POK_SYSCALL_PARTITION_GET_PERIOD,(uint32_t)period,0)
+
+#define pok_current_partition_get_duration(duration) pok_syscall2(POK_SYSCALL_PARTITION_GET_DURATION,(uint32_t)duration,0)
+
+#define pok_current_partition_get_lock_level(lock_level) pok_syscall2(POK_SYSCALL_PARTITION_GET_LOCK_LEVEL,(uint32_t)lock_level,0)
+
+#define pok_current_partition_get_operating_mode(op_mode) pok_syscall2(POK_SYSCALL_PARTITION_GET_OPERATING_MODE,(uint32_t)op_mode,0)
+
+#define pok_current_partition_get_start_condition(start_condition) pok_syscall2(POK_SYSCALL_PARTITION_GET_START_CONDITION,(uint32_t)start_condition,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,12 @@
 #endif
 #ifdef POK_NEEDS_PARTITIONS
    POK_SYSCALL_PARTITION_SET_MODE                  = 404,
+   POK_SYSCALL_PARTITION_GET_ID	                   = 405,
+   POK_SYSCALL_PARTITION_GET_PERIOD                = 406,
+   POK_SYSCALL_PARTITION_GET_DURATION              = 407,
+   POK_SYSCALL_PARTITION_GET_LOCK_LEVEL            = 408,
+   POK_SYSCALL_PARTITION_GET_OPERATING_MODE        = 409,
+   POK_SYSCALL_PARTITION_GET_START_CONDITION       = 410,
 #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,23 @@
 void GET_PARTITION_STATUS (PARTITION_STATUS_TYPE *partition_status,
                            RETURN_CODE_TYPE      *return_code)
 {
-   (void) partition_status;
-   *return_code = NOT_AVAILABLE;
+  pok_current_partition_get_id(&partition_status->IDENTIFIER);
+  pok_current_partition_get_period(&partition_status->PERIOD);
+  pok_current_partition_get_duration(&partition_status->DURATION);
+  pok_current_partition_get_lock_level(&partition_status->LOCK_LEVEL);
+  pok_current_partition_get_operating_mode(&partition_status->OPERATING_MODE);
+  pok_current_partition_get_start_condition(&partition_status->START_CONDITION);
+  *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_ret_t            core_ret;
+  pok_partition_mode_t core_mode;
+  pok_ret_t            core_ret;
+  pok_partition_mode_t current_mode;
 
+  pok_current_partition_get_operating_mode(&current_mode);
    switch (operating_mode)
    {
       case IDLE:
@@ -49,17 +56,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 (current_mode == core_mode)
+     {
+       *return_code = NO_ACTION;
+       return ;
+     }
+   if (current_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/