uboot/arch/nios2/lib/bootm.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
   4 * Scott McNutt <smcnutt@psyent.com>
   5 */
   6
   7#include <common.h>
   8#include <cpu_func.h>
   9#include <env.h>
  10#include <image.h>
  11#include <irq_func.h>
  12#include <log.h>
  13#include <asm/global_data.h>
  14
  15DECLARE_GLOBAL_DATA_PTR;
  16
  17#define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
  18
  19int do_bootm_linux(int flag, int argc, char *const argv[],
  20                   bootm_headers_t *images)
  21{
  22        void (*kernel)(int, int, int, char *) = (void *)images->ep;
  23        char *commandline = env_get("bootargs");
  24        ulong initrd_start = images->rd_start;
  25        ulong initrd_end = images->rd_end;
  26        char *of_flat_tree = NULL;
  27#if defined(CONFIG_OF_LIBFDT)
  28        /* did generic code already find a device tree? */
  29        if (images->ft_len)
  30                of_flat_tree = images->ft_addr;
  31#endif
  32        if (!of_flat_tree && argc > 1)
  33                of_flat_tree = (char *)hextoul(argv[1], NULL);
  34        if (of_flat_tree)
  35                initrd_end = (ulong)of_flat_tree;
  36
  37        /*
  38         * allow the PREP bootm subcommand, it is required for bootm to work
  39         */
  40        if (flag & BOOTM_STATE_OS_PREP)
  41                return 0;
  42
  43        if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  44                return 1;
  45
  46        /* flushes data and instruction caches before calling the kernel */
  47        disable_interrupts();
  48        flush_dcache_all();
  49
  50        debug("bootargs=%s @ 0x%lx\n", commandline, (ulong)&commandline);
  51        debug("initrd=0x%lx-0x%lx\n", (ulong)initrd_start, (ulong)initrd_end);
  52        /* kernel parameters passing
  53         * r4 : NIOS magic
  54         * r5 : initrd start
  55         * r6 : initrd end or fdt
  56         * r7 : kernel command line
  57         * fdt is passed to kernel via r6, the same as initrd_end. fdt will be
  58         * verified with fdt magic. when both initrd and fdt are used at the
  59         * same time, fdt must follow immediately after initrd.
  60         */
  61        kernel(NIOS_MAGIC, initrd_start, initrd_end, commandline);
  62        /* does not return */
  63
  64        return 1;
  65}
  66
  67static ulong get_sp(void)
  68{
  69        ulong ret;
  70
  71        asm("mov %0, sp" : "=r"(ret) : );
  72        return ret;
  73}
  74
  75void arch_lmb_reserve(struct lmb *lmb)
  76{
  77        arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
  78}
  79