blob: bc69cf10b55eaf71233a15946697515955340edd [file] [log] [blame]
Liam Girdwood05ef4342018-02-13 20:29:40 +00001/*
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 <sys/time.h>
19#include "rimage.h"
20#include "css.h"
21#include "manifest.h"
22
23void ri_css_hdr_create(struct image *image)
24{
25 struct css_header *css = image->fw_image + MAN_CSS_HDR_OFFSET;
26 struct tm *date;
27 struct timeval tv;
28 int val;
29
30 fprintf(stdout, " cse: completing CSS manifest\n");
31
32 /* get local time and date */
33 gettimeofday(&tv, NULL);
34 date = localtime(&tv.tv_sec);
35 date->tm_year += 1900;
36 fprintf(stdout, " css: set build date to %d:%2.2d:%2.2d\n",
37 date->tm_year, date->tm_mon, date->tm_mday);
38
39 /* year yYyy */
40 val = date->tm_year / 1000;
41 css->date |= val << 28;
42 date->tm_year -= val * 1000;
43 /* year yyYy */
44 val = date->tm_year / 100;
45 css->date |= val << 24;
46 date->tm_year -= val * 100;
47 /* year yyyY */
48 val = date->tm_year / 10;
49 css->date |= val << 20;
50 date->tm_year -= val * 10;
51 /* year Yyyy */
52 val = date->tm_year;
53 css->date |= val << 16;
54
55 /* month Mm - for some reason month starts at 0 */
56 val = ++date->tm_mon / 10;
57 css->date |= val << 12;
58 date->tm_mon -= (val * 10);
59 /* month mM */
60 val = date->tm_mon;
61 css->date |= val << 8;
62
63 /* Day Dd */
64 val = date->tm_mday / 10;
65 css->date |= val << 4;
66 date->tm_mday -= (val * 10);
67 /* Day dD */
68 val = date->tm_mday;
69 css->date |= val << 0;
70}