summaryrefslogtreecommitdiff
path: root/platform/wavelet3d/host_sw/init.c
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2024-05-23 20:24:51 -0600
committerAlejandro Soto <alejandro@34project.org>2024-05-24 05:58:44 -0600
commitc2d178577ae7d9272d7aff35895a36aefe626eca (patch)
tree1c8ef89df743f01db9e108dc10f559bae5a10ce6 /platform/wavelet3d/host_sw/init.c
parenta148430ae145d99ba50a87b6147fa0e6e81cb258 (diff)
platform/wavelet3d/host_sw: implement firmware loading
Diffstat (limited to '')
-rw-r--r--platform/wavelet3d/host_sw/init.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/platform/wavelet3d/host_sw/init.c b/platform/wavelet3d/host_sw/init.c
new file mode 100644
index 0000000..3acc8f3
--- /dev/null
+++ b/platform/wavelet3d/host_sw/init.c
@@ -0,0 +1,46 @@
+#define MOD_NAME "init"
+
+#include <stdlib.h>
+
+#include "gfx.h"
+#include "init.h"
+#include "log.h"
+
+extern const unsigned char _binary_gfx_fw_bin_start[];
+extern const unsigned char _binary_gfx_fw_bin_end;
+extern const unsigned char _binary_gfx_fw_bin_size;
+
+static void __attribute__((noreturn)) init_gfx_failed(void)
+{
+ log("fatal: probe of gfx device failed");
+ abort();
+}
+
+static void init_gfx(int bootrom)
+{
+ switch (gfx_probe()) {
+ case GFX_PROBE_FAILED:
+ init_gfx_failed();
+ break;
+
+ case GFX_PROBE_BOOTROM:
+ if (bootrom)
+ log("gfx bootloader didn't handover to firmware");
+
+ size_t fw_size = (size_t)&_binary_gfx_fw_bin_size;
+ if (bootrom || gfx_fw_load(_binary_gfx_fw_bin_start, fw_size) < 0)
+ init_gfx_failed();
+
+ init_gfx(1);
+ break;
+
+ case GFX_PROBE_FIRMWARE:
+ break;
+ }
+}
+
+void init(void)
+{
+ log("host cpu is up");
+ init_gfx(0);
+}