Liam Girdwood | 05ef434 | 2018-02-13 20:29:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, Intel Corporation. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | */ |
| 13 | |
| 14 | #ifndef __CSS_H__ |
| 15 | #define __CSS_H__ |
| 16 | |
| 17 | #include <stdint.h> |
| 18 | |
| 19 | struct image; |
| 20 | |
| 21 | #define MAN_CSS_MOD_TYPE 4 |
| 22 | #define MAN_CSS_HDR_SIZE 161 /* in words */ |
| 23 | #define MAN_CSS_HDR_VERSION 0x10000 |
| 24 | #define MAN_CSS_MOD_VENDOR 0x8086 |
| 25 | #define MAN_CSS_HDR_ID {'$', 'M', 'N', '2'} |
| 26 | |
| 27 | #define MAN_CSS_KEY_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2) |
| 28 | #define MAN_CSS_MOD_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2) |
| 29 | #define MAN_CSS_EXP_SIZE (MAN_RSA_KEY_EXPONENT_LEN >> 2) |
| 30 | #define MAN_CSS_MAN_SIZE \ |
| 31 | (sizeof(struct fw_image_manifest) >> 2) |
| 32 | |
| 33 | /* |
| 34 | * RSA Key and Crypto |
| 35 | */ |
| 36 | #define MAN_RSA_KEY_MODULUS_LEN 256 |
| 37 | #define MAN_RSA_KEY_EXPONENT_LEN 4 |
| 38 | #define MAN_RSA_SIGNATURE_LEN 256 |
| 39 | |
| 40 | struct fw_version { |
| 41 | uint16_t major_version; |
| 42 | uint16_t minor_version; |
| 43 | uint16_t hotfix_version; |
| 44 | uint16_t build_version; |
| 45 | } __attribute__((packed)); |
| 46 | |
| 47 | struct css_header { |
| 48 | uint32_t header_type; |
| 49 | uint32_t header_len; |
| 50 | uint32_t header_version; |
| 51 | uint32_t reserved0; /* must be 0x0 */ |
| 52 | uint32_t module_vendor; |
| 53 | uint32_t date; |
| 54 | uint32_t size; |
| 55 | uint8_t header_id[4]; |
| 56 | uint32_t padding; /* must be 0x0 */ |
| 57 | struct fw_version version; |
| 58 | uint32_t svn; |
| 59 | uint32_t reserved1[18]; /* must be 0x0 */ |
| 60 | uint32_t modulus_size; |
| 61 | uint32_t exponent_size; |
| 62 | uint8_t modulus[MAN_RSA_KEY_MODULUS_LEN]; |
| 63 | uint8_t exponent[MAN_RSA_KEY_EXPONENT_LEN]; |
| 64 | uint8_t signature[MAN_RSA_SIGNATURE_LEN]; |
| 65 | } __attribute__((packed)); |
| 66 | |
| 67 | void ri_css_hdr_create(struct image *image); |
| 68 | |
| 69 | #endif |