mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
Store our image size (known at build time) in our version struct (now renamed to image_data). This will allow us to more efficiently determine the size of an image in a follow-up CL. Note that compatibility is broken for old ROs that do not include this CL. BUG=chromium:577915 TEST=Verify on kevin + lars + lars_pd that stored image size matches output of system_get_image_used() for both RO and RW images. BRANCH=None Change-Id: I7b8dc3ac8cf2df3184d0701a0e0ec8032de8d81b Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/450858 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Embed firmware version number in the binary */
|
|
|
|
#include <stdint.h>
|
|
#include "common.h"
|
|
#include "ec_version.h"
|
|
#include "version.h"
|
|
|
|
const struct image_data __keep current_image_data
|
|
__attribute__((section(".rodata.ver"))) = {
|
|
.cookie1 = CROS_EC_IMAGE_DATA_COOKIE1,
|
|
.version = CROS_EC_VERSION32,
|
|
#ifndef TEST_BUILD
|
|
.size = (const uintptr_t)&__image_size,
|
|
#endif
|
|
.cookie2 = CROS_EC_IMAGE_DATA_COOKIE2,
|
|
};
|
|
|
|
const char build_info[] __keep __attribute__((section(".rodata.buildinfo"))) =
|
|
CROS_EC_VERSION " " DATE " " BUILDER;
|
|
|
|
uint32_t ver_get_numcommits(void)
|
|
{
|
|
int i;
|
|
int numperiods = 0;
|
|
uint32_t ret = 0;
|
|
|
|
/*
|
|
* Version string is formatted like:
|
|
* name_major.branch.numcommits-hash[dirty]
|
|
* we want to return the numcommits as an int.
|
|
*/
|
|
for (i = 0; i < 32; i++) {
|
|
if (current_image_data.version[i] == '.') {
|
|
numperiods++;
|
|
if (numperiods == 2)
|
|
break;
|
|
}
|
|
}
|
|
|
|
i++;
|
|
for (; i < 32; i++) {
|
|
if (current_image_data.version[i] == '-')
|
|
break;
|
|
ret *= 10;
|
|
ret += current_image_data.version[i] - '0';
|
|
}
|
|
|
|
return (i == 32 ? 0 : ret);
|
|
}
|