~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/boot/simpleboot.c

Version: ~ [ linux-5.10-rc1 ] ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * The simple platform -- for booting when firmware doesn't supply a device
  3  *                        tree or any platform configuration information.
  4  *                        All data is extracted from an embedded device tree
  5  *                        blob.
  6  *
  7  * Authors: Scott Wood <scottwood@freescale.com>
  8  *          Grant Likely <grant.likely@secretlab.ca>
  9  *
 10  * Copyright (c) 2007 Freescale Semiconductor, Inc.
 11  * Copyright (c) 2008 Secret Lab Technologies Ltd.
 12  *
 13  * This program is free software; you can redistribute it and/or modify it
 14  * under the terms of the GNU General Public License version 2 as published
 15  * by the Free Software Foundation.
 16  */
 17 
 18 #include "ops.h"
 19 #include "types.h"
 20 #include "io.h"
 21 #include "stdio.h"
 22 #include <libfdt.h>
 23 
 24 BSS_STACK(4*1024);
 25 
 26 extern int platform_specific_init(void) __attribute__((weak));
 27 
 28 void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
 29                    unsigned long r6, unsigned long r7)
 30 {
 31         const u32 *na, *ns, *reg, *timebase;
 32         u64 memsize64;
 33         int node, size, i;
 34 
 35         /* Make sure FDT blob is sane */
 36         if (fdt_check_header(_dtb_start) != 0)
 37                 fatal("Invalid device tree blob\n");
 38 
 39         /* Find the #address-cells and #size-cells properties */
 40         node = fdt_path_offset(_dtb_start, "/");
 41         if (node < 0)
 42                 fatal("Cannot find root node\n");
 43         na = fdt_getprop(_dtb_start, node, "#address-cells", &size);
 44         if (!na || (size != 4))
 45                 fatal("Cannot find #address-cells property");
 46         ns = fdt_getprop(_dtb_start, node, "#size-cells", &size);
 47         if (!ns || (size != 4))
 48                 fatal("Cannot find #size-cells property");
 49 
 50         /* Find the memory range */
 51         node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 52                                              "memory", sizeof("memory"));
 53         if (node < 0)
 54                 fatal("Cannot find memory node\n");
 55         reg = fdt_getprop(_dtb_start, node, "reg", &size);
 56         if (size < (*na+*ns) * sizeof(u32))
 57                 fatal("cannot get memory range\n");
 58 
 59         /* Only interested in memory based at 0 */
 60         for (i = 0; i < *na; i++)
 61                 if (*reg++ != 0)
 62                         fatal("Memory range is not based at address 0\n");
 63 
 64         /* get the memsize and trucate it to under 4G on 32 bit machines */
 65         memsize64 = 0;
 66         for (i = 0; i < *ns; i++)
 67                 memsize64 = (memsize64 << 32) | *reg++;
 68         if (sizeof(void *) == 4 && memsize64 >= 0x100000000ULL)
 69                 memsize64 = 0xffffffff;
 70 
 71         /* finally, setup the timebase */
 72         node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 73                                              "cpu", sizeof("cpu"));
 74         if (!node)
 75                 fatal("Cannot find cpu node\n");
 76         timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
 77         if (timebase && (size == 4))
 78                 timebase_period_ns = 1000000000 / *timebase;
 79 
 80         /* Now we have the memory size; initialize the heap */
 81         simple_alloc_init(_end, memsize64 - (unsigned long)_end, 32, 64);
 82 
 83         /* prepare the device tree and find the console */
 84         fdt_init(_dtb_start);
 85 
 86         if (platform_specific_init)
 87                 platform_specific_init();
 88 
 89         serial_console_init();
 90 }
 91 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp