summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2017-09-20efi_loader: Some console improvements for vidconsoleRob Clark
1) use fputs() to reduce cache flushes from once-per-char to once-per-string 2) handle \r, \t, and \b in addition to just \n for tracking cursor position 3) cursor row/col are zero based, not one based Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: s/unsigned/unsigned int/] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: Correctly figure out size for vidconsoleRob Clark
If stdout is vidconsole, we cannot rely on ANSI escape sequences to query the size, as vidconsole cannot reply on stdin. Instead special- case this if stdout is vidconsole. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: split out escape sequence based size queryRob Clark
We need to do something different for vidconsole, since it cannot respond to the query on stdin. Prep work for next patch. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: print GUIDsRob Clark
Utilize printf GUID support to print GUIDs. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: set loaded image code/data type properlyRob Clark
These should be set according to the image type. Shell.efi and SCT.efi use these fields to determine what sort of image they are loading. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: add bootmgrRob Clark
Similar to a "real" UEFI implementation, the bootmgr looks at the BootOrder and BootXXXX variables to try to find an EFI payload to load and boot. This is added as a sub-command of bootefi. The idea is that the distro bootcmd would first try loading a payload via the bootmgr, and then if that fails (ie. first boot or corrupted EFI variables) it would fallback to loading bootaa64.efi. (Which would then load fallback.efi which would look for \EFI\*\boot.csv and populate BootOrder and BootXXXX based on what it found.) Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: efi variable supportRob Clark
Add EFI variable support, mapping to u-boot environment variables. Variables are pretty important for setting up boot order, among other things. If the board supports saveenv, then it will be called in ExitBootServices() to persist variables set by the efi payload. (For example, fallback.efi configuring BootOrder and BootXXXX load-option variables.) Variables are *not* currently exposed at runtime, post ExitBootServices. On boards without a dedicated device for storage, which the loaded OS is not trying to also use, this is rather tricky. One idea, at least for boards that can persist RAM across reboot, is to keep a "journal" of modified variables in RAM, and then turn halt into a reboot into u-boot, plus store variables, plus halt. Whatever the solution, it likely involves some per-board support. Mapping between EFI variables and u-boot variables: efi_$guid_$varname = {attributes}(type)value For example: efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_OsIndicationsSupported= "{ro,boot,run}(blob)0000000000000000" efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_BootOrder= "(blob)00010000" The attributes are a comma separated list of these possible attributes: + ro - read-only + boot - boot-services access + run - runtime access NOTE: with current implementation, no variables are available after ExitBootServices, and all are persisted (if possible). If not specified, the attributes default to "{boot}". The required type is one of: + utf8 - raw utf8 string + blob - arbitrary length hex string Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: make pool allocations cacheline alignedRob Clark
This avoids printf() spam about file reads (such as loading an image) into unaligned buffers (and the associated memcpy()). And generally seems like a good idea. Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: use __aligned] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: support load_image() from a file-pathRob Clark
Previously we only supported the case when the EFI application loaded the image into memory for us. But fallback.efi does not do this. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: add file/filesys supportRob Clark
fallback.efi (and probably other things) use UEFI's simple-file-system protocol and file support to search for OS's to boot. Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: whitespace fixes, unsigned fixes] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: refactor boot device and loaded_image handlingRob Clark
Get rid of the hacky fake boot-device and duplicate device-path constructing (which needs to match what efi_disk and efi_net do). Instead convert over to use efi_device_path helpers to construct device-paths, and use that to look up the actual boot device. Also, extract out a helper to plug things in properly to the loaded_image. In a following patch we'll want to re-use this in efi_load_image() to handle the case of loading an image from a file_path. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: use proper device-paths for netRob Clark
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: use proper device-paths for partitionsRob Clark
Also, create disk objects for the disk itself, in addition to the partitions. (UEFI terminology is a bit confusing, a "disk" object is really a partition.) This helps grub properly identify the boot device since it is trying to match up partition "disk" object with it's parent device. Now instead of seeing devices like: /File(sdhci@07864000.blk)/EndEntire /File(usb_mass_storage.lun0)/EndEntire You see: /ACPI(133741d0,0)/UnknownMessaging(1d)/EndEntire /ACPI(133741d0,0)/UnknownMessaging(1d)/HD(0,800,64000,dd904a8c00000000,1,1)/EndEntire /ACPI(133741d0,0)/UnknownMessaging(1d)/HD(1,64800,200000,dd904a8c00000000,1,1)/EndEntire /ACPI(133741d0,0)/UnknownMessaging(1d)/HD(2,264800,19a000,dd904a8c00000000,1,1)/EndEntire /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/EndEntire /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(0,800,60000,38ca680200000000,1,1)/EndEntire /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(1,61000,155000,38ca680200000000,1,1)/EndEntire /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(2,20fa800,1bbf8800,38ca680200000000,1,1)/EndEntire /ACPI(133741d0,0)/USB(0,0)/USB(0,0)/USB(0,0)/HD(3,1b6800,1f44000,38ca680200000000,1,1)/EndEntire This is on a board with single USB disk and single sd-card. The UnknownMessaging(1d) node in the device-path is the MMC device, but grub_efi_print_device_path() hasn't been updated yet for some of the newer device-path sub-types. This patch is inspired by a patch originally from Peter Jones, but re-worked to use efi_device_path, so it doesn't much resemble the original. Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: s/unsigned/unsigned int/] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: flesh out device-path to textRob Clark
It needs to handle more device-path node types, and also multiple levels of path hierarchy. To simplify this, initially construct utf8 string to a temporary buffer, and then allocate the real utf16 buffer that is returned. This should be mostly for debugging or at least not critical- path so an extra copy won't hurt, and is saner than the alternative. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: drop redundant efi_device_path_protocolRob Clark
This is really the same thing as the efi_device_path struct. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: add device-path utilsRob Clark
Helpers to construct device-paths from devices, partitions, files, and for parsing and manipulating device-paths. For non-legacy devices, this will use u-boot's device-model to construct device-paths which include bus hierarchy to construct device-paths. For legacy devices we still fake it, but slightly more convincingly. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_selftest: check notification of ExitBootServicesHeinrich Schuchardt
Check that the notification function of an EVT_SIGNAL_EXIT_BOOT_SERVICES event is called exactly once. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: notify when ExitBootServices is invokedHeinrich Schuchardt
All events of type EVT_SIGNAL_EXIT_BOOT_SERVICES have to be notified when ExitBootServices is invoked. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_selftest: test task priority levelsHeinrich Schuchardt
Run a 10 ms periodic timer and check that it is called 10 times while waiting for 100 ms single shot timer. Raise the TPL level to the level of the 10 ms timer and observe that the notification function is not called again. Lower the TPL level and check that the queued notification function is called. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: implement task priority level (TPL)Heinrich Schuchardt
Define variable holding tpl. Implement RaiseTPL and RestoreTPL. Implement TPL check in efi_signal_event. Implement TPL check in efi_wait_for_event. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_selftest: provide unit test for event servicesHeinrich Schuchardt
This unit test uses timer events to check the implementation of the following boottime services: CreateEvent, CloseEvent, WaitForEvent, CheckEvent, SetTimer Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: efi_set_timer: reset signaled stateHeinrich Schuchardt
We should be able to call efi_set_timer repeatedly. So let us reset the signaled state here. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: implement queueing of the notification functionHeinrich Schuchardt
For the correct implementation of the task priority level (TPL) calling the notification function must be queued. Add a status field 'queued' to events. In function efi_signal_event set status queued if a notification function exists and reset it after we have called the function. A later patch will add a check of the TPL here. In efi_create_event and efi_close_event unset the queued status. In function efi_wait_for_event and efi_check_event queue the notification function. In efi_timer_check call the efi_notify_event if the status queued is set. For all timer events set status signaled. In efi_console_timer_notify set the signaled state of the WaitForKey event. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_selftest: provide an EFI selftest applicationHeinrich Schuchardt
A testing framework for the EFI API is provided. It can be executed with the 'bootefi selftest' command. It is coded in a way that at a later stage we may turn it into a standalone EFI application. The current build system does not allow this yet. All tests use a driver model and are run in three phases: setup, execute, teardown. A test may be setup and executed at boottime, it may be setup at boottime and executed at runtime, or it may be setup and executed at runtime. After executing all tests the system is reset. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: allow return value in EFI_CALLHeinrich Schuchardt
Macro EFI_CALL was introduced to call an UEFI function. Unfortunately it does not support return values. Most UEFI functions have a return value. So let's rename EFI_CALL to EFI_CALL_VOID and introduce a new EFI_CALL macro that supports return values. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: avoid obscure constants in efi_runtime.cHeinrich Schuchardt
We should use the predefined constants EFI_PAGE_SHIFT and EFI_PAGE_MASK where applicable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: usage of always in MakefileHeinrich Schuchardt
Variable always should only be appended but not overwritten by lib/efi_loader/Makefile. Remove variable efiprogs which is not otherwise used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: Fix efi_exit gd clobberingAlexander Graf
Commit f494950b (efi_loader: call __efi_exit_check in efi_exit) added a call to __efi_exit_check inside efi_exit to account for the fact that we're exiting the efi_exit function via a longjmp call. However, __efi_exit_check also swizzles gd to the application gd while the longjmp will put us back into EFI context, so we need the efi (u-boot) gd. This patch fixes that up by explicitly setting gd back to efi_gd before doing the longjmp. It also adds a few comments on why it does that. Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: write protocol GUID in OpenProtocolHeinrich Schuchardt
To understand what is happening in OpenProtocol or LocateProtocol it is necessary to know the protocol interface GUID. Let's write a debug message. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: call __efi_exit_check in efi_exitHeinrich Schuchardt
The calls to __efi_entry_check and __efi_exit_check have to match. If DEBUG is defined, panic() will be called otherwise. If debugging is activated some Travis CI builds fail due to an assertion in EFI_CALL without the patch. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_disk: efi_disk_rw_blocks is not an API functionHeinrich Schuchardt
There is no need to use attribute EFIAPI for efi_disk_rw_blocks. It is not an API function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-15Merge git://git.denx.de/u-boot-fdtTom Rini
2017-09-15fdt: Allow stacked overlays phandle referencesPantelis Antoniou
This patch enables an overlay to refer to a previous overlay's labels by performing a merge of symbol information at application time. In a nutshell it allows an overlay to refer to a symbol that a previous overlay has defined. It requires both the base and all the overlays to be compiled with the -@ command line switch so that symbol information is included. base.dts -------- /dts-v1/; / { foo: foonode { foo-property; }; }; $ dtc -@ -I dts -O dtb -o base.dtb base.dts bar.dts ------- /dts-v1/; /plugin/; / { fragment@1 { target = <&foo>; __overlay__ { overlay-1-property; bar: barnode { bar-property; }; }; }; }; $ dtc -@ -I dts -O dtb -o bar.dtb bar.dts baz.dts ------- /dts-v1/; /plugin/; / { fragment@1 { target = <&bar>; __overlay__ { overlay-2-property; baz: baznode { baz-property; }; }; }; }; $ dtc -@ -I dts -O dtb -o baz.dtb baz.dts Applying the overlays: $ fdtoverlay -i base.dtb -o target.dtb bar.dtb baz.dtb Dumping: $ fdtdump target.dtb / { foonode { overlay-1-property; foo-property; linux,phandle = <0x00000001>; phandle = <0x00000001>; barnode { overlay-2-property; phandle = <0x00000002>; linux,phandle = <0x00000002>; bar-property; baznode { phandle = <0x00000003>; linux,phandle = <0x00000003>; baz-property; }; }; }; __symbols__ { baz = "/foonode/barnode/baznode"; bar = "/foonode/barnode"; foo = "/foonode"; }; }; Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Simon Glass <sjg@chromium.org>
2017-09-15libfdt: Initialize the stack variableTien Fong Chee
Report Coverity log: The code uses a variable that has not been initialized, leading to unpredictable or unintended results. Reported-by: Coverity (CID: 60519) Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
2017-09-15fdt: Sync libfdt up to upstreamSimon Glass
Add upstream changes to U-Boot: - new pylibfdt functions - fdt_setprop_placeholder() Signed-off-by: Simon Glass <sjg@chromium.org>
2017-09-14lib: strto: fix incorrect handling of specified baseRob Clark
The strto functions should honor the specified base (if non-zero) rather than permitting a hex or octal string when the user wanted (for example) base 10. This has been fixed somewhere along the way in the upstream linux kernel src tree, at some point after these was copied in to u-boot. And also in a way that duplicates less code. So port _parse_integer_fixup_radix() to u-boot. Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-14lib: at91: Add logo files used via API of DM_VIDEOWenyou Yang
In order to display the company's logo via the API of DM_VIDEO, and add the logo files of both Atmel and Microchip. Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-12vsprintf.c: add GUID printingRob Clark
This works (roughly) the same way as linux's, but we currently always print lower-case (ie. we just keep %pUB and %pUL for compat with linux), mostly just because that is what uuid_bin_to_str() supports. %pUb: 01020304-0506-0708-090a-0b0c0d0e0f10 %pUl: 04030201-0605-0807-090a-0b0c0d0e0f10 It will be used by a later efi_loader paths for efi variables and for device-path-to-text protocol, and also quite useful for debug prints of protocol GUIDs. Signed-off-by: Rob Clark <robdclark@gmail.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-12vsprintf.c: add UTF-16 string (%ls) supportRob Clark
This is convenient for efi_loader which deals a lot with UTF-16. Only enabled with CC_SHORT_WCHAR, leaving room to add a UTF-32 version when CC_SHORT_WCHAR is not enabled. Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-12lib: add some utf16 handling helpersRob Clark
We'll eventually want these in a few places in efi_loader, and also vsprintf. Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-09-12Merge git://git.denx.de/u-boot-fsl-qoriqTom Rini
2017-09-11moveconfig: Use fd.write() instead of print >>Simon Glass
Adjust this code so that it can work with Python 2 and 3. Fixes: d73fcb1 (moveconfig: Support building a simple config database) Reported-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-09-11spl: fit: Eanble GZIP support for image decompressionYork Sun
Add Kconfig option SPL_GZIP and SPL_ZLIB to enable gunzip support for SPL boot, eg. falcon boot compressed kernel image. Signed-off-by: York Sun <york.sun@nxp.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-03bch: don't use __BSD_VISIBLE to test for flsJonathan Gray
Commit 4ecc988301bc8e981e6d7538c57cdb3aa82f7c1d assumes fls is in libc if __BSD_VISIBLE is defined. This appears to only be true on FreeBSD and DragonFlyBSD. OpenBSD defines __BSD_VISIBLE and does not have fls in strings.h/libc. Switch the test for __BSD_VISIBLE to one for __DragonFly__ and __FreeBSD__ to unbreak the build on OpenBSD. Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
2017-09-01Convert CONFIG_BCH to KconfigAdam Ford
This converts the following to Kconfig: CONFIG_BCH Signed-off-by: Adam Ford <aford173@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-20Fix 'notes' typosAnatolij Gustschin
s/notes/nodes Signed-off-by: Anatolij Gustschin <agust@denx.de>
2017-08-18Merge tag 'signed-efi-next' of git://github.com/agraf/u-bootTom Rini
EFI Fixes for 2017.09: - Fix GOP w/o display - Fix LocateHandle - Fix exit return value truncation - Fix missing EFIAPI in efi_locate_handle (for x86)
2017-08-16env: Rename getenv_hex(), getenv_yesno(), getenv_ulong()Simon Glass
We are now using an env_ prefix for environment functions. Rename these for consistency. Also add function comments in common.h. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename getenv/_f() to env_get()Simon Glass
We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h. Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename setenv() to env_set()Simon Glass
We are now using an env_ prefix for environment functions. Rename setenv() for consistency. Also add function comments in common.h. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>