X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=include%2Fblk.h;h=86f6d5057f23e7155a6ead3248d426baef94d171;hb=b8babd8050f6780bb67e90d9402f9f19e0d63045;hp=8672e32fe1dfd7c9aface8d5ccb35d91a8cd4d5b;hpb=6faa4ed74df2d83cbb959ba799032da4249893b6;p=oweals%2Fu-boot.git diff --git a/include/blk.h b/include/blk.h index 8672e32fe1..86f6d5057f 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,12 +31,27 @@ enum if_type { IF_TYPE_SD, IF_TYPE_SATA, IF_TYPE_HOST, - IF_TYPE_SYSTEMACE, IF_TYPE_NVME, + IF_TYPE_EFI, IF_TYPE_COUNT, /* Number of interface types */ }; +#define BLK_VEN_SIZE 40 +#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) @@ -60,9 +76,14 @@ struct blk_desc { lbaint_t lba; /* number of blocks */ unsigned long blksz; /* block size */ int log2blksz; /* for convenience: log2(blksz) */ - char vendor[40+1]; /* IDE model, SCSI Vendor */ - char product[20+1]; /* IDE Serial no, SCSI product */ - char revision[8+1]; /* firmware revision */ + 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 @@ -90,7 +111,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 * @@ -311,12 +332,12 @@ int blk_next_device(struct udevice **devp); * @devnum: Device number, specific to the interface type, or -1 to * allocate the next available number * @blksz: Block size of the device in bytes (typically 512) - * @size: Total size of the device in bytes + * @lba: Total number of blocks of the device * @devp: the new device (which has not been probed) */ int blk_create_device(struct udevice *parent, const char *drv_name, const char *name, int if_type, int devnum, int blksz, - lbaint_t size, struct udevice **devp); + lbaint_t lba, struct udevice **devp); /** * blk_create_devicef() - Create a new named block device @@ -328,12 +349,12 @@ int blk_create_device(struct udevice *parent, const char *drv_name, * @devnum: Device number, specific to the interface type, or -1 to * allocate the next available number * @blksz: Block size of the device in bytes (typically 512) - * @size: Total size of the device in bytes + * @lba: Total number of blocks of the device * @devp: the new device (which has not been probed) */ int blk_create_devicef(struct udevice *parent, const char *drv_name, const char *name, int if_type, int devnum, int blksz, - lbaint_t size, struct udevice **devp); + lbaint_t lba, struct udevice **devp); /** * blk_prepare_device() - Prepare a block device for use @@ -632,4 +653,16 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart); */ const char *blk_get_if_type_name(enum if_type if_type); +/** + * blk_common_cmd() - handle common commands with block devices + * + * @args: Number of arguments to the command (argv[0] is the command itself) + * @argv: Command arguments + * @if_type: Interface type + * @cur_devnump: Current device number for this interface type + * @return 0 if OK, CMD_RET_ERROR on error + */ +int blk_common_cmd(int argc, char * const argv[], enum if_type if_type, + int *cur_devnump); + #endif