OpenSSD Cosmos+ Platform Firmware  0.0.2
The firmware of Cosmos+ OpenSSD Platform for TOSHIBA nand flash module.
ftl_config.h File Reference
#include "nsc_driver.h"
#include "xparameters.h"
#include "nvme/nvme.h"
Include dependency graph for ftl_config.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NSC_7_CONNECTED   0
 
#define NSC_7_UCODEADDR   0
 
#define NSC_7_BASEADDR   0
 
#define NSC_6_CONNECTED   0
 
#define NSC_6_UCODEADDR   0
 
#define NSC_6_BASEADDR   0
 
#define NSC_5_CONNECTED   0
 
#define NSC_5_UCODEADDR   0
 
#define NSC_5_BASEADDR   0
 
#define NSC_4_CONNECTED   0
 
#define NSC_4_UCODEADDR   0
 
#define NSC_4_BASEADDR   0
 
#define NSC_3_CONNECTED   0
 
#define NSC_3_UCODEADDR   0
 
#define NSC_3_BASEADDR   0
 
#define NSC_2_CONNECTED   0
 
#define NSC_2_UCODEADDR   0
 
#define NSC_2_BASEADDR   0
 
#define NSC_1_CONNECTED   0
 
#define NSC_1_UCODEADDR   0
 
#define NSC_1_BASEADDR   0
 
#define NSC_0_CONNECTED   0
 
#define NSC_0_UCODEADDR   0
 
#define NSC_0_BASEADDR   0
 
#define NUMBER_OF_CONNECTED_CHANNEL
 
#define BYTES_PER_DATA_REGION_OF_NAND_ROW   16384 /* the size of data region of a page */
 
#define BYTES_PER_SPARE_REGION_OF_NAND_ROW   1664 /* the size of spare region of a page */
 
#define BYTES_PER_NAND_ROW   (BYTES_PER_DATA_REGION_OF_NAND_ROW + BYTES_PER_SPARE_REGION_OF_NAND_ROW)
 
#define ROWS_PER_SLC_BLOCK   256 /* number of page in this block (SLC mode) */
 
#define ROWS_PER_MLC_BLOCK   256 /* number of page in this block (MLC mode) */
 
#define MAIN_BLOCKS_PER_LUN   2732 /* number of blocks in the main space of a die */
 
#define EXTENDED_BLOCKS_PER_LUN   224 /* number of blocks in the extended space of a die */
 
#define TOTAL_BLOCKS_PER_LUN   (MAIN_BLOCKS_PER_LUN + EXTENDED_BLOCKS_PER_LUN)
 
#define MAIN_ROWS_PER_SLC_LUN   (ROWS_PER_SLC_BLOCK * MAIN_BLOCKS_PER_LUN)
 
#define MAIN_ROWS_PER_MLC_LUN   (ROWS_PER_MLC_BLOCK * MAIN_BLOCKS_PER_LUN)
 
#define LUNS_PER_DIE   1 /* number of planes in a die (way) */
 
#define MAIN_BLOCKS_PER_DIE   (MAIN_BLOCKS_PER_LUN * LUNS_PER_DIE)
 
#define TOTAL_BLOCKS_PER_DIE   (TOTAL_BLOCKS_PER_LUN * LUNS_PER_DIE)
 
#define BAD_BLOCK_MARK_PAGE0   0
 
#define BAD_BLOCK_MARK_PAGE1   (ROWS_PER_MLC_BLOCK - 1)
 
#define BAD_BLOCK_MARK_BYTE0   0
 
#define BAD_BLOCK_MARK_BYTE1   (BYTES_PER_DATA_REGION_OF_NAND_ROW)
 
#define NSC_MAX_CHANNELS   (NUMBER_OF_CONNECTED_CHANNEL)
 
#define NSC_MAX_WAYS   8
 
#define BYTES_PER_DATA_REGION_OF_PAGE   16384
 
#define BYTES_PER_SPARE_REGION_OF_PAGE   256
 
#define PAGES_PER_SLC_BLOCK   (ROWS_PER_SLC_BLOCK)
 
#define PAGES_PER_MLC_BLOCK   (ROWS_PER_MLC_BLOCK)
 
#define ECC_CHUNKS_PER_PAGE   32
 
#define BIT_ERROR_THRESHOLD_PER_CHUNK   24
 
#define ERROR_INFO_WORD_COUNT   11
 
