forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss.c
More file actions
185 lines (160 loc) · 4.16 KB
/
css.c
File metadata and controls
185 lines (160 loc) · 4.16 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2017 Intel Corporation. All rights reserved.
//
// Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
// Keyon Jie <yang.jie@linux.intel.com>
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <rimage/rimage.h>
#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: %s completing CSS manifest\n", __func__);
/* 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;
struct tm *date;
struct timeval tv;
time_t seconds;
int val;
fprintf(stdout, " cse: %s completing CSS manifest\n", __func__);
/* 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_5_hdr_create(struct image *image)
{
struct css_header_v1_5 *css = image->fw_image;
struct tm *date;
struct timeval tv;
time_t seconds;
int val;
fprintf(stdout, " cse: %s completing CSS manifest\n", __func__);
/* 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;
}