mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
g: use single buffer for version reporting
The only place where two separate buffers for the RO version strings
is required is the tpm_registers.c:set_version_string() function.
In preparation of reporting the build string along with the version
string, let's rearrange the function not to require separate buffers
for the RO versions.
BRANCH=none
BUG=chrome-os-partner:55558
TEST=verified that version reported by the TPM driver on Kevin is
still correct:
localhost ~ # grep cr50 /sys/firmware/log
Firmware version: RO_A: 0.0.1/84e2dde7 RO_B:* 0.0.2/13eda43f RW_A:*...
Change-Id: I8924ac48bd838851670f0d659e95aa92a8524665
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364587
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
ff8c0b129e
commit
45e7be2213
@@ -184,7 +184,7 @@ enum system_image_copy_t system_get_ro_image_copy(void)
|
||||
* some here.
|
||||
*/
|
||||
#define MAX_RO_VER_LEN 48
|
||||
static char ro_str[2][MAX_RO_VER_LEN];
|
||||
static char vers_str[MAX_RO_VER_LEN];
|
||||
|
||||
const char *system_get_version(enum system_image_copy_t copy)
|
||||
{
|
||||
@@ -192,7 +192,6 @@ const char *system_get_version(enum system_image_copy_t copy)
|
||||
const struct SignedHeader *h;
|
||||
enum system_image_copy_t this_copy;
|
||||
uintptr_t vaddr, delta;
|
||||
int i;
|
||||
|
||||
switch (copy) {
|
||||
case SYSTEM_IMAGE_RO:
|
||||
@@ -202,11 +201,10 @@ const char *system_get_version(enum system_image_copy_t copy)
|
||||
if (vaddr == INVALID_ADDR)
|
||||
break;
|
||||
h = (const struct SignedHeader *)vaddr;
|
||||
i = (copy == SYSTEM_IMAGE_RO) ? 0 : 1;
|
||||
/* Use some fields from the header for the version string */
|
||||
snprintf(ro_str[i], MAX_RO_VER_LEN, "%d.%d.%d/%08x",
|
||||
snprintf(vers_str, MAX_RO_VER_LEN, "%d.%d.%d/%08x",
|
||||
h->epoch_, h->major_, h->minor_, h->img_chk_);
|
||||
return ro_str[i];
|
||||
return vers_str;
|
||||
|
||||
case SYSTEM_IMAGE_RW:
|
||||
case SYSTEM_IMAGE_RW_B:
|
||||
|
||||
@@ -119,17 +119,40 @@ static uint8_t tpm_fw_ver[180];
|
||||
static void set_version_string(void)
|
||||
{
|
||||
enum system_image_copy_t active_ro, active_rw;
|
||||
size_t offset;
|
||||
|
||||
active_ro = system_get_ro_image_copy();
|
||||
active_rw = system_get_image_copy();
|
||||
|
||||
snprintf(tpm_fw_ver, sizeof(tpm_fw_ver),
|
||||
"RO_A:%s %s RO_B:%s %s RW_A:%s %s RW_B:%s %s",
|
||||
"RO_A:%s %s",
|
||||
(active_ro == SYSTEM_IMAGE_RO ? "*" : ""),
|
||||
system_get_version(SYSTEM_IMAGE_RO),
|
||||
system_get_version(SYSTEM_IMAGE_RO));
|
||||
offset = strlen(tpm_fw_ver);
|
||||
if (offset == sizeof(tpm_fw_ver) - 1)
|
||||
return;
|
||||
|
||||
snprintf(tpm_fw_ver + offset,
|
||||
sizeof(tpm_fw_ver) - offset,
|
||||
" RO_B:%s %s",
|
||||
(active_ro == SYSTEM_IMAGE_RO_B ? "*" : ""),
|
||||
system_get_version(SYSTEM_IMAGE_RO_B),
|
||||
system_get_version(SYSTEM_IMAGE_RO_B));
|
||||
offset = strlen(tpm_fw_ver);
|
||||
if (offset == sizeof(tpm_fw_ver) - 1)
|
||||
return;
|
||||
|
||||
snprintf(tpm_fw_ver + offset,
|
||||
sizeof(tpm_fw_ver) - offset,
|
||||
" RW_A:%s %s",
|
||||
(active_rw == SYSTEM_IMAGE_RW ? "*" : ""),
|
||||
system_get_version(SYSTEM_IMAGE_RW),
|
||||
system_get_version(SYSTEM_IMAGE_RW));
|
||||
offset = strlen(tpm_fw_ver);
|
||||
if (offset == sizeof(tpm_fw_ver) - 1)
|
||||
return;
|
||||
|
||||
snprintf(tpm_fw_ver + offset,
|
||||
sizeof(tpm_fw_ver) - offset,
|
||||
" RW_B:%s %s",
|
||||
(active_rw == SYSTEM_IMAGE_RW_B ? "*" : ""),
|
||||
system_get_version(SYSTEM_IMAGE_RW_B));
|
||||
}
|
||||
@@ -535,7 +558,6 @@ static void call_extension_command(struct tpm_cmd_header *tpmh,
|
||||
|
||||
void tpm_task(void)
|
||||
{
|
||||
set_version_string();
|
||||
tpm_init();
|
||||
sps_tpm_enable();
|
||||
while (1) {
|
||||
|
||||
Reference in New Issue
Block a user