Skip to content
Snippets Groups Projects
Commit 2f546191 authored by Aljoscha Wißfeld's avatar Aljoscha Wißfeld
Browse files

poll implemented but not tested

parent 275ea0d7
No related branches found
No related tags found
2 merge requests!7Multithreads enabled,!6Select
......@@ -9,8 +9,6 @@
* (at your option) any later version.
*/
/* kern_select() */
#include <linux/debugfs.h>
#include <linux/err.h>
#include <linux/fs.h>
......@@ -32,10 +30,14 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/wait.h>
#include <stdbool.h>
#define DRIVER_NAME "remoteproc-shm"
#define SHM_SIZE 0x800000
/* TODO: Semaphore */
struct rproc_shm_device {
struct device *dev;
struct mbox_chan *mbox_channel;
......@@ -46,11 +48,14 @@ struct rproc_shm_device {
struct device *cdev;
int major;
struct fasync_struct *async_queue;
bool interrupted;
//sem_t sem;
};
struct class *rproc_class = NULL;
struct rproc_shm_device *dev;
static struct dentry *root_debugfs_dir;
static wait_queue_head_t *wait_queue;
static void rproc_shm_receive_message(struct mbox_client *client, void *message)
{
......@@ -63,10 +68,15 @@ static void rproc_shm_receive_message(struct mbox_client *client, void *message)
if(dev->async_queue) {
dev_info(client->dev, "dev->async_queue == True\n");
kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
dev_info(client->dev, "After kill_fasync\n");
}
else {
dev_info(client->dev, "dev->async_queue == FALSE\n");
}
dev->interrupted = true;
wake_up_interruptible(wait_queue);
}
static void rproc_shm_message_sent(struct mbox_client *client, void *message, int r)
......@@ -211,9 +221,17 @@ static int rproc_shm_fasync(int fd, struct file *filp, int mode)
static unsigned int rproc_shm_poll(struct file *filp, struct poll_table_struct *poll_table)
{
unsigned int mask = 0;
printk(KERN_INFO "rproc_shm_poll");
poll_wait(filp, wait_queue, poll_table);
return 0;
dev->interrupted = false;
mask |= POLLIN | POLLRDNORM; /* readable */
return mask;
}
static int rproc_shm_open(struct inode *i, struct file *filp)
......@@ -327,6 +345,8 @@ static int rproc_shm_probe(struct platform_device *pdev)
dev->shm_addr = virt_addr;
dev->dma_handle = dma;
init_waitqueue_head(wait_queue);
ret = rproc_shm_add_debugfs(pdev, dev);
if (ret)
return ret;
......@@ -361,7 +381,7 @@ static int rproc_shm_remove(struct platform_device *pdev)
dev_info(&pdev->dev, "ADDRESS OF PTR: %p\n", virt_addr);
dev_info(&pdev->dev, "ADDRESS OF DMA: %x\n", dma);
/* reset fasync
/* reset fasync
rproc_shm_fasync(-1, filp, 0);
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment