PebbleOS v4.45.0-142-gc51251f50
Loading...
Searching...
No Matches
Flash partitions

Access to areas of the board's flash. More...

Data Structures

struct  pbl_flash_partition
 An area of the board's flash. More...
 

Macros

#define PBL_FLASH_PARTITION(name)    ((struct pbl_flash_partition){.offset = name##_OFFSET, .size = name##_SIZE})
 The partition described by the constants name_OFFSET and name_SIZE.
 

Functions

static bool pbl_flash_partition__in_range (struct pbl_flash_partition part, uint32_t offs, size_t len)
 
static int pbl_flash_partition_read (struct pbl_flash_partition part, uint32_t offs, void *buf, size_t len)
 Read data.
 
static int pbl_flash_partition_write (struct pbl_flash_partition part, uint32_t offs, const void *buf, size_t len)
 Write data.
 
static int pbl_flash_partition_erase (struct pbl_flash_partition part, uint32_t offs, size_t len)
 Erase a range.
 
static bool pbl_flash_partition_is_erased (struct pbl_flash_partition part, uint32_t offs, size_t len)
 Check whether a range is erased.
 
static int pbl_flash_partition_protect (struct pbl_flash_partition part)
 Protect a whole partition against writes and erases.
 

Detailed Description

Access to areas of the board's flash.

Offsets given to these functions start at the partition, which they check them against. Code working on flash addresses uses offset and size directly. The partitions themselves belong to the board: see pbl/board/partitions.h.

static_assert(sizeof(struct state) <= PART_TZINFO_SIZE);
if (ret != 0) {
return ret;
}
ret = pbl_flash_partition_write(PART_TZINFO, 0U, &state, sizeof(state));
static int pbl_flash_partition_erase(struct pbl_flash_partition part, uint32_t offs, size_t len)
Erase a range.
Definition partition.h:105
static int pbl_flash_partition_write(struct pbl_flash_partition part, uint32_t offs, const void *buf, size_t len)
Write data.
Definition partition.h:86
#define PART_TZINFO_SIZE
Definition partitions_dual_slot.h:57
#define PART_TZINFO
Definition partitions_dual_slot.h:58

Data Structure Documentation

◆ pbl_flash_partition

struct pbl_flash_partition

An area of the board's flash.

Data Fields
uint32_t offset Offset of the first byte in the flash.
uint32_t size Size in bytes.

Macro Definition Documentation

◆ PBL_FLASH_PARTITION

#define PBL_FLASH_PARTITION (   name)     ((struct pbl_flash_partition){.offset = name##_OFFSET, .size = name##_SIZE})

The partition described by the constants name_OFFSET and name_SIZE.

Parameters
namePrefix of the constants.

Function Documentation

◆ pbl_flash_partition__in_range()

static bool pbl_flash_partition__in_range ( struct pbl_flash_partition  part,
uint32_t  offs,
size_t  len 
)
inlinestatic

◆ pbl_flash_partition_erase()

static int pbl_flash_partition_erase ( struct pbl_flash_partition  part,
uint32_t  offs,
size_t  len 
)
inlinestatic

Erase a range.

Parameters
partPartition.
offsOffset in the partition, aligned to a subsector.
lenNumber of bytes.
Return values
0On success.
-EINVALIf the range is outside the partition.
Returns
Otherwise, the error of pbl_flash_erase().

References FLASH, pbl_flash_partition::offset, pbl_flash_erase(), and pbl_flash_partition__in_range().

◆ pbl_flash_partition_is_erased()

static bool pbl_flash_partition_is_erased ( struct pbl_flash_partition  part,
uint32_t  offs,
size_t  len 
)
inlinestatic

Check whether a range is erased.

Parameters
partPartition.
offsOffset in the partition.
lenNumber of bytes.
Returns
True if the range is inside the partition and erased.

References FLASH, pbl_flash_partition::offset, pbl_flash_is_erased(), and pbl_flash_partition__in_range().

◆ pbl_flash_partition_protect()

static int pbl_flash_partition_protect ( struct pbl_flash_partition  part)
inlinestatic

Protect a whole partition against writes and erases.

Parameters
partPartition.
Returns
The result of pbl_flash_protect().

References FLASH, pbl_flash_partition::offset, pbl_flash_protect(), and pbl_flash_partition::size.

◆ pbl_flash_partition_read()

static int pbl_flash_partition_read ( struct pbl_flash_partition  part,
uint32_t  offs,
void *  buf,
size_t  len 
)
inlinestatic

Read data.

Parameters
partPartition.
offsOffset in the partition.
bufBuffer.
lenNumber of bytes.
Return values
0On success.
-EINVALIf the range is outside the partition.
Returns
Otherwise, the error of pbl_flash_read().

References FLASH, pbl_flash_partition::offset, pbl_flash_partition__in_range(), and pbl_flash_read().

◆ pbl_flash_partition_write()

static int pbl_flash_partition_write ( struct pbl_flash_partition  part,
uint32_t  offs,
const void *  buf,
size_t  len 
)
inlinestatic

Write data.

Parameters
partPartition.
offsOffset in the partition.
bufData.
lenNumber of bytes.
Return values
0On success.
-EINVALIf the range is outside the partition.
Returns
Otherwise, the error of pbl_flash_write().

References FLASH, pbl_flash_partition::offset, pbl_flash_partition__in_range(), and pbl_flash_write().