PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
Mailbox controller drivers

Interface for mailbox controller drivers. More...

Data Structures

struct  pbl_mbox_chan_state
 Channel state, kept by the class. More...
 
struct  pbl_mbox_controller_state
 Controller state, kept by the class. More...
 
struct  pbl_mbox_controller_ops
 Controller operations, implemented by the providers. More...
 
struct  pbl_mbox_controller
 Mailbox controller. More...
 

Macros

#define PBL_MBOX_CONTROLLER_STATE_DEFINE(sym, _num_chans)
 Define the state of a controller, for providers.
 
#define PBL_MBOX_CONTROLLER_INIT(sym, _name, _init, _parent, _ops, _txpoll_period_ms)
 Initializer of a struct pbl_mbox_controller, for providers.
 

Functions

void pbl_mbox_chan_received (const struct pbl_mbox_controller *ctrl, uint8_t idx, const void *msg)
 Report a message from the remote, for providers.
 
void pbl_mbox_chan_txdone (const struct pbl_mbox_controller *ctrl, uint8_t idx, int ret)
 Report that the remote took the last message, for providers with a completion interrupt.
 

Detailed Description

Interface for mailbox controller drivers.

A driver embeds a struct pbl_mbox_controller in its instance, sets it up with PBL_MBOX_CONTROLLER_STATE_DEFINE() and PBL_MBOX_CONTROLLER_INIT(), implements the struct pbl_mbox_controller_ops the class calls, and reports received and sent messages with pbl_mbox_chan_received() and pbl_mbox_chan_txdone().


Data Structure Documentation

◆ pbl_mbox_chan_state

struct pbl_mbox_chan_state

Channel state, kept by the class.

Data Fields
const struct pbl_mbox_client * cl Client, set while the channel is requested.
uint32_t rx_count Messages received.
bool tx_active Whether tx_msg is in flight.
uint32_t tx_count Messages sent.
const void * tx_msg Message in flight.
const void * tx_next Message queued behind tx_msg.
bool tx_queued Whether tx_next is queued.

◆ pbl_mbox_controller_state

struct pbl_mbox_controller_state

Controller state, kept by the class.

Data Fields
const struct pbl_mbox_controller * ctrl Controller.
struct pbl_timer poll Completion poll timer.

◆ pbl_mbox_controller

struct pbl_mbox_controller

Mailbox controller.

Data Fields
struct pbl_mbox_chan_state * chans Channel states, num_chans entries.
struct pbl_device dev Device.
uint8_t num_chans Number of channels.
const struct pbl_mbox_controller_ops * ops Operations.
struct pbl_mbox_controller_state * state Controller state.
uint16_t txpoll_period_ms Completion poll period in milliseconds; 0 if the provider reports completion itself.

Macro Definition Documentation

◆ PBL_MBOX_CONTROLLER_INIT

#define PBL_MBOX_CONTROLLER_INIT (   sym,
  _name,
  _init,
  _parent,
  _ops,
  _txpoll_period_ms 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, &pbl_mbox_class), \
.ops = (_ops), \
.state = &sym##_mbox_ctrl_state, \
.chans = sym##_mbox_chans, \
.num_chans = sizeof(sym##_mbox_chans) / sizeof(sym##_mbox_chans[0]), \
.txpoll_period_ms = (_txpoll_period_ms), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153

Initializer of a struct pbl_mbox_controller, for providers.

Parameters
symController symbol, with its PBL_MBOX_CONTROLLER_STATE_DEFINE().
_nameDevice name.
_initDevice init function.
_parentParent device, or NULL.
_opsOperations.
_txpoll_period_msCompletion poll period in milliseconds, 0 for none.

◆ PBL_MBOX_CONTROLLER_STATE_DEFINE

#define PBL_MBOX_CONTROLLER_STATE_DEFINE (   sym,
  _num_chans 
)
Value:
extern const struct pbl_mbox_controller sym; \
static struct pbl_mbox_controller_state sym##_mbox_ctrl_state = { \
.poll = PBL_TIMER_INITIALIZER(pbl_mbox_poll), \
.ctrl = &sym, \
}; \
static struct pbl_mbox_chan_state sym##_mbox_chans[_num_chans]
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
struct pbl_timer poll
Completion poll timer.
Definition driver.h:49
Channel state, kept by the class.
Definition driver.h:29
Mailbox controller.
Definition driver.h:69
Controller state, kept by the class.
Definition driver.h:47
#define PBL_TIMER_INITIALIZER(_fn)
Static initializer for a timer.
Definition timer.h:50

Define the state of a controller, for providers.

Parameters
symController symbol, of type struct pbl_mbox_controller.
_num_chansNumber of channels.

Function Documentation

◆ pbl_mbox_chan_received()

void pbl_mbox_chan_received ( const struct pbl_mbox_controller *  ctrl,
uint8_t  idx,
const void *  msg 
)

Report a message from the remote, for providers.

Called from interrupt context.

Parameters
ctrlController.
idxChannel index.
msgMessage, nullptr for doorbells.

◆ pbl_mbox_chan_txdone()

void pbl_mbox_chan_txdone ( const struct pbl_mbox_controller *  ctrl,
uint8_t  idx,
int  ret 
)

Report that the remote took the last message, for providers with a completion interrupt.

Called from interrupt context.

Parameters
ctrlController.
idxChannel index.
ret0, or a negative errno.