1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef UPDATER_FLASHD_DEFINE_H
17 #define UPDATER_FLASHD_DEFINE_H
18 
19 #include "common.h"
20 #include "flashd/flashd.h"
21 #include "log/log.h"
22 
23 namespace Flashd {
24 #define FLASHD_LOGE(format, ...) Logger(Updater::ERROR, (UPDATER_LOG_FILE_NAME), (__LINE__), format, ##__VA_ARGS__)
25 #define FLASHD_LOGD(format, ...) Logger(Updater::DEBUG, (UPDATER_LOG_FILE_NAME), (__LINE__), format, ##__VA_ARGS__)
26 #define FLASHD_LOGI(format, ...) Logger(Updater::INFO, (UPDATER_LOG_FILE_NAME), (__LINE__), format, ##__VA_ARGS__)
27 #define FLASHD_LOGW(format, ...) Logger(Updater::WARNING, (UPDATER_LOG_FILE_NAME), (__LINE__), format, ##__VA_ARGS__)
28 }
29 
30 namespace Hdc {
31 constexpr const char *CMDSTR_UPDATE_SYSTEM = "update";
32 constexpr const char *CMDSTR_FLASH_PARTITION = "flash";
33 constexpr const char *CMDSTR_ERASE_PARTITION = "erase";
34 constexpr const char *CMDSTR_FORMAT_PARTITION = "format";
35 constexpr int TASK_UPDATER = TASK_APP + 1;
36 constexpr int TASK_FAKE = TASK_UPDATER + 1;
37 
38 enum FlashdCommander {
39     CMD_UPDATER_UPDATE_INIT = 4000,
40     CMD_UPDATER_FLASH_INIT,
41     CMD_UPDATER_CHECK,
42     CMD_UPDATER_BEGIN,
43     CMD_UPDATER_DATA,
44     CMD_UPDATER_FINISH,
45     CMD_UPDATER_ERASE,
46     CMD_UPDATER_FORMAT,
47     CMD_UPDATER_PROGRESS
48 };
49 }
50 #endif
51