summaryrefslogtreecommitdiff
path: root/lib/main.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2013-03-20 09:52:30 +1000
committerBen Skeggs <bskeggs@redhat.com>2013-06-13 10:38:42 +1000
commit944a68f7add0d2ac4ed2d7eedfdb72b9da9a5a08 (patch)
tree879947fbeb813f1cab2bcac76845ced37be74622 /lib/main.c
parent606c4bdd96caa2b7a3ce73d4867d2553371d90c9 (diff)
downloadnouveau-944a68f7add0d2ac4ed2d7eedfdb72b9da9a5a08.tar.gz
lib: create thread for interrrupt polling
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'lib/main.c')
-rw-r--r--lib/main.c75
1 files changed, 2 insertions, 73 deletions
diff --git a/lib/main.c b/lib/main.c
index afec06d45..ed1b34d2b 100644
--- a/lib/main.c
+++ b/lib/main.c
@@ -23,7 +23,6 @@
*/
#include <core/os.h>
-#include <signal.h>
#include <core/object.h>
#include <core/client.h>
@@ -34,81 +33,13 @@
#include <engine/device.h>
#include <subdev/mc.h>
-struct os_device {
- struct nouveau_device base;
- struct list_head head;
- char *name;
- char *cfg;
- char *dbg;
-};
-
-struct os_client {
- struct nouveau_client base;
- struct list_head head;
-};
+#include "priv.h"
static LIST_HEAD(os_device_list);
static LIST_HEAD(os_client_list);
static int os_client_id = 0;
/******************************************************************************
- * "interrupt" handling
- *****************************************************************************/
-#define INTR_FREQ 10000
-
-struct os_intr {
- struct list_head head;
- irq_handler_t handler;
- int irq;
- void *dev;
-};
-static LIST_HEAD(os_intr_list);
-
-int
-os_intr_init(unsigned int irq, irq_handler_t handler, unsigned long flags,
- const char *name, void *dev)
-{
- struct os_intr *intr = malloc(sizeof(*intr));
- if (!intr)
- return -ENOMEM;
- intr->handler = handler;
- intr->irq = irq;
- intr->dev = dev;
- list_add(&intr->head, &os_intr_list);
- return 0;
-}
-
-void
-os_intr_free(unsigned int irq, void *dev)
-{
- struct os_intr *intr;
-
- list_for_each_entry(intr, &os_intr_list, head) {
- if (intr->irq == irq && intr->dev == dev) {
- list_del(&intr->head);
- free(intr);
- break;
- }
- }
-}
-
-static void
-os_intr(int signal)
-{
- struct os_intr *intr;
-
- list_for_each_entry(intr, &os_intr_list, head) {
- intr->handler(intr->irq, intr->dev);
- }
-
- ualarm(INTR_FREQ, 0);
-}
-
-static struct sigaction intr = {
- .sa_handler = os_intr,
-};
-
-/******************************************************************************
* horrific stuff to implement linux's ioremap interface on top of pciaccess
*****************************************************************************/
static struct os_ioremap_info {
@@ -248,9 +179,7 @@ os_init(char *cfg, char *dbg, bool init)
os_init_device(pdev, cfg, dbg);
}
- sigaction(SIGALRM, &intr, 0);
- ualarm(INTR_FREQ, 0);
- return 0;
+ return pthread_create(&os_intr_thread, NULL, os_intr, NULL);
}
static void