Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros
virtio_rpmsg_bus.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/virtio.h>
#include <linux/virtio_ids.h>
#include <linux/virtio_config.h>
#include <linux/scatterlist.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/idr.h>
#include <linux/jiffies.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/rpmsg.h>
#include <linux/mutex.h>

Go to the source code of this file.

Data Structures

struct  virtproc_info
 
struct  rpmsg_channel_info
 

Macros

#define pr_fmt(fmt)   "%s: " fmt, __func__
 

: name of service

struct rpmsg_channel_info - internal channel info representation

: local address : destination address

#define to_rpmsg_channel(d)   container_of(d, struct rpmsg_channel, dev)
 
#define to_rpmsg_driver(d)   container_of(d, struct rpmsg_driver, drv)
 
#define RPMSG_NUM_BUFS   (512)
 
#define RPMSG_BUF_SIZE   (512)
 
#define RPMSG_TOTAL_BUF_SPACE   (RPMSG_NUM_BUFS * RPMSG_BUF_SIZE)
 
#define RPMSG_RESERVED_ADDRESSES   (1024)
 
#define RPMSG_NS_ADDR   (53)
 
#define rpmsg_show_attr(field, path, format_string)
 
 rpmsg_show_attr (name, id.name,"%s\n")
 
 rpmsg_show_attr (src, src,"0x%x\n")
 
 rpmsg_show_attr (dst, dst,"0x%x\n")
 
 rpmsg_show_attr (announce, announce?"true":"false","%s\n")
 
struct rpmsg_endpointrpmsg_create_ept (struct rpmsg_channel *rpdev, rpmsg_rx_cb_t cb, void *priv, u32 addr)
 
 EXPORT_SYMBOL (rpmsg_create_ept)
 
void rpmsg_destroy_ept (struct rpmsg_endpoint *ept)
 
 EXPORT_SYMBOL (rpmsg_destroy_ept)
 
int register_rpmsg_driver (struct rpmsg_driver *rpdrv)
 
 EXPORT_SYMBOL (register_rpmsg_driver)
 
void unregister_rpmsg_driver (struct rpmsg_driver *rpdrv)
 
 EXPORT_SYMBOL (unregister_rpmsg_driver)
 
int rpmsg_send_offchannel_raw (struct rpmsg_channel *rpdev, u32 src, u32 dst, void *data, int len, bool wait)
 
 EXPORT_SYMBOL (rpmsg_send_offchannel_raw)
 
 subsys_initcall (rpmsg_init)
 
 module_exit (rpmsg_fini)
 
 MODULE_DEVICE_TABLE (virtio, id_table)
 
 MODULE_DESCRIPTION ("Virtio-based remote processor messaging bus")
 
 MODULE_LICENSE ("GPL v2")
 

Macro Definition Documentation

#define pr_fmt (   fmt)    "%s: " fmt, __func__

Definition at line 20 of file virtio_rpmsg_bus.c.

#define RPMSG_BUF_SIZE   (512)

Definition at line 106 of file virtio_rpmsg_bus.c.

#define RPMSG_NS_ADDR   (53)

Definition at line 117 of file virtio_rpmsg_bus.c.

#define RPMSG_NUM_BUFS   (512)

Definition at line 105 of file virtio_rpmsg_bus.c.

#define RPMSG_RESERVED_ADDRESSES   (1024)

Definition at line 114 of file virtio_rpmsg_bus.c.

#define rpmsg_show_attr (   field,
  path,
  format_string 
)
Value:
static ssize_t \
field##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
\
return sprintf(buf, format_string, rpdev->path); \
}

Definition at line 120 of file virtio_rpmsg_bus.c.

#define RPMSG_TOTAL_BUF_SPACE   (RPMSG_NUM_BUFS * RPMSG_BUF_SIZE)

Definition at line 107 of file virtio_rpmsg_bus.c.

#define to_rpmsg_channel (   d)    container_of(d, struct rpmsg_channel, dev)

Definition at line 85 of file virtio_rpmsg_bus.c.

#define to_rpmsg_driver (   d)    container_of(d, struct rpmsg_driver, drv)

Definition at line 86 of file virtio_rpmsg_bus.c.

Function Documentation

EXPORT_SYMBOL ( rpmsg_create_ept  )
EXPORT_SYMBOL ( rpmsg_destroy_ept  )
EXPORT_SYMBOL ( register_rpmsg_driver  )
EXPORT_SYMBOL ( unregister_rpmsg_driver  )
EXPORT_SYMBOL ( rpmsg_send_offchannel_raw  )
MODULE_DESCRIPTION ( "Virtio-based remote processor messaging bus )
MODULE_DEVICE_TABLE ( virtio  ,
id_table   
)
module_exit ( rpmsg_fini  )
MODULE_LICENSE ( "GPL v2 )
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.

rpmsg_show_attr ( name  ,
id.  name,
"%s\n"   
)
rpmsg_show_attr ( src  ,
src  ,
"0x%x\n"   
)
rpmsg_show_attr ( dst  ,
dst  ,
"0x%x\n"   
)
rpmsg_show_attr ( announce  ,
announce?"true":"false ,
"%s\n"   
)
subsys_initcall ( rpmsg_init  )
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.