Rob Clark [Thu, 27 Jul 2017 12:04:19 +0000 (08:04 -0400)]
efi_loader: indent entry/exit prints to show nesting level
This should make it easier to see when a callback back to UEFI world
calls back in to the u-boot world, and generally match up EFI_ENTRY()
and EFI_EXIT() calls.
Signed-off-by: Rob Clark <robdclark@gmail.com>
[agraf: remove static from const var]
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Thu, 27 Jul 2017 12:04:18 +0000 (08:04 -0400)]
efi_loader: add checking for incorrect use of EFI_ENTRY/EXIT
Missing an EFI_ENTRY() or doubling up EFI_EXIT() leads to non-obvious
crashes. Let's add some error checking.
Signed-off-by: Rob Clark <robdclark@gmail.com>
[agraf: fix bogus assert() and fix app_gd breakage]
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Thu, 27 Jul 2017 12:04:17 +0000 (08:04 -0400)]
efi_loader: Add an EFI_CALL() macro
Rather than open-coding EFI_EXIT() + callback + EFI_ENTRY(), introduce
an EFI_CALL() macro. This makes callbacks into UEFI world (of which
there will be more in the future) more concise and easier to locate in
the code.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Thu, 27 Jul 2017 12:04:16 +0000 (08:04 -0400)]
efi_loader: only evaluate EFI_EXIT()'s ret once
There are a couple spots doing things like:
return EFI_EXIT(some_fxn(...));
which I handn't noticed before. With addition of printing return value
in the EFI_EXIT() macro, now the fxn call was getting evaluated twice.
Which we didn't really want.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Thu, 27 Jul 2017 15:28:33 +0000 (11:28 -0400)]
efi_loader: add some missing breaks
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Wed, 26 Jul 2017 18:34:05 +0000 (14:34 -0400)]
efi_loader: fix bug in efi_get_memory_map
When booting shim -> fallback -> shim -> grub -> linux the memory map is
a bit larger than the size linux passes in on the first call. But in
the EFI_BUFFER_TOO_SMALL case we were not passing back the updated size
to linux so it would loop forever.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Alexander Graf [Wed, 26 Jul 2017 11:41:05 +0000 (13:41 +0200)]
efi_loader: Fix configuration table override
Before commit
7cbc12415d ("efi_loader: initalize EFI object list
only once") we recreated the world on every bootefi invocation.
That included the object tree as well as the configuration tables.
Now however we don't recreate them, which means we must not explicitly
override the configuration tables, as otherwise we may lose our SMBIOS
table from the configuration table list on second bootefi invocation.
This patch makes bootefi call our normal configuration table modification
APIs to add/remove the FDT instead of recreating all tables from scratch.
That way the SMBIOS table gets preserved across multiple invocations.
Signed-off-by: Alexander Graf <agraf@suse.de>
Alexander Graf [Wed, 26 Jul 2017 11:41:04 +0000 (13:41 +0200)]
efi_loader: Improve install_configuration_table
The INSTALL_CONFIGURATION_TABLE callback also provides the ability to
remove table entries. This patch adds that functionality.
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Wed, 26 Jul 2017 00:28:29 +0000 (20:28 -0400)]
efi_loader: remove more double EFI_EXIT() in efi_disk.c
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Wed, 26 Jul 2017 00:17:59 +0000 (20:17 -0400)]
efi_loader: remove double EFI_EXIT() with efi_unsupported
Probably this went unnoticed before, but it causes problems with
addition of
804b1d73 ("efi_loader: log EFI return values too")
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Mon, 24 Jul 2017 14:39:01 +0000 (10:39 -0400)]
efi_loader: expose protocols via GUID
shim.efi (or rather gnu-efi's LibLocateProtocol() which shim.efi uses)
resolves protocols via efi_locate_handle() so the console protocols
need to be added to the efi object list.
Signed-off-by: Rob Clark <robdclark@gmail.com>
[agraf: whitespace fixes]
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Mon, 24 Jul 2017 14:39:00 +0000 (10:39 -0400)]
efi_loader: add helper macro to construct protocol objects
There are a bunch of protocols which should be exposed by GUID but are
not. Add a helper macro to create an efi_object, to avoid much typing.
Note that using the pointer for efiobj->handle is semi-arbitrary. We
just need a unique value to match the efiobj supporting the protocol
with the handle that LocateHandle() returns..
See LibLocateProtocol() in gnu-efi. It does LocateHandle() to find all
the handles, and then loops over them calling HandleProtocol() with the
GUID of the protocol it is trying to find.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Mon, 24 Jul 2017 14:31:52 +0000 (10:31 -0400)]
efi_loader: log EFI return values too
Turns out this is rather useful to tracking down where things fail.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Thu, 13 Jul 2017 21:24:32 +0000 (23:24 +0200)]
efi_loader: implement ProtocolsPerHandle
Boot service ProtocolsPerHandle is implemented in
efi_protocols_per_handle.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Wed, 19 Jul 2017 17:22:34 +0000 (19:22 +0200)]
efi_loader: parameter types for CreateEvent, SetTimer
The first argument 'type' of CreateEvent is an 32bit unsigned
integer bitmap and not an enum.
The second argument 'type' of SetTimer take values of an
enum which is called EFI_TIMER_DELAY in the UEFI standard.
To avoid confusion rename efi_event_type to efi_timer_delay.
Reported-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Heinrich Schuchardt [Wed, 19 Jul 2017 17:37:22 +0000 (19:37 +0200)]
efi_loader: initalize EFI object list only once
If several EFI applications are executed in sequence we want
to keep the content of the EFI object list.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Thu, 20 Jul 2017 03:26:07 +0000 (05:26 +0200)]
efi_console: use EFIAPI for callback functions
The call to efi_create_event requires notification functions
flagged as EFIAPI.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Thu, 20 Jul 2017 11:59:39 +0000 (07:59 -0400)]
efi_loader: workaround for grub lsefi bug
Patch has also been sent to fix grub to not ignore the error returned
and treat protocol_buffer_count as valid. But that that might take a
while to trickle into distro's, so this workaround might be useful.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Fri, 21 Jul 2017 17:12:08 +0000 (19:12 +0200)]
efi_loader: implement ConvertDeviceNodeToText
Move the logic for converting a node to text from
efi_convert_device_path_to_text to convert_device_node_to_text.
Provide a wrapper function convert_device_node_to_text_ext.
As we use only shallow device paths so we can call
directly call efi_device_node_to_text from efi_device_path_to_text.
Add output for MAC addresses.
Add output for not yet supported types/subtypes.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Fri, 21 Jul 2017 17:05:44 +0000 (19:05 +0200)]
efi_memory: return MapKey
efi_get_memory_map should set a defined value for map_key.
We later can introduce the test against this value in
efi_exit_boot_services as required by the UEFI standard.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Fri, 21 Jul 2017 17:04:33 +0000 (19:04 +0200)]
efi_memory: do parameter checks first
The parameter checks should be done first.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Fri, 21 Jul 2017 19:00:27 +0000 (15:00 -0400)]
efi_loader: gop: fixes for CONFIG_DM_VIDEO without CONFIG_LCD
Make EFI GOP support work with DM_VIDEO but without legacy LCD.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Mon, 24 Jul 2017 11:59:11 +0000 (07:59 -0400)]
efi_loader: move guidcmp to header
Want to re-use this for file protocol, which I'm working on.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Rob Clark [Mon, 24 Jul 2017 11:59:09 +0000 (07:59 -0400)]
efi_loader: EFI file paths should be DOS style
shim.efi, for example, actually tries to parse this, but is expecting
backslashes.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 18 Jul 2017 18:17:23 +0000 (20:17 +0200)]
efi_loader: correctly implement 100ns conversion
In efi_set_timer we receive the trigger time in intervals of 100 ns.
We should convert it to intervals of 1000 ns by 64bit division.
The patch supplies function efi_div10 that uses multiplication to
implement the missing 64 bit division.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 18 Jul 2017 18:17:22 +0000 (20:17 +0200)]
efi_console: set up events
Set up a timer event and the WaitForKey event.
In the notify function of the timer event check for console input
and signal the WaitForKey event accordingly.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 18 Jul 2017 18:17:21 +0000 (20:17 +0200)]
efi_loader: refactor efi_set_timer
efi_set_timer is refactored to make the function callable internally.
Wrapper function efi_set_timer_ext is provided for EFI applications.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 18 Jul 2017 18:17:20 +0000 (20:17 +0200)]
efi_loader: refactor efi_create_event
efi_create_event is refactored to make it possible to call it
internally. For EFI applications wrapper function
efi_create_event_ext is created.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 18 Jul 2017 18:17:19 +0000 (20:17 +0200)]
efi_loader: correct size for tpl level
The UEFI standard defines the type for the tpl level as EFI_TPL
alias UINTN.
UINTN is an integer is defined as an unsigned integer of native
width. So we can use size_t for the definition.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 18 Jul 2017 18:17:18 +0000 (20:17 +0200)]
efi_loader: implement multiple event support
Up to now the boot time supported only a single event.
This patch now allows four events.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 18 Jul 2017 18:17:17 +0000 (20:17 +0200)]
efi_loader: use struct efi_event * instead of void *
In our implementation the internal structure of events is known.
So use the known type instead of void.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Fri, 14 Jul 2017 17:12:39 +0000 (19:12 +0200)]
efi_memory: avoid NULL dereference in efi_free_pool
If efi_free_pool is called with argument NULL an illegal memory
access occurs.
So let's check the parameter on entry.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 20 Jun 2017 19:10:27 +0000 (19:10 +0000)]
efi_loader: disk: iterate only over valid block devices
The efi_loader currently stops iterating over the available
block devices stopping at the first device that fails.
This may imply that no block device is found.
With the patch efi_loader only iterates over valid devices.
It is based on patch
06d592bf52f6 (dm: core: Add uclass_first/next_device_check())
which is currently in u-boot-dm.git.
For testing I used an odroid-c2 with a dts including
&sd_emmc_a {
status = "okay";
};
This device does not exist on the board and cannot be initialized.
Without the patch:
=> bootefi hello
## Starting EFI application at
01000000 ...
WARNING: Invalid device tree, expect boot to fail
mmc_init: -95, time 1806
Found 0 disks
Hello, world!
## Application terminated, r = 0
With the patch:
=> bootefi hello
## Starting EFI application at
01000000 ...
WARNING: Invalid device tree, expect boot to fail
mmc_init: -95, time 1806
Scanning disk mmc@70000.blk...
Scanning disk mmc@72000.blk...
Card did not respond to voltage select!
mmc_init: -95, time 9
Scanning disk mmc@74000.blk...
Found 3 disks
Hello, world!
## Application terminated, r = 0
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 4 Jul 2017 21:15:23 +0000 (23:15 +0200)]
efi_loader: provide meaningful status code
Currenty any EFI status other than EFI_SUCCESS is reported as
Application terminated, r = -22
With the patch the status code returned by the EFI application
is printed.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 4 Jul 2017 21:15:22 +0000 (23:15 +0200)]
efi_loader: define all known status codes
efi.h held only a few EFI status codes.
The patch adds the missing definitions for later usage.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 4 Jul 2017 21:15:21 +0000 (23:15 +0200)]
bootefi: allow return without EFI_BOOT_SERVICES.Exit
The Unified Extensible Firmware Interface Specification, version 2.7,
defines in chapter 2.1.2 - UEFI Application that an EFI application may
either directly return or call EFI_BOOT_SERVICES.Exit().
Unfortunately U-Boot makes the incorrect assumption that
EFI_BOOT_SERVICES.Exit() is always called.
So the following application leads to a memory exception on the aarch64
architecture when returning:
EFI_STATUS efi_main(
EFI_HANDLE handle,
EFI_SYSTEM_TABlE systable) {
return EFI_SUCCESS;
}
With this patch the entry point is stored in the image handle.
The new wrapper function do_enter is used to call the EFI entry point.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:25 +0000 (22:06 +0200)]
efi_loader: implement EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
ConvertPathToText is implemented for
* type 4 - media device path
* subtype 4 - file path
This is the kind of device path we hand out for block devices.
All other cases may be implemented later.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
[agraf: fix whitespace]
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:24 +0000 (22:06 +0200)]
efi_loader: reimplement efi_locate_protocol
The UEFI specification requires that LocateProtol finds the first
handle supporting the protocol and to return a pointer to its
interface.
So we have to assign the protocols to an efi_object and not use
any separate storage.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:23 +0000 (22:06 +0200)]
efi_loader: provide a sufficient number of protocols
Four protocols per object is too few to run iPXE.
Let's raise the number of protocols per object to eight.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:22 +0000 (22:06 +0200)]
efi_loader: implement LocateHandleBuffer
UEFI boot service LocateHandleBuffer is implemented by calling
efi_allocate_handle and efi_locate_handle.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:21 +0000 (22:06 +0200)]
efi_loader: refactor efi_locate_handle
To implement LocateHandleBuffer we need to call efi_locate_handle
internally without running through EFI_EXIT.
So put EFI_ENTRY and EFI_EXIT into a new wrapper function
efi_locate_handle_ext.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:20 +0000 (22:06 +0200)]
efi_loader: implement InstallMultipleProtocolInterfaces
Implement InstallMultipleProtocolInterfaces in function
efi_install_multiple_protocol_interfaces by repeatedly
calling efi_install_protocol_interface.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:19 +0000 (22:06 +0200)]
efi_loader: refactor efi_uninstall_protocol_interface
For the implementation of UninstallMultipleProtocolInterfaces we
need to call efi_uninstall_protocol_interface. In internal calls
we should not pass through EFI_EXIT.
The patch introduces a wrapper function
efi_uninstall_protocol_interface_ext.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:18 +0000 (22:06 +0200)]
efi_loader: refactor efi_install_protocol_interface
For the implementation of InstallMultipleProtocolInterfaces we
need to call efi_install_protocol_interface. In internal calls
we should not pass through EFI_EXIT.
The patch introduces a wrapper function
efi_install_protocol_interface_ext.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:17 +0000 (22:06 +0200)]
efi_loader: implement UninstallProtocolInterface
Without the patch efi_uninstall_protocol_interface always returns an
error.
With the patch protocols without interface can be uninstalled.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:16 +0000 (22:06 +0200)]
efi_loader: implement InstallProtocolInterface
efi_install_protocol_interface up to now only returned an error code.
The patch implements the UEFI specification for InstallProtocolInterface
with the exception that it will not create new handles.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:15 +0000 (22:06 +0200)]
efi_loader: efi_open_protocol: parameter checks
Add all parameter checks for function efi_open_protocol that do not
depend on a locking table.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
xypron.glpk@gmx.de [Tue, 11 Jul 2017 20:06:14 +0000 (22:06 +0200)]
efi_loader: refactor efi_open_protocol
efi_open_protocol was implemented to call a protocol specific open
function to retrieve the protocol interface.
The UEFI specification does not know of such a function.
It is not possible to implement InstallProtocolInterface with the
current design.
With the patch the protocol interface itself is stored in the list
of installed protocols of an efi_object instead of an open function.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
[agraf: fix efi gop support]
Signed-off-by: Alexander Graf <agraf@suse.de>
Tom Rini [Wed, 12 Jul 2017 00:28:46 +0000 (20:28 -0400)]
Merge git://git.denx.de/u-boot-dm
Tom Rini [Tue, 11 Jul 2017 18:21:50 +0000 (14:21 -0400)]
Merge branch 'master' of git://git.denx.de/u-boot-rockchip
Masahiro Yamada [Thu, 22 Jun 2017 08:57:50 +0000 (17:57 +0900)]
dm: ofnode: use fdt32_t for DT property value to fix sparse warning
DTB is encoded in big endian. When we retrieve property values,
we need to use fdt32_to_cpu (aka be32_to_cpu) for endian conversion.
This is a bit error-prone, but sparse is useful to detect endian
mismatch.
We need to use (fdt32_t *) instead of (u32 *) for a pointer of a
property value. Otherwise sparse warns "cast to restricted __be32".
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada [Thu, 22 Jun 2017 08:10:11 +0000 (17:10 +0900)]
dm: include <dm/util.h> from driver/core/dump.c
Include <dm/util.h> to fix sparse warnings:
symbol 'dm_dump_all' was not declared. Should it be static?
symbol 'dm_dump_uclass' was not declared. Should it be static?
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada [Thu, 22 Jun 2017 07:54:07 +0000 (16:54 +0900)]
dm: ofnode: simplify ofnode_read_bool()
Reuse ofnode_get_property() to simplify the implementation.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada [Thu, 22 Jun 2017 07:54:05 +0000 (16:54 +0900)]
dm: ofnode: rename ofnode_read_prop() to ofnode_get_property()
This function returns the pointer to the value of a node property.
The current name ofnode_read_prop() is confusing. Follow the naming
of_get_property() from Linux.
The return type (const u32 *) is wrong. DT property values can be
strings as well as integers. This is why of_get_property/fdt_getprop
returns an opaque pointer.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada [Thu, 22 Jun 2017 07:54:04 +0000 (16:54 +0900)]
dm: ofnode: simplify ofnode_read_prop()
The code inside the if-block is the same as of_get_property().
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada [Thu, 22 Jun 2017 07:54:03 +0000 (16:54 +0900)]
dm: ofnode: use ofnode_read_bool() to check property existence
This will clarify the code.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada [Thu, 22 Jun 2017 07:50:01 +0000 (16:50 +0900)]
dm: include <dm/util.h> from drivers/core/util.c
Fix sparse warnings "... was not declared. Should it be static?"
Also, fix redefinition of dm_warn/dm_dbg.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tom Rini [Tue, 13 Jun 2017 11:10:35 +0000 (07:10 -0400)]
fdt: Check for NULL return from fdt_getprop in 'fdt set'
While the previous pass through fixed one place where we knew that
fdt_getprop would be given a positive len, in the case of 'fdt set' we
do not, so check that we did no get NULL from fdt_getprop().
Cc: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 163249)
Fixes
72c98ed1ab48 ("fdt: Add a check to do_fdt() for coverity")
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 12 Jun 2017 12:22:01 +0000 (06:22 -0600)]
tegra: fdt: Ensure that the console UART is enabled
Many tegra boards have the console UART node disabled. With livetree this
prevents serial from working since it does not 'force' the console to be
bound. Updates the affected boards to fix this error.
The boards were checked with:
for b in $(grep tegra boards.cfg |grep -v integrator | \
awk '{print $7}' | sort); do
echo $b;
fdtgrep -c nvidia,tegra20-uart b/$b/u-boot.dtb |grep okay;
done
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:59 +0000 (06:21 -0600)]
tegra: Show a debug message if the LCD PMIC fails to start
This error condition should have a debug() message. Add it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:58 +0000 (06:21 -0600)]
dm: serial: Add livetree support
Add support for a live device tree to the core serial uclass.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:57 +0000 (06:21 -0600)]
dm: serial: Separate out the core serial-device finding code
This function is quite long. Move the core code into a separate function
in preparation for adding livetree support.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:56 +0000 (06:21 -0600)]
dm: serial: ns16550: Convert to livetree
Update this driver to support a live device tree.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:39 +0000 (06:21 -0600)]
tegra: Fix up include file ordering
Update these two files so include files in the right order.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:38 +0000 (06:21 -0600)]
video: simple-panel: Add a little more debugging
Add some debugging to show when the backlight is enabled.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:37 +0000 (06:21 -0600)]
dm: video: Update pwm_backlight to support livetree
Update this driver to support a live device tree.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:36 +0000 (06:21 -0600)]
dm: video: Sync display on backspace
We should sync the display (e.g. flush cache) when backspace is pressed
to ensure that the character is erased correctly.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:35 +0000 (06:21 -0600)]
tegra: nyan-big: Enable bootstage
Enable full bootstage support so we can time SPL and U-Boot.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:34 +0000 (06:21 -0600)]
dm: Fix error handling when unflattening the DT
The error handling code does not current detect an error right away.
Adjust it to return immediately.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:33 +0000 (06:21 -0600)]
tegra: nyan-big: Enable the debug UART
Enable this to allow debugging when the serial UART driver is
misconfigured.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:32 +0000 (06:21 -0600)]
tegra: video: Time the LCD init
Calculate the time taken to set up the LCD.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:31 +0000 (06:21 -0600)]
dm: core: Add functions to obtain node's address/size cells
The of_n_addr_cells() and of_n_size_cells() functions are useful for
getting the size of addresses in a node, but in a few places U-Boot needs
to obtain the actual property value for a node without walking up the
stack. Add functions for this and just the existing code to use it.
Add a comment to the existing ofnode functions which do not do the right
thing with a flat tree.
This fixes a problem reading PCI addresses.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:30 +0000 (06:21 -0600)]
dm: core: Add dev_read_enabled() to check if a device is enabled
This function allows a device's status to be read. This indicates whether
the device should be enabled or disabled.
Note: In normal operation disabled devices will not be present in the
driver-model tree.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:29 +0000 (06:21 -0600)]
dm: core: Add dev_read_resource() to read device resources
Add a function which reads resources from a device, such as the device
hardware address. This uses the "reg" property in the device.
Unlike other functions there is little sense in inlining this when
livetree is not being used because it has some logic in it and this would
just bloat the code size.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Mon, 12 Jun 2017 12:21:28 +0000 (06:21 -0600)]
dm: core: Add ofnode_read_string_count()
This provides a way to find the number of strings in a string list. Add it
and also fix up the comment for ofnode_read_string_index().
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Simon Glass [Wed, 21 Jun 2017 03:28:49 +0000 (21:28 -0600)]
binman: Put our local modules ahead of system modules
If a system module is named the same as one of those used by binman we
currently pick the system module. Adjust the ordering so that our modules
are chosen instead.
The module conflict reported was 'tools' from jira-python. I cannot access
that package to test it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Kevin Hilman <khilman@baylibre.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Simon Glass [Mon, 19 Jun 2017 04:09:06 +0000 (22:09 -0600)]
dtoc: Add tests
Add some tests of dtoc's functionality to make it easier to expand and
enhance the tool.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:09:05 +0000 (22:09 -0600)]
sandbox: Stop printing platdata at the start of SPL
Currently we have code which prints out platform data at the start of SPL.
Now that we have tests for dtoc this is probably not necessary. Drop it.
Update test_ofplatdata to check for empty output since it is useful to
check that sandbox_spl works as expected.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:09:04 +0000 (22:09 -0600)]
dtoc: Add a comment about string replace in conv_name_to_c()
This function uses several separate string replaces where a regular
expression might seem more reasonable. Add a comment justifying the way it
is currently done.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:09:03 +0000 (22:09 -0600)]
dtoc: Move the main logic into the dtb_platdata file
Collect the main logic of dtoc into a function and put it into
dtb_platdata. This will allow tests to use this function instead of
duplicating the code themselves.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:09:02 +0000 (22:09 -0600)]
dtoc: Move static functions out of the class
Rather than using static functions within the class, move them out of the
class. This will make it slightly easier for tests to call them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:09:01 +0000 (22:09 -0600)]
dtoc: Pass include_disabled explicitly
This option is the only one actually used by the dtb_platdata class. Pass
it explicitly to avoid needing to pass the whole option object to the
constructor.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:09:00 +0000 (22:09 -0600)]
dtoc: Don't handle properties with / in them
This conversion appears to not be needed as it does not occur in practice.
Drop it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:08:59 +0000 (22:08 -0600)]
dtoc: Fix pylint warnings
Unfortunately I neglected to run pylint on this tool with its initial
submission. Fix the warnings.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:08:58 +0000 (22:08 -0600)]
dtoc: Split out the main class into its own file
To simplify running tests we should move this class into its own file.
This allows the tests to import it without having to import dtoc.py, which
runs the tests.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:08:57 +0000 (22:08 -0600)]
dtoc: Add a comment at the top
Add a description of the dtoc tool at the top of the file.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Mon, 19 Jun 2017 04:08:56 +0000 (22:08 -0600)]
dtoc: Use self._options instead of the global options
This class should use the options object passed to it rather than finding
the global one. Fix it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Fri, 16 Jun 2017 03:39:33 +0000 (21:39 -0600)]
moveconfig: Allow automatic location and adding of 'imply'
By using a Kconfig parser we can find the location of each option in the
Kconfig tree. Using the information from the database we can then
automatically add an 'imply' option into the right place if requested by
the user.
Add a -a option to support adding 'imply' options. Display the location of
any existing 'imply' option so that progress can be examined. Add a -A
option to hide any existing 'imply' options so that already-completed
additions need not be considered further.
Also add documentation for this feature.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Fri, 16 Jun 2017 03:39:32 +0000 (21:39 -0600)]
moveconfig: Allow control of which implying configs are shown
Sometimes it is useful to display CONFIG_TARGET or CONFIG_CMD configs. Add
an option to control this.
Also we generally ignore implying configs which affect fewer than 5
boards. But sometimes it is useful to show those those, so add an option
that reduces the minimum to two.
ERRATUM configs are never useful for implying things, so ignore those.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Fri, 16 Jun 2017 03:39:31 +0000 (21:39 -0600)]
moveconfig: Allow piping in 'git show --stat' output
It is useful to be able to process only a subset of boards to save time.
Often that subset is defined by the defconfig files in a git commit. This
change allows things like:
# Build the database
./tools.moveconfig.py -b
# Find some implying configs
./tools/moveconfig.py -i CONFIG_X
# Add some 'imply' statements to Kconfig files
./tools/moveconfig.py -i CONFIG_X -a CONFIG_A,CONFIG_B
# Reprocess the defconfig files to see if we can drop some changes
git show --stat | ./tools/moveconfig.py -s -d -
# Update the commit, with fewer defconfig changes
gii commit -au
Where the commit contains defconfig files, this will reprocess them to
take account of the imply statements that you added.
Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass [Fri, 16 Jun 2017 03:37:54 +0000 (21:37 -0600)]
sandbox: Drop special case console code for sandbox
At present sandbox has a special case where it directly calls os_putc()
when it does not have a console yet.
Now that we have the pre-console buffer enabled we can drop this. Any
early characters will be buffered and output later.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Simon Glass [Fri, 16 Jun 2017 03:37:53 +0000 (21:37 -0600)]
sandbox: Enable more console options
Enable the pre-console buffer, displaying the model and post-relocation
console announce on sandbox. Also add a model name to the device tree.
This allows testing of these features.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Simon Glass [Fri, 16 Jun 2017 03:37:52 +0000 (21:37 -0600)]
console: Use map_sysmem() for the pre-relocation console
At present this feature casts the address to a pointer. Use the
map_sysmem() function so that it will work correctly on sandbox.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Simon Glass [Fri, 16 Jun 2017 03:37:51 +0000 (21:37 -0600)]
test: Add a test for snprintf() and the banner/version
Add a simple test to make sure that these functions obey the buffer size
passed into them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Simon Glass [Fri, 16 Jun 2017 03:37:50 +0000 (21:37 -0600)]
Allow displaying the U-Boot banner on a video display
At present the U-Boot banner is only displayed on the serial console. If
this is not visible to the user, the banner does not show. Some devices
have a video display which can usefully display this information.
Add a banner which is printed after relocation only on non-serial devices
if CONFIG_DISPLAY_BOARDINFO_LATE is defined.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Simon Glass [Fri, 16 Jun 2017 18:51:42 +0000 (12:51 -0600)]
display_options: Refactor to allow obtaining the banner
Move the display options code into a separate function so that the U-Boot
banner can be obtained from other code. Adjust the 'version' command to
use it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Simon Glass [Thu, 15 Jun 2017 03:28:48 +0000 (21:28 -0600)]
x86: Move link to use driver model for SCSI
As a demonstration of how to use SCSI with driver model, move link over
to use this. This patch needs more work, but illustrates the concept.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Simon Glass [Thu, 15 Jun 2017 03:28:47 +0000 (21:28 -0600)]
dm: scsi: Drop scsi_init() when driver model is used
This function should not be used with driver model. Update the code to
reflect this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Simon Glass [Thu, 15 Jun 2017 03:28:46 +0000 (21:28 -0600)]
dm: ahci: Add a driver for SCSI on AHCI
Some AHCI drivers use SCSI under the hood. Rather than making the AHCI
driver be in the SCSI uclass it makes sense to have the AHCI device create
a SCSI device as a child. That way we can handle any AHCI-specific
operations rather than trying to pretend tha the device is just SCSI.
To handle this we need to provide a way for AHCI drivers to bind a SCSI
device as its child, and probe it. Add functions for this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Simon Glass [Thu, 15 Jun 2017 03:28:45 +0000 (21:28 -0600)]
dm: scsi: Split out the bus scanning code
Split out the code that scans a single SCSI bus into a separate function.
This will allow it to be used from driver model.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>