POK
/home/jaouen/pok_official/pok/trunk/libpok/arinc653/partition.c
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00017 
00018 #ifdef POK_NEEDS_ARINC653_PARTITION
00019 
00020 #include <arinc653/types.h>
00021 #include <arinc653/partition.h>
00022 
00023 #include <core/partition.h>
00024 
00025 #include <errno.h>
00026 
00027 void GET_PARTITION_STATUS (PARTITION_STATUS_TYPE *partition_status,
00028                            RETURN_CODE_TYPE      *return_code)
00029 {
00030   pok_current_partition_get_id(&partition_status->IDENTIFIER);
00031   pok_current_partition_get_period(&partition_status->PERIOD);
00032   pok_current_partition_get_duration(&partition_status->DURATION);
00033   pok_current_partition_get_lock_level(&partition_status->LOCK_LEVEL);
00034   pok_current_partition_get_operating_mode(&partition_status->OPERATING_MODE);
00035   pok_current_partition_get_start_condition(&partition_status->START_CONDITION);
00036   *return_code = NO_ERROR;
00037 }
00038 
00039 void SET_PARTITION_MODE (OPERATING_MODE_TYPE operating_mode,
00040                          RETURN_CODE_TYPE *return_code)
00041 {
00042   pok_partition_mode_t core_mode;
00043   pok_ret_t            core_ret;
00044   pok_partition_mode_t current_mode;
00045 
00046   pok_current_partition_get_operating_mode(&current_mode);
00047    switch (operating_mode)
00048    {
00049       case IDLE:
00050          core_mode = POK_PARTITION_MODE_IDLE;
00051          break;
00052 
00053       case NORMAL:
00054          core_mode = POK_PARTITION_MODE_NORMAL;
00055          break;
00056 
00057       case COLD_START:
00058          core_mode = POK_PARTITION_MODE_INIT_COLD;
00059          *return_code = NOT_AVAILABLE;
00060          return;
00061 
00062       case WARM_START:
00063          core_mode = POK_PARTITION_MODE_INIT_WARM;
00064          break;
00065 
00066       default:
00067          *return_code = INVALID_PARAM;
00068          return;
00069    }
00070 
00071    if (current_mode == core_mode)
00072      {
00073        *return_code = NO_ACTION;
00074        return ;
00075      }
00076    if (current_mode == POK_PARTITION_MODE_INIT_COLD &&
00077        core_mode == POK_PARTITION_MODE_INIT_WARM)
00078      {
00079        *return_code = INVALID_MODE;
00080        return ;
00081      }
00082    core_ret = pok_partition_set_mode (core_mode);
00083    *return_code = core_ret;
00084 }
00085 
00086 #endif