Simon Glass | 1a73661 | 2016-02-29 15:25:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2004 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #ifndef BLK_H |
| 9 | #define BLK_H |
| 10 | |
| 11 | #ifdef CONFIG_SYS_64BIT_LBA |
| 12 | typedef uint64_t lbaint_t; |
| 13 | #define LBAFlength "ll" |
| 14 | #else |
| 15 | typedef ulong lbaint_t; |
| 16 | #define LBAFlength "l" |
| 17 | #endif |
| 18 | #define LBAF "%" LBAFlength "x" |
| 19 | #define LBAFU "%" LBAFlength "u" |
| 20 | |
| 21 | /* Interface types: */ |
Simon Glass | 5ec4f1a | 2016-02-29 15:25:40 -0700 | [diff] [blame^] | 22 | enum if_type { |
| 23 | IF_TYPE_UNKNOWN = 0, |
| 24 | IF_TYPE_IDE, |
| 25 | IF_TYPE_SCSI, |
| 26 | IF_TYPE_ATAPI, |
| 27 | IF_TYPE_USB, |
| 28 | IF_TYPE_DOC, |
| 29 | IF_TYPE_MMC, |
| 30 | IF_TYPE_SD, |
| 31 | IF_TYPE_SATA, |
| 32 | IF_TYPE_HOST, |
| 33 | |
| 34 | IF_TYPE_COUNT, /* Number of interface types */ |
| 35 | }; |
Simon Glass | 1a73661 | 2016-02-29 15:25:39 -0700 | [diff] [blame] | 36 | |
| 37 | struct blk_desc { |
Simon Glass | 5ec4f1a | 2016-02-29 15:25:40 -0700 | [diff] [blame^] | 38 | enum if_type if_type; /* type of the interface */ |
Simon Glass | 1a73661 | 2016-02-29 15:25:39 -0700 | [diff] [blame] | 39 | int dev; /* device number */ |
| 40 | unsigned char part_type; /* partition type */ |
| 41 | unsigned char target; /* target SCSI ID */ |
| 42 | unsigned char lun; /* target LUN */ |
| 43 | unsigned char hwpart; /* HW partition, e.g. for eMMC */ |
| 44 | unsigned char type; /* device type */ |
| 45 | unsigned char removable; /* removable device */ |
| 46 | #ifdef CONFIG_LBA48 |
| 47 | /* device can use 48bit addr (ATA/ATAPI v7) */ |
| 48 | unsigned char lba48; |
| 49 | #endif |
| 50 | lbaint_t lba; /* number of blocks */ |
| 51 | unsigned long blksz; /* block size */ |
| 52 | int log2blksz; /* for convenience: log2(blksz) */ |
| 53 | char vendor[40+1]; /* IDE model, SCSI Vendor */ |
| 54 | char product[20+1]; /* IDE Serial no, SCSI product */ |
| 55 | char revision[8+1]; /* firmware revision */ |
| 56 | unsigned long (*block_read)(struct blk_desc *block_dev, |
| 57 | lbaint_t start, |
| 58 | lbaint_t blkcnt, |
| 59 | void *buffer); |
| 60 | unsigned long (*block_write)(struct blk_desc *block_dev, |
| 61 | lbaint_t start, |
| 62 | lbaint_t blkcnt, |
| 63 | const void *buffer); |
| 64 | unsigned long (*block_erase)(struct blk_desc *block_dev, |
| 65 | lbaint_t start, |
| 66 | lbaint_t blkcnt); |
| 67 | void *priv; /* driver private struct pointer */ |
| 68 | }; |
| 69 | |
| 70 | #define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz)) |
| 71 | #define PAD_TO_BLOCKSIZE(size, blk_desc) \ |
| 72 | (PAD_SIZE(size, blk_desc->blksz)) |
| 73 | |
| 74 | #endif |