summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib/bootm.c
Commit message (Collapse)AuthorAgeFilesLines
* ARM: Add PSCI supportSascha Hauer2017-02-131-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch contains the barebox implementation for the ARM "Power State Coordination Interface" (PSCI). The interface is aimed at the generalization of code in the following power management scenarios: * Core idle management. * Dynamic addition and removal of cores, and secondary core boot. * big.LITTLE migration. * System shutdown and reset. In practice, all that's currently implemented is a way to enable the secondary core one some SoCs. With PSCI the Kernel is either started in nonsecure or in Hypervisor mode and PSCI is used to apply power to the secondary cores. The start mode is passed in the global.bootm.secure_state variable. This enum can contain "secure" (Kernel is started in secure mode, means no PSCI), "nonsecure" (Kernel is started in nonsecure mode, PSCI available) or "hyp" (Kernel is started in hyp mode, meaning it can support virtualization). We currently only support putting the secure monitor code into SDRAM, which means we always steal some amount of memory from the Kernel. To keep things simple for now we simply keep the whole barebox binary in memory The PSCI support has been tested on i.MX7 only so far. The only supported operations are CPU_ON and CPU_OFF. The PSCI and secure monitor code is based on the corresponding U-Boot code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: Fix appended device tree when CONFIG_OFTREE is enabledSascha Hauer2016-11-081-2/+10
| | | | | | | | | When CONFIG_OFTREE is enabled the appended device tree is unflattened and put into data->of_root_node, but there it is never used again. To actually use the appended device tree put it into data->oftree instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: Fix free_mem calculation when initrd is givenSascha Hauer2016-10-181-1/+1
| | | | | | | | | | | | | | When a initrd is given we calculate the next free memory position as: free_mem = PAGE_ALIGN(initrd_end); This is wrong when initrd_end exactly falls on a page boundary. In this case PAGE_ALIGN() does nothing and free_mem becomes initrd_end and the following bootm_load_devicetree() and thus booting fails with -ENOMEM. Fix this by correctly advancing to the next free memory position. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_unflatten_dtb(): Check return value with IS_ERRAndrey Smirnov2016-09-051-1/+1
| | | | | | | | Of_unflatten_dtb returns a ERR_PTR value so checking it against NULL is incorrect. Fix it in all of the places where this was happening. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: Move bulk of boot.h to bootm.hSascha Hauer2016-07-261-0/+1
| | | | | | | | The majority of the stuff currently in include/boot.h is about bootm code implemented common/bootm.c. To be more consistent move it to a new file include/bootm.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: Fix compiler warningSascha Hauer2016-07-051-1/+1
| | | | | | | | fixes: arch/arm/lib/bootm.c:92:137: warning: comparison of distinct pointer types lacks a cast Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: recalculate decompression spaceStefan Müller-Klieser2016-07-041-3/+15
| | | | | | | | | | | | | | | | According to the kernel documentation it is recommended to place the compressed image between 32 MiB and 128 MiB. The DTB and initrd should be placed above 128 MiB. We will follow the recommendation as long as we have enough RAM. If this is not the case, we fall back to the scheme. This change is required because of the ARM default kernel config changes regarding RODATA layout, which lead to an increased compression factor of the kernel image. This should be regarded as an intermediate solution until there is a mechanism for the kernel image to report the decompressed layout requirements to the bootloader. Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Move bootm options to common/KconfigSascha Hauer2016-05-101-2/+2
| | | | | | | | | | | | bootm has a C API, so the bootm options have to depend on the option providing the bootm code (CONFIG_BOOTM), not on the option providing the command (CONFIG_CMD_BOOTM). Fixing the dependencies makes it possible to fully use bootm from C without enabling the bootm command support. This also removes the CMD_ prefix from the options which means we have to update the defconfigs aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: Bootm: FIT image handler depends on CONFIG_FITIMAGESascha Hauer2016-04-251-1/+1
| | | | | | | | CONFIG_FITIMAGE is the variable to depend on, not CONFIG_CMD_BOOTM_FITIMAGE which is only a wrapper option to let CONFIG_FITIMAGE select from the bootm Kconfig menu. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: Move mem_free calculation into get_kernel_addresses()Sascha Hauer2016-04-201-11/+10
| | | | | | | | | The callers of get_kernel_addresses() are not interested in the spacing after the kernel image, they are interested in the place where they can put device tree and initrd, so pass a pointer to mem_free to get_kernel_addresses(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: Let get_kernel_addresses() determine SDRAM region itselfSascha Hauer2016-04-201-14/+20
| | | | | | | Move the call to sdram_start_and_size() into get_kernel_addresses() and remove the now unnecessary parameter mem_start. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* arm: bootm: be more clever about kernel spacingLucas Stach2016-03-011-0/+8
| | | | | | | | | | When the kernel load address is chosen by the user/image we need to check if the kernel needs to relocate itself before decompression. If that's the case the spacing behind the kernel must allow for this relocation without overwriting anything placed behind the kernel. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* arm: bootm: unify kernel load address calculationLucas Stach2016-03-011-37/+37
| | | | | | | | | Instead of having the same logic for uImage and zImage types duplicated in the code, split it out into a separate function. This does not change the behavior of the calculation. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: add initial FIT supportJan Luebbe2016-01-261-0/+8
| | | | | | | | | | | | | | | This implementation is inspired by U-Boot's FIT support. Instead of using libfdt (which does not exist in barebox), configuration signatures are verified by using a simplified DT parser based on barebox's own code. Currently, only signed configurations with hashed images are supported, as the other variants are less useful for verified boot. Compatible FIT images can be created using U-Boot's mkimage tool. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: move initrd code togetherSascha Hauer2016-01-261-3/+5
| | | | | | | The initrd code is distributed in several places in the bootm code. Move it all together in bootm_load_initrd(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Push dryrun to handlersSascha Hauer2016-01-261-0/+3
| | | | | | | We can make the dryrun option more useful by calling into the handlers. With this we can detect more cases that can go wrong during boot. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: Use kernel handler to start barebox imageSascha Hauer2016-01-221-29/+1
| | | | | | | | barebox can be called with the kernel calling convention, so we can reuse the handler instead of creating a barebox specific handler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: introduce bootm_get_os_sizeSascha Hauer2016-01-221-1/+1
| | | | | | | | ARM do_bootm_linux is not only called with uImages but also with raw images, so we can't use uimage_get_size() here. Introduce bootm_get_os_size() which handles the different image types. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: zImage: add missing free() in appended device tree codeSascha Hauer2016-01-221-0/+1
| | | | | | oftree must be freed when the tree is successfully unflattened. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* restart: replace reset_cpu with registered restart handlersSascha Hauer2015-08-271-3/+4
| | | | | | | | | | | | | | | | | | | | | | This replaces the reset_cpu() function which every SoC or board must provide with registered handlers. This makes it possible to have multiple reset functions for boards which have multiple ways to reset the machine. Also boards which have no way at all to reset the machine no longer have to provide a dummy reset_cpu() function. The problem this solves is that some machines have external PMICs or similar to reset the system which have to be preferred over the internal SoC reset, because the PMIC can reset not only the SoC but also the external devices. To pick the right way to reset a machine each handler has a priority. The default priority is 100 and all currently existing restart handlers are registered with this priority. of_get_restart_priority() allows to retrieve the priority from the device tree which makes it possible for boards to give certain restart handlers a higher priority in order to use this one instead of the default one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sizes.h: move include/sizes.h to include/linux/sizes.hMasahiro Yamada2015-01-081-1/+1
| | | | | | | | | | | | | | This file originates in Linux. Linux has it under include/linux/ directory since commit dccd2304cc90. Let's move it to the same place as well in barebox. This commit was generated by the following commands: find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:' git mv include/sizes.h include/linux/ Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/metadata'Sascha Hauer2014-08-071-0/+1
|\ | | | | | | | | | | | | Conflicts: arch/arm/dts/Makefile common/Makefile lib/Makefile
| * move file helper functions to separate fileSascha Hauer2014-08-071-0/+1
| | | | | | | | | | | | | | | | | | | | We have our file helper functions in several places. Move them all to lib/libfile.c. With this we no longer have file helpers in fs/fs.c which contains the core fs functions and no functions in lib/libbb.c which are not from busybox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/arm'Sascha Hauer2014-08-071-2/+16
|\ \ | |/ |/|
| * ARM: Android image boot: automatically assign space for kernelSascha Hauer2014-07-211-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | The Android image format makes the same mistake as the U-Boot uImage format: It makes the load address mandatory. In a way it is even worse since the 'fastboot' host tool thinks that 0x10000000 is a good default when no address has been specified on the command line. Instead of only relying on the Kernel load address in the image try to automatically find a good base address when requesting the addresses from the image failed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | arch/arm/lib/bootm: fix length check of kernel imagebasti@linux-source.de2014-07-221-1/+1
|/ | | | | Signed-off-by: Sebastian Block <basti@linux-source.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* misc: upper-case some abbreviationsHolger Schurig2014-06-021-2/+2
| | | | | Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Drop devicetree merge supportSascha Hauer2014-05-221-1/+1
| | | | | | | | | | | | I assume I am the only person knowing that barebox is able to merge devicetrees. This feature seems broken for a while now since trying to merge devicetress results in: unflatten: too many end nodes Remove this feature to save the complexity. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: fix default uImage placementLucas Stach2014-05-051-7/+10
| | | | | | | | | | | | | For small systems we would put the zImage at 32KiB after the start of memory, and put the DT a bit after the uImage. The kernel will always try to relocate itself and overwrite the DT. Try to be more clever at uImage placement to avoid triggering the kernel relocation. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: be more clever while deciding where to put zImageLucas Stach2014-05-051-28/+29
| | | | | | | | | | | | | | For small systems we would put the zImage at 8MiB after the start of memory, and put the DT a bit after the zImage. When we encounter an image which is bigger than 8MiB uncompressed, the kernel would try to relocate itself and overwrite the DT. Try to be more clever at zImage placement to avoid triggering the kernel relocation. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: pass free memory to __do_bootm_linuxSascha Hauer2014-01-221-17/+41
| | | | | | | | | | | | | This improves the initrd/devicetree placement in the bootm code. We used to put the initrd at the start of the kernel + 8MiB. This of course fails once the kernel gets bigger than 8MiB. Also the place for the devicetree was allocated using malloc(). This can lead to the problem that the devicetree is outside of the kernels lowmem and thus not reachable for the kernel. With this patch __do_bootm_linux gets a pointer to free space where the devicetree and the initrd can be safely put. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: locate zImage higher into RAMSascha Hauer2014-01-221-8/+64
| | | | | | | | | | The zImage should be placed where it won't be overwritten by the uncompressed image, otherwise the kernel decompressing code has to relocate the zImage before decompression. As Kernels tend to become bigger put it into 32MiB into RAM if we have enough RAM available. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: introduce bootm_load_initrd helperSascha Hauer2014-01-141-11/+5
| | | | | | | Make the bootm handlers simpler by factoring out an initrd load function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: move os loading to do_bootm_linuxSascha Hauer2014-01-101-18/+19
| | | | | | | | | | __do_bootm_linux is called from the uImage, zImage and raw handlers. In case of the zImage handler the kernel will already be loaded and the kernel load code in __do_bootm_linux will do nothing. Move the loading code to do_bootm_linux so that __do_bootm_linux will always be called with the kernel already loaded. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: introduce bootm_load_os helperSascha Hauer2014-01-101-17/+7
| | | | | | | | | | The common bootm code used to load uImage contents to SDRAM before calling into the handlers if possible. This makes the handlers complicated since they have to handle many cases. Instead, introduce a helper to load the os after the handlers have figured out a good load address. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: boot barebox with kernel calling conventionSascha Hauer2014-01-061-3/+16
| | | | | | | | | Start a 2nd stage barebox with the Linux Kernel calling convention. Right now barebox does not interpret ATAGs or devicetree passed to it, but it doesn't hurt to pass parameters so that future bareboxes can use them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: Print Kernel commandline unconditionallySascha Hauer2013-07-271-2/+1
| | | | | | | | The Kernel commandline is an important debugging aid when people ask why their Kernel won't start, so print it unconditionally. This is done in !dt mode anyway, so also do it with dt. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of'Sascha Hauer2013-06-021-0/+4
|\
| * bootm: print Kernel commandline in verbose modeSascha Hauer2013-05-311-0/+2
| | | | | | | | | | | | | | Without devicetree support we print the Kernel commandline in verbose mode. Do the same with devicetree boot aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bootm: make sure to print fixed oftreeSascha Hauer2013-05-311-0/+2
| | | | | | | | | | | | | | | | when doing bootm -v -v we dumped the original tree to the console. Make sure to print the fixed tree instead so that the fixups can be examined. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: Using unsigned specifiers for unsigned arguments for printfAlexander Shiyan2013-05-311-1/+1
|/ | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: remove unused libfdtSascha Hauer2013-03-061-1/+0
| | | | | | | Now that we are completely independent of libfdt remove the unused code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM bootm: Switch initrd support to unflattened treeSascha Hauer2013-03-061-1/+10
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Pass unflattened devicetree to handlersSascha Hauer2013-03-061-6/+2
| | | | | | | | | This makes it possible to modify the tree in the handlers. This is necessary because the initrd addresses are only known inside the handlers, but not to the generic bootm code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: bootm: rework concatenated oftreeSascha Hauer2013-03-061-20/+16
| | | | | | | | | | | Without compiled in devicetree support we used to copy the concatenated devicetree directly behind the zImage. This is unnecessary, even if we do not have devicetree support we can copy the devicetree whereever we like and pass the kernel a pointer to it. This makes the code a bit easier. While at it, add the missing free calls in the error case. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Pass barebox internal format devicetree to of_get_fixed_treeSascha Hauer2013-03-061-1/+9
| | | | | | | With this every devicetree is first converted to the barebox internal format before it's converted back to dtb again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM bootm: Use of_get_fixed_treeSascha Hauer2013-03-061-7/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM bootm: only use concatenated oftree when no other is availableSascha Hauer2013-01-191-0/+3
| | | | | | | | When an oftree is already specified use it. This lets the user boot a kernel with an oftree he provided himself rather than hardcoding the concatenated one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM android image: remove double of_fix_treeSascha Hauer2013-01-111-6/+0
| | | | | | | | With bootm of_fix_tree() will already be called from the generic bootm code, so do not do this again in the Android image handler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* filetype: Pass bufsizeSascha Hauer2012-12-031-1/+1
| | | | | | | | | | Pass the buffer size to the file detection code. This makes sure we do not read past the buffer. This is especially useful for ext filesystem detection as the magic is at byte offset 1080. Also introduce a FILE_TYPE_SAFE_BUFSIZE define which is set to the minimum bufsize the detection code needs to detect all known filetypes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>