When exit-boot-services is called, active devices should be removed.
Update testapp to call this method and check that the USB controller is
removed as expected.
Signed-off-by: Simon Glass <sjg@chromium.org>
An EFI app expects pointers to be returned, cast to u64. The conversion
to use addresses missed this, so fix the call.
Signed-off-by: Simon Glass <sjg@chromium.org>
The allocate/free-pages functions return an address, so there is no need
to convert it. Fix this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: c824a96d76 ("efi_loader: Use the log with memory-related...")
Update a few memory functions to log their inputs and outputs. To avoid
the use of 'goto', etc. the functions are turned into stubs, calling a
separate function to do the actual operation.
Add a few tests.
Signed-off-by: Simon Glass <sjg@chromium.org>
Create a test which does some sample calls and checks the output.
Expand the size of the sandbox bloblist to accommodate the log.
Signed-off-by: Simon Glass <sjg@chromium.org>
Create an EFI log when the EFI subsystem is first touched. This happens
after relocation in board_init_f()
Signed-off-by: Simon Glass <sjg@chromium.org>
The current logging system suffers from some disadvantages, mainly that
it writes its output to the console and cannot be easily reviewed.
Add a dedicated log, storing records in a binary format and including
the result codes and any return values from each call. The log is built
sequentially in memory and can be reviewed after any EFI operation. It
could potentially be written to media for later review, but that is not
implemented so far.
Signed-off-by: Simon Glass <sjg@chromium.org>
Rather than setting up the global variables and then making the call,
pass them into function directly. This cleans up the code and makes it
all a bit easier to understand.
Signed-off-by: Simon Glass <sjg@chromium.org>
This code is only needed if an invalid image/device path is passed in.
Move the code out to a caller where this can be dealt with. The normal
flow will provide these parameters.
Signed-off-by: Simon Glass <sjg@chromium.org>
This uses a few global variables at present. With the bootflow we have
the required parameters, so add a function which accepts these. Update
the existing function to call the new one with the globals.
Signed-off-by: Simon Glass <sjg@chromium.org>
Provide these globals as parameters to this function, on the way to
making it possible to start an image without relying on the globals.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This function is not called from outside this file and has no entry in
the header file, so mark it static.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This returns a devicetree and updates a parameter with an error code.
Swap it, since this fits better with the way U-Boot normally works. It
also (more easily) allows leaving the existing pointer unchanged.
No yaks were harmed in this change, but there is a very small code-size
reduction.
For sifive, the OF_BOARD option must be set for the function to be
called, so there is no point in checking it again. Also OF_SEPARATE is
defined always.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
This collects together several v3 patches into one, to avoid any
temporary test-breakage which would make future bisecting difficult.
For efi_memory, the efi_allocate_pool() call uses a pointer to refer to
memory, but efi_allocate_pages() uses an int. This causes quite a bit of
confusion, since sandbox has a distinction between pointers and
addresses. Adjust efi_allocate/free_pages_ext() to handle the
conversions.
Update efi_add_memory_map() function and its friend to use an address
rather than a pointer cast to an integer.
For lmb, now that efi_add_memory_map_pg() uses a address rather than a
pointer cast to an int, we can simplify the code here.
For efi_reserve_memory(), use addresses rather than pointers, so that it
doesn't have to use mapmem.
In general this simplifies the code, but the main benefit is that casts
are no-longer needed in most places, so the compiler can check that we
are doing the right thing.
For efi_add_runtime_mmio(), now that efi_add_memory_map() takes an
address rather than a pointer, do the mapping in this function.
Update the memset() parameter to be a char while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
This cannot work since the code is not present in the emulated memory.
In any case, sandbox cannot make use of the runtime code.
For now, just drop it from sandbox. We can always adjust things to copy
it into memory, if needed.
Signed-off-by: Simon Glass <sjg@chromium.org>
When logging pool allocations, show the address of the pointer, not the
pointer itself. This makes it easier to debug with sandbox
Signed-off-by: Simon Glass <sjg@chromium.org>
This function is passed the address of a void * so update the argument
to match. It is better to have casts in the caller than introduce
confusion as to what is passed in.
Signed-off-by: Simon Glass <sjg@chromium.org>
The word 'physical' suggests that there is an associated virtual address
but there is not. Use 'base' since this is the base address of a region.
Change some uint64_t and remove some brackets to keep checkpatch happy.
Signed-off-by: Simon Glass <sjg@chromium.org>
This struct is really a node in the list, not a list itself. Also it
doesn't need an efi_ prefix. Rename it.
Signed-off-by: Simon Glass <sjg@chromium.org>
We don't need a separate struct for the values in this node. Move
everything in together, so that there is just one struct to consider.
Add a comment about physical_start, so it is clear that it is really
a pointer.
Signed-off-by: Simon Glass <sjg@chromium.org>
This field is always the same as physical_start, so keeping track of it
separately is unnecessary and confusing. Drop it.
Signed-off-by: Simon Glass <sjg@chromium.org>
At present efi_memory uses struct efi_mem_desc for each node of its
memory list. This is convenient but is not ideal, since:
- it means that the fields are under a 'desc' sub-structure
- it includes an unused 'reserved' field
- it includes virtual_start which is confusing as it is always the same
as physical_start
- we must use u64 to store pointers, since that is how they are returned
by calls to efi_get_memory_map()
As a first step to tidying this up, create a new, private struct to hold
these fields.
Signed-off-by: Simon Glass <sjg@chromium.org>
Exported functions should be documented in the header file, not the
implementation. We tend to make such updates on a piecemeal basis to
avoid a 'flag day'. Move some comments related to memory allocation to
follow the convention.
Signed-off-by: Simon Glass <sjg@chromium.org>
Update efi_allocate_pool_ext() to log the pointer returned from this
call, which can be helpful when debugging.
Signed-off-by: Simon Glass <sjg@chromium.org>
Some functions are passing addresses instead of pointers to the
efi_add_memory_map() function. This confusion is understandable since
the function arguments indicate an address.
Make a note of the 8 places where there are problems, which would break
usage in sandbox tests.
Future work will resolve these problems.
Signed-off-by: Simon Glass <sjg@chromium.org>
There is quite a bit of confusion in the EFI code as to whether a field
contains an address or a pointer. As a first step towards resolving
this, document the memory-descriptor struct, indicating that it holds
pointers, not addresses.
Dro the same for efi_add_memory_map() as it is widely used, as well as
efi_add_memory_map_pg() which is only used by lmb
Signed-off-by: Simon Glass <sjg@chromium.org>
The cache-flush function is incorrect which causes a crash in the
remoteproc tests with arm64.
Fix both problems by using map_sysmem() to convert an address to a
pointer and map_to_sysmem() to convert a pointer to an address.
Also update the image-loader's cache-flushing logic.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 3286d223fd ("sandbox: implement invalidate_icache_all()")
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Changes in v6:
- Re-introduce
Changes in v2:
- Drop message about EFI_LOADER
arch/sandbox/cpu/cache.c | 8 +++++++-
drivers/remoteproc/rproc-elf-loader.c | 18 +++++++++++-------
lib/efi_loader/efi_image_loader.c | 3 ++-
3 files changed, 20 insertions(+), 9 deletions(-)
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
While we do plan to switch to OF_SEPARATE now it is supported, it seems
worth at least showing how OF_EMBED could be used instead, just for the
record.
So make the Makefile rule conditional on OF_SEPARATE and adjust fdtdec
to avoid a build error when OF_EMBED is used.
Finally. the dtb symbol has a double underscore, so update it to avoid a
build warning.
With future patches, OF_EMBED will no-longer be used with the EFI app,
so it is expected that it will eventually stop working.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 2e7bf25f6b ("Support separate DTB files with the UEFI app")
efi_bind_block had two issues.
1. A pointer to a the stack was inserted as plat structure and thus used
beyond its life time.
2. Only the first segment of the device path was copied into the
platfom data structure resulting in an unterminated device path.
Signed-off-by: Janis Danisevskis <jdanisevskis@aurora.tech>
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
The UEFI app is an actual executable with things like section headers,
so just gluing the DTB onto the end of it won't work. Add an additional
section to contain this and allocate some space, and then during build
copy the DTB into that section.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add support for driving a TPM via UEFI firmware provided drivers, and
bind those devices from the UEFI app.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add a driver that makes use of the UEFI Simple Network Protocol to
support network access when using the UEFI app implementation, and hook
up the app code to instantiate it for probed devices.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add include of linux/ctype in epautoconf.c and conditional net.h:
Signed-off-by: Simon Glass <sjg@chromium.org>
Add simple support for accessing EFI variables when in EFI app mode
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
We want to jump into the EFI stub in the kernel so it can perform
appropriate init and call ExitBootServices. Add support for doing that,
including ensuring that we copy the kernel to somewhere that's not
currently being used by the firmware.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Drop use of image_info_t:
Signed-off-by: Simon Glass <sjg@chromium.org>