aboutsummaryrefslogtreecommitdiffstats
path: root/roms/u-boot/arch/sandbox/lib/bootm.c
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/u-boot/arch/sandbox/lib/bootm.c
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/u-boot/arch/sandbox/lib/bootm.c')
-rw-r--r--roms/u-boot/arch/sandbox/lib/bootm.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/roms/u-boot/arch/sandbox/lib/bootm.c b/roms/u-boot/arch/sandbox/lib/bootm.c
new file mode 100644
index 000000000..d1d460b84
--- /dev/null
+++ b/roms/u-boot/arch/sandbox/lib/bootm.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * Copyright (c) 2015 Sjoerd Simons <sjoerd.simons@collabora.co.uk>
+ */
+
+#include <common.h>
+#include <bootstage.h>
+#include <image.h>
+#include <asm/io.h>
+
+#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818
+
+struct arm_z_header {
+ uint32_t code[9];
+ uint32_t zi_magic;
+ uint32_t zi_start;
+ uint32_t zi_end;
+} __attribute__ ((__packed__));
+
+int bootz_setup(ulong image, ulong *start, ulong *end)
+{
+ uint8_t *zimage = map_sysmem(image, 0);
+ struct arm_z_header *arm_hdr = (struct arm_z_header *)zimage;
+ int ret = 0;
+
+ if (memcmp(zimage + 0x202, "HdrS", 4) == 0) {
+ uint8_t setup_sects = *(zimage + 0x1f1);
+ uint32_t syssize =
+ le32_to_cpu(*(uint32_t *)(zimage + 0x1f4));
+
+ *start = 0;
+ *end = (setup_sects + 1) * 512 + syssize * 16;
+
+ printf("setting up X86 zImage [ %ld - %ld ]\n",
+ *start, *end);
+ } else if (le32_to_cpu(arm_hdr->zi_magic) == LINUX_ARM_ZIMAGE_MAGIC) {
+ *start = le32_to_cpu(arm_hdr->zi_start);
+ *end = le32_to_cpu(arm_hdr->zi_end);
+
+ printf("setting up ARM zImage [ %ld - %ld ]\n",
+ *start, *end);
+ } else {
+ printf("Unrecognized zImage\n");
+ ret = 1;
+ }
+
+ unmap_sysmem((void *)image);
+
+ return ret;
+}
+
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+{
+ if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
+ bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+ printf("## Transferring control to Linux (at address %08lx)...\n",
+ images->ep);
+ printf("sandbox: continuing, as we cannot run Linux\n");
+ }
+
+ return 0;
+}