From: Simon Glass <simon.glass@canonical.com>
Add a function to dump expo structures to a file, which is useful for
debugging. This uses the configurable output function added in the
previous patch.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
boot/expo_dump.c | 36 ++++++++++++++++++++++++++++++++++++
include/expo.h | 9 +++++++++
2 files changed, 45 insertions(+)
@@ -12,6 +12,7 @@
#include <expo.h>
#include <mapmem.h>
#include <membuf.h>
+#include <os.h>
#include <video.h>
#include <video_console.h>
#include "scene_internal.h"
@@ -306,3 +307,38 @@ void expo_dump(struct expo *exp, struct membuf *mb)
expo_dump_(&ctx, exp);
}
+
+/**
+ * dump_out_file() - Output function that writes to a file
+ *
+ * @priv: Pointer to file descriptor (int *)
+ * @buf: Buffer containing data to output
+ * @len: Length of data in buffer
+ */
+static void dump_out_file(void *priv, const char *buf, int len)
+{
+ int *fdp = priv;
+
+ os_write(*fdp, buf, len);
+}
+
+int expo_dump_file(struct expo *exp, const char *fname)
+{
+ struct dump_ctx ctx;
+ int fd;
+
+ fd = os_open(fname, OS_O_WRONLY | OS_O_CREAT | OS_O_TRUNC);
+ if (fd < 0)
+ return fd;
+
+ ctx.out = dump_out_file;
+ ctx.priv = &fd;
+ ctx.scn = NULL;
+ ctx.indent = 0;
+
+ expo_dump_(&ctx, exp);
+
+ os_close(fd);
+
+ return 0;
+}
@@ -1279,6 +1279,15 @@ void expo_damage_add(struct expo *exp, const struct vid_bbox *bbox);
*/
void expo_dump(struct expo *exp, struct membuf *mb);
+/**
+ * expo_dump_file() - Dump expo structure to a file (sandbox only)
+ *
+ * @exp: Expo to dump
+ * @fname: Filename to write to
+ * Return: 0 if OK, -ve on error
+ */
+int expo_dump_file(struct expo *exp, const char *fname);
+
/**
* scene_dump() - Dump scene structure to a membuf
*