summaryrefslogtreecommitdiff
path: root/include/amlogic/aml_tlv.h (plain)
blob: 93fa0a305f47971df752609fe59eceda3e90d525
1/*
2 * Copyright (C) 2018 Amlogic, Inc. All rights reserved.
3 *
4 * All information contained herein is Amlogic confidential.
5 *
6 * This software is provided to you pursuant to Software License Agreement
7 * (SLA) with Amlogic Inc ("Amlogic"). This software may be used
8 * only in accordance with the terms of this agreement.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification is strictly prohibited without prior written permission from
12 * Amlogic.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * Created by haixiang.bao@amlogic.com
27 *
28 * Revision history: 1. 2018.05.31 v0.1 init for transfer data from BL2 to BL3X
29 *
30 */
31
32
33#ifndef __AMLOGIC_TLV_H_
34#define __AMLOGIC_TLV_H_
35
36typedef struct __s_bl2_tlv_item_t{
37 unsigned int nType; //type: user defined, should sync between BL2 and BL3X
38 unsigned int nLength; //length: length of szContent, no alignment
39 unsigned int nStoreLength; //length: length of szContent, alignment to 16
40 unsigned char szRserved1[4];//reserved for future
41 struct __s_bl2_tlv_item_t * pNextItem;//next item, list for fetch all quickly
42 unsigned char szContent[4]; //data transfered from BL2
43}s_bl2_tlv_item_t;
44
45typedef struct __s_bl2_to_bl3x_hdr_t{
46 unsigned int nMagic; //magic for identify itself, AML_BL2_TMASTER_MAGIC (@BL2)
47 unsigned int nVersion; //version for control
48 unsigned int nHeadSize; //sizeof(this)
49 unsigned char szRserved1[4]; //reserved for furture
50
51 unsigned char szBL2Info[96]; //BL2 build information
52
53 s_bl2_tlv_item_t * pNextBlob; //next active valid blob item
54 unsigned int nTLVCount; //current valid TLV item number
55 unsigned int nTotalSize; //total size of all TLV items
56 unsigned char szSHA2TLV[32]; //SHA2 of all TLV items, size is nTotalSize
57
58} s_bl2_to_bl3x_hdr_t;
59
60typedef struct __s_bl2_to_bl3x_send_t{
61
62 s_bl2_to_bl3x_hdr_t hdr;
63
64 unsigned char szSHA2Head[32];
65
66 s_bl2_tlv_item_t blob[1];
67
68} s_bl2_to_bl3x_send_t;
69
70typedef enum{
71 e_ok_ret = 0,
72
73 e_err_not_support = 0x01,
74
75 e_err_no_item = 0x10,
76 e_err_sha_hdr = 0x11,
77 e_err_sha_tlv = 0x12,
78
79 e_err_in_data = 0x20,
80 e_err_in_size = 0x21,
81 e_err_over_size=0x22,
82 e_err_item_exit=0x23,
83
84}e_ret_type;
85
86typedef enum{
87 e_t_ap_ver = 0x10,
88 e_t_scp_ver = 0x11,
89 e_t_sp_ver = 0x12,
90 e_t_bl2z_ver = 0x13,
91 e_t_bl30_ver = 0x14,
92 e_t_bl301_ver = 0x15,
93 e_t_bl31_ver = 0x16,
94 e_t_bl32_ver = 0x17,
95 e_t_bl33_ver = 0x18,
96
97 e_t_root_aes = 0x20,
98 e_t_root_rsa_sha_all = 0x21,
99 e_t_root_rsa_sha = 0x22,
100 e_t_root_rsa_puk = 0x23,
101
102 e_t_user_aes = 0x30,
103 e_t_user_rsa_sha_all = 0x31,
104 e_t_user_rsa_sha = 0x32,
105 e_t_user_rsa_puk = 0x33,
106
107 e_t_bl30_rsa_puk = 0x50,
108 e_t_bl30_aes = 0x51,
109
110 e_t_bl31_rsa_puk = 0x60,
111 e_t_bl31_aes = 0x61,
112
113 e_t_bl32_rsa_puk = 0x70,
114 e_t_bl32_aes = 0x71,
115
116 e_t_bl33_rsa_puk = 0x80,
117 e_t_bl33_aes = 0x81,
118
119
120 //....
121
122}e_item_type;
123
124
125//magic ID
126#define AML_BL2_TMASTER_MAGIC (0x324c4240) //@BL2
127
128//major & minor version
129#define AML_BL2_TMASTER_MAJ_VER (0x00) //major version
130#define AML_BL2_TMASTER_MIN_VER (0x01) //minor version
131#define AML_BL2_TMASTER_VERSION ((AML_BL2_TMASTER_MAJ_VER << 16) |\
132 AML_BL2_TMASTER_MIN_VER) //major << 16 | minor version
133
134//item data length alignment
135#define AML_BL2_TMASTER_ITEM_UNIT_LEN (16)
136#define AML_BL2_TMASTER_ITEM_ALIGN_LEN(len) ((len) + (AML_BL2_TMASTER_ITEM_UNIT_LEN-1)) & (~(AML_BL2_TMASTER_ITEM_UNIT_LEN-1))
137
138//CFG reg to store DDR address
139#define AML_BL2_TMASTER_CFG_REG (AO_SEC_GP_CFG6)
140
141//DDR buffer size
142#ifndef AML_BL2_TMASTER_DDR_MLEN
143#define AML_BL2_TMASTER_DDR_MLEN ((1<<20) - sizeof(s_bl2_to_bl3x_send_t)) //1MB for transfer data from BL2 to BL3X
144#endif
145
146//flag to pass BL2 build info to BL3X
147//#define CONFIG_AML_TLV_BL2_VER_INFO
148
149//IMPORTANT: BECAUSE THOSE FUNCTIONS WILL USE DDR AS STORAGE(DEFAULT) THEN
150// ALL THE APIS MSUT BE USED AFTER DDR INIT DONE
151//global APIs to pad & fetch item
152//pad item with data, type and length
153e_ret_type aml_append_item(unsigned int nType, unsigned int nLength, unsigned char *pData);
154//fetch item with type
155e_ret_type aml_fetch_item(unsigned int nType, s_bl2_tlv_item_t **ppItem);
156
157#endif /* __AMLOGIC_TLV_H_ */
158