X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=include%2Fblk.h;h=d0c033aece0fb7986a614cef5a9176dc6bca2f44;hb=94a16b8e70ba8102d8abb0c9bc64b11e19d4bd55;hp=1965812a9d5a39f0148ce133a895a69b4058d07b;hpb=1c7b5d0309c1da3952b1236d42c82c5ea8446476;p=oweals%2Fu-boot.git diff --git a/include/blk.h b/include/blk.h index 1965812a9d..d0c033aece 100644 --- a/include/blk.h +++ b/include/blk.h @@ -1,13 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * (C) Copyright 2000-2004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef BLK_H #define BLK_H +#include + #ifdef CONFIG_SYS_64BIT_LBA typedef uint64_t lbaint_t; #define LBAFlength "ll" @@ -30,8 +31,9 @@ enum if_type { IF_TYPE_SD, IF_TYPE_SATA, IF_TYPE_HOST, - IF_TYPE_SYSTEMACE, IF_TYPE_NVME, + IF_TYPE_EFI, + IF_TYPE_VIRTIO, IF_TYPE_COUNT, /* Number of interface types */ }; @@ -40,6 +42,17 @@ enum if_type { #define BLK_PRD_SIZE 20 #define BLK_REV_SIZE 8 +/* + * Identifies the partition table type (ie. MBR vs GPT GUID) signature + */ +enum sig_type { + SIG_TYPE_NONE, + SIG_TYPE_MBR, + SIG_TYPE_GUID, + + SIG_TYPE_COUNT /* Number of signature types */ +}; + /* * With driver model (CONFIG_BLK) this is uclass platform data, accessible * with dev_get_uclass_platdata(dev) @@ -67,6 +80,11 @@ struct blk_desc { char vendor[BLK_VEN_SIZE + 1]; /* device vendor string */ char product[BLK_PRD_SIZE + 1]; /* device product number */ char revision[BLK_REV_SIZE + 1]; /* firmware revision */ + enum sig_type sig_type; /* Partition table signature type */ + union { + uint32_t mbr_sig; /* MBR integer signature */ + efi_guid_t guid_sig; /* GPT GUID Signature */ + }; #if CONFIG_IS_ENABLED(BLK) /* * For now we have a few functions which take struct blk_desc as a @@ -94,7 +112,7 @@ struct blk_desc { #define PAD_TO_BLOCKSIZE(size, blk_desc) \ (PAD_SIZE(size, blk_desc->blksz)) -#ifdef CONFIG_BLOCK_CACHE +#if CONFIG_IS_ENABLED(BLOCK_CACHE) /** * blkcache_read() - attempt to read a set of blocks from cache * @@ -339,16 +357,6 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name, const char *name, int if_type, int devnum, int blksz, lbaint_t lba, struct udevice **devp); -/** - * blk_prepare_device() - Prepare a block device for use - * - * This reads partition information from the device if supported. - * - * @dev: Device to prepare - * @return 0 if ok, -ve on error - */ -int blk_prepare_device(struct udevice *dev); - /** * blk_unbind_all() - Unbind all device of the given interface type * @@ -371,6 +379,17 @@ int blk_unbind_all(int if_type); */ int blk_find_max_devnum(enum if_type if_type); +/** + * blk_next_free_devnum() - get the next device number for an interface type + * + * Finds the next number that is safe to use for a newly allocated device for + * an interface type @if_type. + * + * @if_type: Interface type to scan + * @return next device number safe to use, or -ve on error + */ +int blk_next_free_devnum(enum if_type if_type); + /** * blk_select_hwpart() - select a hardware partition * @@ -389,6 +408,15 @@ int blk_select_hwpart(struct udevice *dev, int hwpart); */ int blk_get_from_parent(struct udevice *parent, struct udevice **devp); +/** + * blk_get_by_device() - Get the block device descriptor for the given device + * @dev: Instance of a storage device + * + * Return: With block device descriptor on success , NULL if there is no such + * block device. + */ +struct blk_desc *blk_get_by_device(struct udevice *dev); + #else #include /*