Add `struct string` for strings parsed from FDT
Just a small wrapper around a char array to make things simpler.
Bug: 117551352
Change-Id: I0880ebbb81258830290ce49bf3772280551d3483
diff --git a/src/boot_flow/linux.c b/src/boot_flow/linux.c
index f4f34e0..9d4d886 100644
--- a/src/boot_flow/linux.c
+++ b/src/boot_flow/linux.c
@@ -14,34 +14,13 @@
* limitations under the License.
*/
+#include "hf/check.h"
#include "hf/cpio.h"
#include "hf/dlog.h"
#include "hf/fdt_handler.h"
#include "hf/plat/boot_flow.h"
#include "hf/std.h"
-/**
- * Looks for a file in the given cpio archive. The file, if found, is returned
- * in the "it" argument.
- */
-static bool find_file(const struct memiter *cpio, const char *name,
- struct memiter *it)
-{
- const char *fname;
- const void *fcontents;
- size_t fsize;
- struct memiter iter = *cpio;
-
- while (cpio_next(&iter, &fname, &fcontents, &fsize)) {
- if (!strcmp(fname, name)) {
- memiter_init(it, fcontents, fsize);
- return true;
- }
- }
-
- return false;
-}
-
/* Set by arch-specific boot-time hook. */
uintreg_t plat_boot_flow_fdt_addr;
@@ -76,9 +55,10 @@
struct boot_params_update *update,
struct memiter *cpio, struct mpool *ppool)
{
+ static struct string filename = STRING_INIT("initrd.img");
struct memiter primary_initrd;
- if (!find_file(cpio, "initrd.img", &primary_initrd)) {
+ if (!cpio_get_file(cpio, &filename, &primary_initrd)) {
dlog("Unable to find initrd.img\n");
return false;
}