• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __CMD_LOOP_H__
17 #define __CMD_LOOP_H__
18 
19 #include <uart_auth.h>
20 
21 #define ACK_SUCCESS        0x5A
22 #define ACK_FAILURE        0xA5
23 
24 enum {
25     CMD_ACK = 0xE1,
26     CMD_DL_IMAGE = 0xD2,
27     CMD_BURN_EFUSE = 0xC3,
28     CMD_UL_DATA = 0xB4,
29     CMD_READ_EFUSE = 0xA5,
30     CMD_FLASH_PROTECT = 0x96,
31     CMD_RESET = 0x87,
32     CMD_FACTORY_IMAGE = 0x78,
33     CMD_VERSION = 0x69
34 };
35 
36 #define LOADER_CMD_MAX      8
37 
38 hi_u32 loader_download_image(const uart_ctx *cmd_ctx);
39 hi_u32 loader_burn_efuse(const uart_ctx *cmd_ctx);
40 hi_u32 loader_upload_data(const uart_ctx *cmd_ctx);
41 hi_u32 loader_read_efuse(const uart_ctx *cmd_ctx);
42 hi_u32 loader_flash_protect(const uart_ctx *cmd_ctx);
43 hi_u32 loader_reset(const uart_ctx *cmd_ctx);
44 hi_u32 loader_burn_version(const uart_ctx *cmd_ctx);
45 uart_ctx *cmd_loop_init(hi_void);
46 hi_u32 cmd_loop_deinit(hi_void);
47 hi_void cmd_loop(uart_ctx *ctx);
48 hi_void loader_ack(hi_u8 err_code);
49 
50 extern void *__nmi_stack_top;    /* defined in link scripts. */
51 extern void *__nmi_stack_bottom; /* defined in link scripts. */
52 #define bit_set(x, i, b) ((x) = (hi_u8)((b) ? ((1 << (i)) | (x)) : ((~(hi_u8)(1 << (i))) & (x))))
53 #define bit_get(x, i)    (((1 << (i)) & (x)) ? 1 : 0)
54 #define SRV_BIT_LOW  0
55 #define SRV_BIT_HIGH 1
56 
57 #endif /* __CMD_LOOP_H__ */
58 
59