NAND Flash Translation.
This file contains definitions and functions for NAND Flash translation operation.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "nand_flash_management.h"
Data Structures | |
struct | nand_flash_map |
struct | nand_flash_translation |
Functions | |
void | nand_flash_flush (void) |
Carry out all pending operations. More... | |
void | nand_flash_get_version (uint32_t *minor_version, uint32_t *major_version) |
Get FTL version. More... | |
uint32_t | nand_flash_read (uint32_t address, void *data, uint32_t length) |
Read data at the specified address of NAND Flash. More... | |
uint32_t | nand_flash_translation_erase_all (struct nand_flash_translation *translated, uint32_t level) |
Erase all blocks in the translated area of NAND Flash. More... | |
uint32_t | nand_flash_translation_flush (struct nand_flash_translation *translated) |
Terminate the current write operation by copying all the missing pages from the previous physical block. More... | |
uint16_t | nand_flash_translation_get_device_size_in_block (const struct nand_flash_translation *translated) |
Return the number of available blocks in a translated NAND Flash. More... | |
uint64_t | nand_flash_translation_get_device_size_in_byte (const struct nand_flash_translation *translated) |
Return the number of available data bytes in a translated NAND Flash. More... | |
uint32_t | nand_flash_translation_get_device_size_in_page (const struct nand_flash_translation *translated) |
Return the number of available pages in a translated NAND Flash. More... | |
uint32_t | nand_flash_translation_initialize (struct nand_flash_translation *translated, const struct nand_flash_model *model, uint32_t command_address, uint32_t address_address, uint32_t data_address, uint16_t base_block, uint16_t size_in_block, uint8_t *p_page_write_buffer, uint8_t *p_page_read_buffer) |
Initialize a nand_flash_translation instance. More... | |
uint32_t | nand_flash_translation_read_page (const struct nand_flash_translation *translated, uint16_t block, uint16_t page, void *data, void *spare) |
Read the data and/or the spare area of a page on a translated NAND Flash. More... | |
uint32_t | nand_flash_translation_save_logical_mapping (struct nand_flash_translation *translated) |
Allocate a free block to save the current logical mapping in it. More... | |
uint32_t | nand_flash_translation_write_page (struct nand_flash_translation *translated, uint16_t block, uint16_t page, void *data, void *spare) |
Writes the data and/or spare area of a page on a translated NAND Flash. More... | |
uint32_t | nand_flash_write (uint32_t address, const void *data, uint32_t length) |
Write a data buffer at the specified address to NAND Flash. More... | |
void nand_flash_flush | ( | void | ) |
Carry out all pending operations.
Referenced by nand_flash_test_unit_ready(), and nand_flash_unload().
void nand_flash_get_version | ( | uint32_t * | minor_version, |
uint32_t * | major_version | ||
) |
Get FTL version.
minor_version | Minor version number. |
major_version | Major version number. |
uint32_t nand_flash_read | ( | uint32_t | address, |
void * | data, | ||
uint32_t | length | ||
) |
Read data at the specified address of NAND Flash.
address | Address at which the data shall be read. |
data | Data buffer. |
length | Number of bytes to read. |
Referenced by nand_flash_mem_2_ram(), and nand_flash_usb_read_10().
uint32_t nand_flash_translation_erase_all | ( | struct nand_flash_translation * | translated, |
uint32_t | level | ||
) |
Erase all blocks in the translated area of NAND Flash.
translated | Pointer to a nand_flash_translation instance. |
level | Erase level. |
uint32_t nand_flash_translation_flush | ( | struct nand_flash_translation * | translated | ) |
Terminate the current write operation by copying all the missing pages from the previous physical block.
translated | Pointer to a nand_flash_translation instance. |
uint16_t nand_flash_translation_get_device_size_in_block | ( | const struct nand_flash_translation * | translated | ) |
Return the number of available blocks in a translated NAND Flash.
translated | Pointer to a nand_flash_translation instance. |
uint64_t nand_flash_translation_get_device_size_in_byte | ( | const struct nand_flash_translation * | translated | ) |
Return the number of available data bytes in a translated NAND Flash.
translated | Pointer to a nand_flash_translation instance. |
Referenced by nand_flash_read_capacity().
uint32_t nand_flash_translation_get_device_size_in_page | ( | const struct nand_flash_translation * | translated | ) |
Return the number of available pages in a translated NAND Flash.
translated | Pointer to a nand_flash_translation instance. |
uint32_t nand_flash_translation_initialize | ( | struct nand_flash_translation * | translated, |
const struct nand_flash_model * | model, | ||
uint32_t | command_address, | ||
uint32_t | address_address, | ||
uint32_t | data_address, | ||
uint16_t | base_block, | ||
uint16_t | size_in_block, | ||
uint8_t * | p_page_write_buffer, | ||
uint8_t * | p_page_read_buffer | ||
) |
Initialize a nand_flash_translation instance.
translated | Pointer to a nand_flash_translation instance. |
model | Pointer to the underlying nand chip model. Can be 0. |
command_address | Address at which commands are sent. |
address_address | Address at which addresses are sent. |
data_address | Address at which data is sent. |
base_block | Basic physical block address of mapped area. |
size_in_block | Number of blocks that is mapped. |
p_page_write_buffer | Pointer to buffer for page write, must be allocated with the same size of the NAND Flash page size used. |
p_page_read_buffer | Pointer to buffer for page read, must be allocated with the same size of the NAND Flash page size used. |
Referenced by nand_flash_read_capacity(), and nand_flash_test_unit_ready().
uint32_t nand_flash_translation_read_page | ( | const struct nand_flash_translation * | translated, |
uint16_t | block, | ||
uint16_t | page, | ||
void * | data, | ||
void * | spare | ||
) |
Read the data and/or the spare area of a page on a translated NAND Flash.
If the block is not currently mapped but could be (i.e. there are available physical blocks), then the data/spare is filled with 0xFF.
translated | Pointer to a nand_flash_translation instance. |
block | Logical block number. |
page | Number of page to read inside logical block. |
data | Data area buffer, can be 0. |
spare | Spare area buffer, can be 0. |
uint32_t nand_flash_translation_save_logical_mapping | ( | struct nand_flash_translation * | translated | ) |
Allocate a free block to save the current logical mapping in it.
translated | Pointer to a nand_flash_translation instance. |
uint32_t nand_flash_translation_write_page | ( | struct nand_flash_translation * | translated, |
uint16_t | block, | ||
uint16_t | page, | ||
void * | data, | ||
void * | spare | ||
) |
Writes the data and/or spare area of a page on a translated NAND Flash.
Allocate block has needed to keep the wear even between all blocks.
translated | Pointer to a nand_flash_translation instance. |
block | Logical block number. |
page | Number of page to read inside logical block. |
data | Data area buffer, can be 0. |
spare | Spare area buffer, can be 0. |
uint32_t nand_flash_write | ( | uint32_t | address, |
const void * | data, | ||
uint32_t | length | ||
) |
Write a data buffer at the specified address to NAND Flash.
address | Address where the data shall be written. |
data | Data buffer. |
length | Number of bytes to write. |
Referenced by nand_flash_ram_2_mem(), and nand_flash_usb_write_10().