Skip to content

Commit 4e1fb07

Browse files
author
Veijo Pesonen
committed
SFDP: reorganizes internal info structure
1 parent 6a69040 commit 4e1fb07

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ int QSPIFBlockDevice::init()
256256
}
257257

258258
/**************************** Parse Basic Parameters Table ***********************************/
259-
if (0 != _sfdp_parse_basic_param_table(hdr_info.basic_table_addr, hdr_info.basic_table_size)) {
259+
if (0 != _sfdp_parse_basic_param_table(hdr_info.bptbl.addr, hdr_info.bptbl.size)) {
260260
tr_error("Init - Parse Basic Param Table Failed");
261261
status = QSPIF_BD_ERROR_PARSING_FAILED;
262262
goto exit_point;
@@ -267,10 +267,10 @@ int QSPIFBlockDevice::init()
267267
_device_size_bytes; // If there's no region map, we have a single region sized the entire device size
268268
_region_high_boundary[0] = _device_size_bytes - 1;
269269

270-
if ((hdr_info.sector_map_table_addr != 0) && (0 != hdr_info.sector_map_table_size)) {
271-
tr_debug("Init - Parsing Sector Map Table - addr: 0x%lxh, Size: %d", hdr_info.sector_map_table_addr,
272-
hdr_info.sector_map_table_size);
273-
if (0 != _sfdp_parse_sector_map_table(hdr_info.sector_map_table_addr, hdr_info.sector_map_table_size)) {
270+
if ((hdr_info.smtbl.addr != 0) && (0 != hdr_info.smtbl.size)) {
271+
tr_debug("Init - Parsing Sector Map Table - addr: 0x%lxh, Size: %d", hdr_info.smtbl.addr,
272+
hdr_info.smtbl.size);
273+
if (0 != _sfdp_parse_sector_map_table(hdr_info.smtbl.addr, hdr_info.smtbl.size)) {
274274
tr_error("Init - Parse Sector Map Table Failed");
275275
status = QSPIF_BD_ERROR_PARSING_FAILED;
276276
goto exit_point;

components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ int SPIFBlockDevice::init()
189189

190190

191191
/**************************** Parse Basic Parameters Table ***********************************/
192-
if (0 != _sfdp_parse_basic_param_table(hdr_info.basic_table_addr, hdr_info.basic_table_size)) {
192+
if (0 != _sfdp_parse_basic_param_table(hdr_info.bptbl.addr, hdr_info.bptbl.size)) {
193193
tr_error("init - Parse Basic Param Table Failed");
194194
status = SPIF_BD_ERROR_PARSING_FAILED;
195195
goto exit_point;
@@ -200,10 +200,10 @@ int SPIFBlockDevice::init()
200200
_device_size_bytes; // If there's no region map, we have a single region sized the entire device size
201201
_region_high_boundary[0] = _device_size_bytes - 1;
202202

203-
if ((hdr_info.sector_map_table_addr != 0) && (0 != hdr_info.sector_map_table_size)) {
204-
tr_debug("init - Parsing Sector Map Table - addr: 0x%" PRIx32 "h, Size: %d", hdr_info.sector_map_table_addr,
205-
hdr_info.sector_map_table_size);
206-
if (0 != _sfdp_parse_sector_map_table(hdr_info.sector_map_table_addr, hdr_info.sector_map_table_size)) {
203+
if ((hdr_info.smtbl.addr != 0) && (0 != hdr_info.smtbl.size)) {
204+
tr_debug("init - Parsing Sector Map Table - addr: 0x%" PRIx32 "h, Size: %d", hdr_info.smtbl.addr,
205+
hdr_info.smtbl.size);
206+
if (0 != _sfdp_parse_sector_map_table(hdr_info.smtbl.addr, hdr_info.smtbl.size)) {
207207
tr_error("init - Parse Sector Map Table Failed");
208208
status = SPIF_BD_ERROR_PARSING_FAILED;
209209
goto exit_point;

drivers/internal/SFDP.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,22 @@ namespace mbed {
2828
static const int SFDP_HEADER_SIZE = 8; ///< Size of an SFDP header */
2929
static const int SFDP_BASIC_PARAMS_TBL_SIZE = 80; ///< Basic Parameter Table size in Bytes, 20 DWORDS */
3030

31+
/** SFDP Basic Parameter Table info */
32+
struct sfdp_bptbl_info {
33+
uint32_t addr;
34+
size_t size;
35+
};
36+
37+
/** SFDP Sector Map Table info */
38+
struct sfdp_smtbl_info {
39+
uint32_t addr;
40+
size_t size;
41+
};
42+
3143
/** SFDP Parameter Table addresses and sizes */
3244
struct sfdp_hdr_info {
33-
uint32_t basic_table_addr; // Basic Parameter Table address
34-
size_t basic_table_size; // Basic Parameter Table size
35-
uint32_t sector_map_table_addr; // Sector Map Parameter Table address
36-
size_t sector_map_table_size; // Sector Map Parameter Table size
45+
sfdp_bptbl_info bptbl;
46+
sfdp_smtbl_info smtbl;
3747
};
3848

3949
/** SFDP Header */

drivers/source/SFDP.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ int sfdp_parse_single_param_header(sfdp_prm_hdr *phdr, sfdp_hdr_info &hdr_info)
6767

6868
if ((phdr->PID_LSB == 0) && (sfdp_get_param_id_msb(phdr->DWORD2) == 0xFF)) {
6969
tr_debug("Parameter Header: Basic Parameter Header");
70-
hdr_info.basic_table_addr = sfdp_get_param_tbl_ptr(phdr->DWORD2);
71-
hdr_info.basic_table_size = std::min((phdr->P_LEN * 4), SFDP_BASIC_PARAMS_TBL_SIZE);
70+
hdr_info.bptbl.addr = sfdp_get_param_tbl_ptr(phdr->DWORD2);
71+
hdr_info.bptbl.size = std::min((phdr->P_LEN * 4), SFDP_BASIC_PARAMS_TBL_SIZE);
7272

7373
} else if ((phdr->PID_LSB == 0x81) && (sfdp_get_param_id_msb(phdr->DWORD2) == 0xFF)) {
7474
tr_debug("Parameter Header: Sector Map Parameter Header");
75-
hdr_info.sector_map_table_addr = sfdp_get_param_tbl_ptr(phdr->DWORD2);
76-
hdr_info.sector_map_table_size = phdr->P_LEN * 4;
75+
hdr_info.smtbl.addr = sfdp_get_param_tbl_ptr(phdr->DWORD2);
76+
hdr_info.smtbl.size = phdr->P_LEN * 4;
7777

7878
} else {
7979
tr_debug("Parameter Header vendor specific or unknown. Parameter ID LSB: 0x%" PRIX8 "; MSB: 0x%" PRIX8 "",

0 commit comments

Comments
 (0)