coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
storage.h File Reference
Include dependency graph for storage.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  storage_media
 

Macros

#define EXT_CSD_GP_SIZE_MULT_GP0   143 /* RO */
 
#define EXT_CSD_GP_SIZE_MULT_GP1   146 /* RO */
 
#define EXT_CSD_GP_SIZE_MULT_GP2   149 /* RO */
 
#define EXT_CSD_GP_SIZE_MULT_GP3   152 /* RO */
 
#define EXT_CSD_PARTITIONING_SUPPORT   160 /* RO */
 
#define EXT_CSD_RPMB_SIZE_MULT   168 /* RO */
 
#define EXT_CSD_ERASE_GROUP_DEF   175 /* R/W */
 
#define EXT_CSD_PART_CONF   179 /* R/W */
 
#define EXT_CSD_BUS_WIDTH   183 /* R/W */
 
#define EXT_CSD_STROBE_SUPPORT   184 /* RO */
 
#define EXT_CSD_HS_TIMING   185 /* R/W */
 
#define EXT_CSD_REV   192 /* RO */
 
#define EXT_CSD_CARD_TYPE   196 /* RO */
 
#define EXT_CSD_SEC_CNT   212 /* RO, 4 bytes */
 
#define EXT_CSD_HC_WP_GRP_SIZE   221 /* RO */
 
#define EXT_CSD_HC_ERASE_GRP_SIZE   224 /* RO */
 
#define EXT_CSD_BOOT_SIZE_MULT   226 /* RO */
 
#define EXT_CSD_TRIM_MULT   232 /* RO */
 
#define EXT_CSD_CMD_SET_NORMAL   (1 << 0)
 
#define EXT_CSD_CMD_SET_SECURE   (1 << 1)
 
#define EXT_CSD_CMD_SET_CPSECURE   (1 << 2)
 
#define EXT_CSD_CARD_TYPE_26   (1 << 0) /* Card can run at 26MHz */
 
#define EXT_CSD_CARD_TYPE_52   (1 << 1) /* Card can run at 52MHz */
 
#define EXT_CSD_BUS_WIDTH_1   0 /* Card is in 1 bit mode */
 
#define EXT_CSD_BUS_WIDTH_4   1 /* Card is in 4 bit mode */
 
#define EXT_CSD_BUS_WIDTH_8   2 /* Card is in 8 bit mode */
 
#define EXT_CSD_DDR_BUS_WIDTH_4   5 /* Card is in 4 bit DDR mode */
 
#define EXT_CSD_DDR_BUS_WIDTH_8   6 /* Card is in 8 bit DDR mode */
 
#define EXT_CSD_BUS_WIDTH_STROBE   (1<<7) /* Enhanced strobe mode */
 
#define EXT_CSD_TIMING_BC   0 /* Backwards compatibility */
 
#define EXT_CSD_TIMING_HS   1 /* High speed */
 
#define EXT_CSD_TIMING_HS200   2 /* HS200 */
 
#define EXT_CSD_TIMING_HS400   3 /* HS400 */
 
#define EXT_CSD_SIZE   512
 
#define EXT_CSD_PART_ACCESS_MASK   7 /* Partition access mask */
 
#define EXT_CSD_PARTITION_ENABLE   1 /* Enable partition access */
 
#define MMC_PARTITION_USER   0
 
#define MMC_PARTITION_BOOT_1   1
 
#define MMC_PARTITION_BOOT_2   2
 
#define MMC_PARTITION_RPMB   3
 
#define MMC_PARTITION_GP1   4
 
#define MMC_PARTITION_GP2   5
 
#define MMC_PARTITION_GP3   6
 
#define MMC_PARTITION_GP4   7
 
#define SD_VERSION_SD   0x20000
 
#define SD_VERSION_2   (SD_VERSION_SD | 0x20)
 
#define SD_VERSION_1_0   (SD_VERSION_SD | 0x10)
 
#define SD_VERSION_1_10   (SD_VERSION_SD | 0x1a)
 
#define MMC_VERSION_MMC   0x10000
 
#define MMC_VERSION_UNKNOWN   (MMC_VERSION_MMC)
 
#define MMC_VERSION_1_2   (MMC_VERSION_MMC | 0x12)
 
#define MMC_VERSION_1_4   (MMC_VERSION_MMC | 0x14)
 
#define MMC_VERSION_2_2   (MMC_VERSION_MMC | 0x22)
 
#define MMC_VERSION_3   (MMC_VERSION_MMC | 0x30)
 
#define MMC_VERSION_4   (MMC_VERSION_MMC | 0x40)
 
#define OCR_BUSY   0x80000000
 