#define BYTES_PER_NVME_BLOCK   4096
 
#define NVME_BLOCKS_PER_PAGE   (BYTES_PER_DATA_REGION_OF_PAGE / BYTES_PER_NVME_BLOCK)
 
#define SLC_MODE   1
 
#define MLC_MODE   2
 
#define BITS_PER_FLASH_CELL   SLC_MODE
 
#define USER_BLOCKS_PER_LUN   2048
 
#define USER_CHANNELS   8
 
#define USER_WAYS   8
 
#define BYTES_PER_DATA_REGION_OF_SLICE   16384
 
#define BYTES_PER_SPARE_REGION_OF_SLICE   256
 
#define SLICES_PER_PAGE    (BYTES_PER_DATA_REGION_OF_PAGE / BYTES_PER_DATA_REGION_OF_SLICE)
 
#define NVME_BLOCKS_PER_SLICE   (BYTES_PER_DATA_REGION_OF_SLICE / BYTES_PER_NVME_BLOCK)
 
#define USER_DIES   (USER_CHANNELS * USER_WAYS)
 
#define USER_PAGES_PER_BLOCK   (PAGES_PER_SLC_BLOCK * BITS_PER_FLASH_CELL)
 
#define USER_PAGES_PER_LUN   (USER_PAGES_PER_BLOCK * USER_BLOCKS_PER_LUN)
 
#define USER_PAGES_PER_DIE   (USER_PAGES_PER_LUN * LUNS_PER_DIE)
 
#define USER_PAGES_PER_CHANNEL   (USER_PAGES_PER_DIE * USER_WAYS)
 
#define USER_PAGES_PER_SSD   (USER_PAGES_PER_CHANNEL * USER_CHANNELS)
 
#define SLICES_PER_BLOCK   (USER_PAGES_PER_BLOCK * SLICES_PER_PAGE)
 
#define SLICES_PER_LUN   (USER_PAGES_PER_LUN * SLICES_PER_PAGE)
 
#define SLICES_PER_DIE   (USER_PAGES_PER_DIE * SLICES_PER_PAGE)
 
#define SLICES_PER_CHANNEL   (USER_PAGES_PER_CHANNEL * SLICES_PER_PAGE)
 
#define SLICES_PER_SSD   (USER_PAGES_PER_SSD * SLICES_PER_PAGE)
 
#define USER_BLOCKS_PER_DIE   (USER_BLOCKS_PER_LUN * LUNS_PER_DIE)
 
#define USER_BLOCKS_PER_CHANNEL   (USER_BLOCKS_PER_DIE * USER_WAYS)
 
#define USER_BLOCKS_PER_SSD   (USER_BLOCKS_PER_CHANNEL * USER_CHANNELS)
 
#define MB_PER_BLOCK   ((BYTES_PER_DATA_REGION_OF_SLICE * SLICES_PER_BLOCK) / (1024 * 1024))
 
#define MB_PER_SSD   (USER_BLOCKS_PER_SSD * MB_PER_BLOCK)
 
#define MB_PER_MIN_FREE_BLOCK_SPACE   (USER_DIES * MB_PER_BLOCK)
 
#define MB_PER_METADATA_BLOCK_SPACE   (USER_DIES * MB_PER_BLOCK)
 
#define MB_PER_OVER_PROVISION_BLOCK_SPACE   ((USER_BLOCKS_PER_SSD / 10) * MB_PER_BLOCK)
 

Functions

void InitFTL ()
 The entry function for FTL initialization. More...
 
void InitChCtlReg ()
 Initialize the base addresses of all channel controllers. More...
 
void InitNandArray ()
 Send RESET and SET_FEATURE to all the flash dies. More...
 
void CheckConfigRestriction ()
 Check the configurations are legal before the initializations start. More...
 

Variables

unsigned int storageCapacity_L
 
T4REGS chCtlReg [USER_CHANNELS]
 

Macro Definition Documentation

◆ BAD_BLOCK_MARK_BYTE0

#define BAD_BLOCK_MARK_BYTE0   0

Definition at line 167 of file ftl_config.h.

◆ BAD_BLOCK_MARK_BYTE1

#define BAD_BLOCK_MARK_BYTE1   (BYTES_PER_DATA_REGION_OF_NAND_ROW)

Definition at line 168 of file ftl_config.h.

