Skip to content

Commit 5912e40

Browse files
committed
change the 1.8 and 1.5 header defines
add comments and change the 1.5 1.8 header defines Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
1 parent f1c5a15 commit 5912e40

9 files changed

Lines changed: 75 additions & 41 deletions

File tree

rimage/css.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "css.h"
2121
#include "manifest.h"
2222

23-
void ri_css_hdr_create_v1_8(struct image *image)
23+
void ri_css_hdr_create(struct image *image)
2424
{
25-
struct css_header_v1_8 *css = image->fw_image + MAN_CSS_HDR_OFFSET_V1_8;
25+
struct css_header_v1_8 *css = image->fw_image + MAN_CSS_HDR_OFFSET;
2626
struct tm *date;
2727
struct timeval tv;
2828
int val;

rimage/css.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ struct css_header_v1_5 {
8484
uint8_t signature[MAN_RSA_SIGNATURE_LEN];
8585
} __attribute__((packed));
8686

87-
void ri_css_hdr_create_v1_8(struct image *image);
87+
void ri_css_hdr_create(struct image *image);
8888

8989
#endif

rimage/man_apl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct fw_image_manifest_v1_8 apl_manifest = {
3535
{
3636
/* CssHeader + platformFirmwareAuthenticationExtension - padding */
3737
.entry_name = "ADSP.man",
38-
.offset = MAN_CSS_HDR_OFFSET_V1_8,
38+
.offset = MAN_CSS_HDR_OFFSET,
3939
.length = sizeof(struct css_header_v1_8) +
4040
PLAT_AUTH_SIZE,
4141
},

rimage/man_cnl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct fw_image_manifest_v1_8 cnl_manifest = {
3434
{
3535
/* CssHeader + platformFirmwareAuthenticationExtension - padding */
3636
.entry_name = "ADSP.man",
37-
.offset = MAN_CSS_HDR_OFFSET_V1_8,
37+
.offset = MAN_CSS_HDR_OFFSET,
3838
.length = sizeof(struct css_header_v1_8) +
3939
PLAT_AUTH_SIZE,
4040
},

rimage/man_kbl.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation.
2+
* Copyright (c) 2018, Intel Corporation.
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms and conditions of the GNU General Public License,
@@ -18,6 +18,11 @@
1818
#include <config.h>
1919
#include <version.h>
2020

21+
/*
22+
* TODO: check if all platform for 1.5 are the same base and length.
23+
* if yes, define it as HARDWARE_BUFFER_BASE_V1_5, HARDWARE_BUFFER_LEN_v1_5
24+
* if not, define a platform specific base and length.
25+
*/
2126
#define KBL_HARDWARE_BUFFER_BASE 0xBE500000
2227
#define KBL_HARDWARE_BUFFER_LEN 0x4A000
2328

rimage/manifest.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,7 @@ static int man_write_fw_v1_5(struct image *image)
703703
fprintf(stdout, "Firmware completing manifest v1.5\n");
704704

705705
/* create structures from end of file to start of file */
706-
ri_adsp_meta_data_create(image, MAN_META_EXT_OFFSET_V1_8,
707-
MAN_FW_DESC_OFFSET_V1_8);
708-
ri_plat_ext_data_create(image);
709-
ri_css_hdr_create_v1_8(image);
710-
ri_cse_create(image);
706+
ri_css_hdr_create(image);
711707

712708
fprintf(stdout, "Firmware file size 0x%x page count %d\n",
713709
FILE_TEXT_OFFSET - MAN_DESC_OFFSET + image->image_end,
@@ -727,8 +723,8 @@ static int man_write_fw_v1_5(struct image *image)
727723
goto err;
728724

729725
/* write the unsigned files*/
730-
ret = man_write_unsigned_mod(image, MAN_META_EXT_OFFSET_V1_8,
731-
MAN_FW_DESC_OFFSET_V1_8);
726+
ret = man_write_unsigned_mod(image, MAN_META_EXT_OFFSET_V1_5,
727+
MAN_FW_DESC_OFFSET_V1_5);
732728
if (ret < 0)
733729
goto err;
734730

@@ -785,7 +781,7 @@ static int man_write_fw_v1_8(struct image *image)
785781
ri_adsp_meta_data_create(image, MAN_META_EXT_OFFSET_V1_8,
786782
MAN_FW_DESC_OFFSET_V1_8);
787783
ri_plat_ext_data_create(image);
788-
ri_css_hdr_create_v1_8(image);
784+
ri_css_hdr_create(image);
789785
ri_cse_create(image);
790786

791787
fprintf(stdout, "Firmware file size 0x%x page count %d\n",
@@ -985,6 +981,14 @@ static int man_write_fw_meu_v1_8(struct image *image)
985981
#define ADSP_APL_DSP_ROM_SIZE 0x00002000
986982
#define APL_DSP_BASE_ENTRY 0xa000a000
987983

984+
#define ADSP_KBL_DSP_ROM_BASE 0xBEFE0000
985+
#define ADSP_KBL_DSP_ROM_SIZE 0x00002000
986+
#define KBL_DSP_BASE_ENTRY 0xa000a000
987+
988+
#define ADSP_SKL_DSP_ROM_BASE 0xBEFE0000
989+
#define ADSP_SKL_DSP_ROM_SIZE 0x00002000
990+
#define SKL_DSP_BASE_ENTRY 0xa000a000
991+
988992
#define ADSP_CNL_DSP_ROM_BASE 0xBEFE0000
989993
#define ADSP_CNL_DSP_ROM_SIZE 0x00002000
990994
#define CNL_DSP_IMR_BASE_ENTRY 0xb0038000
@@ -1017,9 +1021,9 @@ const struct adsp machine_apl = {
10171021

10181022
const struct adsp machine_kbl = {
10191023
.name = "kbl",
1020-
.rom_base = ADSP_APL_DSP_ROM_BASE,
1021-
.rom_size = ADSP_APL_DSP_ROM_SIZE,
1022-
.sram_base = APL_DSP_BASE_ENTRY,
1024+
.rom_base = ADSP_KBL_DSP_ROM_BASE,
1025+
.rom_size = ADSP_KBL_DSP_ROM_SIZE,
1026+
.sram_base = KBL_DSP_BASE_ENTRY,
10231027
.sram_size = 0x100000,
10241028
.image_size = 0x100000,
10251029
.dram_offset = 0,
@@ -1031,9 +1035,9 @@ const struct adsp machine_kbl = {
10311035

10321036
const struct adsp machine_skl = {
10331037
.name = "skl",
1034-
.rom_base = ADSP_APL_DSP_ROM_BASE,
1035-
.rom_size = ADSP_APL_DSP_ROM_SIZE,
1036-
.sram_base = APL_DSP_BASE_ENTRY,
1038+
.rom_base = ADSP_SKL_DSP_ROM_BASE,
1039+
.rom_size = ADSP_SKL_DSP_ROM_SIZE,
1040+
.sram_base = SKL_DSP_BASE_ENTRY,
10371041
.sram_size = 0x100000,
10381042
.image_size = 0x100000,
10391043
.dram_offset = 0,

rimage/manifest.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
#define MAN_EXT_PADDING 0x20
4040
#define MAN_DESC_OFFSET 0x2000
4141

42-
#define MAN_CSS_HDR_OFFSET_V1_8 \
42+
#define MAN_CSS_HDR_OFFSET \
4343
(MAN_CSE_HDR_OFFSET + \
4444
sizeof(struct CsePartitionDirHeader) + \
4545
MAN_CSE_PARTS * sizeof(struct CsePartitionDirEntry))
4646

4747
#define MAN_SIG_PKG_OFFSET_V1_8 \
48-
(MAN_CSS_HDR_OFFSET_V1_8 + \
48+
(MAN_CSS_HDR_OFFSET + \
4949
sizeof(struct css_header_v1_8))
5050

5151
#define MAN_PART_INFO_OFFSET_V1_8 \
@@ -66,6 +66,21 @@
6666
#define MAN_DESC_PADDING_SIZE_V1_8 \
6767
(MAN_DESC_OFFSET - MAN_FW_DESC_OFFSET_V1_8)
6868

69+
#define MAN_SIG_PKG_OFFSET_V1_5 \
70+
(MAN_CSS_HDR_OFFSET + \
71+
sizeof(struct css_header_v1_5))
72+
73+
#define MAN_META_EXT_OFFSET_V1_5 \
74+
(MAN_SIG_PKG_OFFSET_V1_5 + \
75+
sizeof(struct signed_pkg_info_ext) + \
76+
sizeof(struct partition_info_ext) + \
77+
MAN_CSE_PADDING_SIZE)
78+
79+
#define MAN_FW_DESC_OFFSET_V1_5 \
80+
(MAN_META_EXT_OFFSET_V1_5 + \
81+
sizeof(struct sof_man_adsp_meta_file_ext) + \
82+
MAN_EXT_PADDING)
83+
6984
/*
7085
* Firmware manifest header V1.8 used on APL onwards
7186
*/
@@ -99,6 +114,10 @@ struct fw_image_manifest_v1_5 {
99114
struct sof_man_fw_desc desc;
100115
} __attribute__((packed));
101116

117+
/*
118+
* TODO: verify if we need platform specific manifest, or just
119+
* define manifest_v1_5 and manifest_v1_8.
120+
*/
102121
extern struct fw_image_manifest_v1_5 skl_manifest;
103122
extern struct fw_image_manifest_v1_5 kbl_manifest;
104123
#endif

rimage/pkcs1_5.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ static void bytes_swap(uint8_t *ptr, uint32_t size)
6868
* manifest header (Public Key, Exponent and Signature).
6969
*/
7070

71-
int pkcs_sign_v1_5(struct image *image, struct fw_image_manifest_v1_5 *man,
72-
void *ptr1, unsigned int size1)
71+
int pkcs_v1_5_sign_man_v1_5(struct image *image,
72+
struct fw_image_manifest_v1_5 *man,
73+
void *ptr1, unsigned int size1)
7374
{
7475
RSA *priv_rsa = NULL;
7576
EVP_PKEY *privkey;
@@ -159,9 +160,10 @@ int pkcs_sign_v1_5(struct image *image, struct fw_image_manifest_v1_5 *man,
159160
* manifest header (Public Key, Exponent and Signature).
160161
*/
161162

162-
int pkcs_sign_v1_8(struct image *image, struct fw_image_manifest_v1_8 *man,
163-
void *ptr1, unsigned int size1, void *ptr2,
164-
unsigned int size2)
163+
int pkcs_v1_5_sign_man_v1_8(struct image *image,
164+
struct fw_image_manifest_v1_8 *man,
165+
void *ptr1, unsigned int size1, void *ptr2,
166+
unsigned int size2)
165167
{
166168
RSA *priv_rsa = NULL;
167169
EVP_PKEY *privkey;
@@ -245,21 +247,23 @@ int ri_manifest_sign_v1_5(struct image *image)
245247
{
246248
struct fw_image_manifest_v1_5 *man = image->fw_image;
247249

248-
pkcs_sign_v1_5(image, man, (void *)man + MAN_CSS_MAN_SIZE_V1_5,
249-
image->image_end - sizeof(*man));
250+
pkcs_v1_5_sign_man_v1_5(image, man,
251+
(void *)man + MAN_CSS_MAN_SIZE_V1_5,
252+
image->image_end - sizeof(*man));
250253
return 0;
251254
}
252255

253256
int ri_manifest_sign_v1_8(struct image *image)
254257
{
255258
struct fw_image_manifest_v1_8 *man = image->fw_image;
256259

257-
pkcs_sign_v1_8(image, man, (void *)man + MAN_CSS_HDR_OFFSET_V1_8,
258-
sizeof(struct css_header_v1_8) -
259-
(MAN_RSA_KEY_MODULUS_LEN + MAN_RSA_KEY_EXPONENT_LEN +
260-
MAN_RSA_SIGNATURE_LEN),
261-
(void *)man + MAN_SIG_PKG_OFFSET_V1_8,
262-
(man->css.size - man->css.header_len)
263-
* sizeof(uint32_t));
260+
pkcs_v1_5_sign_man_v1_8(image, man, (void *)man + MAN_CSS_HDR_OFFSET,
261+
sizeof(struct css_header_v1_8) -
262+
(MAN_RSA_KEY_MODULUS_LEN +
263+
MAN_RSA_KEY_EXPONENT_LEN +
264+
MAN_RSA_SIGNATURE_LEN),
265+
(void *)man + MAN_SIG_PKG_OFFSET_V1_8,
266+
(man->css.size - man->css.header_len)
267+
* sizeof(uint32_t));
264268
return 0;
265269
}

rimage/rimage.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,13 @@ int ri_manifest_sign_v1_5(struct image *image);
162162
int ri_manifest_sign_v1_8(struct image *image);
163163
void ri_hash(struct image *image, unsigned offset, unsigned size, uint8_t *hash);
164164

165-
int pkcs_sign_v1_5(struct image *image, struct fw_image_manifest_v1_5 *man,
166-
void *ptr1, unsigned int size1);
167-
int pkcs_sign_v1_8(struct image *image, struct fw_image_manifest_v1_8 *man,
168-
void *ptr1, unsigned int size1, void *ptr2,
169-
unsigned int size2);
165+
int pkcs_v1_5_sign_man_v1_5(struct image *image,
166+
struct fw_image_manifest_v1_5 *man,
167+
void *ptr1, unsigned int size1);
168+
int pkcs_v1_5_sign_man_v1_8(struct image *image,
169+
struct fw_image_manifest_v1_8 *man,
170+
void *ptr1, unsigned int size1, void *ptr2,
171+
unsigned int size2);
170172

171173
int elf_parse_module(struct image *image, int module_index, const char *name);
172174
void elf_free_module(struct image *image, int module_index);

0 commit comments

Comments
 (0)