#define OCR_HCS   0x40000000
 
#define OCR_VOLTAGE_MASK   0x00FFFF80
 
#define OCR_ACCESS_MODE   0x60000000
 

Functions

uint64_t storage_block_erase (struct storage_media *media, uint64_t start, uint64_t count)
 
uint64_t storage_block_fill_write (struct storage_media *media, uint64_t start, uint64_t count, uint32_t fill_pattern)
 
uint64_t storage_block_read (struct storage_media *media, uint64_t start, uint64_t count, void *buffer)
 
uint64_t storage_block_write (struct storage_media *media, uint64_t start, uint64_t count, const void *buffer)
 
unsigned int storage_get_current_partition (struct storage_media *media)
 
const char * storage_partition_name (struct storage_media *media, unsigned int partition_number)
 
int storage_setup_media (struct storage_media *media, struct sd_mmc_ctrlr *ctrlr)
 
int storage_set_partition (struct storage_media *media, unsigned int partition_number)
 
void storage_display_setup (struct storage_media *media)
 

Macro Definition Documentation

◆ EXT_CSD_BOOT_SIZE_MULT

#define EXT_CSD_BOOT_SIZE_MULT   226 /* RO */

Definition at line 27 of file storage.h.

◆ EXT_CSD_BUS_WIDTH

#define EXT_CSD_BUS_WIDTH   183 /* R/W */

Definition at line 19 of file storage.h.

◆ EXT_CSD_BUS_WIDTH_1

#define EXT_CSD_BUS_WIDTH_1   0 /* Card is in 1 bit mode */

Definition at line 41 of file storage.h.

◆ EXT_CSD_BUS_WIDTH_4

#define EXT_CSD_BUS_WIDTH_4   1 /* Card is in 4 bit mode */

Definition at line 42 of file storage.h.

◆ EXT_CSD_BUS_WIDTH_8

#define EXT_CSD_BUS_WIDTH_8   2 /* Card is in 8 bit mode */

Definition at line 43 of file storage.h.

◆ EXT_CSD_BUS_WIDTH_STROBE

#define EXT_CSD_BUS_WIDTH_STROBE   (1<<7) /* Enhanced strobe mode */

Definition at line 46 of file storage.h.

◆ EXT_CSD_CARD_TYPE

#define EXT_CSD_CARD_TYPE   196 /* RO */

Definition at line 23 of file storage.h.

◆ EXT_CSD_CARD_TYPE_26

#define EXT_CSD_CARD_TYPE_26   (1 << 0) /* Card can run at 26MHz */

Definition at line 38 of file storage.h.

◆ EXT_CSD_CARD_TYPE_52

#define EXT_CSD_CARD_TYPE_52   (1 << 1) /* Card can run at 52MHz */

Definition at line 39 of file storage.h.

◆ EXT_CSD_CMD_SET_CPSECURE

#define EXT_CSD_CMD_SET_CPSECURE   (1 << 2)

Definition at line 36 of file storage.h.

◆ EXT_CSD_CMD_SET_NORMAL

#define EXT_CSD_CMD_SET_NORMAL   (1 << 0)

Definition at line 34 of file storage.h.

◆ EXT_CSD_CMD_SET_SECURE

#define EXT_CSD_CMD_SET_SECURE   (1 << 1)

Definition at line 35 of file storage.h.

◆ EXT_CSD_DDR_BUS_WIDTH_4

#define EXT_CSD_DDR_BUS_WIDTH_4   5 /* Card is in 4 bit DDR mode */

Definition at line 44 of file storage.h.

◆ EXT_CSD_DDR_BUS_WIDTH_8

#define EXT_CSD_DDR_BUS_WIDTH_8   6 /* Card is in 8 bit DDR mode */

Definition at line 45 of file storage.h.

◆ EXT_CSD_ERASE_GROUP_DEF

#define EXT_CSD_ERASE_GROUP_DEF   175 /* R/W */

Definition at line 17 of file storage.h.

◆ EXT_CSD_GP_SIZE_MULT_GP0

#define EXT_CSD_GP_SIZE_MULT_GP0   143 /* RO */

Definition at line 11 of file storage.h.

◆ EXT_CSD_GP_SIZE_MULT_GP1

#define EXT_CSD_GP_SIZE_MULT_GP1   146 /* RO */

Definition at line 12 of file storage.h.

◆ EXT_CSD_GP_SIZE_MULT_GP2

#define EXT_CSD_GP_SIZE_MULT_GP2   149 /* RO */

Definition at line 13 of file storage.h.

◆ EXT_CSD_GP_SIZE_MULT_GP3