◆ BAD_BLOCK_MARK_PAGE0

#define BAD_BLOCK_MARK_PAGE0   0

Definition at line 165 of file ftl_config.h.

◆ BAD_BLOCK_MARK_PAGE1

#define BAD_BLOCK_MARK_PAGE1   (ROWS_PER_MLC_BLOCK - 1)

Definition at line 166 of file ftl_config.h.

◆ BIT_ERROR_THRESHOLD_PER_CHUNK

#define BIT_ERROR_THRESHOLD_PER_CHUNK   24

Definition at line 187 of file ftl_config.h.

◆ BITS_PER_FLASH_CELL

#define BITS_PER_FLASH_CELL   SLC_MODE

Definition at line 205 of file ftl_config.h.

◆ BYTES_PER_DATA_REGION_OF_NAND_ROW

#define BYTES_PER_DATA_REGION_OF_NAND_ROW   16384 /* the size of data region of a page */

Definition at line 140 of file ftl_config.h.

◆ BYTES_PER_DATA_REGION_OF_PAGE

#define BYTES_PER_DATA_REGION_OF_PAGE   16384

Definition at line 179 of file ftl_config.h.

◆ BYTES_PER_DATA_REGION_OF_SLICE

#define BYTES_PER_DATA_REGION_OF_SLICE   16384

Definition at line 212 of file ftl_config.h.

◆ BYTES_PER_NAND_ROW

Definition at line 144 of file ftl_config.h.

◆ BYTES_PER_NVME_BLOCK

#define BYTES_PER_NVME_BLOCK   4096

Definition at line 194 of file ftl_config.h.

◆ BYTES_PER_SPARE_REGION_OF_NAND_ROW

#define BYTES_PER_SPARE_REGION_OF_NAND_ROW   1664 /* the size of spare region of a page */

Definition at line 141 of file ftl_config.h.

◆ BYTES_PER_SPARE_REGION_OF_PAGE

#define BYTES_PER_SPARE_REGION_OF_PAGE   256

Definition at line 180 of file ftl_config.h.

◆ BYTES_PER_SPARE_REGION_OF_SLICE

#define BYTES_PER_SPARE_REGION_OF_SLICE   256

Definition at line 213 of file ftl_config.h.

◆ ECC_CHUNKS_PER_PAGE

#define ECC_CHUNKS_PER_PAGE   32

Definition at line 186 of file ftl_config.h.

◆ ERROR_INFO_WORD_COUNT

#define ERROR_INFO_WORD_COUNT   11

Definition at line 188 of file ftl_config.h.

◆ EXTENDED_BLOCKS_PER_LUN

#define EXTENDED_BLOCKS_PER_LUN   224 /* number of blocks in the extended space of a die */

Definition at line 154 of file ftl_config.h.

◆ LUNS_PER_DIE

#define LUNS_PER_DIE   1 /* number of planes in a die (way) */

Definition at line 160 of file ftl_config.h.

◆ MAIN_BLOCKS_PER_DIE

#define MAIN_BLOCKS_PER_DIE   (MAIN_BLOCKS_PER_LUN * LUNS_PER_DIE)

Definition at line 162 of file ftl_config.h.

◆ MAIN_BLOCKS_PER_LUN

#define MAIN_BLOCKS_PER_LUN   2732 /* number of blocks in the main space of a die */

Definition at line 153 of file ftl_config.h.

◆ MAIN_ROWS_PER_MLC_LUN

#define MAIN_ROWS_PER_MLC_LUN   (ROWS_PER_MLC_BLOCK * MAIN_BLOCKS_PER_LUN)

Definition at line 158 of file ftl_config.h.

◆ MAIN_ROWS_PER_SLC_LUN

#define MAIN_ROWS_PER_SLC_LUN   (ROWS_PER_SLC_BLOCK * MAIN_BLOCKS_PER_LUN)

Definition at line 157 of file ftl_config.h.

◆ MB_PER_BLOCK

#define MB_PER_BLOCK   ((BYTES_PER_DATA_REGION_OF_SLICE * SLICES_PER_BLOCK) / (1024 * 1024))

Definition at line 237 of file ftl_config.h.

◆ MB_PER_METADATA_BLOCK_SPACE

#define MB_PER_METADATA_BLOCK_SPACE   (USER_DIES * MB_PER_BLOCK)

Definition at line 240 of file ftl_config.h.

