summaryrefslogtreecommitdiffstats
path: root/video_in_hal/boot_hal/hal_api/boot_hal.h
blob: 783db97a85bd54ee4cc634e71a18c73d6abe0642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
 * @copyright Copyright (c) 2018-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HAL_API_BOOT_HAL_H_
#define HAL_API_BOOT_HAL_H_

#include <stdint.h>
#include <native_service/frameworkunified_types.h>

/**
 * @file boot_hal.h
 * @brief This file provides API for get boot info from boot device, set boot info to boot device,
 *        set next boot mode to coldstart and get current boot mode
 */

/** @addtogroup reproservice
 *  @{
 */
/** @addtogroup boot_hal
 *  @ingroup reprogramming_service
 *  @{
 */

/**
 * \~english BootHalBootMode
 */
enum BootHalBootMode{
  /**
   * \~english cold start
   */
  COLD_START = 0,
  /**
   * \~english hot start
   */
  HOT_START = 1,
};

/**
 * \~english BootHalUpTableID
 */
enum BootHalUpTableID{
  /**
   * \~english UBOOT
   */
  BOOTHAL_SIDE_IDX_UBOOT = 0,
  /**
   * \~english Secure loader
   */
  BOOTHAL_SIDE_IDX_SECURE = 1,
  /**
   * \~english MAIN software
   */
  BOOTHAL_SIDE_IDX_MAINSOFT = 2,
  /**
   * \~english Max num of modules(include reserves)
   */
  BOOTHAL_NUMTARGS = 20
};

/**
 * \~english BootHalStatus
 */
typedef enum BootHalStatus {
/**
 * \~english Success
 */
  BOOTHAL_RET_SUCCESS = 0,
/**
 * \~english No permission to operate
 */
  BOOTHAL_RET_ERR_PERMISSION = 1,
/**
 * \~english Time out
 */
  BOOTHAL_RET_ERR_TIMEOUT = 2,
/**
 * \~english Status error
 */
  BOOTHAL_RET_ERR_STATUS = 3,
/**
 * \~english Write error
 */
  BOOTHAL_RET_ERR_WRITE = 4,
/**
 * \~english Paramater error
 */
  BOOTHAL_RET_ERR_PARAM = 5,
/**
 * \~english Internal IO error(open, read, write, strstr, close)
 */
  BOOTHAL_RET_ERR_FAIL = 6,
} BootHalStatus;

/**
 * \~english Not rewrite.
 */
#define BOOTHAL_SIDE_NONE 0
/**
 * \~english Rewrites side A.
 */
#define BOOTHAL_SIDE_A 1
/**
 * \~english Rewrites side B.
 */
#define BOOTHAL_SIDE_B 2
/**
 * \~english Max parameter num
 */
#define BOOTHAL_NUMSIDE_MAX 3

/**\ingroup setSide
 * \~english @par Brief
 *      This API set boot info to boot device, the caller control this API not be called at the
 *      same time
 * \~english @param [in] upTableID
 *      unsigned int           - Boot info
 * \~english @retval BOOTHAL_RET_SUCCESS OK
 * \~english @retval BOOTHAL_RET_ERR_PARAM Parameter error
 * \~english @retval BOOTHAL_RET_ERR_WRITE Write error
 * \~english @retval BOOTHAL_RET_ERR_FAIL Internal IO error
 * \~english @par Preconditions
 *      - There is no preconditions for this API.
 * \~english @par Change of internal state
 *      - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 *      - If the parameter upTableId is NULL. [BOOTHAL_RET_ERR_PARAM]
 *      - If write /dev/mmcblk0boot1 return -1. [BOOTHAL_RET_ERR_WRITE]
 *      - Internal IO error(open, read, lseek). [BOOTHAL_RET_ERR_FAIL]
 * \~english @par Detail
 *      - This API set boot info.
 *      - The API can only be used by 1 process.
 * \~english @par Classification
 *      Public
 * \~english @par Type
 *      Sync
 * \~english @see getSide
 */
BootHalStatus setSide(unsigned int upTableID[]);

/**\ingroup getSide
 * \~english @par Brief
 *      Get boot info from boot device
 * \~english @param [out] upTableID
 *      unsigned int              - boot info
 * \~english @retval BOOTHAL_RET_SUCCESS OK
 * \~english @retval BOOTHAL_RET_ERR_PARAM Parameter error
 * \~english @retval BOOTHAL_RET_ERR_FAIL Internal IO error
 * \~english @par Preconditions
 *      - There is no preconditions for this API.
 * \~english @par Change of internal state
 *      - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 *      - If the parameter upTableId is NULL. [BOOTHAL_RET_ERR_PARAM]
 *      - Internal IO error.[BOOTHAL_RET_ERR_FAIL]
 * \~english @par Detail
 *      - This API get boot info from boot device.
 *      - The API can only be used by 1 process.
 * \~english @par Classification
 *      Public
 * \~english @par Type
 *      Sync
 * \~english @see setSide
 */
BootHalStatus getSide(unsigned int upTableID[]);

/**\ingroup setBootColdStart
 * \~english @par Brief
 *     Set next boot to ColdStart mode.
 * \~english @retval BOOTHAL_RET_SUCCESS OK
 * \~english @retval BOOTHAL_RET_ERR_FAIL set next boot start mode failed
 * \~english @par Preconditions
 *      - There is no preconditions for this API.
 * \~english @par Change of internal state
 *      - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 *      - Internal IO error.[BOOTHAL_RET_ERR_FAIL]
 * \~english @par Detail
 *      - This API Set next boot to ColdStart mode.
 *      - The API can only be used by 1 process.
 * \~english @par Classification
 *      Public
 * \~english @par Type
 *      Sync
 * \~english @see getBootMode
 */
BootHalStatus setBootColdStart(void);

/**\ingroup getBootMode
 * \~english @par Brief
 *      Get boot mode.
 * \~english @param [out] mode
 *      unsigned int              - boot mode(COLD_START or HOT_START)
 * \~english @retval BOOTHAL_RET_SUCCESS OK
 * \~english @retval BOOTHAL_RET_ERR_PARAM Parameter error
 * \~english @par Preconditions
 *      - There is no preconditions for this API.
 * \~english @par Change of internal state
 *      - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 *      - If the parameter mode is NULL. [BOOTHAL_RET_ERR_PARAM]
 * \~english @par Detail
 *      - This API get boot mode.
 *      - The API can only be used by 1 process.
 * \~english @par Classification
 *      Public
 * \~english @par Type
 *      Sync
 * \~english @see setBootColdStart
 */
BootHalStatus getBootMode(uint32_t *mode);

/** @}*/  // end of boot_hal
/** @}*/  // end of reprogramming_service

#endif  // HAL_API_BOOT_HAL_H_