#define EXT_CSD_GP_SIZE_MULT_GP3   152 /* RO */

Definition at line 14 of file storage.h.

◆ EXT_CSD_HC_ERASE_GRP_SIZE

#define EXT_CSD_HC_ERASE_GRP_SIZE   224 /* RO */

Definition at line 26 of file storage.h.

◆ EXT_CSD_HC_WP_GRP_SIZE

#define EXT_CSD_HC_WP_GRP_SIZE   221 /* RO */

Definition at line 25 of file storage.h.

◆ EXT_CSD_HS_TIMING

#define EXT_CSD_HS_TIMING   185 /* R/W */

Definition at line 21 of file storage.h.

◆ EXT_CSD_PART_ACCESS_MASK

#define EXT_CSD_PART_ACCESS_MASK   7 /* Partition access mask */

Definition at line 56 of file storage.h.

◆ EXT_CSD_PART_CONF

#define EXT_CSD_PART_CONF   179 /* R/W */

Definition at line 18 of file storage.h.

◆ EXT_CSD_PARTITION_ENABLE

#define EXT_CSD_PARTITION_ENABLE   1 /* Enable partition access */

Definition at line 59 of file storage.h.

◆ EXT_CSD_PARTITIONING_SUPPORT

#define EXT_CSD_PARTITIONING_SUPPORT   160 /* RO */

Definition at line 15 of file storage.h.

◆ EXT_CSD_REV

#define EXT_CSD_REV   192 /* RO */

Definition at line 22 of file storage.h.

◆ EXT_CSD_RPMB_SIZE_MULT

#define EXT_CSD_RPMB_SIZE_MULT   168 /* RO */

Definition at line 16 of file storage.h.

◆ EXT_CSD_SEC_CNT

#define EXT_CSD_SEC_CNT   212 /* RO, 4 bytes */

Definition at line 24 of file storage.h.

◆ EXT_CSD_SIZE

#define EXT_CSD_SIZE   512

Definition at line 53 of file storage.h.

◆ EXT_CSD_STROBE_SUPPORT

#define EXT_CSD_STROBE_SUPPORT   184 /* RO */

Definition at line 20 of file storage.h.

◆ EXT_CSD_TIMING_BC

#define EXT_CSD_TIMING_BC   0 /* Backwards compatibility */

Definition at line 48 of file storage.h.

◆ EXT_CSD_TIMING_HS

#define EXT_CSD_TIMING_HS   1 /* High speed */

Definition at line 49 of file storage.h.

◆ EXT_CSD_TIMING_HS200

#define EXT_CSD_TIMING_HS200   2 /* HS200 */

Definition at line 50 of file storage.h.

◆ EXT_CSD_TIMING_HS400

#define EXT_CSD_TIMING_HS400   3 /* HS400 */

Definition at line 51 of file storage.h.

◆ EXT_CSD_TRIM_MULT

#define EXT_CSD_TRIM_MULT   232 /* RO */

Definition at line 28 of file storage.h.

◆ MMC_PARTITION_BOOT_1

#define MMC_PARTITION_BOOT_1   1

Definition at line 66 of file storage.h.

◆ MMC_PARTITION_BOOT_2

#define MMC_PARTITION_BOOT_2   2

Definition at line 67 of file storage.h.

◆ MMC_PARTITION_GP1

#define MMC_PARTITION_GP1   4

Definition at line 69 of file storage.h.

◆ MMC_PARTITION_GP2

#define MMC_PARTITION_GP2   5

Definition at line 70 of file storage.h.

◆ MMC_PARTITION_GP3

#define MMC_PARTITION_GP3   6

Definition at line 71 of file storage.h.

◆ MMC_PARTITION_GP4

#define MMC_PARTITION_GP4   7

Definition at line 72 of file storage.h.

◆ MMC_PARTITION_RPMB

#define MMC_PARTITION_RPMB   3

Definition at line 68 of file storage.h.

◆ MMC_PARTITION_USER

#define MMC_PARTITION_USER   0

Definition at line 65 of file storage.h.

◆ MMC_VERSION_1_2

#define MMC_VERSION_1_2   (MMC_VERSION_MMC | 0x12)

Definition at line 83 of file storage.h.

◆ MMC_VERSION_1_4

#define MMC_VERSION_1_4   (MMC_VERSION_MMC | 0x14)

Definition at line 84 of file storage.h.

◆ MMC_VERSION_2_2

#define MMC_VERSION_2_2   (MMC_VERSION_MMC | 0x22)

Definition at line 85 of file storage.h.

◆ MMC_VERSION_3

#define MMC_VERSION_3   (MMC_VERSION_MMC | 0x30)

