23#include "blockdevice/BlockDevice.h"
24#include "platform/Callback.h"
51enum sfdp_cmd_addr_size_t {
52 SFDP_CMD_ADDR_NONE = 0x00,
53 SFDP_CMD_ADDR_3_BYTE = 0x01,
54 SFDP_CMD_ADDR_4_BYTE = 0x02,
55 SFDP_CMD_ADDR_SIZE_VARIABLE = 0x03
59constexpr sfdp_cmd_addr_size_t SFDP_READ_CMD_ADDR_TYPE = SFDP_CMD_ADDR_3_BYTE;
60constexpr uint8_t SFDP_READ_CMD_INST = 0x5A;
61constexpr uint8_t SFDP_READ_CMD_DUMMY_CYCLES = 8;
64constexpr uint8_t SFDP_CMD_DUMMY_CYCLES_VARIABLE = 0xF;
Callback class based on template specialization.
constexpr int SFDP_ERASE_BITMASK_NONE
Erase type None.
int sfdp_iterate_next_largest_erase_type(uint8_t bitfield, bd_size_t size, bd_addr_t offset, int region, const sfdp_smptbl_info &smptbl)
Finds the largest Erase Type of the Region to which the offset belongs to.
int sfdp_parse_sector_map_table(Callback< int(bd_addr_t, sfdp_cmd_addr_size_t, uint8_t, uint8_t, void *, bd_size_t)> sfdp_reader, sfdp_hdr_info &sfdp_info)
Parse Sector Map Parameter Table Retrieves the table from a device and parses the information contain...
constexpr int SFDP_BASIC_PARAMS_TBL_SIZE
Basic Parameter Table size in bytes, 20 DWORDS.
constexpr int SFDP_SECTOR_MAP_MAX_REGIONS
Maximum number of regions with different erase granularity.
constexpr int SFDP_HEADER_SIZE
Size of an SFDP header in bytes, 2 DWORDS.
int sfdp_detect_erase_types_inst_and_size(uint8_t *bptbl_ptr, sfdp_hdr_info &sfdp_info)
Detect all supported erase types.
int sfdp_detect_device_density(uint8_t *bptbl_ptr, sfdp_bptbl_info &bptbl_info)
Detect device density.
constexpr int SFDP_ERASE_BITMASK_TYPE4
Erase type 4 (erase granularity) identifier.
constexpr int SFDP_MAX_NUM_OF_ERASE_TYPES
Maximum number of different erase types (erase granularity)
size_t sfdp_detect_page_size(uint8_t *bptbl_ptr, size_t bptbl_size)
Detect page size used for writing on flash.
constexpr int SFDP_ERASE_BITMASK_TYPE3
Erase type 3 (erase granularity) identifier.
int sfdp_find_addr_region(bd_addr_t offset, const sfdp_hdr_info &sfdp_info)
Find the region to which the given offset belongs to.
int sfdp_detect_addressability(uint8_t *bptbl_ptr, sfdp_bptbl_info &bptbl_info)
Detect is it possible to access the whole memory region.
constexpr int SFDP_ERASE_BITMASK_TYPE1
Erase type 1 (erase granularity) identifier.
int sfdp_parse_headers(Callback< int(bd_addr_t, sfdp_cmd_addr_size_t, uint8_t, uint8_t, void *, bd_size_t)> sfdp_reader, sfdp_hdr_info &sfdp_info)
Parse SFDP Database Retrieves all headers from within a memory device and parses the information cont...
constexpr int SFDP_ERASE_BITMASK_TYPE2
Erase type 2 (erase granularity) identifier.
constexpr int SFDP_ERASE_BITMASK_ALL
Erase type All.
uint64_t bd_size_t
Type representing a quantity of 8-bit bytes.
uint64_t bd_addr_t
Type representing the address of a specific block.
JEDEC Basic Flash Parameter Table info.
int legacy_erase_instruction
Legacy 4K erase instruction.
JEDEC 4-byte Address Instruction Parameter Table info.
int erase_type_4_byte_inst_arr[SFDP_MAX_NUM_OF_ERASE_TYPES]
// Up To 4 Erase Types are supported by SFDP (each with its own command Instruction and Size)
SFDP JEDEC Parameter Table info.
JEDEC Sector Map Table info.
uint8_t region_erase_types_bitfld[SFDP_SECTOR_MAP_MAX_REGIONS]
Each Region can support a bit combination of any of the 4 Erase Types.
int erase_type_inst_arr[SFDP_MAX_NUM_OF_ERASE_TYPES]
// Up To 4 Erase Types are supported by SFDP (each with its own command Instruction and Size)
int region_size[SFDP_SECTOR_MAP_MAX_REGIONS]
Erase region size in bytes.
bd_size_t region_high_boundary[SFDP_SECTOR_MAP_MAX_REGIONS]
Region high address offset boundary.
int region_cnt
Number of erase regions.
unsigned int erase_type_size_arr[SFDP_MAX_NUM_OF_ERASE_TYPES]
Erase sizes for all different erase types.
unsigned int regions_min_common_erase_size
Minimal common erase size for all regions (0 if none exists)