summaryrefslogtreecommitdiff
path: root/include/chromeos
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2011-11-03 14:00:57 -0700
committerVadim Bendebury <vbendeb@chromium.org>2011-11-04 09:51:55 -0700
commitb09086595e7844d068994476bd64737dc37a072b (patch)
treebc0f92ec1d18bb96ce7edf49a0784c00873b122e /include/chromeos
parent103dcae4b23ba2a3a33447af20342ca9fb4b55ce (diff)
Introduce ability to use hardware SPI mapping for read accesses.
On X86 systems the hardware maps the bootprom SPI flash chip into the top of memory address range. This could be used for accessing all information in the SPI flash. The vboot-reference code requires access to FMAP sections containing cryptographic information, and as of today, u-boot reads the whole sections, which are 64 KB in size, even though the actual areas accessed by vboot-reference are much smaller. A much faster way of accessing this information would be just passing around pointers to the appropriate memory areas. This would eliminate one copy, and also would make sure that only the areas actually accessed get fetched from SPI flash. This patch provides this ability trying to keep code changes to a minimum. New feature is enabled by defining CONFIG_HARDWARE_MAPPED_SPI. The firmware storage API for file reads changes when the new configuration option is set: a pointer to pointer to buffer is passed to the read_spi() function instead of a pointer to buffer. When the new feature is enabled the read_spi() function sets the pointer value to point to the requested data instead of copying the data into the buffer. A new data type is introduced (read_buf_type), which is set to be a (void *) if the new feature is not enabled, or (void **) otherwise. This type is used as the buffer pointer in the spi_read() function. Code allocating/freeing buffers used to keep data read from SPI flash is now conditionally compiled. Call sites for the spi_read() function are modified to adjust the buffer pointer parameter (pass the address of the parameter instead of the parameter, when the new feature is enabled). gbb field access functions can be aliased to gbb_init(), as they all in fact do the same - read a certain section of the gbb area. This change does not benefit the ARM implementations, and makes the code more complicated that it should be. Some u-boot rearchitecture along with vboot_reference API enhancements could address this. A tracking issue (http://code.google.com/p/chromium-os/issues/detail?id=22528) has been opened for that. BUG=chrome-os-partner:6585, chromium-os:22528 TEST=manual . build a new stumpy firmware image . boot the stumpy, observe it start up chromeos. . assess the boot timing using the cbmem.py utility (this modification shaves in excess of 100ms off the boot time). . disable the new feature, build a stumpy image, observe that is still boots chromeOs. . run emerge-terga2_kaen chromeos-u-boot to confirem that ARM version builds cleanly. Change-Id: I4e6ab530d24f5771b5a86a48d3f3135101b469a6 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/11152
Diffstat (limited to 'include/chromeos')
-rw-r--r--include/chromeos/firmware_storage.h12
-rw-r--r--include/chromeos/gbb.h13
2 files changed, 21 insertions, 4 deletions
diff --git a/include/chromeos/firmware_storage.h b/include/chromeos/firmware_storage.h
index 2ef6e2b034..e45819079b 100644
--- a/include/chromeos/firmware_storage.h
+++ b/include/chromeos/firmware_storage.h
@@ -15,6 +15,16 @@
#include <chromeos/fdt_decode.h>
+#ifndef CONFIG_HARDWARE_MAPPED_SPI
+typedef void *read_buf_type;
+#define BT_EXTRA
+#define FREE_IF_NEEDED(p) free(p)
+#else
+typedef void **read_buf_type;
+#define BT_EXTRA (read_buf_type) &
+#define FREE_IF_NEEDED(p)
+#endif
+
/**
* These read or write [count] bytes starting from [offset] of storage into or
* from the [buf].
@@ -27,7 +37,7 @@
*/
typedef struct firmware_storage_t {
int (*read)(struct firmware_storage_t *file,
- uint32_t offset, uint32_t count, void *buf);
+ uint32_t offset, uint32_t count, read_buf_type buf);
int (*write)(struct firmware_storage_t *file,
uint32_t offset, uint32_t count, void *buf);
int (*close)(struct firmware_storage_t *file);
diff --git a/include/chromeos/gbb.h b/include/chromeos/gbb.h
index 0d54f8fdd8..c3bc304b38 100644
--- a/include/chromeos/gbb.h
+++ b/include/chromeos/gbb.h
@@ -24,8 +24,9 @@
* @param gbb_offset Offset of GBB in flashrom device
* @return zero if this succeeds, non-zero if this fails
*/
-int gbb_init(void *gbb, firmware_storage_t *file, uint32_t gbb_offset);
+int gbb_init(read_buf_type gbb, firmware_storage_t *file, uint32_t gbb_offset);
+#ifndef CONFIG_HARDWARE_MAPPED_SPI
/**
* This loads the BMP block of GBB from flashrom.
*
@@ -34,7 +35,7 @@ int gbb_init(void *gbb, firmware_storage_t *file, uint32_t gbb_offset);
* @param gbb_offset Offset of GBB in flashrom device
* @return zero if this succeeds, non-zero if this fails
*/
-int gbb_read_bmp_block(void *gbb,
+int gbb_read_bmp_block(read_buf_type gbb,
firmware_storage_t *file, uint32_t gbb_offset);
/*
@@ -45,9 +46,15 @@ int gbb_read_bmp_block(void *gbb,
* @param gbb_offset Offset of GBB in flashrom device
* @return zero if this succeeds, non-zero if this fails
*/
-int gbb_read_recovery_key(void *gbb,
+int gbb_read_recovery_key(read_buf_type gbb,
firmware_storage_t *file, uint32_t gbb_offset);
+#else
+
+#define gbb_read_bmp_block gbb_init
+#define gbb_read_recovery_key gbb_init
+
+#endif
/**
* This is a sanity check of GBB blob.
*