aboutsummaryrefslogtreecommitdiff
path: root/include/blk.h
AgeCommit message (Collapse)AuthorFilesLines
2023-10-24rockchip: block: blk-uclass: add bounce buffer flag to blk_descJohan Jonker1-0/+1
Currently bounce buffer support is enabled for all block devices when available. Add a flag to blk_desc to enable only on demand. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-10-10dm: blk: Drop blk_{read,write}_devnum()Bin Meng1-26/+0
blk_{read,write}_devnum() are no longer used by anywhere in the source tree. Drop them. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-10dm: blk: Rename get_desc() and make it externally visibleBin Meng1-0/+12
get_desc() can be useful outside blk-uclass.c. Let's change it to an API and make it externally visible. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-10blk: Use a macro for the typical block sizeBin Meng1-0/+2
Avoid using the magic number 512 directly. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-09-14blkcache: Remove unused NEEDS_MANUAL_RELOC code bitsMarek Vasut1-6/+0
The last user of the NEEDS_MANUAL_RELOC has been removed in commit 26af162ac8f8 ("arch: m68k: Implement relocation") Remove now unused NEEDS_MANUAL_RELOC code. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22blk: Add bounce buffer support to read/write operationsMarek Vasut1-0/+19
Some devices have limited DMA capabilities and require that the buffers passed to them fit specific properties. Add new optional callback which can be used at driver level to indicate whether a buffer alignment is suitable for the device DMA or not, and trigger use of generic bounce buffer implementation to help use of unsuitable buffers at the expense of performance degradation. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-08-22disk: Make blk_get_ops() internal to blk uclassMarek Vasut1-2/+0
Move the macro into blk-uclass.c , since it is only used there. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-27ide: Avoid preprocessor for CONFIG_LBA48Simon Glass1-3/+1
Use IS_ENABLED() instead for all conditions. Add the 'lba48' flag into struct blk_desc always, since it uses very little space. Use a bool so the meaning is clearer. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-27ide: Correct use of ATAPISimon Glass1-0/+1
The use of atapi_read() was incorrect dropped. Fix this so that it will be used when needed. Use a udevice for the first argument of atapi_read() so it is consistent with ide_read(). This requires much of the ATAPI code to be brought out from behind the existing #ifdef. It will still be removed by the compiler if it is not needed. Add an atapi flag to struct blk_desc so the information can be retained. Fixes: 145df842b44 ("dm: ide: Add support for driver-model block devices") Fixes: d0075059e4d ("ide: Drop non-DM code for BLK") Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: blk: Tidy up obtaining a block device from its parentSimon Glass1-1/+27
This function now finds its block-device child by looking for a child device of the correct uclass (UCLASS_BLK). It cannot produce a device of any other type, so drop the superfluous check. Provide a version which does not probe the device, since that is often needed when setting up the device's platdata. Also fix up the function's comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-07dm: test: Clear the block cache after running a testSimon Glass1-2/+7
Some tests access data in block devices and so cause the cache to fill up. This results in memory being allocated. Some tests check the malloc usage at the beginning and then again at the end, to ensure there is no memory leak caused by the test. The block cache makes this difficult, since the any test may cause entries to be allocated or even freed, if the cache becomes full. It is simpler to clear the block cache after each test. This ensures that it will not introduce noise in tests which check malloc usage. Add the logic to clear the cache, using the existing blkcache_invalidate() function. Drop the duplicate code at the same time. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31dm: blk: Add udevice functionsSimon Glass1-1/+38
At present we have functions called blk_dread(), etc., which take a struct blk_desc * to refer to the block device. Add some functions which use udevice instead, since this is more in keeping with how driver model is supposed to work. Update one of the tests to use this. Note that it would be nice to update the functions in disk-uclass.c to use these new functions. However they are not quite the same. For example, disk_blk_read() adds the partition offset to 'start' when calling the cache read/fill functions, but does not with part_blk_read(), which does the addition itself. So as designed the code is duplicated. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-21blk: fix a couple of trivial documentation typosMattijs Korpershoek1-3/+5
In some cases, the param variable is wrong, and in other cases we have undocumented arguments. Fix the docs. Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-25blk: Rename if_type to uclass_idSimon Glass1-61/+61
Use the word 'uclass' instead of 'if_type' to complete the conversion. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop if_typeWIP/2022-09-16-rationalize-the-block-interfaceSimon Glass1-22/+19
Use the uclass ID instead. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-09-16blk: Switch over to using uclass IDsSimon Glass1-16/+2
We currently have an if_type (interface type) and a uclass id. These are closely related and we don't need to have both. Drop the if_type values and use the uclass ones instead. Maintain the existing, subtle, one-way conversion between UCLASS_USB and UCLASS_MASS_STORAGE for now, and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_SDSimon Glass1-1/+0
This is not really needed since it does the same things as MMC. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_ATAPISimon Glass1-1/+0
This is not really needed since it does the same things as IDE. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_DOCSimon Glass1-1/+0
This doesn't seem to be used for anything and it isn't clear what it is. It dates from the first U-Boot commit. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Rename HAVE_BLOCK_DEVICESimon Glass1-1/+1
This option is fact really related to SPL. For U-Boot proper we always use driver model for block devices, so CONFIG_BLK is enabled if block devices are in use. It is only for SPL that we have two cases: - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c - SPL_BLK is not enabled, in which case (if we need block devices) we must use blk_legacy.c Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is different enough from BLK and SPL_BLK that there should be no confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Use a function for whether block devices are availableSimon Glass1-0/+5
At present we use HAVE_BLOCK_DEVICE to indicate when block devices are available. This is a very strange option, since it partially duplicates the BLK option used by driver model. It also covers both U-Boot proper and SPL, even though one might have block devices and another not. As a first step towards correcting this, create a new inline function called blk_enabled() which indicates if block devices are available. This cannot be used in Makefiles, or #if clauses, but can be used in C code. A function is useful because we cannot use CONFIG_IS_ENABLED(BLK) to decide if block devices are needed, since we must consider the legacy block interface, enabled by HAVE_BLOCK_DEVICE Update a few places where it can be used and drop some unnecessary #if checks around some functions in disk/part.c - rely on the compiler's dead-code elimination instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-04-25dm: blk: Add a function to return the device typeSimon Glass1-0/+8
Use the uclass name to get the device type for a block device. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-04-06dm: blk: Expand iteration and add testsWIP/2022-04-06-various-verified-boot-bugfixesSimon Glass1-0/+45
Add some functions which support iteration before probing. Also add tests for the functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-19doc: replace @return by Return:Heinrich Schuchardt1-24/+24
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-12-18blk: add a helper function, blk_probe_or_unbind()AKASHI Takahiro1-0/+12
This function will be commonly used in block device drivers in the succeeding patches. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-12-09efi: Add uclass for devices provided by UEFI firmwareSimon Glass1-0/+1
UCLASS_EFI_LOADER is used for devices created by applications and drivers loaded by U-Boots UEFI implementation. This patch provides a new uclass (UCLASS_EFI_MEDIA) to be used for devices that provided by a UEFI firmware calling U-Boot as an EFI application. If the two uclasses can be unified, is left to future redesign. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-12-09efi: Rename UCLASS_EFI and IF_TYPE_EFISimon Glass1-1/+1
These names are better used for access to devices provided by an EFI layer. Use EFI_LOADER instead here, since these are only available in U-Boot's EFI_LOADER layer. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-10-26efi_loader: add UEFI GPT measurementMasahisa Kojima1-0/+3
This commit adds the UEFI GPT disk partition topology measurement required in TCG PC Client Platform Firmware Profile Specification Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-07-21blk: Support iterationSimon Glass1-0/+56
It is useful to be able to iterate over block devices. Typically there are fixed and removable devices. For security reasons it is sometimes useful to ignore removable devices since they are under user control. Add iterators which support selecting the block-device type. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass1-1/+1
We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-14xen: pvblock: Add initial support for para-virtualized block driverAnastasiia Lukianenko1-0/+1
Add initial infrastructure for Xen para-virtualized block device. This includes compile-time configuration and the skeleton for the future driver implementation. Add new class UCLASS_PVBLOCK which is going to be a parent for virtual block devices. Add new interface type IF_TYPE_PVBLOCK. Implement basic driver setup by reading XenStore configuration. Signed-off-by: Andrii Anisov <andrii_anisov@epam.com> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
2020-05-18command: Remove the cmd_tbl_t typedefSimon Glass1-1/+1
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-25common: blk: fix comment about blkcache_read return valueEric Nelson1-1/+1
The blkcache_read() routine returns 1 (true) to indicate that a block was found in the cache and returned, or 0 if not. Signed-off-by: Eric Nelson <eric@nelint.com>
2020-01-25common: add blkcache initAngelo Durgehello1-0/+6
On m68k, block_cache list is relocated, but next and prev list pointers are not adjusted to the relocated struct list_head address, so the first iteration over the block_cache list hangs. This patch initializes the block_cache list after relocation. Signed-off-by: Angelo Durgehello <angelo.dureghello@timesys.com> Reviewed-by: Eric Nelson <eric@nelint.com>
2018-11-14blk: Introduce IF_TYPE_VIRTIOTuomas Tynkkynen1-0/+1
This adds a new block interface type for VirtIO block devices. Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-14blk: Make blk_next_free_devnum() publicBin Meng1-0/+11
blk_next_free_devnum() can be helpful in some cases. Make it a public API. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-14blk: Drop blk_prepare_device()Bin Meng1-10/+0
With the post_probe() changes, this API is no longer needed. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-28block: Add a function to find block device descriptorTien Fong Chee1-0/+9
Add a function to find the block device descriptor of the parent device. Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com> [trini: Move function declaration to avoid warning] Signed-off-by: Tom Rini <trini@konsulko.com>
2018-06-18block: Add SPL_BLOCK_CACHE and default nAdam Ford1-1/+1
When enabling BLOCK_CACHE on devices with limited RAM during SPL, some devices may not boot. This creates an option to enable block caching in SPL by defaults off. It is dependent on SPL_BLK Fixes: 46960ad6d09b ("block: Have BLOCK_CACHE default to y in some cases") Signed-off-by: Adam Ford <aford173@gmail.com>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-02-13SystemACE: RemoveTom Rini1-1/+0
This driver is no longer used on any supported platform in U-Boot and there is no interest in maintaining it further from people that have used it historically. Cc: Simon Glass <sjg@chromium.org> Cc: Michal Simek <michal.simek@xilinx.com> c: Alexey Brodkin <alexey.brodkin@gmail.com> Signed-off-by: Tom Rini <trini@konsulko.com> Acked-by: Michal Simek <michal.simek@xilinx.com>
2018-01-22efi_driver: EFI block driverHeinrich Schuchardt1-0/+1
This patch provides * a uclass for EFI drivers * a EFI driver for block devices For each EFI driver the uclass * creates a handle * adds the driver binding protocol The uclass provides the bind, start, and stop entry points for the driver binding protocol. In bind() and stop() it checks if the controller implements the protocol supported by the EFI driver. In the start() function it calls the bind() function of the EFI driver. In the stop() function it destroys the child controllers. The EFI block driver binds to controllers implementing the block io protocol. When the bind function of the EFI block driver is called it creates a new U-Boot block device. It installs child handles for all partitions and installs the simple file protocol on these. The read and write functions of the EFI block driver delegate calls to the controller that it is bound to. A usage example is as following: U-Boot loads the iPXE snp.efi executable. iPXE connects an iSCSI drive and exposes a handle with the block IO protocol. It calls ConnectController. Now the EFI block driver installs the partitions with the simple file protocol. iPXE uses the simple file protocol to load Grub or the Linux Kernel. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: add comment on calloc len] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20part: extract MBR signature from partitionsPeter Jones1-0/+18
EFI client programs need the signature information from the partition table to determine the disk a partition is on, so we need to fill that in here. Signed-off-by: Peter Jones <pjones@redhat.com> [separated from efi_loader part, and fixed build-errors for non- CONFIG_EFI_PARTITION case] Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-11blk: dm: make blk_create_device() take a number of block instead of a sizeJean-Jacques Hiblot1-4/+4
There is an overflow problem when taking the size instead of the number of blocks in blk_create_device(). This results in a wrong device size: the device apparent size is its real size modulo 4GB. Using the number of blocks instead of the device size fixes the problem and is more coherent with the internals of the block layer. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-10blk: Use macros for block device vendor/product/rev string sizeBin Meng1-3/+7
So far these are using magic numbers. Replace them with macros. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-08-17dm: blk: Add a generic function for block device commandsSimon Glass1-0/+12
Most block devices provide a command (e.g. 'sata', 'scsi', 'ide') and these commands generally do the same thing. This makes it harder to maintain this code and keep it consistent. We now have a block device interface which is either implemented by driver model (when CONFIG_BLK is enabled) or with a legacy interface. Therefore it is possible to handle most of what these commands do with generic code. Add a new generic function to process block-device commands using the interface type and the current device number for that type. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-17dm: blk: Add a function to find an interface-type nameSimon Glass1-0/+8
Add a function to find the name of an interface type (e.g. "sata", "scsi") from the interface type enum. This is useful for generic code (not specific to SATA or SCSI, for example) that wants to display the type of interface it is dealing with. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-13dm: blk: part: Add UCLASS_NVME and IF_TYPE_NVMEZhikang Zhang1-0/+1
This adds a new uclass id and block interface type for NVMe. Signed-off-by: Zhikang Zhang <zhikang.zhang@nxp.com> Signed-off-by: Wenbin Song <wenbin.song@nxp.com> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Jon Nettleton <jon@solid-run.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-01dm: mmc: Allow disabling driver model in SPLSimon Glass1-2/+2
At present if U-Boot proper uses driver model for MMC, then SPL has to also. While this is desirable, it places a significant barrier to moving to driver model in some cases. For example, with a space-constrained SPL it may be necessary to enable CONFIG_SPL_OF_PLATDATA which involves adjusting some drivers. Add new SPL versions of the options for DM_MMC, DM_MMC_OPS and BLK. By default these follow their non-SPL versions, but this can be changed by boards which need it. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-10dm: blk: Fix warning on !CONFIG_BLKTom Rini1-7/+7
When we don't have CONFIG_BLK defined we don't have a forward declaration of struct udevice, and thus get a warning about it on blk_get_from_parent(), which we only have when CONFIG_BLK is set. Move the declaration of blk_get_from_parent() to be with the other CONFIG_BLK parts. Fixes 9f103b9cb5f8 ("dm: blk: Add a way to obtain a block device from ...") Signed-off-by: Tom Rini <trini@konsulko.com>