blob: 2de03fb8e02e616f6a435d115e0ddbc068986a33 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Sjoerd Simonsc8f34822015-04-13 22:54:20 +02002/*
3 * Copyright (c) 2011 The Chromium OS Authors.
Sjoerd Simonsa5ddcbe2015-04-13 22:54:21 +02004 * Copyright (c) 2015 Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Sjoerd Simonsc8f34822015-04-13 22:54:20 +02005 */
6
7#include <common.h>
8#include <asm/io.h>
9
Sjoerd Simonsa5ddcbe2015-04-13 22:54:21 +020010#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818
11
12struct arm_z_header {
13 uint32_t code[9];
14 uint32_t zi_magic;
15 uint32_t zi_start;
16 uint32_t zi_end;
17} __attribute__ ((__packed__));
18
19int bootz_setup(ulong image, ulong *start, ulong *end)
20{
21 uint8_t *zimage = map_sysmem(image, 0);
22 struct arm_z_header *arm_hdr = (struct arm_z_header *)zimage;
23 int ret = 0;
24
25 if (memcmp(zimage + 0x202, "HdrS", 4) == 0) {
26 uint8_t setup_sects = *(zimage + 0x1f1);
27 uint32_t syssize =
28 le32_to_cpu(*(uint32_t *)(zimage + 0x1f4));
29
30 *start = 0;
31 *end = (setup_sects + 1) * 512 + syssize * 16;
32
33 printf("setting up X86 zImage [ %ld - %ld ]\n",
34 *start, *end);
35 } else if (le32_to_cpu(arm_hdr->zi_magic) == LINUX_ARM_ZIMAGE_MAGIC) {
36 *start = le32_to_cpu(arm_hdr->zi_start);
37 *end = le32_to_cpu(arm_hdr->zi_end);
38
39 printf("setting up ARM zImage [ %ld - %ld ]\n",
40 *start, *end);
41 } else {
42 printf("Unrecognized zImage\n");
43 ret = 1;
44 }
45
46 unmap_sysmem((void *)image);
47
48 return ret;
49}
50
Sjoerd Simonsc8f34822015-04-13 22:54:20 +020051int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
52{
53 if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
54 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
55 printf("## Transferring control to Linux (at address %08lx)...\n",
56 images->ep);
Simon Glass43cdb792016-07-03 09:40:35 -060057 printf("sandbox: continuing, as we cannot run Linux\n");
Sjoerd Simonsc8f34822015-04-13 22:54:20 +020058 }
59
60 return 0;
61}