◆ MB_PER_MIN_FREE_BLOCK_SPACE

#define MB_PER_MIN_FREE_BLOCK_SPACE   (USER_DIES * MB_PER_BLOCK)

Definition at line 239 of file ftl_config.h.

◆ MB_PER_OVER_PROVISION_BLOCK_SPACE

#define MB_PER_OVER_PROVISION_BLOCK_SPACE   ((USER_BLOCKS_PER_SSD / 10) * MB_PER_BLOCK)

Definition at line 241 of file ftl_config.h.

◆ MB_PER_SSD

#define MB_PER_SSD   (USER_BLOCKS_PER_SSD * MB_PER_BLOCK)

Definition at line 238 of file ftl_config.h.

◆ MLC_MODE

#define MLC_MODE   2

Definition at line 202 of file ftl_config.h.

◆ NSC_0_BASEADDR

#define NSC_0_BASEADDR   0

Definition at line 128 of file ftl_config.h.

◆ NSC_0_CONNECTED

#define NSC_0_CONNECTED   0

Definition at line 126 of file ftl_config.h.

◆ NSC_0_UCODEADDR

#define NSC_0_UCODEADDR   0

Definition at line 127 of file ftl_config.h.

◆ NSC_1_BASEADDR

#define NSC_1_BASEADDR   0

Definition at line 119 of file ftl_config.h.

◆ NSC_1_CONNECTED

#define NSC_1_CONNECTED   0

Definition at line 117 of file ftl_config.h.

◆ NSC_1_UCODEADDR

#define NSC_1_UCODEADDR   0

Definition at line 118 of file ftl_config.h.

◆ NSC_2_BASEADDR

#define NSC_2_BASEADDR   0

Definition at line 110 of file ftl_config.h.

◆ NSC_2_CONNECTED

#define NSC_2_CONNECTED   0

Definition at line 108 of file ftl_config.h.

◆ NSC_2_UCODEADDR

#define NSC_2_UCODEADDR   0

Definition at line 109 of file ftl_config.h.

◆ NSC_3_BASEADDR

#define NSC_3_BASEADDR   0

Definition at line 101 of file ftl_config.h.

◆ NSC_3_CONNECTED

#define NSC_3_CONNECTED   0

Definition at line 99 of file ftl_config.h.

◆ NSC_3_UCODEADDR

#define NSC_3_UCODEADDR   0

Definition at line 100 of file ftl_config.h.

◆ NSC_4_BASEADDR

#define NSC_4_BASEADDR   0

Definition at line 92 of file ftl_config.h.

◆ NSC_4_CONNECTED

#define NSC_4_CONNECTED   0

Definition at line 90 of file ftl_config.h.

◆ NSC_4_UCODEADDR

#define NSC_4_UCODEADDR   0

Definition at line 91 of file ftl_config.h.

◆ NSC_5_BASEADDR

#define NSC_5_BASEADDR   0

Definition at line 83 of file ftl_config.h.

◆ NSC_5_CONNECTED

#define NSC_5_CONNECTED   0

Definition at line 81 of file ftl_config.h.

◆ NSC_5_UCODEADDR

#define NSC_5_UCODEADDR   0

Definition at line 82 of file ftl_config.h.

◆ NSC_6_BASEADDR

#define NSC_6_BASEADDR   0

Definition at line 74 of file ftl_config.h.

◆ NSC_6_CONNECTED

#define NSC_6_CONNECTED   0

Definition at line 72 of file ftl_config.h.

◆ NSC_6_UCODEADDR

#define NSC_6_UCODEADDR   0

Definition at line 73 of file ftl_config.h.

◆ NSC_7_BASEADDR

#define NSC_7_BASEADDR   0

Definition at line 65 of file ftl_config.h.

◆ NSC_7_CONNECTED

#define NSC_7_CONNECTED   0

Definition at line 63 of file ftl_config.h.

◆ NSC_7_UCODEADDR

#define NSC_7_UCODEADDR   0

Definition at line 64 of file ftl_config.h.

◆ NSC_MAX_CHANNELS

#define NSC_MAX_CHANNELS   (NUMBER_OF_CONNECTED_CHANNEL)

Definition at line 175 of file ftl_config.h.

◆ NSC_MAX_WAYS

#define NSC_MAX_WAYS   8

Definition at line 176 of file ftl_config.h.

◆ NUMBER_OF_CONNECTED_CHANNEL

