PebbleOS v4.47.0-160-g9e782207f
Loading...
Searching...
No Matches

Memory-mapped RAM outside the SoC's own, only powered while it has users. More...

Modules

 HyperRAM
 RAM driver for HyperRAM, PSRAM with a HyperBus interface.
 

Data Structures

struct  pbl_ram_ops
 Driver operations. More...
 
struct  pbl_ram
 RAM device. More...
 

Macros

#define PBL_RAM_STATE_DEFINE(sym)
 
#define PBL_RAM_INIT(sym, _name, _parent, _deps, _ops)
 

Functions

int pbl_ram_dev_init (const struct pbl_device *dev)
 
void pbl_ram_get_region (const struct pbl_ram *ram, uintptr_t *base, size_t *size)
 Get where the memory is mapped, and its size.
 
int pbl_ram_get (const struct pbl_ram *ram)
 Start using the memory, powering it on if it is off.
 
void pbl_ram_put (const struct pbl_ram *ram)
 Stop using the memory.
 
void pbl_ram_suspend (const struct pbl_ram *ram)
 Prepare the memory for deep sleep.
 
void pbl_ram_resume (const struct pbl_ram *ram)
 Bring the memory back after deep sleep.
 
void pbl_ram_quiesce (const struct pbl_ram *ram)
 Let the memory settle before the CPU stops its clocks.
 

Variables

const struct pbl_device_class pbl_ram_class
 
const struct pbl_ram *const EXTRAM
 External RAM, behind the kernel scratch heap.
 

Detailed Description

Memory-mapped RAM outside the SoC's own, only powered while it has users.

A device maps its memory at an address its driver finds out at init, see pbl_ram_get_region(). Its contents are only there between pbl_ram_get() and the matching pbl_ram_put(): the first user powers the memory on, and once the last one is gone, the next deep sleep powers it off. While it has users, deep sleep keeps its contents. What goes where in the memory is up to its user, the kernel scratch heap (see Scratch heap).


Data Structure Documentation

◆ pbl_ram

struct pbl_ram

RAM device.

Data Fields
struct pbl_device dev Device.
const struct pbl_ram_ops * ops Driver operations.
struct pbl_ram_state * state Runtime state.

Macro Definition Documentation

◆ PBL_RAM_INIT

#define PBL_RAM_INIT (   sym,
  _name,
  _parent,
  _deps,
  _ops 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_ram_dev_init, _parent, _deps, &pbl_ram_class), \
.ops = (_ops), \
.state = &sym##_ram_state, \
}
#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:145
int pbl_ram_dev_init(const struct pbl_device *dev)
const struct pbl_device_class pbl_ram_class

◆ PBL_RAM_STATE_DEFINE

#define PBL_RAM_STATE_DEFINE (   sym)
Value:
static struct pbl_ram_state sym##_ram_state = {.lock = PBL_MUTEX_INITIALIZER}
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:131
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50

Function Documentation

◆ pbl_ram_dev_init()

int pbl_ram_dev_init ( const struct pbl_device *  dev)

◆ pbl_ram_get()

int pbl_ram_get ( const struct pbl_ram *  ram)

Start using the memory, powering it on if it is off.

Its contents are undefined if it had no user. Not callable from interrupts.

Parameters
ramDevice.
Returns
0, -ENODEV if the device is not ready, or the error powering it on.

◆ pbl_ram_get_region()

void pbl_ram_get_region ( const struct pbl_ram *  ram,
uintptr_t *  base,
size_t *  size 
)

Get where the memory is mapped, and its size.

Parameters
ramDevice.
[out]baseCPU address of the memory.
[out]sizeSize of the memory, in bytes; 0 if the device is not ready.

◆ pbl_ram_put()

void pbl_ram_put ( const struct pbl_ram *  ram)

Stop using the memory.

Without users, the next deep sleep powers it off.

Parameters
ramDevice.

◆ pbl_ram_quiesce()

void pbl_ram_quiesce ( const struct pbl_ram *  ram)

Let the memory settle before the CPU stops its clocks.

Called by the SoC before a clock-stopping idle state other than deep sleep, with interrupts disabled.

Parameters
ramDevice.

◆ pbl_ram_resume()

void pbl_ram_resume ( const struct pbl_ram *  ram)

Bring the memory back after deep sleep.

Called by the SoC on deep sleep exit, with interrupts disabled.

Parameters
ramDevice.

◆ pbl_ram_suspend()

void pbl_ram_suspend ( const struct pbl_ram *  ram)

Prepare the memory for deep sleep.

Called by the SoC on deep sleep entry, with interrupts disabled: the memory is retained if it has users, and powered off otherwise.

Parameters
ramDevice.

Variable Documentation

◆ EXTRAM

const struct pbl_ram* const EXTRAM
extern

External RAM, behind the kernel scratch heap.

◆ pbl_ram_class

const struct pbl_device_class pbl_ram_class
extern