summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@chromium.org>2011-07-25 15:03:57 +0800
committerSimon Glass <sjg@chromium.org>2011-08-29 10:59:07 -0700
commita0f700ab4b06f7c8d87d336324f5813c9a31c684 (patch)
tree8fe7bf39c8807290e7a60dd2d2a976063ca1b8e6 /lib
parente15ae271675d02be118708ebb4498ffc7924e3f2 (diff)
CHROMIUM: move VbExNvStorageRead/Write to board-specific directory
As ARM accesses non-volatile storage from eMMC and x86 from CMOS, the accessor functions that export to vboot_reference are really not board-independent and so should be put at a board-dependent module. BUG=none TEST=make Change-Id: Idbd4d70372770597aa8897524ee6a1ffe173bfea Reviewed-on: http://gerrit.chromium.org/gerrit/4646 Tested-by: Che-Liang Chiou <clchiou@chromium.org> Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/vbexport/Makefile1
-rw-r--r--lib/vbexport/nvstorage.c113
2 files changed, 0 insertions, 114 deletions
diff --git a/lib/vbexport/Makefile b/lib/vbexport/Makefile
index c59cd8e87c..378e043ad2 100644
--- a/lib/vbexport/Makefile
+++ b/lib/vbexport/Makefile
@@ -17,7 +17,6 @@ COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += display.o
COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += keyboard.o
COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += load_firmware.o
COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += misc.o
-COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += nvstorage.o
COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += tlcl_stub.o
COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += utility.o
diff --git a/lib/vbexport/nvstorage.c b/lib/vbexport/nvstorage.c
deleted file mode 100644
index e9f49c4f85..0000000000
--- a/lib/vbexport/nvstorage.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2011 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.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- */
-
-#include <common.h>
-#include <chromeos/common.h>
-
-/* Import the header files from vboot_reference. */
-#include <vboot_api.h>
-
-#define PREFIX "nvstorage: "
-
-/*
- * We had a discussion about the non-volatile storage device for keeping
- * the cookies. Due to the lack of SPI flash driver in kernel, kernel cannot
- * access cookies in SPI flash. So the final descision is to store the
- * cookies in eMMC device where we are certain that kernel can access.
- */
-
-/*
- * Gets the first internal disk and caches the result in a static variable.
- * Returns 0 for success, non-zero for failure.
- */
-static int get_internal_disk(VbDiskInfo **disk_ptr)
-{
- static VbDiskInfo internal_disk;
-
- if (internal_disk.handle == NULL) {
- VbDiskInfo* disk_info;
- uint32_t disk_count;
-
- if (VbExDiskGetInfo(&disk_info, &disk_count,
- VB_DISK_FLAG_FIXED) || disk_count == 0) {
- VBDEBUG(PREFIX "No internal disk found!\n");
- return 1;
- }
- internal_disk = disk_info[0];
- VbExDiskFreeInfo(disk_info, internal_disk.handle);
- }
-
- *disk_ptr = &internal_disk;
- return 0;
-}
-
-/*
- * Allocates 1-block-sized memory to block_buf_ptr and fills it as the first
- * block of the disk.
- * Returns 0 for success, non-zero for failure.
- */
-static int get_nvcxt_block_of_disk(const VbDiskInfo *disk,
- uint8_t **block_buf_ptr)
-{
- uint8_t *block_buf = NULL;
-
- block_buf = VbExMalloc(disk->bytes_per_lba);
-
- if (VbExDiskRead(disk->handle,
- CHROMEOS_VBNVCONTEXT_LBA, 1, block_buf)) {
- VBDEBUG(PREFIX "Failed to read internal disk!\n");
- VbExFree(block_buf);
- return 1;
- }
-
- *block_buf_ptr = block_buf;
- return 0;
-}
-
-VbError_t VbExNvStorageRead(uint8_t* buf)
-{
- VbDiskInfo *internal_disk;
- uint8_t *block_buf;
-
- if (get_internal_disk(&internal_disk))
- return 1;
-
- if (get_nvcxt_block_of_disk(internal_disk, &block_buf))
- return 1;
-
- memcpy(buf, block_buf, VBNV_BLOCK_SIZE);
-
- VbExFree(block_buf);
- return VBERROR_SUCCESS;
-}
-
-VbError_t VbExNvStorageWrite(const uint8_t* buf)
-{
- VbDiskInfo *internal_disk;
- uint8_t *block_buf;
-
- if (get_internal_disk(&internal_disk))
- return 1;
-
- if (get_nvcxt_block_of_disk(internal_disk, &block_buf))
- return 1;
-
- memcpy(block_buf, buf, VBNV_BLOCK_SIZE);
-
- if (VbExDiskWrite(internal_disk->handle,
- CHROMEOS_VBNVCONTEXT_LBA, 1, block_buf)) {
- VBDEBUG(PREFIX "Failed to write internal disk!\n");
- VbExFree(block_buf);
- return 1;
- }
-
- VbExFree(block_buf);
- return VBERROR_SUCCESS;
-}