css: add css header for cavs v2.5

Header contests are the same but with bigger key.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This commit is contained in:
Liam Girdwood 2020-10-26 10:42:42 +00:00 committed by Liam Girdwood
parent d6cf696066
commit 48ba01ec45
2 changed files with 83 additions and 0 deletions

View File

@ -11,6 +11,63 @@
#include <rimage/css.h>
#include <rimage/manifest.h>
void ri_css_v2_5_hdr_create(struct image *image)
{
struct css_header_v2_5 *css = image->fw_image + MAN_CSS_HDR_OFFSET_2_5;
struct tm *date;
struct timeval tv;
time_t seconds;
int val;
fprintf(stdout, " cse: completing CSS manifest\n");
/* get local time and date */
gettimeofday(&tv, NULL);
seconds = tv.tv_sec;
date = localtime(&seconds);
if (!date) {
fprintf(stderr, "error: cant get localtime %d\n", -errno);
return;
}
date->tm_year += 1900;
fprintf(stdout, " css: set build date to %d:%2.2d:%2.2d\n",
date->tm_year, date->tm_mon, date->tm_mday);
/* year yYyy */
val = date->tm_year / 1000;
css->date |= val << 28;
date->tm_year -= val * 1000;
/* year yyYy */
val = date->tm_year / 100;
css->date |= val << 24;
date->tm_year -= val * 100;
/* year yyyY */
val = date->tm_year / 10;
css->date |= val << 20;
date->tm_year -= val * 10;
/* year Yyyy */
val = date->tm_year;
css->date |= val << 16;
/* month Mm - for some reason month starts at 0 */
val = ++date->tm_mon / 10;
css->date |= val << 12;
date->tm_mon -= (val * 10);
/* month mM */
val = date->tm_mon;
css->date |= val << 8;
/* Day Dd */
val = date->tm_mday / 10;
css->date |= val << 4;
date->tm_mday -= (val * 10);
/* Day dD */
val = date->tm_mday;
css->date |= val << 0;
}
void ri_css_v1_8_hdr_create(struct image *image)
{
struct css_header_v1_8 *css = image->fw_image + MAN_CSS_HDR_OFFSET;

View File

@ -13,12 +13,15 @@ struct image;
#define MAN_CSS_LT_MODULE_TYPE 0x00000006
#define MAN_CSS_MOD_TYPE 4
#define MAN_CSS_HDR_SIZE 161 /* in words */
#define MAN_CSS_HDR_SIZE_2_5 225 /* in words */
#define MAN_CSS_HDR_VERSION 0x10000
#define MAN_CSS_HDR_VERSION_2_5 0x21000
#define MAN_CSS_MOD_VENDOR 0x8086
#define MAN_CSS_HDR_ID {'$', 'M', 'N', '2'}
#define MAN_CSS_KEY_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2)
#define MAN_CSS_MOD_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2)
#define MAN_CSS_MOD_SIZE_2_5 (MAN_RSA_KEY_MODULUS_LEN_2_5 >> 2)
#define MAN_CSS_EXP_SIZE (MAN_RSA_KEY_EXPONENT_LEN >> 2)
#define MAN_CSS_MAN_SIZE_V1_8 \
(sizeof(struct fw_image_manifest_v1_8) >> 2)
@ -29,8 +32,10 @@ struct image;
* RSA Key and Crypto
*/
#define MAN_RSA_KEY_MODULUS_LEN 256
#define MAN_RSA_KEY_MODULUS_LEN_2_5 384
#define MAN_RSA_KEY_EXPONENT_LEN 4
#define MAN_RSA_SIGNATURE_LEN 256
#define MAN_RSA_SIGNATURE_LEN_2_5 384
struct fw_version {
uint16_t major_version;
@ -39,6 +44,26 @@ struct fw_version {
uint16_t build_version;
} __attribute__((packed));
struct css_header_v2_5 {
uint32_t header_type;
uint32_t header_len;
uint32_t header_version;
uint32_t reserved0; /* must be 0x1 */
uint32_t module_vendor;
uint32_t date;
uint32_t size;
uint8_t header_id[4];
uint32_t padding; /* must be 0x0 */
struct fw_version version;
uint32_t svn;
uint32_t reserved1[18]; /* must be 0x0 */
uint32_t modulus_size;
uint32_t exponent_size;
uint8_t modulus[MAN_RSA_KEY_MODULUS_LEN_2_5];
uint8_t exponent[MAN_RSA_KEY_EXPONENT_LEN];
uint8_t signature[MAN_RSA_SIGNATURE_LEN_2_5];
} __attribute__((packed));
struct css_header_v1_8 {
uint32_t header_type;
uint32_t header_len;
@ -78,5 +103,6 @@ struct css_header_v1_5 {
void ri_css_v1_8_hdr_create(struct image *image);
void ri_css_v1_5_hdr_create(struct image *image);
void ri_css_v2_5_hdr_create(struct image *image);
#endif