SAM EEPROM Emulator.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | _eeprom_master_page |
Structure describing the EEPROM Emulation master page. More... | |
struct | _eeprom_module |
Internal device instance struct. More... | |
struct | _eeprom_page |
Structure describing emulated pages of EEPROM data. More... | |
Macros | |
#define | EEPROM_MAGIC_KEY {0x41744545, 0x50524f4d, 0x456d752e} |
#define | EEPROM_MAGIC_KEY_COUNT 3 |
Functions | |
static void | _eeprom_emulator_check_logical_page (void) |
Check if there exist rows with same logical pages due to power drop when writing or erasing page. More... | |
static void | _eeprom_emulator_create_master_page (void) |
Create master emulated EEPROM management page. More... | |
static void | _eeprom_emulator_erase_invalid_page (uint16_t pre_phy_page, uint16_t next_phy_page) |
Erase one invalid page according to two invalid physical page. More... | |
static void | _eeprom_emulator_format_memory (void) |
Initializes the emulated EEPROM memory, destroying the current contents. More... | |
static bool | _eeprom_emulator_is_full_row (uint16_t phy_page) |
Check if a row is a full row because the page is a invalid page, so if two pages have data, it is the full row. More... | |
static bool | _eeprom_emulator_is_page_free_on_row (const uint8_t start_physical_page, uint8_t *const free_physical_page) |
Finds the next free page in the given row if one is available. More... | |
static enum status_code | _eeprom_emulator_move_data_to_spare (const uint8_t row_number, const uint8_t logical_page, const uint8_t *const data) |
Moves data from the specified logical page to the spare row. More... | |
static void | _eeprom_emulator_nvm_commit_cache (const uint16_t physical_page) |
Commits the internal NVM controller page buffer to physical memory. More... | |
static void | _eeprom_emulator_nvm_erase_row (const uint8_t row) |
Erases a given row within the physical EEPROM memory space. More... | |
static void | _eeprom_emulator_nvm_fill_cache (const uint16_t physical_page, const void *const data) |
Fills the internal NVM controller page buffer in physical EEPROM memory space. More... | |
static void | _eeprom_emulator_nvm_read_page (const uint16_t physical_page, void *const data) |
Reads a page of data stored in physical EEPROM memory space. More... | |
static void | _eeprom_emulator_update_page_mapping (void) |
Creates a map in SRAM to translate logical EEPROM pages to physical FLASH pages. More... | |
static enum status_code | _eeprom_emulator_verify_master_page (void) |
Verify the contents of a master EEPROM page. More... | |
COMPILER_PACK_RESET () | |
COMPILER_PACK_SET (1) | |
enum status_code | eeprom_emulator_commit_page_buffer (void) |
Commits any cached data to physical non-volatile memory. More... | |
void | eeprom_emulator_erase_memory (void) |
Erases the entire emulated EEPROM memory space. More... | |
enum status_code | eeprom_emulator_get_parameters (struct eeprom_emulator_parameters *const parameters) |
Retrieves the parameters of the EEPROM Emulator memory layout. More... | |
enum status_code | eeprom_emulator_init (void) |
Initializes the EEPROM Emulator service. More... | |
enum status_code | eeprom_emulator_read_buffer (const uint16_t offset, uint8_t *const data, const uint16_t length) |
Reads a buffer of data from the emulated EEPROM memory space. More... | |
enum status_code | eeprom_emulator_read_page (const uint8_t logical_page, uint8_t *const data) |
Reads a page of data from an emulated EEPROM memory page. More... | |
enum status_code | eeprom_emulator_write_buffer (const uint16_t offset, const uint8_t *const data, const uint16_t length) |
Writes a buffer of data to the emulated EEPROM memory space. More... | |
enum status_code | eeprom_emulator_write_page (const uint8_t logical_page, const uint8_t *const data) |
Writes a page of data to an emulated EEPROM memory page. More... | |
Variables | |
static struct _eeprom_module | _eeprom_instance |
Internal EEPROM emulator instance. More... | |
#define EEPROM_MAGIC_KEY {0x41744545, 0x50524f4d, 0x456d752e} |
Magic key is the sequence "AtEEPROMEmu." in ASCII. The key is encoded as a sequence of 32-bit values to speed up checking of the key, which can be implemented as a number of simple integer comparisons,
Referenced by _eeprom_emulator_create_master_page(), and _eeprom_emulator_verify_master_page().
#define EEPROM_MAGIC_KEY_COUNT 3 |
Length of the magic key, in 32-bit elements.
Referenced by _eeprom_emulator_create_master_page(), and _eeprom_emulator_verify_master_page().
|
static |
Check if there exist rows with same logical pages due to power drop when writing or erasing page.
when existed same logical page, the old(full) row will be erased.
References _eeprom_emulator_erase_invalid_page(), _eeprom_module::flash, _eeprom_page::header, i, j, _eeprom_page::logical_page, and _eeprom_module::physical_pages.
Referenced by _eeprom_emulator_update_page_mapping().
|
static |
Create master emulated EEPROM management page.
Creates a new master page in emulated EEPROM, giving information on the emulator used to store the EEPROM data.
References _eeprom_emulator_nvm_commit_cache(), _eeprom_emulator_nvm_erase_row(), _eeprom_emulator_nvm_fill_cache(), c, EEPROM_EMULATOR_ID, EEPROM_MAGIC_KEY, EEPROM_MAGIC_KEY_COUNT, EEPROM_MAJOR_VERSION, EEPROM_MINOR_VERSION, EEPROM_REVISION, _eeprom_master_page::emulator_id, _eeprom_master_page::magic_key, _eeprom_master_page::major_version, _eeprom_master_page::minor_version, and _eeprom_master_page::revision.
Referenced by eeprom_emulator_erase_memory().
|
static |
Erase one invalid page according to two invalid physical page.
[in] | pre_phy_page | One physical invalid page |
[in] | next_phy_page | Another physical invalid page |
References _eeprom_emulator_is_full_row(), and _eeprom_emulator_nvm_erase_row().
Referenced by _eeprom_emulator_check_logical_page().
|
static |
Initializes the emulated EEPROM memory, destroying the current contents.
References _eeprom_emulator_nvm_commit_cache(), _eeprom_emulator_nvm_erase_row(), _eeprom_emulator_nvm_fill_cache(), _eeprom_page::header, _eeprom_page::logical_page, _eeprom_module::physical_pages, and _eeprom_module::spare_row.
Referenced by eeprom_emulator_erase_memory().
|
static |
Check if a row is a full row because the page is a invalid page, so if two pages have data, it is the full row.
[in] | phy_page | Physical page that in a row |
References _eeprom_module::flash, _eeprom_page::header, and _eeprom_page::logical_page.
Referenced by _eeprom_emulator_erase_invalid_page().
|
static |
Finds the next free page in the given row if one is available.
[in] | start_physical_page | Physical FLASH page index of the row to search |
[out] | free_physical_page | Index of the physical FLASH page that is currently free (if one was found) |
\c | true If a free page was found |
\c | false If the specified row was full and needs an erase |
References c, _eeprom_module::flash, _eeprom_page::header, and _eeprom_page::logical_page.
Referenced by eeprom_emulator_write_page().
|
static |
Moves data from the specified logical page to the spare row.
Moves the contents of the specified row into the spare row, so that the original row can be erased and re-used. The contents of the given logical page is replaced with a new buffer of data.
[in] | row_number | Physical row to examine |
[in] | logical_page | Logical EEPROM page number in the row to update |
[in] | data | New data to replace the old in the logical page |
References _eeprom_emulator_nvm_erase_row(), _eeprom_emulator_nvm_fill_cache(), _eeprom_emulator_nvm_read_page(), c, _eeprom_module::cache, _eeprom_module::cache_active, _eeprom_page::data, eeprom_emulator_commit_page_buffer(), EEPROM_PAGE_SIZE, _eeprom_module::flash, header, _eeprom_page::header, _eeprom_page::logical_page, _eeprom_module::page_map, _eeprom_module::spare_row, and STATUS_OK.
Referenced by eeprom_emulator_write_page().
|
static |
Commits the internal NVM controller page buffer to physical memory.
[in] | physical_page | Physical page in EEPROM space to commit |
References _eeprom_module::flash, NVM_COMMAND_WRITE_PAGE, nvm_execute_command(), STATUS_BUSY, and STATUS_OK.
Referenced by _eeprom_emulator_create_master_page(), _eeprom_emulator_format_memory(), and eeprom_emulator_commit_page_buffer().
|
static |
Erases a given row within the physical EEPROM memory space.
[in] | row | Physical row in EEPROM space to erase |
References _eeprom_module::flash, nvm_erase_row(), STATUS_BUSY, and STATUS_OK.
Referenced by _eeprom_emulator_create_master_page(), _eeprom_emulator_erase_invalid_page(), _eeprom_emulator_format_memory(), and _eeprom_emulator_move_data_to_spare().
|
static |
Fills the internal NVM controller page buffer in physical EEPROM memory space.
[in] | physical_page | Physical page in EEPROM space to fill |
[in] | data | Data to write to the physical memory page |
References _eeprom_module::flash, nvm_write_buffer(), STATUS_BUSY, and STATUS_OK.
Referenced by _eeprom_emulator_create_master_page(), _eeprom_emulator_format_memory(), _eeprom_emulator_move_data_to_spare(), and eeprom_emulator_write_page().
|
static |
Reads a page of data stored in physical EEPROM memory space.
[in] | physical_page | Physical page in EEPROM space to read |
[out] | data | Destination buffer to fill with the read data |
References _eeprom_module::flash, nvm_read_buffer(), STATUS_BUSY, and STATUS_OK.
Referenced by _eeprom_emulator_move_data_to_spare(), _eeprom_emulator_verify_master_page(), and eeprom_emulator_read_page().
|
static |
Creates a map in SRAM to translate logical EEPROM pages to physical FLASH pages.
References _eeprom_emulator_check_logical_page(), c, _eeprom_module::flash, _eeprom_page::header, _eeprom_page::logical_page, _eeprom_module::logical_pages, _eeprom_module::page_map, _eeprom_module::physical_pages, and _eeprom_module::spare_row.
Referenced by eeprom_emulator_erase_memory(), and eeprom_emulator_init().
|
static |
Verify the contents of a master EEPROM page.
Verify the contents of a master EEPROM page to ensure that it contains the correct information for this version of the EEPROM emulation service.
STATUS_OK | Given master page contents is valid |
STATUS_ERR_BAD_FORMAT | Master page contents was invalid |
STATUS_ERR_IO | Master page indicates the data is incompatible with this version of the EEPROM emulator |
References _eeprom_emulator_nvm_read_page(), c, EEPROM_EMULATOR_ID, EEPROM_MAGIC_KEY, EEPROM_MAGIC_KEY_COUNT, EEPROM_MAJOR_VERSION, EEPROM_MINOR_VERSION, _eeprom_master_page::emulator_id, _eeprom_master_page::magic_key, _eeprom_master_page::major_version, _eeprom_master_page::minor_version, STATUS_ERR_BAD_FORMAT, STATUS_ERR_IO, and STATUS_OK.
Referenced by eeprom_emulator_init().
COMPILER_PACK_RESET | ( | ) |
COMPILER_PACK_SET | ( | 1 | ) |
Item structure for faster search of item
< Id of an item.
< Location of the this item.
|
static |
Internal EEPROM emulator instance.