arm: sc8830: fix redefined macro warnings
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8830 / secure_boot.h
1 #ifndef _SECURE_BOOT_H_
2 #define _SECURE_BOOT_H_
3
4 #define KEY_INFO_SIZ    (512)
5 #define CUSTOM_DATA_SIZ (1024)
6 #define VLR_INFO_SIZ    (512)
7
8 #if defined(CONFIG_SPX30G)
9 #define INTER_RAM_BEGIN                 0x50003000
10 #else
11 #define INTER_RAM_BEGIN                 0x50005000
12 #endif
13 #define CONFIG_SEC_LOAD_LEN             0xC00
14 #define CONFIG_SYS_NAND_U_BOOT_LOAD_LEN 0x80000
15
16 #define KEY_INFO_OFF (INTER_RAM_BEGIN + CONFIG_SPL_LOAD_LEN - KEY_INFO_SIZ - VLR_INFO_SIZ)
17 #define VLR_INFO_OFF (CONFIG_SYS_NAND_U_BOOT_START + CONFIG_SYS_NAND_U_BOOT_SIZE - VLR_INFO_SIZ)
18
19 #ifdef CONFIG_NAND_SPL
20 #define panic(x...)  do{}while(0)
21 #define printf(x...) do{}while(0)
22 #endif
23
24 #define MIN_UNIT        (512)
25 #define HEADER_NAME "SPRD-SECUREFLAG"
26
27 #define VLR_NAME (0x3A524C56)
28 #define PUK_NAME (0x3A4B5550)
29 #define CODE_NAME (0x45444F43)
30
31 #define PUBLIC
32 #define SHA1HashSize 20
33 typedef unsigned int uint32_t;
34 typedef unsigned char uint8_t;
35 /*
36 * This structure will hold context information for the SHA-1
37 * hashing operation
38 */
39 typedef struct SHA1Context32 {
40         unsigned int Intermediate_Hash[5];      /* Message Digest */
41         unsigned int Length_Low;        /* Message length in bits */
42         unsigned int Length_High;       /* Message length in bits */
43         /* Index into message block array */
44         unsigned int Message_Block_Index;
45         unsigned int W[80];     /* 512-bit message blocks */
46 } SHA1Context_32;
47
48 typedef struct {
49         uint32_t tag_name;
50         uint32_t tag_offset;
51         uint32_t tag_size;
52         uint8_t reserved[4];
53 } tag_info_t;
54
55 typedef struct {
56         uint8_t header_magic[16];
57         uint32_t header_ver;
58         uint32_t tags_number;
59         uint8_t header_ver_padding[8];
60         tag_info_t tag[3];
61         uint8_t reserved[432];
62 } header_info_t;
63
64 typedef struct {
65         struct {
66                 uint32_t e;
67                 uint8_t m[128];
68                 uint8_t r2[128];
69         } key;
70         uint8_t reserved[4];
71 } bsc_info_t;
72
73 #define VLR_MAGIC (0x524C56FF)
74 typedef struct {
75         uint32_t magic;
76         uint8_t hash[128];
77         uint32_t setting;
78         uint32_t length;
79         uint8_t reserved[20];
80 } vlr_info_t;
81
82 typedef struct {
83         uint32_t intermediate_hash[5];
84         uint32_t length_low;
85         uint32_t length_high;
86         uint32_t msg_block_idx;
87         uint32_t W[80];
88 } sha1context_32;
89
90 typedef struct {
91         uint32_t ver;
92         uint8_t cap;
93         void (*efuse_init) (void);
94         void (*efuse_close) (void);
95          uint32_t(*efuse_read) (uint32_t block_id, uint32_t * data);
96          uint32_t(*sha1reset_32) (sha1context_32 *);
97          uint32_t(*sha1input_32) (sha1context_32 *, const uint32_t *, uint32_t);
98          uint32_t(*sha1result_32) (sha1context_32 *, uint8_t *);
99         void (*rsa_modpower) (uint32_t * p, uint32_t * m, uint32_t * r2, uint32_t e);
100 } rom_callback_func_t;
101
102 typedef struct {
103         rom_callback_func_t *rom_callback;
104         void (*secure_check) (uint8_t * data, uint32_t data_len, uint8_t * data_hash, uint8_t * data_key);
105 } sec_callback_func_t;
106
107 void secure_check(uint8_t * data, uint32_t data_len, uint8_t * data_hash, uint8_t * data_key);
108 int cal_md5(void *data, uint32_t len, void *harsh_data);
109 int secureboot_enabled(void);
110
111 /*
112 * Function Prototypes
113 */
114 PUBLIC int SHA1Reset_32(SHA1Context_32 *);
115 PUBLIC int SHA1Input_32(SHA1Context_32 *, const unsigned int *message, unsigned int len);
116 PUBLIC int SHA1Result_32(SHA1Context_32 * context, unsigned char *Message_Digest);
117
118 #endif