summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: Handle memory overflowsAndreas Färber2016-04-181-4/+4
| | | | | | | | | | jetson-tk1 has 2 GB of RAM at 0x80000000, causing gd->ram_top to be zero. Handle this by either avoiding ram_top or by using the same type as ram_top to reverse the overflow effect. Cc: Alexander Graf <agraf@suse.de> Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Alexander Graf <agraf@suse.de>
* gunzip.c: use block layer for writesEric Nelson2016-04-181-3/+2
| | | | | | | | Call blk_dwrite to ensure that the block cache is notified if enabled and remove build breakage when CONFIG_BLK is enabled. Signed-off-by: Eric Nelson <eric@nelint.com> Reviewed-by: Stephen Warren <swarren@nvidia.com>
* efi_loader: Expose ascending efi memory mapAlexander Graf2016-04-181-2/+7
| | | | | | | | | | | | The EFI memory map does not need to be in a strict order, but 32bit grub2 does expect it to be ascending. If it's not, it may try to allocate memory inside the U-Boot data memory region. We already sort the memory map in descending order, so let's just reverse it when we pass it to a payload. Signed-off-by: Alexander Graf <agraf@suse.de> Tested-by: Andreas Färber <afaerber@suse.de>
* efi_loader: Always flush in cache line size granularityAlexander Graf2016-04-181-1/+9
| | | | | | | | | | | | The cache line flush helpers only work properly when they get aligned start and end addresses. Round our flush range to cache line size. It's safe because we're guaranteed to flush within a single page which has the same cache attributes. Reported-by: Marek Vasut <marex@denx.de> Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Andreas Färber <afaerber@suse.de> Tested-by: Andreas Färber <afaerber@suse.de>
* efi_loader: Increase path string to 32 charactersAlexander Graf2016-04-181-2/+2
| | | | | | | | | | | | Whenever we want to tell our payload about a path, we limit ourselves to a reasonable amount of characters. So far we only passed in device names - exceeding 16 chars was unlikely there. However by now we also pass real file path information, so let's increase the limit to 32 characters. That way common paths like "boot/efi/bootaa64.efi" fit just fine. Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Add el torito supportAlexander Graf2016-04-181-0/+35
| | | | | | | | | | When loading an el torito image, uEFI exposes said image as a raw block device to the payload. Let's do the same by creating new block devices with added offsets for the respective el torito partitions. Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Split drive add into functionAlexander Graf2016-04-181-37/+47
| | | | | | | | The snippet of code to add a drive to our drive list needs to get called from 2 places in the future. Split it into a separate function. Signed-off-by: Alexander Graf <agraf@suse.de>
* lib/crc8: Add crc start valueStefan Roese2016-04-111-13/+20
| | | | | | | | | | | | | | | | | | To make the usage of this function more flexible, lets add the CRC start value as parameter to this function. This way it can be used by other functions requiring different start values than 0 as well. For non-zero CRC start values to work, I've reworked the function a bit. The new implementation is copied from the Linux version in drivers/i2c/i2c-core.c / i2c_smbus_pec(). Which supports non-zero CRC stating values. I've double-checked that the results for zero starting values are identical to the results from the original version of this function. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* efi_loader: Always allocate the highest available addressAlexander Graf2016-04-011-0/+29
| | | | | | | | | | | | Some EFI applications (grub2) expect that an allocation always returns the highest available memory address for the given size. Without this, we may run into situations where the initrd gets allocated at a lower address than the kernel. This patch fixes booting in such situations for me. Signed-off-by: Alexander Graf <agraf@suse.de>
* lib/physmem.c: Switch to __weak for arch_phys_memsetTom Rini2016-04-011-4/+2
| | | | | | | We normally use __weak rather than calling it out directly as an alias. Update this function to the normal method. Signed-off-by: Tom Rini <trini@konsulko.com>
* cosmetic: Fix typos "privide"Masahiro Yamada2016-04-011-1/+1
| | | | Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* efi_loader: Fix some entry/exit pointsAlexander Graf2016-03-272-7/+11
| | | | | | | | | | | | When switching between EFI context and U-Boot context we need to swap the register that "gd" resides in. Some functions slipped through here, with efi_allocate_pool / efi_free_pool not doing the switch correctly and efi_return_handle switching too often. Fix them all up to make sure we always have consistent register state. Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_stub: Move carriage return before line feed in putc()Bin Meng2016-03-271-2/+3
| | | | | | | A carriage return needs to execute before a line feed. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* efi_loader: Add GOP supportAlexander Graf2016-03-272-0/+153
| | | | | | | | | | | | The EFI standard defines a simple boot protocol that an EFI payload can use to access video output. This patch adds support to expose exactly that one (and the mode already in use) as possible graphical configuration to an EFI payload. With this, I can successfully run grub2 with graphical output. Signed-off-by: Alexander Graf <agraf@suse.de>
* cmd_dhry.c: Use lldiv for vax_mips calculation as wellTom Rini2016-03-171-1/+1
| | | | | | | | | | Since dhry_per_sec is a u64 we must also use lldiv here when working with it. Otherwise: ../lib/dhry/cmd_dhry.c:(.text.do_dhry+0xd8): undefined reference to `__udivdi3' On some platforms. Signed-off-by: Tom Rini <trini@konsulko.com>
* x86: dts: Drop memory SPD compatible stringSimon Glass2016-03-171-1/+0
| | | | | | | | This is not needed now that the memory controller driver has the SPD data in its own node. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* dhry: Correct dhrystone calculation for fast machinesSimon Glass2016-03-171-3/+5
| | | | | | | At present samus reports about 5600 DMIPS. With the default iteration count this is OK, but if 10 million runs are performed it overflows. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
* x86: Drop all the old pin configuration codeSimon Glass2016-03-171-1/+0
| | | | | | | | We don't need this anymore - we can use device tree and the new pinconfig driver instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* efi_loader: Pass proper device path in on bootAlexander Graf2016-03-151-6/+0
| | | | | | | | | | | | | | | | | EFI payloads can query for the device they were booted from. Because we have a disconnect between loading binaries and running binaries, we passed in a dummy device path so far. Unfortunately that breaks grub2's logic to find its configuration file from the same device it was booted from. This patch adds logic to have the "load" command call into our efi code to set the device path to the one we last loaded a binary from. With this grub2 properly detects where we got booted from and can find its configuration file, even when searching by-partition. Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: hook up in build environmentAlexander Graf2016-03-154-0/+23
| | | | | | | | | | | Now that we have all the bits and pieces ready for EFI payload loading support, hook them up in Makefiles and KConfigs so that we can build. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> [trini: Enable only when we of OF_LIBFDT, disable on kwb and colibri_pxa270] Signed-off-by: Tom Rini <trini@konsulko.com>
* efi_loader: Implement memory allocation and mapAlexander Graf2016-03-151-0/+319
| | | | | | | | | | | | | | | | | | | The EFI loader needs to maintain views of memory - general system memory windows as well as used locations inside those and potential runtime service MMIO windows. To manage all of these, add a few helpers that maintain an internal representation of the map the similar to how the EFI API later on reports it to the application. For allocations, the scheme is very simple. We basically allow allocations to replace chunks of previously done maps, so that a new LOADER_DATA allocation for example can remove a piece of the RAM map. When no specific address is given, we just take the highest possible address in the lowest RAM map that fits the allocation size. Signed-off-by: Alexander Graf <agraf@suse.de> Tested-by: Simon Glass <sjg@chromium.org>
* efi_loader: Add disk interfacesAlexander Graf2016-03-151-0/+218
| | | | | | | | | | | | | | | A EFI applications usually want to access storage devices to load data from. This patch adds support for EFI disk interfaces. It loops through all block storage interfaces known to U-Boot and creates an EFI object for each existing one. EFI applications can then through these objects call U-Boot's read and write functions. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> [trini: Update for various DM changes since posting] Signed-off-by: Tom Rini <trini@konsulko.com>
* efi_loader: Add runtime servicesAlexander Graf2016-03-152-3/+293
| | | | | | | | | | | | | | | | | After booting has finished, EFI allows firmware to still interact with the OS using the "runtime services". These callbacks live in a separate address space, since they are available long after U-Boot has been overwritten by the OS. This patch adds enough framework for arbitrary code inside of U-Boot to become a runtime service with the right section attributes set. For now, we don't make use of it yet though. We could maybe in the future map U-boot environment variables to EFI variables here. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* efi_loader: Add console interfaceAlexander Graf2016-03-151-0/+360
| | | | | | | | | | | | | | One of the basic EFI interfaces is the console interface. Using it an EFI application can interface with the user. This patch implements an EFI console interface using getc() and putc(). Today, we only implement text based consoles. We also convert the EFI Unicode characters to UTF-8 on the fly, hoping that everyone managed to jump on the train by now. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* efi_loader: Add boot time servicesAlexander Graf2016-03-151-0/+781
| | | | | | | | | | | | | | When an EFI application runs, it has access to a few descriptor and callback tables to instruct the EFI compliant firmware to do things for it. The bulk of those interfaces are "boot time services". They handle all object management, and memory allocation. This patch adds support for the boot time services and also exposes a system table, which is the point of entry descriptor table for EFI payloads. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* efi_loader: Add PE image loaderAlexander Graf2016-03-151-0/+188
| | | | | | | | | EFI uses the PE binary format for its application images. Add support to EFI PE binaries as well as all necessary bits for the "EFI image loader" interfaces. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* Merge git://git.denx.de/u-boot-dmTom Rini2016-03-143-6/+7
|\
| * dm: fdtdec: Correct a sandbox build warningSimon Glass2016-03-141-2/+3
| | | | | | | | | | | | | | Adjust the cast to avoid a warning when stdint.h is used. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com>
| * dm: Drop the block_dev_desc_t typedefSimon Glass2016-03-141-1/+1
| | | | | | | | | | | | | | | | | | Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long and causes 80-column violations, rename it to struct blk_desc. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
| * dm: Use uclass_first_device_err() where it is usefulSimon Glass2016-03-141-3/+3
| | | | | | | | | | | | Use this new function in places where it simplifies the code. Signed-off-by: Simon Glass <sjg@chromium.org>
* | lib/crc16.c: Rename cyg_crc16() to crc16_ccitt() and add crc start valueStefan Roese2016-03-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | The original name of this function is unclear. This patch renames this CRC16 function to crc16_ccitt() matching its name with its implementation. To make the usage of this function more flexible, lets add the CRC start value as parameter to this function. This way it can be used by other functions requiring different start values than 0 as well. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* | lib/crc16.c: Coding-style cleanupStefan Roese2016-03-141-41/+40
| | | | | | | | | | | | | | lib/crc16.c is changed to match the common U-Boot coding-style. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* | fdt: Allow libfdt to be used in SPLSimon Glass2016-03-142-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | Add an option to enable libfdt in SPL. This can be useful when decoding FIT files in SPL. We need to make sure this option is not enabled in SPL by this change. Also this option needs to be enabled in host builds. Si add a new IMAGE_USE_LIBFDT #define which can be used in files that are built on the host but must also build for U-Boot and SPL. Signed-off-by: Simon Glass <sjg@chromium.org>
* | Kconfig: Move CONFIG_FIT and related options to KconfigSimon Glass2016-03-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are already two FIT options in Kconfig but the CONFIG options are still in the header files. We need to do a proper move to fix this. Move these options to Kconfig and tidy up board configuration: CONFIG_FIT CONFIG_OF_BOARD_SETUP CONFIG_OF_SYSTEM_SETUP CONFIG_FIT_SIGNATURE CONFIG_FIT_BEST_MATCH CONFIG_FIT_VERBOSE CONFIG_OF_STDOUT_VIA_ALIAS CONFIG_RSA Unfortunately the first one is a little complicated. We need to make sure this option is not enabled in SPL by this change. Also this option is enabled automatically in the host builds by defining CONFIG_FIT in the image.h file. To solve this, add a new IMAGE_USE_FIT #define which can be used in files that are built on the host but must also build for U-Boot and SPL. Note: Masahiro's moveconfig.py script is amazing. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Add microblaze change, various configs/ re-applies] Signed-off-by: Tom Rini <trini@konsulko.com>
* | Move CONFIG_OF_LIBFDT to KconfigSimon Glass2016-03-141-0/+10
| | | | | | | | | | | | Move this option to Kconfig and tidy up existing boards. Signed-off-by: Simon Glass <sjg@chromium.org>
* | libfdt: Add a function to write a property placeholderSimon Glass2016-03-141-2/+14
|/ | | | | | | | | | | | | The existing function to add a new property to a tree being built requires that the entire contents of the new property be passed in. For some applications it is more convenient to be able to add the property contents later, perhaps by reading from a file. This avoids double-buffering of the contents. Add a new function to support this and adust the existing fdt_property() to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
* timer: Provide an early timerSimon Glass2016-02-261-7/+21
| | | | | | | | | | In some cases the timer must be accessible before driver model is active. Examples include when using CONFIG_TRACE to trace U-Boot's execution before driver model is set up. Enable this option to use an early timer. These functions must be supported by your timer driver: timer_early_get_count() and timer_early_get_rate(). Signed-off-by: Simon Glass <sjg@chromium.org>
* lib: Don't instrument the div64 functionSimon Glass2016-02-261-1/+2
| | | | | | | | This function can be called from the timer code on instrumented functions. Mark it as 'notrace' so that it doesn't cause infinite recursion. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* tegra: nyan-big: Move the LCD driver to driver modelSimon Glass2016-02-161-1/+0
| | | | | | | | | | Adjust the driver to use driver model. The SOR becomes a bridge device. We use the normal simple_panel driver to handle the display itself. We also need to enable some options such as regulators, PWMs and DM_VIDEO itself. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Anatolij Gustschin <agust@denx.de> Signed-off-by: Tom Warren <twarren@nvidia.com>
* Makefile: remove BUILD_TAG from KBUILD_CFLAGSStephen Warren2016-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes, all files get rebuilt. In a continuous integration environment, the value will change every build. This wastes time, assuming that incremental builds would otherwise occur. To solve this, remove BUILD_TAG from KBUILD_CFLAGS and add it to CFLAGS for just the one file that uses it. This does have the disadvantage that if any other files want to use the flag, we'll need to duplicate this custom CFLAGS setup logic. However, it seems unlikely we'll need this. An alternative would be to add BUILD_TAG to the "local version" and remove the special case code from display_options.c. However, that would affect the format of the U-Boot signon message, which may negatively affect people looking for specific data there. The approach of using file-specific CFLAGS was suggested by Masahiro Yamada. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
* gunzip: remove avail_in recalculationStephen Warren2016-02-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current, the following passes: ./u-boot -d arch/sandbox/dts/test.dtb -c 'ut_image_decomp' but the following fails: ./u-boot -d arch/sandbox/dts/test.dtb -c 'ut dm; ut_image_decomp' This is because the gunzip code reads input data beyond the end of its input buffer. In the first case above, this data just happens to be 0, which just happens to trigger gzip to signal the error the decompression unit test expects. In the second case above, the "ut dm" test has written data to the accidentally-read memory, which causes the gzip code to take a different path and so return a different value, which triggers the test failure. The cause of gunzip reading past its input buffer is the re-calculation of s.avail_in in zunzip(), since it can underflow. Not only is the formula non-sensical (it uses the delta between two output buffer pointers to calculate available input buffer size), it also appears to be unnecessary, since the gunzip code already maintains this value itself. This patch removes this re-calculation to avoid the underflow and redundant work. The loop exit condition is also adjusted so that if inflate() has consumed the entire input buffer, without indicating returning Z_STREAM_END (i.e. decompression complete without error), an error is raised. There is still opportunity to simplify the code here by splitting up the loop exit condition into separate tests. However, this patch makes the minimum modifications required to solve the problem at hand, in order to keep the Acked-by: Kees Cook <keescook@chromium.org> diff simple. I am not entirely convinced that the loop in zunzip() is necessary at all. It could only be useful if inflate() can return Z_BUF_ERROR (which typically means that it needs more data in the input buffer, or more space in the output buffer), even though Z_FINISH is set /and/ the full input is available in the input buffer /and/ there is enough space to store the decompressed output in the output buffer. The comment in zlib.h after the prototype of inflate() implies this is never the case. However, I assume there must have been some reason for introducing this loop in the first place, as part of commit "Fix gunzip to work for any gziped uImage size". This patch is similar to the earlier b75650d84d4b "gzip: correctly bounds-check output buffer", which corrected a similar issue for s.avail_out. Cc: Catalin Radu <Catalin@VirtualMetrix.com> Cc: Kees Cook <keescook@chromium.org> Fixes: f039ada5c109 ("Fix gunzip to work for any gziped uImage size") Signed-off-by: Stephen Warren <swarren@nvidia.com>
* fdt: introduce fdtdec_get_child_countPeng Fan2016-02-061-0/+11
| | | | | | | | | Introduce fdtdec_get_child_count for get the number of subnodes of one parent node. Signed-off-by: Peng Fan <van.freenix@gmail.com> Cc: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
* bzlib: Try another way to fix an unused variableSimon Glass2016-02-061-4/+3
| | | | | | | | | Use __maybe_unused which should avoid the Coverity error. Reported-by: Coverity (CID: 134900) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* Use correct spelling of "U-Boot"Bin Meng2016-02-064-4/+4
| | | | | | | | | | Correct spelling of "U-Boot" shall be used in all written text (documentation, comments in source files etc.). Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Minkyu Kang <mk7.kang@samsung.com>
* tpm: Fix fault in case CONFIG_DM_TPM is set without any TPMChristophe Ricard2016-01-281-1/+1
| | | | | | | | In case CONFIG_DM_TPM was set without any TPM chipset configured a fault was generated (NULL pointer access). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
* x86: Drop the irq router compatible stringSimon Glass2016-01-241-1/+0
| | | | | | | We use driver model for this now, so we don't need this string. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* dm: video: sandbox: Convert sandbox to use driver model for videoSimon Glass2016-01-201-1/+0
| | | | | | | | Now that driver model support is available, convert sandbox over to use it. We can remove a few of the special hooks that sandbox currently has. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Anatolij Gustschin <agust@denx.de>
* bzip2: Support compression for sandboxSimon Glass2016-01-203-0/+1849
| | | | | | | | | | | Add the missing code to allow bzip2 compression to be used. This is useful for sandbox tests. These files are taken from the bzip2 1.0.6 release. The license text is copied to the top of each file as is done with other bzip2 files in U-Boot. The only other change is to squash a compiler warning with nBytes. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* tiny-printf: Always print zeroesSimon Glass2016-01-201-4/+12
| | | | | | | | | At present this does not print zero values in numeric format (hex and decimal). Add a special case for this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* tiny-printf: Avoid printing NULL stringsSimon Glass2016-01-201-2/+4
| | | | | | | Add a check for NULL strings to avoid printing junk to the console. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
OpenPOWER on IntegriCloud