summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2011-08-02 21:45:02 -0700
committerSimon Glass <sjg@chromium.org>2011-08-29 10:59:22 -0700
commitf2dd80ae0a4e4f3b9b22e03a3ca1de91c95114aa (patch)
tree99a90d586620e789a3fe9e68f9ee288af2f3bc37 /lib
parent4cf39fdb7dda7e76b6d8c55e990c2234c648bb51 (diff)
Make the chromeos FMAP data structures more generic and in their own files.
This change separates out the FMAP data structures from the FDT decode functions and renames them to more neutral names. These structures don't intrinsically have to be loaded from the FDT, and their new names and location remove the implied dependency. BUG=chrome-os-partner:5248 TEST=Built for x86-alex and tegra2_kaen. Installed on Kaen and booted to chromeos login. Change-Id: I5680a3f3aaa52efe44c2060d0b6db9ad47a547ec Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: http://gerrit.chromium.org/gerrit/5231 Reviewed-by: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org>
Diffstat (limited to 'lib')
-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
6 files changed, 57 insertions, 37 deletions
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;