Definition at line 86 of file storage.h.

◆ MMC_VERSION_4

#define MMC_VERSION_4   (MMC_VERSION_MMC | 0x40)

Definition at line 87 of file storage.h.

◆ MMC_VERSION_MMC

#define MMC_VERSION_MMC   0x10000

Definition at line 81 of file storage.h.

◆ MMC_VERSION_UNKNOWN

#define MMC_VERSION_UNKNOWN   (MMC_VERSION_MMC)

Definition at line 82 of file storage.h.

◆ OCR_ACCESS_MODE

#define OCR_ACCESS_MODE   0x60000000

Definition at line 103 of file storage.h.

◆ OCR_BUSY

#define OCR_BUSY   0x80000000

Definition at line 100 of file storage.h.

◆ OCR_HCS

#define OCR_HCS   0x40000000

Definition at line 101 of file storage.h.

◆ OCR_VOLTAGE_MASK

#define OCR_VOLTAGE_MASK   0x00FFFF80

Definition at line 102 of file storage.h.

◆ SD_VERSION_1_0

#define SD_VERSION_1_0   (SD_VERSION_SD | 0x10)

Definition at line 79 of file storage.h.

◆ SD_VERSION_1_10

#define SD_VERSION_1_10   (SD_VERSION_SD | 0x1a)

Definition at line 80 of file storage.h.

◆ SD_VERSION_2

#define SD_VERSION_2   (SD_VERSION_SD | 0x20)

Definition at line 78 of file storage.h.

◆ SD_VERSION_SD

#define SD_VERSION_SD   0x20000

Definition at line 77 of file storage.h.

Function Documentation

◆ storage_block_erase()

◆ storage_block_fill_write()

uint64_t storage_block_fill_write ( struct storage_media media,
uint64_t  start,
uint64_t  count,
uint32_t  fill_pattern 
)

Definition at line 84 of file storage_write.c.

References sd_mmc_ctrlr::b_max, buffer, count, storage_media::ctrlr, free(), malloc(), media, MiB, MIN, storage_block_setup(), storage_write(), and storage_media::write_bl_len.

Here is the call graph for this function:

◆ storage_block_read()

uint64_t storage_block_read ( struct storage_media media,
uint64_t  start,
uint64_t  count,
void buffer 
)

Definition at line 286 of file storage.c.

References sd_mmc_ctrlr::b_max, buffer, count, storage_media::ctrlr, media, MIN, storage_media::read_bl_len, sd_mmc_trace, storage_block_setup(), and storage_read().

Referenced by partial_block_read(), and storage_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storage_block_write()

uint64_t storage_block_write ( struct storage_media media,
uint64_t  start,
uint64_t  count,
const void buffer 
)

Definition at line 63 of file storage_write.c.

References sd_mmc_ctrlr::b_max, buffer, count, storage_media::ctrlr, media, MIN, mmc_data::src, storage_block_setup(), storage_write(), and storage_media::write_bl_len.

Here is the call graph for this function:

◆ storage_display_setup()

void storage_display_setup ( struct storage_media media)

Definition at line 88 of file storage.c.

References ARRAY_SIZE, storage_media::capacity, storage_media::cid, CONFIG, display_capacity(), storage_media::erase_blocks, IS_SD, media, sd_mmc_debug, sdhc_debug, and storage_media::write_bl_len.

Referenced by boot_device_init(), storage_startup(), and storage_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storage_get_current_partition()

unsigned int storage_get_current_partition ( struct storage_media media)

Definition at line 339 of file storage.c.

References EXT_CSD_PART_ACCESS_MASK, media, and storage_media::partition_config.

Referenced by storage_test().

Here is the caller graph for this function:

◆ storage_partition_name()

const char* storage_partition_name ( struct storage_media media,
unsigned int  partition_number 
)

Definition at line 325 of file storage.c.

References CONFIG, IS_SD, media, mmc_partition_name(), name, NULL, and sd_partition_name().

Referenced by display_capacity(), and storage_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storage_set_partition()

int storage_set_partition ( struct storage_media media,
unsigned int  partition_number 
)

Definition at line 309 of file storage.c.

References CONFIG, IS_SD, media, mmc_set_partition(), sd_mmc_error, and sd_set_partition().

Referenced by storage_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storage_setup_media()

int storage_setup_media ( struct storage_media media,
struct sd_mmc_ctrlr ctrlr 
)

Definition at line 188 of file storage.c.

References storage_media::ctrlr, media, memset(), sd_mmc_enter_standby(), and storage_startup().

Referenced by boot_device_init(), and storage_test().

Here is the call graph for this function:
Here is the caller graph for this function: