Files
OpenCellular/chip/g/flash_info.h
Philip Chen ee54592238 cr50: Add console and TPM vendor commands to get/set board ID
This patch adds vendor and console commands to read and write the
board ID space in the INFO1 block.

Current image's board ID settings are saved in the image header by the
latest codesigner.

Board ID write attempts are rejected if the board ID space is already
initialized, or if the currently running image will not be allowed to
run with the new board ID space settings.

Error codes are returned to the caller as a single byte value.
Successful read command returns 12 bytes of the board ID space
contents.

The console command always allows to read the board ID value, and
allows to write it if the image was built with debug enabled.

BUG=b:35586335
BRANCH=cr50
TEST=as follows:
   - verified that board ID can be read by any image and set by debug
     images.

   - with the upcoming patches verified the ability to set and read
     board ID values using vendor commands.

Change-Id: I35a3e2db92175a29de8011172b80091065b27414
Signed-off-by: Philip Chen <philipchen@google.com>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/522234
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-02 16:59:33 -07:00

43 lines
1.3 KiB
C

/*
* Copyright 2016 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.
*/
#ifndef __EC_CHIP_G_FLASH_INFO_H
#define __EC_CHIP_G_FLASH_INFO_H
#include <stddef.h>
#include "signed_header.h"
/*
* Info1 space available to the app firmware is split in four equal size
* areas, used as follows:
*
* Area 0 - RO rollback prevention
* Area 1 - RW rollback prevention
* Area 2 - Board specific stuff
* Area 3 - Crypto scratch
*/
#define INFO_AREA_SIZE (INFO_MAX * 4)
#define INFO_TOTAL_SIZE (INFO_AREA_SIZE * 4)
#define INFO_RO_MAP_OFFSET 0
#define INFO_RO_MAP_SIZE INFO_AREA_SIZE
#define INFO_RW_MAP_OFFSET (INFO_RO_MAP_OFFSET + INFO_RO_MAP_SIZE)
#define INFO_RW_MAP_SIZE INFO_AREA_SIZE
#define INFO_BOARD_SPACE_OFFSET (INFO_RW_MAP_OFFSET + INFO_RW_MAP_SIZE)
int flash_info_read_enable(uint32_t offset, size_t size);
/* This in fact enables both read and write. */
int flash_info_write_enable(uint32_t offset, size_t size);
void flash_info_write_disable(void);
int flash_info_physical_write(int byte_offset, int num_bytes, const char *data);
int flash_physical_info_read_word(int byte_offset, uint32_t *dst);
void flash_open_ro_window(uint32_t offset, size_t size_b);
#endif /* ! __EC_CHIP_G_FLASH_INFO_H */