aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-01-05dm: Use access methods for dev/uclass private dataSimon Glass113-278/+372
Most drivers use these access methods but a few do not. Update them. In some cases the access is not permitted, so mark those with a FIXME tag for the maintainer to check. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pratyush Yadav <p.yadav@ti.com>
2021-01-05dm: core: Add functions to set priv/platSimon Glass2-0/+114
This should not normally be needed in drivers, but add accessors for the few cases that exist. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dm: core: Add function to access uclass privSimon Glass3-0/+32
Add functions so this information is not accessed directly. This will be needed for of-platdata which stores it in a different place. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05x86: apl: Drop support for !OF_PLATDATA_PARENTSimon Glass4-45/+1
This code was kept around after of-platdata started supporting parent devices. That feature seems stable now, so let's drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dm: core: Only include simple-bus devicetree id when neededSimon Glass1-1/+3
This is not needed when of-platdata is in use. Update it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dm: core: Use 'uclass_driver' for the uclass linker_listSimon Glass3-5/+5
At present the name 'uclass_driver' is used for the uclass linker list. This does not follow the convention of using the struct name. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dm: core: Support dm_dump_all() in SPLSimon Glass1-2/+4
At present the output from this function is hard to read in SPL, due to (intended) limitations in SPL's printf() function. Add an SPL version so it is clearer. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05spl: Drop bd_info in the data sectionSimon Glass4-10/+34
This uses up space in the SPL binary but it always starts as zero. Also some boards cannot support data in TPL (e.g. Intel Apollo Lake). Use malloc() to allocate this structure instead, by moving the init a little later, after malloc() is inited. Make this function optional since it pulls in malloc(). This reduces the TPL binary size on coral by about 64 bytes Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05sandbox: Drop unnecessary test nodeSimon Glass4-23/+0
The spl-test4 node deliberately has an invalid compatible string. This causes a warning from dtoc and the check it does is not really necessary. Drop it, to avoid the warning and associated confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05serial: Rename ns16550 functions to lower caseSimon Glass20-53/+54
Lower case should be used for function names. Update this driver and its callers accordingly. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-01-05serial: Update NS16550_t and struct NS16550Simon Glass27-82/+85
Typedefs should not be used in U-Boot and structs should be lower case. Update the code to use struct ns16550 consistently. Put a header guard on the file while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-01-05Makefile: Use common args for dtocSimon Glass1-2/+5
At present the dtoc commmand line is repeated twice in the Makefile. Use a variable to avoid this, so it is easier to add more conditional arguments. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05Makefile: Tidy up SPL dtb productionSimon Glass2-12/+13
Use the SPL_NAME variable to simplify the rules. Drop the SPL targets clean-files since the SPL and TPL dts/ directories are removed by existing rules. Move the SPL rules into a new spl_dtbs to avoid the complicated $(if) construct. Also drop unused pieces from the 'targets' variable. With this, SPL and TPL have separate dtbs which respect the various u-boot,dm-spl / u-boot,dm-tpl tags. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05Makefile: Build SPL dtbs in the spl/ directorySimon Glass2-5/+6
Rather than putting these in the top-level dts/ directory (which is intended for U-Boot proper), put them in the correct subdirectory for SPL (either spl/ or tpl/). This is where other SPL targets are kept, so this is more consistent. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05Makefile: Build a separate .dtb for TPLSimon Glass2-4/+11
At present both SPL and TPL use the same devicetree binary. While there is logic to run fdtgrep separately on each one, it does not actually happen. Add a new TPL rule and use that instead. Make this rule conditional on there actually being a TPL. Do the same for SPL for consistency. Note that the SPL and TPL dtbs are build by a Makefule rule used for U-Boot proper. This is the 'dtbs' target in dts/Makefile. So the check for CONFIG_TPL_BUILD in cmd_fdtgrep never actually works at present. We don't support CONFIG_OF_EMBED for TPL at present. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-31Merge tag 'efi-next' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi ↵WIP/01Jan2021-nextTom Rini36-205/+1240
into next Pull request for UEFI sub-system for next * UEFI capsule authentication * UEFI capsule update on QEMU ARM * fsuuid command for FAT file system * bug fixes
2020-12-31qemu: arm64: Add documentation for capsule updateSughosh Ganu2-0/+211
Add documentation highlighting the steps for using the uefi capsule update feature for updating the u-boot firmware image. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31efidebug: capsule: Add a command to update capsule on diskSughosh Ganu1-0/+14
Add a efidebug subcommand to initiate a firmware update using the efi firmware management protocol(fmp) set_image routine. The firmware update can be initiated through 'efidebug capsule disk-update' This would locate the efi capsule file on the efi system partition, and call the platform's set_image fmp routine to initiate the firmware update. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31efi_loader: Enable uefi capsule authenticationSughosh Ganu1-1/+35
Add support for enabling uefi capsule authentication. This feature is enabled by setting the environment variable "capsule_authentication_enabled". The following configs are needed for enabling uefi capsule update and capsule authentication features on the platform. CONFIG_EFI_HAVE_CAPSULE_SUPPORT=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT=y CONFIG_EFI_CAPSULE_FIRMWARE=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31efi: capsule: Add support for uefi capsule authenticationSughosh Ganu7-2/+214
Add support for authenticating uefi capsules. Most of the signature verification functionality is shared with the uefi secure boot feature. The root certificate containing the public key used for the signature verification is stored as part of the device tree blob. The root certificate is stored as an efi signature list(esl) file -- this file contains the x509 certificate which is the root certificate. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31efi_loader: Re-factor code to build the signature store from efi signature listSughosh Ganu2-42/+63
The efi_sigstore_parse_sigdb function reads the uefi authenticated variable, stored in the signature database format and builds the signature store structure. Factor out the code for building the signature store. This can then be used by the capsule authentication routine to build the signature store even when the signature database is not stored as an uefi authenticated variable Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31efi_loader: Make the pkcs7 header parsing function an externSughosh Ganu3-89/+93
The pkcs7 header parsing functionality is pretty generic, and can be used by other features like capsule authentication. Make the function an extern, also changing it's name to efi_parse_pkcs7_header Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31dfu_mtd: Add provision to unlock mtd deviceSughosh Ganu1-3/+17
Prior to writing to an mtd device, mtd_erase is called. This call fails in case the sector being erased is locked. Call mtd_unlock to unlock the region which is to be erased and later written to. Lock the region once the write to the region has completed. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31efi_loader: Add logic to parse EDKII specific fmp payload headerSughosh Ganu1-0/+41
When building the capsule using scripts in edk2, a fmp header is added on top of the binary payload. Add logic to detect presence of the header. When present, the pointer to the image needs to be adjusted as per the size of the header to point to the actual binary payload. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31fsp: Move and rename fsp_types.h fileSughosh Ganu2-4/+5
The fsp_types.h header file contains macros for building signatures of different widths. These signature macros are architecture agnostic, and can be used in all places which use signatures in a data structure. Move and rename the fsp_types.h under the common include header. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-12-31qemu: common: Set dfu_alt_info variable for the platformSughosh Ganu3-0/+70
The dfu framework uses the dfu_alt_info environment variable to get information that is needed for performing the firmware update. Add logic to set the dfu_alt_info for the qemu arm64 platform to reflect the two mtd partitions created for the u-boot env and the firmware image. This can be subsequently extended for other qemu architectures which need this variable set. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31qemu: common: Add support for dynamic mtdparts for the platformSughosh Ganu4-0/+107
Add support for setting the default values for mtd partitions on the platform. This would be used for updating the firmware image using uefi capsule update with the dfu mtd backend driver. Currently, values have been defined for the qemu arm64 platform, with default values defined for the mtd partitions based on the NOR flash. This can be subsequently extended for other qemu architectures which need mtdparts set. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31crypto: Fix the logic to calculate hash with authattributes setSughosh Ganu1-11/+26
RFC 2315 Section 9.3 describes the message digesting process. The digest calculated depends on whether the authenticated attributes are present. In case of a scenario where the authenticated attributes are present, the message digest that gets signed and is part of the pkcs7 message is computed from the auth attributes rather than the contents field. Check if the auth attributes are present, and if set, use the auth attributes to compute the hash that would be compared with the encrypted hash on the pkcs7 message. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31qemu: arm: Initialise virtio devices in board_late_initSughosh Ganu2-0/+7
On the qemu arm platform, the virtio devices are initialised in the board_init function, which gets called before the initr_pci. With this sequence, the virtio block devices on the pci bus are not initialised. Move the initialisation of the virtio devices to board_late_init which gets called after the call to initr_pci. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31mkeficapsule: Add support for embedding public key in a dtbSughosh Ganu2-12/+222
Add options for embedding the public key esl(efi signature list) file to the platform's dtb. The esl file is then retrieved and used for authenticating the capsule to be used for updating firmare components on the platform. The esl file can now be embedded in the dtb by invoking the following command mkeficapsule -K <pub_key.esl> -D <dtb> In the scenario where the esl file is to be embedded in an overlay, this can be done through the following command mkeficapsule -O -K <pub_key.esl> -D <dtb> This will create a node named 'signature' in the dtb, and the esl file will be stored as 'capsule-key' Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-31efi_loader: event queueingHeinrich Schuchardt1-1/+1
When a new event is queued we have to process the event queue by calling efi_process_event_queue(). But there is not reason to call the function when the event is not queueable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: Add size checks to efi_create_indexed_name()Ilias Apalodimas4-7/+15
Although the function description states the caller must provide a sufficient buffer, it's better to have in function checks that the destination buffer can hold the intended value. So let's add an extra argument with the buffer size and check that before doing any copying. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: Remove unconditional installation of file2 protocol for initrdIlias Apalodimas1-5/+0
Up to now we install the EFI_LOAD_FILE2_PROTOCOL to load an initrd unconditionally. Although we correctly return various EFI exit codes depending on the file status (i.e EFI_NO_MEDIA, EFI_NOT_FOUND etc), the kernel loader only falls back to the cmdline interpreted initrd if the protocol is not installed. This creates a problem for EFI installers, since they won't be able to load their own initrd and start the installation. A following patch introduces a different logic where we search for an initrd path defined in an EFI variable named 'Initrd####'. If the bootmgr is used to launch the EFI payload, we'll will try to match the BootCurrent value and find the corresponding initrd (i.e Boot0000 -> Initrd0000 etc). If the file is found, we'll install the required protocol which the kernel's efi-stub can use and load our initrd. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: Remove unused headers from efi_load_initrd.cIlias Apalodimas1-5/+3
dm.h and env.h serve no purpose here. Remove them and sort the remaining in alphabetical order. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: use after free in efi_exit()Heinrich Schuchardt2-7/+14
Do not use data from the loaded image object after deleting it. Fixes: 126a43f15b36 ("efi_loader: unload applications upon Exit()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: describe struct efi_loaded_image_objHeinrich Schuchardt1-1/+3
Add the missing description of some fields of struct efi_loaded_image_obj. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: efi_signal_event() fix comment typosHeinrich Schuchardt1-2/+2
Add missing commas. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: avoid invalid freeHeinrich Schuchardt1-1/+1
load_options passed from do_efibootmgr() to do_bootefi_exec() may contain invalid data from the stack which will lead to an invalid free(). Fixes: 0ad64007feb9 ("efi_loader: set load options in boot manager") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: escape key handlingHeinrich Schuchardt1-0/+12
Up to now the escape key was not correctly detected in UEFI applications. We had to hit it twice for a single escape to be recognized. Use a 10 ms delay to detect if we are dealing with the escape key or an escape sequence. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: missing parentheses after ifHeinrich Schuchardt1-1/+1
IS_ENABLED() contains parentheses. But we should still put extra parentheses around it in an if statement for readability. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31fs/fat: implement fsuuid commandHeinrich Schuchardt3-1/+31
The FAT file system does not have a UUID but a 4 byte volume ID. Let the fsuuid command show it in XXXX-XXXX format. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31fs: fat: eliminate DIRENTSPERBLOCK() macroHeinrich Schuchardt2-4/+2
The FAT filesystem implementation uses several marcros referring to a magic variable name mydata which renders the code less readable. Eliminate one of them which is only used for a debug() statement. Use log_debug() instead of debug(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-31efi_loader: Extra checks while opening an OPTEE sessionIlias Apalodimas1-5/+15
When opening an OP-TEE session we need to check the internal return value of OP-TEE call arguments as well the return code of the function itself. The code was also ignoring to close the OP-TEE session in case the shared memory registration failed. Fixes: f042e47e8fb43 ("efi_loader: Implement EFI variable handling via OP-TEE") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-31efi_loader: make variable store size customizableHeinrich Schuchardt2-1/+15
Currently the size of the buffer to keep UEFI variables in memory is fixed at 16384 bytes. This size has proven to be too small for some use cases. Make the size of the memory buffer for UEFI variables customizable. Reported-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2020-12-23Merge tag 'dm-next-23dec20' of git://git.denx.de/u-boot-dm into nextWIP/23Dec2020-nextTom Rini162-680/+964
dm: New sequence number implementation SPI handling of bus with different-speed devices patman supression of sign-offs
2020-12-22dm: core: Inline a few ofnode functions in SPLSimon Glass3-11/+63
A recent change to unify the flattree/livetree code introduced a small size increase in SPL on some boards. For example SPL code size for px30-core-ctouch2-px30 increased by 40 bytes. To address this we can take advantage of the fact that some of the ofnode functions are only called a few times in SPL, so it is worth inlining them. Add new Kconfig options to control this. These functions are not inlined for U-Boot proper, since this increases code size. Fixes: 2ebea5eaebf ("dm: core: Combine the flattree and livetree binding code") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-22buildman: Remove output binaries before buildingSimon Glass1-1/+13
Buildman reuses build directories from previous builds to avoid the cost of 'make mrproper' for every build. If the previous build produced an SPL image but the current one does not, the SPL image will remain and buildman will think it is a result of building the current board. Remove these files before building, to avoid this problem. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-22dm: spi: Fix spi_free_slave() freed memory writeNiel Fourie1-1/+0
Remove setting slave->dev to NULL after the device_remove() call. The slave pointer points to dev->parent_priv, which has already been freed by device_free(), called from device_remove() in the preceding line. Writing to slave->dev may cause corruption of the dlmalloc free chunk forward pointer of the previously freed chunk. Signed-off-by: Niel Fourie <lusus@denx.de> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-22test: dm: spi: Add testcase for spi_claim_bus()Ovidiu Panait1-0/+82
Add testcase for spi_claim_bus(), which checks that sandbox spi bus speed/mode settings are updated correctly when multiple slaves use the bus consecutively. The following configurations are used for the two spi slaves involved: * different max_hz / different modes * different max_hz / same modes * different modes / same max_hz asm/test.h header is added in order to be able to retrieve the current speed/mode of the sandbox spi bus, via sandbox_spi_get_{speed, mode}. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-22spi: spi-uclass: Fix spi_claim_bus() speed/mode setup logicOvidiu Panait3-10/+26
Currently, when different spi slaves claim the bus consecutively using spi_claim_bus(), spi_set_speed_mode() will only be executed on the first two calls, leaving the bus in a bad state starting with the third call. This patch drops spi_slave->speed member and adds caching of bus speed/mode in dm_spi_bus struct. It also updates spi_claim_bus() to call spi_set_speed_mode() if either speed or mode is different from what the bus is currently configured for. Current behavior is to only take into account the speed, but not the mode, which seems wrong. Fixes: 60e2809a848 ("dm: spi: Avoid setting the speed with every transfer") Reviewed-by: Simon Glass <sjg@chromium.org> Reported-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Reported-by: Moshe, Yaniv <yanivmo@amazon.com> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>