afc3e280b924039f8d0af765c16dce6c9f8a464f
[platform/core/system/initrd-flash.git] / src / dfu.h
1 /*
2  * flash-manager - Tizen kernel-level image flashing solution
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __DFU_H
18 #define __DFU_H
19
20 #include <sys/queue.h>
21 #include "tfm.h"
22
23 #define DFU_DELIMITER           " :,\t\n"
24 #define DFU_INFO_NUM            100
25 #define DFU_MOUNT_PATH          "/mnt/tfm-temp"
26
27 enum dfu_info_entry {
28         DFU_INFO_MODE = 0,
29         DFU_INFO_LABEL,
30         DFU_INFO_NAME,
31         DFU_INFO_PATH,
32         DFU_INFO_MAX,
33 };
34
35 enum dfu_thread_state {
36         DFU_THREAD_STATE_ERROR = -1,
37         DFU_THREAD_STATE_IDLE,
38         DFU_THREAD_STATE_FLASHING,
39 };
40
41 struct dfu_frame {
42         void *buf;
43         unsigned long len;
44         TAILQ_ENTRY(dfu_frame) entry;
45 };
46
47 void *dfu_get_buffer(unsigned long size);
48 void dfu_put_buffer(void *ptr);
49 int dfu_init(struct tfm_context *ctx, const char *dfu_info_file);
50 void dfu_exit(struct tfm_context *ctx);
51 int dfu_start(struct tfm_context *ctx, const char *entity);
52 int dfu_request_io(struct tfm_context *ctx, unsigned long len);
53 void dfu_sync(struct tfm_context *ctx);
54
55 #endif