Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros
rpmsg.h File Reference
#include <linux/types.h>
#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/kref.h>
#include <linux/mutex.h>

Go to the source code of this file.

Data Structures

struct  rpmsg_hdr
 
struct  rpmsg_ns_msg
 
struct  rpmsg_channel
 
struct  rpmsg_endpoint
 
struct  rpmsg_driver
 

Macros

#define VIRTIO_RPMSG_F_NS   0 /* RP supports name service notifications */
 

: name of remote service that is published

struct rpmsg_ns_msg - dynamic name service announcement message

: address of remote service that is published : indicates whether service is created or destroyed

This message is sent across to publish a new service, or announce about its removal. When we receive these messages, an appropriate rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe() or ->remove() handler of the appropriate rpmsg driver will be invoked (if/as-soon-as one is registered).

#define RPMSG_ADDR_ANY   0xFFFFFFFF
 
enum  rpmsg_ns_flags { RPMSG_NS_CREATE = 0, RPMSG_NS_DESTROY = 1 }
 
typedef void(* rpmsg_rx_cb_t )(struct rpmsg_channel *, void *, int, void *, u32)
 
struct rpmsg_hdr __packed
 
int register_rpmsg_device (struct rpmsg_channel *dev)
 
void unregister_rpmsg_device (struct rpmsg_channel *dev)
 
int register_rpmsg_driver (struct rpmsg_driver *drv)
 
void unregister_rpmsg_driver (struct rpmsg_driver *drv)
 
void rpmsg_destroy_ept (struct rpmsg_endpoint *)
 
struct rpmsg_endpointrpmsg_create_ept (struct rpmsg_channel *, rpmsg_rx_cb_t cb, void *priv, u32 addr)
 
int rpmsg_send_offchannel_raw (struct rpmsg_channel *, u32, u32, void *, int, bool)
 

Macro Definition Documentation

#define RPMSG_ADDR_ANY   0xFFFFFFFF

Definition at line 96 of file rpmsg.h.

#define VIRTIO_RPMSG_F_NS   0 /* RP supports name service notifications */

Definition at line 45 of file rpmsg.h.

Typedef Documentation

typedef void(* rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32)

Definition at line 120 of file rpmsg.h.

Enumeration Type Documentation

enum rpmsg_ns_flags - dynamic name service announcement flags

: a new remote service was just created : a known remote service was just destroyed

Enumerator:
RPMSG_NS_CREATE 
RPMSG_NS_DESTROY 

Definition at line 91 of file rpmsg.h.

Function Documentation

int register_rpmsg_device ( struct rpmsg_channel dev)
int register_rpmsg_driver ( struct rpmsg_driver rpdrv)

register_rpmsg_driver() - register an rpmsg driver with the rpmsg bus : pointer to a struct rpmsg_driver

Returns 0 on success, and an appropriate error value on failure.

Definition at line 448 of file virtio_rpmsg_bus.c.

struct rpmsg_endpoint* rpmsg_create_ept ( struct rpmsg_channel rpdev,
rpmsg_rx_cb_t  cb,
void priv,
u32  addr 
)
read

rpmsg_create_ept() - create a new rpmsg_endpoint : rpmsg channel device : rx callback handler : private data for the driver's use : local rpmsg address to bind with

Every rpmsg address in the system is bound to an rx callback (so when inbound messages arrive, they are dispatched by the rpmsg bus using the appropriate callback handler) by means of an rpmsg_endpoint struct.

This function allows drivers to create such an endpoint, and by that, bind a callback, and possibly some private data too, to an rpmsg address (either one that is known in advance, or one that will be dynamically assigned for them).

Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint is already created for them when they are probed by the rpmsg bus (using the rx callback provided when they registered to the rpmsg bus).

So things should just work for simple drivers: they already have an endpoint, their rx callback is bound to their rpmsg address, and when relevant inbound messages arrive (i.e. messages which their dst address equals to the src address of their rpmsg channel), the driver's handler is invoked to process it.

That said, more complicated drivers might do need to allocate additional rpmsg addresses, and bind them to different rx callbacks. To accomplish that, those drivers need to call this function.

Drivers should provide their channel (so the new endpoint would belong to the same remote processor their channel belongs to), an rx callback function, an optional private data (which is provided back when the rx callback is invoked), and an address they want to bind with the callback. If is RPMSG_ADDR_ANY, then rpmsg_create_ept will dynamically assign them an available rpmsg address (drivers should have a very good reason why not to always use RPMSG_ADDR_ANY here).

Returns a pointer to the endpoint on success, or NULL on error.

Definition at line 308 of file virtio_rpmsg_bus.c.

void rpmsg_destroy_ept ( struct rpmsg_endpoint ept)

rpmsg_destroy_ept() - destroy an existing rpmsg endpoint : endpoing to destroy

Should be used by drivers to destroy an rpmsg endpoint previously created with rpmsg_create_ept().

Definition at line 348 of file virtio_rpmsg_bus.c.

int rpmsg_send_offchannel_raw ( struct rpmsg_channel rpdev,
u32  src,
u32  dst,
void data,
int  len,
bool  wait 
)

rpmsg_send_offchannel_raw() - send a message across to the remote processor : the rpmsg channel : source address : destination address : payload of message : length of payload : indicates whether caller should block in case no TX buffers available

This function is the base implementation for all of the rpmsg sending API.

It will send of length to , and say it's from . The message will be sent to the remote processor which the channel belongs to.

The message is sent using one of the TX buffers that are available for communication with this remote processor.

If is true, the caller will be blocked until either a TX buffer is available, or 15 seconds elapses (we don't want callers to sleep indefinitely due to misbehaving remote processors), and in that case -ERESTARTSYS is returned. The number '15' itself was picked arbitrarily; there's little point in asking drivers to provide a timeout value themselves.

Otherwise, if is false, and there are no TX buffers available, the function will immediately fail, and -ENOMEM will be returned.

Normally drivers shouldn't use this function directly; instead, drivers should use the appropriate rpmsg_{try}send{to, _offchannel} API (see include/linux/rpmsg.h).

Returns 0 on success and an appropriate error value on failure.

Definition at line 689 of file virtio_rpmsg_bus.c.

void unregister_rpmsg_device ( struct rpmsg_channel dev)
void unregister_rpmsg_driver ( struct rpmsg_driver rpdrv)

unregister_rpmsg_driver() - unregister an rpmsg driver from the rpmsg bus : pointer to a struct rpmsg_driver

Returns 0 on success, and an appropriate error value on failure.

Definition at line 461 of file virtio_rpmsg_bus.c.

Variable Documentation