#define NUMBER_OF_CONNECTED_CHANNEL
Value:
NSC_1_CONNECTED + NSC_0_CONNECTED)
#define NSC_7_CONNECTED
Definition: ftl_config.h:63
#define NSC_0_CONNECTED
Definition: ftl_config.h:126
#define NSC_2_CONNECTED
Definition: ftl_config.h:108
#define NSC_4_CONNECTED
Definition: ftl_config.h:90
#define NSC_5_CONNECTED
Definition: ftl_config.h:81
#define NSC_3_CONNECTED
Definition: ftl_config.h:99
#define NSC_6_CONNECTED
Definition: ftl_config.h:72

Definition at line 132 of file ftl_config.h.

◆ NVME_BLOCKS_PER_PAGE

#define NVME_BLOCKS_PER_PAGE   (BYTES_PER_DATA_REGION_OF_PAGE / BYTES_PER_NVME_BLOCK)

Definition at line 195 of file ftl_config.h.

◆ NVME_BLOCKS_PER_SLICE

#define NVME_BLOCKS_PER_SLICE   (BYTES_PER_DATA_REGION_OF_SLICE / BYTES_PER_NVME_BLOCK)

Definition at line 217 of file ftl_config.h.

◆ PAGES_PER_MLC_BLOCK

#define PAGES_PER_MLC_BLOCK   (ROWS_PER_MLC_BLOCK)

Definition at line 183 of file ftl_config.h.

◆ PAGES_PER_SLC_BLOCK

#define PAGES_PER_SLC_BLOCK   (ROWS_PER_SLC_BLOCK)

Definition at line 182 of file ftl_config.h.

◆ ROWS_PER_MLC_BLOCK

#define ROWS_PER_MLC_BLOCK   256 /* number of page in this block (MLC mode) */

Definition at line 151 of file ftl_config.h.

◆ ROWS_PER_SLC_BLOCK

#define ROWS_PER_SLC_BLOCK   256 /* number of page in this block (SLC mode) */
Warning
SLC mode == MLC mode?

Definition at line 150 of file ftl_config.h.

◆ SLC_MODE

#define SLC_MODE   1

Definition at line 201 of file ftl_config.h.

◆ SLICES_PER_BLOCK

#define SLICES_PER_BLOCK   (USER_PAGES_PER_BLOCK * SLICES_PER_PAGE)

Definition at line 227 of file ftl_config.h.

◆ SLICES_PER_CHANNEL

#define SLICES_PER_CHANNEL   (USER_PAGES_PER_CHANNEL * SLICES_PER_PAGE)

Definition at line 230 of file ftl_config.h.

◆ SLICES_PER_DIE

#define SLICES_PER_DIE   (USER_PAGES_PER_DIE * SLICES_PER_PAGE)

Definition at line 229 of file ftl_config.h.

◆ SLICES_PER_LUN

#define SLICES_PER_LUN   (USER_PAGES_PER_LUN * SLICES_PER_PAGE)

Definition at line 228 of file ftl_config.h.

◆ SLICES_PER_PAGE

Definition at line 215 of file ftl_config.h.

◆ SLICES_PER_SSD

#define SLICES_PER_SSD   (USER_PAGES_PER_SSD * SLICES_PER_PAGE)

Definition at line 231 of file ftl_config.h.

◆ TOTAL_BLOCKS_PER_DIE

#define TOTAL_BLOCKS_PER_DIE   (TOTAL_BLOCKS_PER_LUN * LUNS_PER_DIE)

Definition at line 163 of file ftl_config.h.

◆ TOTAL_BLOCKS_PER_LUN

#define TOTAL_BLOCKS_PER_LUN   (MAIN_BLOCKS_PER_LUN + EXTENDED_BLOCKS_PER_LUN)

Definition at line 155 of file ftl_config.h.

◆ USER_BLOCKS_PER_CHANNEL

#define USER_BLOCKS_PER_CHANNEL   (USER_BLOCKS_PER_DIE * USER_WAYS)

Definition at line 234 of file ftl_config.h.

◆ USER_BLOCKS_PER_DIE

#define USER_BLOCKS_PER_DIE   (USER_BLOCKS_PER_LUN * LUNS_PER_DIE)

Definition at line 233 of file ftl_config.h.

◆ USER_BLOCKS_PER_LUN

