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 | * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> |
| 14 | * Keyon Jie <yang.jie@linux.intel.com> |
| 15 | */ |
| 16 | |
| 17 | #include <stdio.h> |
| 18 | #include "rimage.h" |
| 19 | #include "cse.h" |
| 20 | #include "manifest.h" |
| 21 | |
| 22 | void ri_cse_create(struct image *image) |
| 23 | { |
| 24 | struct CsePartitionDirHeader *cse_hdr = image->fw_image; |
| 25 | struct sof_man_adsp_meta_file_ext *meta = image->fw_image + |
| 26 | MAN_META_EXT_OFFSET; |
| 27 | struct CsePartitionDirEntry *cse_entry = |
| 28 | image->fw_image + sizeof(*cse_hdr); |
| 29 | uint8_t csum = 0, *val = image->fw_image; |
| 30 | int i, size; |
| 31 | |
| 32 | fprintf(stdout, " cse: completing CSE manifest\n"); |
| 33 | |
| 34 | cse_entry[2].length = meta->comp_desc[0].limit_offset - |
| 35 | MAN_DESC_OFFSET; |
| 36 | |
| 37 | /* calculate checksum using BSD algo */ |
| 38 | size = sizeof(*cse_hdr) + sizeof(*cse_entry) * MAN_CSE_PARTS; |
| 39 | for (i = 0; i < size; i++) { |
| 40 | if (i == 11) |
| 41 | continue; |
| 42 | csum += val[i]; |
| 43 | } |
| 44 | cse_hdr->checksum = 0x100 - csum; |
| 45 | } |