-
Notifications
You must be signed in to change notification settings - Fork 308
/
cse.c
45 lines (40 loc) · 1.33 KB
/
cse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (c) 2017, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Keyon Jie <yang.jie@linux.intel.com>
*/
#include <stdio.h>
#include "rimage.h"
#include "cse.h"
#include "manifest.h"
void ri_cse_create(struct image *image)
{
struct CsePartitionDirHeader *cse_hdr = image->fw_image;
struct sof_man_adsp_meta_file_ext *meta = image->fw_image +
MAN_META_EXT_OFFSET;
struct CsePartitionDirEntry *cse_entry =
image->fw_image + sizeof(*cse_hdr);
uint8_t csum = 0, *val = image->fw_image;
int i, size;
fprintf(stdout, " cse: completing CSE manifest\n");
cse_entry[2].length = meta->comp_desc[0].limit_offset -
MAN_DESC_OFFSET;
/* calculate checksum using BSD algo */
size = sizeof(*cse_hdr) + sizeof(*cse_entry) * MAN_CSE_PARTS;
for (i = 0; i < size; i++) {
if (i == 11)
continue;
csum += val[i];
}
cse_hdr->checksum = 0x100 - csum;
}