#define USER_BLOCKS_PER_LUN   2048

Definition at line 206 of file ftl_config.h.

◆ USER_BLOCKS_PER_SSD

#define USER_BLOCKS_PER_SSD   (USER_BLOCKS_PER_CHANNEL * USER_CHANNELS)

Definition at line 235 of file ftl_config.h.

◆ USER_CHANNELS

#define USER_CHANNELS   8

Definition at line 207 of file ftl_config.h.

◆ USER_DIES

#define USER_DIES   (USER_CHANNELS * USER_WAYS)

Definition at line 219 of file ftl_config.h.

◆ USER_PAGES_PER_BLOCK

#define USER_PAGES_PER_BLOCK   (PAGES_PER_SLC_BLOCK * BITS_PER_FLASH_CELL)

Definition at line 221 of file ftl_config.h.

◆ USER_PAGES_PER_CHANNEL

#define USER_PAGES_PER_CHANNEL   (USER_PAGES_PER_DIE * USER_WAYS)

Definition at line 224 of file ftl_config.h.

◆ USER_PAGES_PER_DIE

#define USER_PAGES_PER_DIE   (USER_PAGES_PER_LUN * LUNS_PER_DIE)

Definition at line 223 of file ftl_config.h.

◆ USER_PAGES_PER_LUN

#define USER_PAGES_PER_LUN   (USER_PAGES_PER_BLOCK * USER_BLOCKS_PER_LUN)

Definition at line 222 of file ftl_config.h.

◆ USER_PAGES_PER_SSD

#define USER_PAGES_PER_SSD   (USER_PAGES_PER_CHANNEL * USER_CHANNELS)

Definition at line 225 of file ftl_config.h.

◆ USER_WAYS

#define USER_WAYS   8

Definition at line 208 of file ftl_config.h.

Function Documentation

◆ CheckConfigRestriction()

void CheckConfigRestriction ( )

Check the configurations are legal before the initializations start.

This function will check two things:

  1. the geometry of flash memory doesn't exceed the limit of flash controller
  2. there is no overlap in the memory map
Warning
only allow SLC mode ?

Definition at line 242 of file ftl_config.c.

243{
244 // geometry configutations of flash memory
246 assert(!"[WARNING] Configuration Error: Channel [WARNING]");
248 assert(!"[WARNING] Configuration Error: WAY [WARNING]");
250 assert(!"[WARNING] Configuration Error: BLOCK [WARNING]");
252 assert(!"[WARNING] Configuration Error: BIT_PER_FLASH_CELL [WARNING]");
253
254 // the size of some area are variable, make sure there is no overlap
256 assert(!"[WARNING] Configuration Error: Data buffer size is too large to be allocated to predefined range "
257 "[WARNING]");
259 assert(!"[WARNING] Configuration Error: Metadata for NAND request completion process is too large to be "
260 "allocated to predefined range [WARNING]");
262 assert(!"[WARNING] Configuration Error: Metadata of FTL is too large to be allocated to DRAM [WARNING]");
263}
#define USER_CHANNELS
Definition: ftl_config.h:207
#define BITS_PER_FLASH_CELL
Definition: ftl_config.h:205
#define NSC_MAX_WAYS
Definition: ftl_config.h:176
#define SLC_MODE
Definition: ftl_config.h:201
#define USER_BLOCKS_PER_LUN
Definition: ftl_config.h:206
#define NSC_MAX_CHANNELS
Definition: ftl_config.h:175
#define MAIN_BLOCKS_PER_LUN
Definition: ftl_config.h:153
#define USER_WAYS
Definition: ftl_config.h:208
#define RESERVED_DATA_BUFFER_BASE_ADDR
Definition: memory_map.h:85
#define FTL_MANAGEMENT_END_ADDR
Definition: memory_map.h:117
#define DATA_BUFFER_MAP_ADDR
Definition: memory_map.h:95
#define TEMPORARY_PAY_LOAD_ADDR
Definition: memory_map.h:92
#define COMPLETE_FLAG_TABLE_ADDR
Definition: memory_map.h:89
#define DRAM_END_ADDR
Definition: memory_map.h:122
Here is the caller graph for this function:

◆ InitChCtlReg()

void InitChCtlReg ( )

Initialize the base addresses of all channel controllers.

Definition at line 119 of file ftl_config.c.

