Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: host/lib/fmap.c

Issue 6465018: Add load_firmware_test utility program (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Code review & remove tabs Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: host/lib/fmap.c
diff --git a/host/lib/fmap.c b/host/lib/fmap.c
new file mode 100644
index 0000000000000000000000000000000000000000..c2e28ec3deb12823a6b50ddb608204d774c28087
--- /dev/null
+++ b/host/lib/fmap.c
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "fmap.h"
+
+/* Return NULL if fail */
gauravsh 2011/02/10 20:02:05 remove this comment - since you already document t
Che-Liang Chiou 2011/02/14 02:27:53 Done.
+const char *FindFmap(const char *ptr, size_t size)
gauravsh 2011/02/10 20:02:05 const char*
Che-Liang Chiou 2011/02/14 02:27:53 Done.
+{
+ size_t i;
+ for (i=0; i<size; i += FMAP_SEARCH_STRIDE) {
+ if (0 == strncmp(ptr, "__FMAP__", 8))
Randall Spangler 2011/02/11 17:26:04 Seems like "__FMAP__" should be a const string or
Che-Liang Chiou 2011/02/14 02:27:53 Done.
+ return ptr;
+ ptr += FMAP_SEARCH_STRIDE;
+ }
+ return NULL;
+}
+
+int FmapAreaIndex(const FmapHeader* fh, const FmapAreaHeader* ah,
+ const char* name) {
+ int i;
+ for (i = 0; i < fh->fmap_nareas; i++)
+ if (!strcmp((const char*) ah[i].area_name, name))
+ return i;
+ return -1;
+}

Powered by Google App Engine
This is Rietveld 408576698