POK
partition.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #ifdef POK_NEEDS_ARINC653_PARTITION
19 
20 #include <arinc653/types.h>
21 #include <arinc653/partition.h>
22 
23 #include <core/partition.h>
24 
25 #include <errno.h>
26 
27 void GET_PARTITION_STATUS (PARTITION_STATUS_TYPE *partition_status,
28  RETURN_CODE_TYPE *return_code)
29 {
30  pok_current_partition_get_id(&partition_status->IDENTIFIER);
31  pok_current_partition_get_period(&partition_status->PERIOD);
32  pok_current_partition_get_duration(&partition_status->DURATION);
33  pok_current_partition_get_lock_level(&partition_status->LOCK_LEVEL);
34  pok_current_partition_get_operating_mode(&partition_status->OPERATING_MODE);
35  pok_current_partition_get_start_condition(&partition_status->START_CONDITION);
36  *return_code = NO_ERROR;
37 }
38 
39 void SET_PARTITION_MODE (OPERATING_MODE_TYPE operating_mode,
40  RETURN_CODE_TYPE *return_code)
41 {
42  pok_partition_mode_t core_mode;
43  pok_ret_t core_ret;
44  pok_partition_mode_t current_mode;
45 
46  pok_current_partition_get_operating_mode(&current_mode);
47  switch (operating_mode)
48  {
49  case IDLE:
50  core_mode = POK_PARTITION_MODE_IDLE;
51  break;
52 
53  case NORMAL:
54  core_mode = POK_PARTITION_MODE_NORMAL;
55  break;
56 
57  case COLD_START:
58  core_mode = POK_PARTITION_MODE_INIT_COLD;
59  *return_code = NOT_AVAILABLE;
60  return;
61 
62  case WARM_START:
63  core_mode = POK_PARTITION_MODE_INIT_WARM;
64  break;
65 
66  default:
67  *return_code = INVALID_PARAM;
68  return;
69  }
70 
71  if (current_mode == core_mode)
72  {
73  *return_code = NO_ACTION;
74  return ;
75  }
76  if (current_mode == POK_PARTITION_MODE_INIT_COLD &&
77  core_mode == POK_PARTITION_MODE_INIT_WARM)
78  {
79  *return_code = INVALID_MODE;
80  return ;
81  }
82  core_ret = pok_partition_set_mode (core_mode);
83  *return_code = core_ret;
84 }
85 
86 #endif