diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2011-04-22 15:52:57 +0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-24 10:01:07 -0700 |
commit | 385ef2c37fb86f9401c1176433d1f5bef20901a7 (patch) | |
tree | 881c6befc8672468d8aa090208e732bb55e0bdea | |
parent | e4ef3d35a1598337e596b7611eeb42f55477ab4d (diff) |
Store VbNvContext in MBR
The VbNvContext cookie has to be stored in a place that firmware and
kernel can access even before the partition table is created. So the EFI
partition is not a good candidate of storage.
On ARM platforms the MBR is not used by any part of the system, and so
it is quite safe to use MBR for VbNvContext storage.
This commit also reverts commit 8e23ac.
Note: The VbNvContext was stored in SPI flash, but it turned out that
kernel could not access SPI flash due to driver issues. So the storage
was temporarily moved to eMMC device.
R=rongchang@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6878095
Change-Id: Ie460318a653c54060dfc238a8d3bd77ade16c59b
-rw-r--r-- | include/fat.h | 1 | ||||
-rw-r--r-- | lib/chromeos/vboot_nvstorage_helper.c | 31 |
2 files changed, 8 insertions, 24 deletions
diff --git a/include/fat.h b/include/fat.h index 74a128baa35..b8dd932ad4f 100644 --- a/include/fat.h +++ b/include/fat.h @@ -213,7 +213,6 @@ int file_cd(const char *path); int file_fat_detectfs(void); int file_fat_ls(const char *dir); long file_fat_read(const char *filename, void *buffer, unsigned long maxsize); -int file_fat_starting_lba(const char *filename, uint64_t *starting_lba_ptr); const char *file_getfsname(int idx); int fat_register_device(block_dev_desc_t *dev_desc, int part_no); diff --git a/lib/chromeos/vboot_nvstorage_helper.c b/lib/chromeos/vboot_nvstorage_helper.c index 993497b988b..07497a7dd58 100644 --- a/lib/chromeos/vboot_nvstorage_helper.c +++ b/lib/chromeos/vboot_nvstorage_helper.c @@ -38,7 +38,6 @@ #include <chromeos/vboot_nvstorage_helper.h> /* TODO: temporary hack for factory bring up; remove/rewrite when necessary */ -#include <fat.h> #include <mmc.h> #include <part.h> #include <asm/arch/nv_sdmmc.h> @@ -55,9 +54,6 @@ #define PREFIX "vboot_nvstorage_helper: " -#define VBNVCONTEXT_PATH "/u-boot/nvcxt.bin" -#define EFI_PART_NUM 0xc - static int set_mmc_device(int new_device_index, int *last_device_index_ptr) { int cur_dev = mmc_get_current_dev_index(); @@ -88,19 +84,8 @@ static int prepare_access_nvcontext(block_dev_desc_t **dev_desc_ptr, return -1; } - if (fat_register_device(dev_desc, EFI_PART_NUM) != 0) { - debug(PREFIX "fat_register_deivce fail\n"); - return -1; - } - - if (file_fat_starting_lba(VBNVCONTEXT_PATH, nvcxt_lba_ptr)) { - debug(PREFIX "file_fat_starting_lba fail\n"); - return -1; - } - - debug(PREFIX "starting_lba=0x%x\n", (int) *nvcxt_lba_ptr); - *dev_desc_ptr = dev_desc; + *nvcxt_lba_ptr = 0; /* Store cookie in MBR */ return 0; } @@ -125,14 +110,14 @@ static int access_nvcontext(firmware_storage_t *file, VbNvContext *nvcxt, goto EXIT; } - if (is_read) { - if (dev_desc->block_read(dev_desc->dev, - nvcxt_lba, 1, buf) < 0) { - debug(PREFIX "block_read fail\n"); - goto EXIT; - } + if (dev_desc->block_read(dev_desc->dev, nvcxt_lba, 1, buf) < 0) { + debug(PREFIX "block_read fail\n"); + goto EXIT; + } + + if (is_read) memcpy(nvcxt->raw, buf, VBNV_BLOCK_SIZE); - } else { + else { memcpy(buf, nvcxt->raw, VBNV_BLOCK_SIZE); if (dev_desc->block_write(dev_desc->dev, nvcxt_lba, 1, buf) < 0) { |