summaryrefslogtreecommitdiff
path: root/ss_engine/fota_common.h
blob: 8213546b9be257dbe45fe074bd2e263934b106f4 (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
/*
 * libtota
 *
 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
 *
 * 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 __FOTA_COMMON_H__
#define __FOTA_COMMON_H__

#include <stdio.h>
#include "fota_log.h"

typedef signed char s8;
typedef unsigned char u8;

typedef signed short s16;
typedef unsigned short u16;

typedef signed int s32;
typedef unsigned int u32;
#ifndef __size_t /* typedef check for x86 env: stddef.h */
#define __size_t
typedef u32 size_t;
#endif /* __size_t */

typedef signed long sl32;
typedef unsigned long ul32;

typedef signed long long s64;
typedef unsigned long long u64;

#define MAX_FILE_PATH           512

#ifndef TIME_PROFILING
	//#define TIME_PROFILING
#endif
#ifndef HEAP_PROFILING
	//#define HEAP_PROFILING;
#endif
#ifndef MEM_PROFILING
	//#define MEM_PROFILING
#endif
#ifndef POWER_FAIL_TEST
	//#define POWER_FAIL_TEST
#endif

#define UNUSED(x) (void)(x)

#define SS_TOTA_VERSION			"1.0.18"
#define BSDIFF				"BSDIFF40"
#define IMGDIFF				"IMGDIFF2"
#define SECTOR_SIZE			512
#define SS_KERNEL_DELTA_HEADER		128

#define SS_COMMON_WORKSPACE			"/system/opt/usr/data/fota"
#define SS_KERNEL_UNPACK_SCRIPT		"unpack.sh"
#define SS_KERN_UNPK_SCRIPT_PATH	SS_COMMON_WORKSPACE "/" SS_KERNEL_UNPACK_SCRIPT
#define SS_BACKUP_SOURCE		SS_COMMON_WORKSPACE "/saved.file"       //How to make sure there is SPACE
#define SS_PATCHFILE_SOURCE		SS_COMMON_WORKSPACE "/patchfile.file"   //define in common place
#define SS_PATCHLIST_BKUPLOC		SS_COMMON_WORKSPACE "/patchlist.txt"
#define SS_NEW_COMPRESSED_FILE		SS_COMMON_WORKSPACE "/system.7z"
#define SS_KERNEL_WORKSPACE		SS_COMMON_WORKSPACE "/kernel-work"
#define SS_GZIP_TARGET			SS_KERNEL_WORKSPACE "/gzip"
#define SS_STAT_TARGET			SS_KERNEL_WORKSPACE "/stat"
#define SS_DD_TARGET			SS_KERNEL_WORKSPACE "/dd"
//#define SS_UPDATE_STATUR_PATH		SS_COMMON_WORKSPACE "/UP.STATUS"
#define SS_UPDATE_STATUR_PATH		"/system/opt/data/recovery/UP.STATUS"

#define SS_GZIP_SOURCE			"system/bin/gzip"
#define SS_STAT_SOURCE			"system/usr/bin/stat"
#define SS_DD_SOURCE			"system/bin/dd"

#define SS_KERNEL_MAGIC			"UnpackdzImage"
#define SS_KERNEL_NAME			"zImage"
#define SS_KERNEL_TARGET_NAME		"dzImage_final"
#define SS_KERNEL_UNPACK_DIR		SS_KERNEL_NAME "_unpacked"
#define SS_PATCHLISTFOLDER		"/p"
#define SS_NEWPATCHFOLDER		"/n"
#define SS_PATCHLISTFORMAT		".txt"
#define SS_PATCH_ATTR_FORMAT		"_attr.txt"
#define SS_FSCOUNT_MAGIC_KEY		"PaTcHCoUnT:"
#define SS_FSCOUNT_MAGIG_KEYLEN		(11)    //length of  SS_FSCOUNT_MAGIC_KEY
#define SS_IMAGE_MAGIC_KEY		"TiZSiG@tOtA_00_:.{0,64}"
#define SS_IMAGE_MAGIC_KEY_VAL		SS_COMMON_WORKSPACE "/delta_sha.txt"

#define SS_TOKEN_SPACE			" "
#define SS_TOKEN_NEWLINE		"\n"
#define SS_TOEKN_COLON			":"
#define SS_CHAR_FWSLASH			'/'
#define SS_FWSLASH			"/"
#define SS_NULLENTRY			"0"
#define SS_MAX_NAMELENSUPPORTED		(200)   //(Tar supports 256, But extra space is used for PartitionName, .delta, /p, so restricting filename max to 200)
#define SS_MAX_FILE_PATH		(512)
#define SS_TOKEN_MAXLINE_LEN		(1024)
#define SS_COMPRESSED_FILE		"system.7z"

#define SS_STRING_DIFF			"DIFF"
#define SS_STRING_MOVE			"MOVE"
#define SS_STRING_DEL			"DEL"
#define SS_STRING_SYM			"SYM"
#define SS_STRING_NEW			"NEW"
#define SS_STRING_REG			"REG"
#define SS_STRING_TPK			"TPK"
#define SS_STRING_ZIP			"ZIP"
#define SS_STRING_END			"END"

#ifdef MEM_PROFILING
#define SS_MEMORY_USAGE_LOG		SS_COMMON_WORKSPACE "/log_memory"
#define SS_MEMORY_PROFILING_SCRIPT	SS_COMMON_WORKSPACE "/mem_use.sh"
#endif

#ifdef POWER_FAIL_TEST
#define SS_POWER_FAIL_TEST_FLAG		SS_COMMON_WORKSPACE "/power_fail_test_flag"
#endif

struct tar_Data {
	int itemSize;
	int itemOffset;
	int itemName[256];
	struct tar_Data *nextnode;
};
typedef struct tar_Data tar_Data_t;

#endif                          /* __FOTA_COMMON_H__ */