2019-06-02 02:01:02 +08:00
|
|
|
// 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>
|
2018-02-14 04:29:40 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "rimage.h"
|
|
|
|
#include "css.h"
|
|
|
|
#include "manifest.h"
|
|
|
|
|
2018-12-01 00:06:30 +08:00
|
|
|
void ri_css_v1_8_hdr_create(struct image *image)
|
2018-02-14 04:29:40 +08:00
|
|
|
{
|
2018-11-08 18:30:03 +08:00
|
|
|
struct css_header_v1_8 *css = image->fw_image + MAN_CSS_HDR_OFFSET;
|
2018-02-14 04:29:40 +08:00
|
|
|
struct tm *date;
|
|
|
|
struct timeval tv;
|
2019-01-30 14:53:06 +08:00
|
|
|
time_t seconds;
|
2018-02-14 04:29:40 +08:00
|
|
|
int val;
|
|
|
|
|
|
|
|
fprintf(stdout, " cse: completing CSS manifest\n");
|
|
|
|
|
|
|
|
/* get local time and date */
|
2018-12-01 00:06:30 +08:00
|
|
|
gettimeofday(&tv, NULL);
|
2019-01-30 14:53:06 +08:00
|
|
|
seconds = tv.tv_sec;
|
|
|
|
date = localtime(&seconds);
|
2018-12-01 00:06:30 +08:00
|
|
|
|
|
|
|
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;
|
2019-01-30 14:53:06 +08:00
|
|
|
time_t seconds;
|
2018-12-01 00:06:30 +08:00
|
|
|
int val;
|
|
|
|
|
|
|
|
fprintf(stdout, " cse: completing CSS manifest\n");
|
|
|
|
|
|
|
|
/* get local time and date */
|
2018-02-14 04:29:40 +08:00
|
|
|
gettimeofday(&tv, NULL);
|
2019-01-30 14:53:06 +08:00
|
|
|
seconds = tv.tv_sec;
|
|
|
|
date = localtime(&seconds);
|
2018-05-11 15:55:40 +08:00
|
|
|
|
|
|
|
if (!date) {
|
|
|
|
fprintf(stderr, "error: cant get localtime %d\n", -errno);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-14 04:29:40 +08:00
|
|
|
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;
|
|
|
|
}
|