120{
121 int i;
122 if (USER_CHANNELS < 1)
123 assert(!"[WARNING] Configuration Error: Channel [WARNING]");
124
125 for (i = 0; i < USER_CHANNELS; i++)
126 {
127 nfc_install_ucode((unsigned int *)NSC_UCODES[i]);
128 V2FInitializeHandle(&chCtlReg[i], (void *)NSCS[i]);
129 nfc_set_dqs_delay(i, 28);
130 }
131
132 // nfc_set_dqs_delay(0, 31);
133 // nfc_set_dqs_delay(1, 31);
134 // nfc_set_dqs_delay(5, 4);
135 // nfc_set_dqs_delay(6, 18);
136}
unsigned int NSC_UCODES[]
Definition: ftl_config.c:113
T4REGS chCtlReg[USER_CHANNELS]
Definition: ftl_config.c:57
unsigned int NSCS[]
Definition: ftl_config.c:108
void V2FInitializeHandle(T4REGS *t4regs, void *t4nscRegisterBaseAddress)
Definition: nsc_driver.c:100
void nfc_set_dqs_delay(int channel, unsigned int newValue)
Definition: nsc_driver.c:59
Here is the caller graph for this function:

◆ InitFTL()

void InitFTL ( )

The entry function for FTL initialization.

Definition at line 62 of file ftl_config.c.

63{
65
66 InitChCtlReg(); // assigned the predefined addresses of channel controllers
67 InitReqPool(); //
70 InitNandArray(); // "[ NAND device reset complete. ]"
71 InitAddressMap(); // "Press 'X' to re-make the bad block table."
72 InitDataBuf(); //
73 InitGcVictimMap(); //
74
75 /*
76 * MB_PER_BLOCK == 16384 * 256 / (1024 * 1024) == 4
77 * MB_PER_SSD == USER_BLOCKS_PER_DIE * USER_DIES * MB_PER_BLOCK == 524288
78 * MB_PER_MIN_FREE_BLOCK_SPACE == USER_DIES * MB_PER_BLOCK
79 * MB_PER_OVER_PROVISION_BLOCK_SPACE == (USER_BLOCKS_PER_DIE * USER_DIES / 10) * MB_PER_BLOCK
80 * BYTES_PER_NVME_BLOCK == 4096
81 */
82 pr_info("[Total bad blocks size: %d MB ]\r\n", mbPerbadBlockSpace); // calculated in `RemapBadBlock()`
83 pr_info("[Total min free block size: %d MB ]\r\n", MB_PER_MIN_FREE_BLOCK_SPACE);
84 pr_info("[Total over provision size: %d MB ]\r\n", MB_PER_OVER_PROVISION_BLOCK_SPACE);
85
88 ((1024 * 1024) / BYTES_PER_NVME_BLOCK);
89
90 pr_info("[ storage capacity %d MB ]\r\n", storageCapacity_L / ((1024 * 1024) / BYTES_PER_NVME_BLOCK));
91 pr_info("[ ftl configuration complete. ]\r\n");
92}
void InitAddressMap()
Initialize the translation related maps.
unsigned int mbPerbadBlockSpace
void InitDataBuf()
Initialization process of the Data buffer.
Definition: data_buffer.c:85
#define pr_info(fmt,...)
Definition: debug.h:86
void InitNandArray()
Send RESET and SET_FEATURE to all the flash dies.
Definition: ftl_config.c:175
void InitChCtlReg()
Initialize the base addresses of all channel controllers.
Definition: ftl_config.c:119
void CheckConfigRestriction()
Check the configurations are legal before the initializations start.
Definition: ftl_config.c:242
unsigned int storageCapacity_L
Definition: ftl_config.c:56
#define BYTES_PER_NVME_BLOCK
Definition: ftl_config.h:194
#define MB_PER_SSD
Definition: ftl_config.h:238
#define MB_PER_OVER_PROVISION_BLOCK_SPACE
Definition: ftl_config.h:241
#define MB_PER_MIN_FREE_BLOCK_SPACE
Definition: ftl_config.h:239
void InitGcVictimMap()
void InitReqPool()
Initialize the request pool and the request queues.
void InitReqScheduler()
Initialize scheduling related tables.
void InitDependencyTable()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitNandArray()

void InitNandArray ( )

Send RESET and SET_FEATURE to all the flash dies.

