Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Bootwrapper for ePAPR compliant firmwares
0004  *
0005  * Copyright 2010 David Gibson <david@gibson.dropbear.id.au>, IBM Corporation.
0006  *
0007  * Based on earlier bootwrappers by:
0008  * (c) Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp,\
0009  *   and
0010  * Scott Wood <scottwood@freescale.com>
0011  * Copyright (c) 2007 Freescale Semiconductor, Inc.
0012  */
0013 
0014 #include "ops.h"
0015 #include "stdio.h"
0016 #include "io.h"
0017 #include <libfdt.h>
0018 
0019 BSS_STACK(4096);
0020 
0021 #define EPAPR_SMAGIC    0x65504150
0022 #define EPAPR_EMAGIC    0x45504150
0023 
0024 static unsigned epapr_magic;
0025 static unsigned long ima_size;
0026 static unsigned long fdt_addr;
0027 
0028 static void platform_fixups(void)
0029 {
0030     if ((epapr_magic != EPAPR_EMAGIC)
0031         && (epapr_magic != EPAPR_SMAGIC))
0032         fatal("r6 contained 0x%08x instead of ePAPR magic number\n",
0033               epapr_magic);
0034 
0035     if (ima_size < (unsigned long)_end)
0036         printf("WARNING: Image loaded outside IMA!"
0037                " (_end=%p, ima_size=0x%lx)\n", _end, ima_size);
0038     if (ima_size < fdt_addr)
0039         printf("WARNING: Device tree address is outside IMA!"
0040                "(fdt_addr=0x%lx, ima_size=0x%lx)\n", fdt_addr,
0041                ima_size);
0042     if (ima_size < fdt_addr + fdt_totalsize((void *)fdt_addr))
0043         printf("WARNING: Device tree extends outside IMA!"
0044                " (fdt_addr=0x%lx, size=0x%x, ima_size=0x%lx\n",
0045                fdt_addr, fdt_totalsize((void *)fdt_addr), ima_size);
0046 }
0047 
0048 void epapr_platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
0049              unsigned long r6, unsigned long r7)
0050 {
0051     epapr_magic = r6;
0052     ima_size = r7;
0053     fdt_addr = r3;
0054 
0055     /* FIXME: we should process reserve entries */
0056 
0057     simple_alloc_init(_end, ima_size - (unsigned long)_end, 32, 64);
0058 
0059     fdt_init((void *)fdt_addr);
0060 
0061     serial_console_init();
0062     platform_ops.fixups = platform_fixups;
0063 }