PebbleOS
Loading...
Searching...
No Matches
Functions
Flash translation layer

Contiguous virtual address space for PFS over several flash regions. More...

Functions

void ftl_add_region (uint32_t region_start, uint32_t region_end, bool erase_new_region)
 Append a flash region to the translation space.
 
uint32_t ftl_get_size (void)
 Get the size of the translation space.
 
void ftl_erase_sector (uint32_t size, uint32_t offset)
 Erase a sector of the translation space.
 
void ftl_erase_subsector (uint32_t size, uint32_t offset)
 Erase a subsector of the translation space.
 
void ftl_read (void *buffer, size_t size, uint32_t offset)
 Read from the translation space.
 
void ftl_write (const void *buffer, size_t size, uint32_t offset)
 Write to the translation space.
 
void ftl_format (void)
 Format all regions of the translation space.
 
void ftl_populate_region_list (void)
 Build the translation space at boot.
 

Detailed Description

Contiguous virtual address space for PFS over several flash regions.

Lets PFS grow into multiple flash regions while keeping a contiguous virtual address space. Regions are added in the order of the board's filesystem region list. On boot, the regions where PFS is already active are added as they are; the remaining ones are erased and then added, growing the filesystem.

Function Documentation

◆ ftl_add_region()

void ftl_add_region ( uint32_t  region_start,
uint32_t  region_end,
bool  erase_new_region 
)

Append a flash region to the translation space.

The region must be the next one in the filesystem region list; otherwise the call is ignored. Grows the PFS size by region_end - region_start.

Parameters
region_startStart address of the region.
region_endEnd address of the region, exclusive.
erase_new_regionErase the region before adding it.

◆ ftl_erase_sector()

void ftl_erase_sector ( uint32_t  size,
uint32_t  offset 
)

Erase a sector of the translation space.

Parameters
sizeSize of the area to erase, must equal SECTOR_SIZE_BYTES (asserted).
offsetVirtual offset of the sector.

◆ ftl_erase_subsector()

void ftl_erase_subsector ( uint32_t  size,
uint32_t  offset 
)

Erase a subsector of the translation space.

Parameters
sizeSize of the area to erase, must equal SUBSECTOR_SIZE_BYTES (asserted).
offsetVirtual offset of the subsector.

◆ ftl_format()

void ftl_format ( void  )

Format all regions of the translation space.

Currently does nothing; use pfs_format() to erase the filesystem.

◆ ftl_get_size()

uint32_t ftl_get_size ( void  )

Get the size of the translation space.

Returns
Size in bytes.

◆ ftl_populate_region_list()

void ftl_populate_region_list ( void  )

Build the translation space at boot.

Adds the regions where PFS already exists, runs pfs_reboot_cleanup(), then erases and adds the remaining regions. Called by pfs_init().

◆ ftl_read()

void ftl_read ( void *  buffer,
size_t  size,
uint32_t  offset 
)

Read from the translation space.

Parameters
[out]bufferDestination buffer.
sizeNumber of bytes to read, at most the size of buffer.
offsetVirtual offset to read from.

◆ ftl_write()

void ftl_write ( const void *  buffer,
size_t  size,
uint32_t  offset 
)

Write to the translation space.

Parameters
bufferData to write.
sizeNumber of bytes to write, at most the size of buffer.
offsetVirtual offset to write to.