This function send two requests to each die:

  1. REQ_CODE_RESET:

    Todo:
  2. REQ_CODE_SET_FEATURE:

    This request is used to make the flash enter the toggle mode, check the function IssueNandReq() for details.

The two types of request have some characteristics:

  • no need to do address translation -> use physical address directly:

    set nandAddr to REQ_OPT_NAND_ADDR_PHY_ORG set physicalCh to the channel number of target die set physicalWay to the way number of target die set physicalBlock to any value (no effect) set physicalPage to any value (no effect)

  • no dependency problem:

    set rowAddrDependencyCheck to REQ_OPT_ROW_ADDR_DEPENDENCY_NONE set prevBlockingReq to REQ_SLOT_TAG_NONE

  • no need data buffer needed:

    set dataBufFormat to REQ_OPT_DATA_BUF_NONE

  • apply to all the blocks (main space + extended space)

    set blockSpace to REQ_OPT_BLOCK_SPACE_TOTAL

These requests must be done in the initialization stage, make sure they are all done before going to next initialization step.

Definition at line 175 of file ftl_config.c.

176{
177 unsigned int chNo, wayNo, reqSlotTag;
178 int i;
179
180 for (chNo = 0; chNo < USER_CHANNELS; ++chNo)
181 for (wayNo = 0; wayNo < USER_WAYS; ++wayNo)
182 {
183 reqSlotTag = GetFromFreeReqQ();
190 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalCh = chNo;
191 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalWay = wayNo;
192 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalBlock = 0; // dummy
193 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalPage = 0; // dummy
195 SelectLowLevelReqQ(reqSlotTag);
196
197 reqSlotTag = GetFromFreeReqQ();
204 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalCh = chNo;
205 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalWay = wayNo;
206 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalBlock = 0; // dummy
207 reqPoolPtr->reqPool[reqSlotTag].nandInfo.physicalPage = 0; // dummy
209 SelectLowLevelReqQ(reqSlotTag);
210 }
211
217
218 for (i = 0; i < USER_CHANNELS; i++)
219 {
220 int j;
221 unsigned char *idData = (unsigned char *)(TEMPORARY_PAY_LOAD_ADDR + 16);
222 V2FReadIdSync(&chCtlReg[i], 0, idData);
223 pr_info("Ch %d ReadId: ", i);
224 for (j = 0; j < 6; j++)
225 pr_raw("%x ", idData[j]);
226 pr("\r\n");
227 }
228
229 xil_printf("[ NAND device reset complete. ]\r\n");
230}
#define pr(fmt,...)
Definition: debug.h:79
#define pr_raw
Definition: debug.h:78
void V2FReadIdSync(T4REGS *t4regs, int way, unsigned int *statusReport)
Definition: nsc_driver.c:333
unsigned int GetFromFreeReqQ()
Get a free request from the free request queue.
P_REQ_POOL reqPoolPtr
#define REQ_SLOT_TAG_NONE
#define REQ_OPT_BLOCK_SPACE_TOTAL
#define REQ_CODE_RESET
#define REQ_OPT_DATA_BUF_NONE
#define REQ_CODE_SET_FEATURE
#define REQ_OPT_NAND_ADDR_PHY_ORG
#define REQ_TYPE_NAND
#define REQ_OPT_ROW_ADDR_DEPENDENCY_NONE
void SyncAllLowLevelReqDone()
Do schedule until all the requests are done.
void SelectLowLevelReqQ(unsigned int reqSlotTag)
Dispatch given NVMe/NAND request to corresponding request queue.
unsigned int physicalBlock
unsigned int physicalWay
unsigned int physicalPage
unsigned int physicalCh
unsigned int dataBufFormat
Type of address stored in the SSD_REQ_FORMAT::dataBufInfo.
unsigned int nandAddr
Type of address stored in the SSD_REQ_FORMAT::nandInfo.
unsigned int blockSpace
unsigned int rowAddrDependencyCheck
SSD_REQ_FORMAT reqPool[AVAILABLE_OUNTSTANDING_REQ_COUNT]
REQ_OPTION reqOpt
unsigned int reqCode
NAND_INFO nandInfo
unsigned int reqType
unsigned int prevBlockingReq
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ chCtlReg

T4REGS chCtlReg[USER_CHANNELS]
extern

Definition at line 57 of file ftl_config.c.

◆ storageCapacity_L

unsigned int storageCapacity_L
extern

Definition at line 56 of file ftl_config.c.