summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/cmd_vbexport_test.c2
-rw-r--r--common/cmd_vboot_twostop.c14
-rw-r--r--include/chromeos/fdt_decode.h33
-rw-r--r--include/chromeos/firmware_storage.h2
-rw-r--r--include/chromeos/fmap.h45
-rw-r--r--lib/chromeos/Makefile1
-rw-r--r--lib/chromeos/fdt_decode.c32
-rw-r--r--lib/chromeos/firmware_storage_twostop.c10
-rw-r--r--lib/chromeos/fmap.c43
-rw-r--r--lib/vboot/bootstub_entry.c6
-rw-r--r--lib/vboot/global_data.c2
11 files changed, 114 insertions, 76 deletions
diff --git a/common/cmd_vbexport_test.c b/common/cmd_vbexport_test.c
index f12c8723cd..b04ab2cd81 100644
--- a/common/cmd_vbexport_test.c
+++ b/common/cmd_vbexport_test.c
@@ -403,7 +403,7 @@ static uint8_t *read_gbb_from_firmware(void)
void *fdt_ptr = (void *)gd->blob;
vb_global_t *global;
firmware_storage_t file;
- struct fdt_twostop_fmap fmap;
+ struct twostop_fmap fmap;
global = get_vboot_global();
diff --git a/common/cmd_vboot_twostop.c b/common/cmd_vboot_twostop.c
index 593fdbde5f..1e72663100 100644
--- a/common/cmd_vboot_twostop.c
+++ b/common/cmd_vboot_twostop.c
@@ -121,7 +121,7 @@ const char *str_selection(uint32_t selection)
}
#endif /* VBOOT_DEBUG */
-int twostop_init_cparams(struct fdt_twostop_fmap *fmap,
+int twostop_init_cparams(struct twostop_fmap *fmap,
void *gbb,
void *vb_shared_data,
VbCommonParams *cparams)
@@ -234,7 +234,7 @@ VbError_t twostop_init_vboot_library(const void const *fdt,
return VBERROR_SUCCESS;
}
-uint32_t twostop_make_selection(struct fdt_twostop_fmap *fmap,
+uint32_t twostop_make_selection(struct twostop_fmap *fmap,
firmware_storage_t *file,
VbCommonParams *cparams,
void **fw_blob_ptr,
@@ -325,7 +325,7 @@ out:
}
uint32_t twostop_select_and_set_main_firmware(const void const *fdt,
- struct fdt_twostop_fmap *fmap,
+ struct twostop_fmap *fmap,
firmware_storage_t *file,
void *gbb,
crossystem_data_t *cdata,
@@ -430,7 +430,7 @@ uint32_t twostop_jump(crossystem_data_t *cdata, void *fw_blob, uint32_t fw_size)
}
int twostop_init(const void const *fdt,
- struct fdt_twostop_fmap *fmap,
+ struct twostop_fmap *fmap,
firmware_storage_t *file,
void *gbb,
crossystem_data_t *cdata,
@@ -508,7 +508,7 @@ out:
return ret;
}
-uint32_t twostop_main_firmware(struct fdt_twostop_fmap *fmap,
+uint32_t twostop_main_firmware(struct twostop_fmap *fmap,
void *gbb,
crossystem_data_t *cdata,
void *vb_shared_data)
@@ -563,7 +563,7 @@ uint32_t twostop_main_firmware(struct fdt_twostop_fmap *fmap,
uint32_t twostop_boot(const void const *fdt)
{
- struct fdt_twostop_fmap fmap;
+ struct twostop_fmap fmap;
firmware_storage_t file;
crossystem_data_t *cdata = (crossystem_data_t *)CROSSYSTEM_DATA_ADDRESS;
void *gbb = (void *)GBB_ADDRESS;
@@ -619,7 +619,7 @@ uint32_t twostop_boot(const void const *fdt)
uint32_t twostop_readwrite_main_firmware(const void const *fdt)
{
- struct fdt_twostop_fmap fmap;
+ struct twostop_fmap fmap;
crossystem_data_t *cdata = (crossystem_data_t *)CROSSYSTEM_DATA_ADDRESS;
void *gbb = (void *)GBB_ADDRESS;
void *vb_shared_data = cdata->vb_shared_data;
diff --git a/include/chromeos/fdt_decode.h b/include/chromeos/fdt_decode.h
index 4585b9a62d..dcb98cbbf1 100644
--- a/include/chromeos/fdt_decode.h
+++ b/include/chromeos/fdt_decode.h
@@ -11,38 +11,11 @@
#ifndef CHROMEOS_FDT_DECODE_H_
#define CHROMEOS_FDT_DECODE_H_
-/* Decode Chrome OS specific configuration from fdt */
-
-struct fdt_fmap_entry {
- uint32_t offset;
- uint32_t length;
-};
-
-struct fdt_firmware_entry {
- struct fdt_fmap_entry boot; /* U-Boot */
- struct fdt_fmap_entry vblock;
- struct fdt_fmap_entry firmware_id;
- uint64_t block_lba;
-};
-
-/*
- * Only sections that are used during booting are put here. More sections will
- * be added if required.
- */
-struct fdt_twostop_fmap {
- struct {
- struct fdt_fmap_entry fmap;
- struct fdt_fmap_entry gbb;
- struct fdt_fmap_entry firmware_id;
- } readonly;
+#include <chromeos/fmap.h>
- struct fdt_firmware_entry readwrite_a;
- struct fdt_firmware_entry readwrite_b;
-};
-
-int fdt_decode_twostop_fmap(const void *fdt, struct fdt_twostop_fmap *config);
+/* Decode Chrome OS specific configuration from fdt */
-void dump_fmap(struct fdt_twostop_fmap *config);
+int fdt_decode_twostop_fmap(const void *fdt, struct twostop_fmap *config);
/**
* This checks whether a property exists.
diff --git a/include/chromeos/firmware_storage.h b/include/chromeos/firmware_storage.h
index 8e82aaa7d6..2ef6e2b034 100644
--- a/include/chromeos/firmware_storage.h
+++ b/include/chromeos/firmware_storage.h
@@ -44,6 +44,6 @@ typedef struct firmware_storage_t {
int firmware_storage_open_spi(firmware_storage_t *file);
int firmware_storage_open_twostop(firmware_storage_t *file,
- struct fdt_twostop_fmap *fmap);
+ struct twostop_fmap *fmap);
#endif /* CHROMEOS_FIRMWARE_STORAGE_H_ */
diff --git a/include/chromeos/fmap.h b/include/chromeos/fmap.h
new file mode 100644
index 0000000000..37efc4b128
--- /dev/null
+++ b/include/chromeos/fmap.h
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#ifndef CHROMEOS_FMAP_H_
+#define CHROMEOS_FMAP_H_
+
+/* Structures to hold Chrome OS specific configuration from the FMAP. */
+
+struct fmap_entry {
+ uint32_t offset;
+ uint32_t length;
+};
+
+struct fmap_firmware_entry {
+ struct fmap_entry boot; /* U-Boot */
+ struct fmap_entry vblock;
+ struct fmap_entry firmware_id;
+ uint64_t block_lba;
+};
+
+/*
+ * Only sections that are used during booting are put here. More sections will
+ * be added if required.
+ */
+struct twostop_fmap {
+ struct {
+ struct fmap_entry fmap;
+ struct fmap_entry gbb;
+ struct fmap_entry firmware_id;
+ } readonly;
+
+ struct fmap_firmware_entry readwrite_a;
+ struct fmap_firmware_entry readwrite_b;
+};
+
+void dump_fmap(struct twostop_fmap *config);
+
+#endif /* CHROMEOS_FMAP_H_ */
diff --git a/lib/chromeos/Makefile b/lib/chromeos/Makefile
index 6305673cc7..d59589c455 100644
--- a/lib/chromeos/Makefile
+++ b/lib/chromeos/Makefile
@@ -16,6 +16,7 @@ COBJS-$(CONFIG_CHROMEOS) += boot_kernel.o
COBJS-$(CONFIG_CHROMEOS) += crossystem_data.o
COBJS-$(CONFIG_CHROMEOS) += fdt_decode.o
COBJS-$(CONFIG_CHROMEOS) += firmware_storage_spi.o
+COBJS-$(CONFIG_CHROMEOS) += fmap.o
COBJS-$(CONFIG_CHROMEOS) += gbb.o
COBJS-$(CONFIG_CHROMEOS) += memory_wipe.o
diff --git a/lib/chromeos/fdt_decode.c b/lib/chromeos/fdt_decode.c
index f5bf177dd2..ace7fa3a87 100644
--- a/lib/chromeos/fdt_decode.c
+++ b/lib/chromeos/fdt_decode.c
@@ -12,6 +12,7 @@
#include <libfdt.h>
#include <chromeos/common.h>
#include <chromeos/fdt_decode.h>
+#include <chromeos/fmap.h>
#include <linux/string.h>
#define PREFIX "chromeos/fdt_decode: "
@@ -43,7 +44,7 @@ static int relpath_offset(const void *blob, int offset, const char *in_path)
}
static int decode_fmap_entry(const void *blob, int offset, const char *base,
- const char *name, struct fdt_fmap_entry *entry)
+ const char *name, struct fmap_entry *entry)
{
char path[50];
int length;
@@ -90,7 +91,7 @@ static int decode_block_lba(const void *blob, int offset, const char *path,
}
int decode_firmware_entry(const char *blob, int fmap_offset, const char *name,
- struct fdt_firmware_entry *entry)
+ struct fmap_firmware_entry *entry)
{
int err;
@@ -103,7 +104,7 @@ int decode_firmware_entry(const char *blob, int fmap_offset, const char *name,
return err;
}
-int fdt_decode_twostop_fmap(const void *blob, struct fdt_twostop_fmap *config)
+int fdt_decode_twostop_fmap(const void *blob, struct twostop_fmap *config)
{
int fmap_offset;
int err;
@@ -129,31 +130,6 @@ int fdt_decode_twostop_fmap(const void *blob, struct fdt_twostop_fmap *config)
return 0;
}
-void dump_entry(const char *path, struct fdt_fmap_entry *entry)
-{
- VBDEBUG(PREFIX "%-20s %08x:%08x\n", path, entry->offset,
- entry->length);
-}
-
-void dump_firmware_entry(const char *name, struct fdt_firmware_entry *entry)
-{
- VBDEBUG(PREFIX "%s\n", name);
- dump_entry("boot", &entry->boot);
- dump_entry("vblock", &entry->vblock);
- dump_entry("firmware_id", &entry->firmware_id);
- VBDEBUG(PREFIX "%-20s %08llx\n", "LBA", entry->block_lba);
-}
-
-void dump_fmap(struct fdt_twostop_fmap *config)
-{
- VBDEBUG(PREFIX "rw-a:\n");
- dump_entry("fmap", &config->readonly.fmap);
- dump_entry("gbb", &config->readonly.gbb);
- dump_entry("firmware_id", &config->readonly.firmware_id);
- dump_firmware_entry("rw-a", &config->readwrite_a);
- dump_firmware_entry("rw-b", &config->readwrite_b);
-}
-
int fdt_decode_chromeos_config_has_prop(const void *fdt, const char *name)
{
int nodeoffset = fdt_path_offset(fdt, "/chromeos-config");
diff --git a/lib/chromeos/firmware_storage_twostop.c b/lib/chromeos/firmware_storage_twostop.c
index 2bc61438fe..913abe61ca 100644
--- a/lib/chromeos/firmware_storage_twostop.c
+++ b/lib/chromeos/firmware_storage_twostop.c
@@ -24,18 +24,18 @@ enum {
};
struct context {
- struct fdt_twostop_fmap *fmap;
+ struct twostop_fmap *fmap;
int section;
firmware_storage_t spi_file;
struct mmc *mmc;
};
-static int within_entry(const struct fdt_fmap_entry *e, uint32_t offset)
+static int within_entry(const struct fmap_entry *e, uint32_t offset)
{
return e->offset <= offset && offset < e->offset + e->length;
}
-static int get_section(const struct fdt_twostop_fmap *fmap, off_t offset)
+static int get_section(const struct twostop_fmap *fmap, off_t offset)
{
if (within_entry(&fmap->readonly.readonly, offset))
return SECTION_RO;
@@ -47,7 +47,7 @@ static int get_section(const struct fdt_twostop_fmap *fmap, off_t offset)
return -1;
}
-static void set_start_block_and_offset(const struct fdt_twostop_fmap *fmap,
+static void set_start_block_and_offset(const struct twostop_fmap *fmap,
int section, uint32_t offset,
uint32_t *start_block_ptr, uint32_t *offset_in_block_ptr)
{
@@ -220,7 +220,7 @@ static int close_twostop(firmware_storage_t *file)
}
int firmware_storage_open_twostop(firmware_storage_t *file,
- struct fdt_twostop_fmap *fmap)
+ struct twostop_fmap *fmap)
{
struct context *cxt;
diff --git a/lib/chromeos/fmap.c b/lib/chromeos/fmap.c
new file mode 100644
index 0000000000..d9b32b679a
--- /dev/null
+++ b/lib/chromeos/fmap.c
@@ -0,0 +1,43 @@
+/*
+ * 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>
+#include <chromeos/fmap.h>
+
+#define PREFIX "chromeos/fdt_decode: "
+
+static void
+dump_fmap_entry(const char *path, struct fmap_entry *entry)
+{
+ VBDEBUG(PREFIX "%-20s %08x:%08x\n", path, entry->offset,
+ entry->length);
+}
+
+static void
+dump_fmap_firmware_entry(const char *name, struct fmap_firmware_entry *entry)
+{
+ VBDEBUG(PREFIX "%s\n", name);
+ dump_fmap_entry("boot", &entry->boot);
+ dump_fmap_entry("vblock", &entry->vblock);
+ dump_fmap_entry("firmware_id", &entry->firmware_id);
+ VBDEBUG(PREFIX "%-20s %08llx\n", "LBA", entry->block_lba);
+}
+
+void
+dump_fmap(struct twostop_fmap *config)
+{
+ VBDEBUG(PREFIX "rw-a:\n");
+ dump_fmap_entry("fmap", &config->readonly.fmap);
+ dump_fmap_entry("gbb", &config->readonly.gbb);
+ dump_fmap_entry("firmware_id", &config->readonly.firmware_id);
+ dump_fmap_firmware_entry("rw-a", &config->readwrite_a);
+ dump_fmap_firmware_entry("rw-b", &config->readwrite_b);
+}
diff --git a/lib/vboot/bootstub_entry.c b/lib/vboot/bootstub_entry.c
index 89351adbaa..c30405076e 100644
--- a/lib/vboot/bootstub_entry.c
+++ b/lib/vboot/bootstub_entry.c
@@ -91,7 +91,7 @@ static int read_verification_block(firmware_storage_t *file,
static void prepare_fparams(firmware_storage_t *file,
firmware_cache_t *cache,
- struct fdt_twostop_fmap *fmap,
+ struct twostop_fmap *fmap,
VbSelectFirmwareParams *fparams)
{
uint32_t fw_main_a_size, fw_main_b_size;
@@ -241,7 +241,7 @@ static VbError_t call_VbSelectFirmware(VbCommonParams *cparams,
static int fill_crossystem_data(vb_global_t *global,
firmware_storage_t *file,
- struct fdt_twostop_fmap *fmap,
+ struct twostop_fmap *fmap,
uint32_t selected_firmware)
{
crossystem_data_t *cdata = &global->cdata_blob;
@@ -291,7 +291,7 @@ done:
void bootstub_entry(void)
{
void *fdt_ptr = (void *)gd->blob;
- struct fdt_twostop_fmap fmap;
+ struct twostop_fmap fmap;
vb_global_t *global;
firmware_storage_t file;
firmware_cache_t cache;
diff --git a/lib/vboot/global_data.c b/lib/vboot/global_data.c
index 0a8ecbf873..0070d3fe18 100644
--- a/lib/vboot/global_data.c
+++ b/lib/vboot/global_data.c
@@ -31,7 +31,7 @@ int init_vboot_global(vb_global_t *global, firmware_storage_t *file)
{
void *fdt_ptr = (void *)gd->blob;
cros_gpio_t wpsw, recsw, devsw;
- struct fdt_twostop_fmap fmap;
+ struct twostop_fmap fmap;
uint8_t frid[ID_LEN];
GoogleBinaryBlockHeader *gbb =
(GoogleBinaryBlockHeader *)global->gbb_data;