dev/portal: implement portal device

Portal is a device that connect devices. Currently, you can only connect
pipes in portal. Pipes are unidirectional. But with portal, you can
construct a bidirectional device with two pipes.
This commit is contained in:
Grissiom
2013-08-20 10:48:15 +08:00
parent 7e68096a88
commit 6e676e7754
3 changed files with 280 additions and 0 deletions

View File

@@ -73,6 +73,14 @@ struct rt_ringbuffer
rt_int16_t buffer_size;
};
/* portal device */
struct rt_portal_device
{
struct rt_device parent;
struct rt_device *write_dev;
struct rt_device *read_dev;
};
/* pipe device */
#define PIPE_DEVICE(device) ((struct rt_pipe_device*)(device))
enum rt_pipe_flag
@@ -101,6 +109,9 @@ struct rt_pipe_device
/* suspended list */
rt_list_t suspended_read_list;
rt_list_t suspended_write_list;
struct rt_portal_device *write_portal;
struct rt_portal_device *read_portal;
};
#define RT_DATAQUEUE_EVENT_UNKNOWN 0x00
@@ -224,6 +235,23 @@ rt_err_t rt_pipe_create(const char *name, enum rt_pipe_flag flag, rt_size_t size
void rt_pipe_destroy(struct rt_pipe_device *pipe);
#endif
/**
* Portal for DeviceDriver
*/
rt_err_t rt_portal_init(struct rt_portal_device *portal,
const char *portal_name,
const char *write_dev,
const char *read_dev);
rt_err_t rt_portal_detach(struct rt_portal_device *portal);
#ifdef RT_USING_HEAP
rt_err_t rt_portal_create(const char *name,
const char *write_dev,
const char *read_dev);
void rt_portal_destroy(struct rt_portal_device *portal);
#endif
/**
* DataQueue for DeviceDriver
*/