PebbleOS v4.45.0-75-g82ce53758
Loading...
Searching...
No Matches
Non-volatile memory

Non-volatile memory class. More...

Modules

 SF32LB52 eFuse
 Non-volatile memory provider of the SF32LB52 eFuse controller.
 

Data Structures

struct  pbl_nvmem_ops
 Provider operations. More...
 
struct  pbl_nvmem
 Non-volatile memory. More...
 
struct  pbl_nvmem_cell
 A data item in a memory, as used by a consumer. More...
 

Macros

#define PBL_NVMEM_INIT(sym, _name, _init, _deps, _ops, _size, _word_size, _stride)
 Initializer of a struct pbl_nvmem, for providers.
 
#define PBL_NVMEM_CELL(_nvmem, _offset, _bytes)
 Initializer of a struct pbl_nvmem_cell.
 

Functions

int pbl_nvmem_cell_read (const struct pbl_nvmem_cell *cell, void *buf, size_t len)
 Read a cell.
 
int pbl_nvmem_device_read (const struct pbl_nvmem *nvmem, unsigned int offset, size_t bytes, void *buf)
 Read raw bytes from a memory.
 

Variables

const struct pbl_device_class pbl_nvmem_class
 Class of the non-volatile memories.
 

Detailed Description

Non-volatile memory class.

Small non-volatile memories holding data the rest of the system consumes, such as eFuses. A provider exposes the memory as a flat byte address space. A consumer holds a struct pbl_nvmem_cell, what a devicetree nvmem-cells entry describes: a named data item at a fixed location in the memory.

static const struct pbl_nvmem_cell s_mac = PBL_NVMEM_CELL(&s_efuse, 0x20U, 8U);
uint8_t mac[8];
ret = pbl_nvmem_cell_read(&s_mac, mac, sizeof(mac));
A data item in a memory, as used by a consumer.
Definition nvmem.h:87
#define PBL_NVMEM_CELL(_nvmem, _offset, _bytes)
Initializer of a struct pbl_nvmem_cell.
Definition nvmem.h:103
int pbl_nvmem_cell_read(const struct pbl_nvmem_cell *cell, void *buf, size_t len)
Read a cell.

Data Structure Documentation

◆ pbl_nvmem

struct pbl_nvmem

Non-volatile memory.

Data Fields
struct pbl_device dev Device.
const struct pbl_nvmem_ops * ops Operations.
size_t size Size in bytes.
uint8_t stride Minimum read alignment in bytes.
uint8_t word_size Minimum read size in bytes; reads are a multiple of it.

◆ pbl_nvmem_cell

struct pbl_nvmem_cell

A data item in a memory, as used by a consumer.

Data Fields
size_t bytes Size in bytes.
const struct pbl_nvmem * nvmem Memory.
unsigned int offset Offset in bytes.

Macro Definition Documentation

◆ PBL_NVMEM_CELL

#define PBL_NVMEM_CELL (   _nvmem,
  _offset,
  _bytes 
)
Value:
{ \
.nvmem = (_nvmem), \
.offset = (_offset), \
.bytes = (_bytes), \
}

Initializer of a struct pbl_nvmem_cell.

Parameters
_nvmemMemory.
_offsetOffset in bytes.
_bytesSize in bytes.

◆ PBL_NVMEM_INIT

#define PBL_NVMEM_INIT (   sym,
  _name,
  _init,
  _deps,
  _ops,
  _size,
  _word_size,
  _stride 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, _init, nullptr, _deps, &pbl_nvmem_class), \
.ops = (_ops), \
.size = (_size), \
.word_size = (_word_size), \
.stride = (_stride), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _deps, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:143
const struct pbl_device_class pbl_nvmem_class
Class of the non-volatile memories.

Initializer of a struct pbl_nvmem, for providers.

Parameters
symMemory symbol, with its PBL_DEVICE_STATE_DEFINE().
_nameDevice name.
_initDevice init function, or NULL.
_depsDevice dependencies from PBL_DEVICE_DEPS(), or NULL.
_opsOperations.
_sizeSize in bytes.
_word_sizeMinimum read size in bytes.
_strideMinimum read alignment in bytes.

Function Documentation

◆ pbl_nvmem_cell_read()

int pbl_nvmem_cell_read ( const struct pbl_nvmem_cell *  cell,
void *  buf,
size_t  len 
)

Read a cell.

Parameters
cellCell.
[out]bufData.
lenSize of buf in bytes, at least the size of the cell.
Returns
0 on success, -ENODEV if the memory is not ready, -EINVAL if buf is too small or the cell does not fit the memory's geometry, or a negative errno from the provider.

◆ pbl_nvmem_device_read()

int pbl_nvmem_device_read ( const struct pbl_nvmem *  nvmem,
unsigned int  offset,
size_t  bytes,
void *  buf 
)

Read raw bytes from a memory.

Parameters
nvmemMemory.
offsetOffset in bytes, a multiple of the stride.
bytesNumber of bytes, a multiple of the word size.
[out]bufData.
Returns
0 on success, -ENODEV if the memory is not ready, -EINVAL if the access does not fit the memory's geometry, or a negative errno from the provider.

Variable Documentation

◆ pbl_nvmem_class

const struct pbl_device_class pbl_nvmem_class
extern

Class of the non-volatile memories.