1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 __BOOT_UPG_COMMON_H__ 17 #define __BOOT_UPG_COMMON_H__ 18 19 #include <hi_upg_file.h> 20 #include <hi_boot_rom.h> 21 #include <hi_flashboot.h> 22 #include <hi_cipher.h> 23 #include <lzmaram.h> 24 25 typedef hi_u8 srv_bit; /* value 0 or 1 */ 26 27 #define BIT_U8 8 28 #define BIT_U16 16 29 #define MASK_U16 0xFFFF 30 31 #define SRV_BIT_LOW 0 32 #define SRV_BIT_HIGH 1 33 34 /* 35 i must 0~7 b must 0 or 1 x must a character 36 high ----------------> low 37 ************************** 38 7 6 5 4 3 2 1 0 39 ************************** 40 */ 41 #define bit_set(x, i, b) ((x) = (hi_u8)((b) ? ((1 << (i)) | (x)) : ((~(hi_u8)(1 << (i))) & (x)))) 42 #define bit_get(x, i) (((1 << (i)) & (x)) ? 1 : 0) 43 44 #define boot_upg_mem_free(sz) \ 45 do { \ 46 if ((sz) != HI_NULL) { \ 47 boot_free((sz)); \ 48 } \ 49 (sz) = HI_NULL; \ 50 } while (0) 51 52 hi_bool boot_upg_tool_bit_test(const hi_u8 *data, hi_u16 pos); 53 hi_void boot_upg_tool_bit_set(hi_u8 *data, hi_u16 pos, hi_u8 val); 54 55 #endif 56 57