Add a few more bits of Tonnerre's NetBSD port (Still need to deal with the
authorEric Anholt <anholt@freebsd.org>
Mon, 6 Jun 2005 06:45:41 +0000 (06:45 +0000)
committerEric Anholt <anholt@freebsd.org>
Mon, 6 Jun 2005 06:45:41 +0000 (06:45 +0000)
    device attachment).

bsd-core/drmP.h
bsd-core/drm_bufs.c
bsd-core/drm_drv.c
bsd-core/drm_irq.c
bsd-core/mga_drv.c
bsd-core/r128_drv.c
bsd-core/radeon_drv.c
bsd-core/sis_drv.c
bsd-core/tdfx_drv.c

index 8d648f6..98e4945 100644 (file)
@@ -723,7 +723,6 @@ struct drm_device {
        struct resource   *irqr;        /* Resource for interrupt used by board    */
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
        struct pci_attach_args  pa;
-       pci_intr_handle_t       ih;
 #endif
        void              *irqh;        /* Handle from bus_setup_intr      */
 
index 0f1b7a0..9397e4d 100644 (file)
@@ -927,7 +927,8 @@ int drm_mapbufs(DRM_IOCTL_ARGS)
        vm_offset_t vaddr;
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
        struct vnode *vn;
-       vm_size_t size;
+       voff_t foff;
+       vsize_t size;
        vaddr_t vaddr;
 #endif /* __NetBSD__ || __OpenBSD__ */
 
index 71fcb7c..44a6c85 100644 (file)
@@ -202,7 +202,7 @@ MOD_DEV("drm", LM_DT_CHAR, CDEV_MAJOR, &drm_cdevsw);
 int drm_lkmentry(struct lkm_table *lkmtp, int cmd, int ver);
 static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd);
 
-int drm_modprobe();
+int drm_modprobe(void);
 int drm_probe(struct pci_attach_args *pa);
 void drm_attach(struct pci_attach_args *pa, dev_t kdev);
 
@@ -212,10 +212,7 @@ int drm_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) {
 
 static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd)
 {
-       int j, error = 0;
-#if defined(__NetBSD__) && (__NetBSD_Version__ > 106080000)
-       struct lkm_dev *args = lkmtp->private.lkm_dev;
-#endif
+       int error = 0;
 
        switch(cmd) {
        case LKM_E_LOAD:
@@ -242,7 +239,8 @@ static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd)
        return error;
 }
 
-int drm_modprobe() {
+int drm_modprobe(void)
+{
        struct pci_attach_args pa;
        int error;
 
@@ -279,6 +277,13 @@ void drm_attach(struct pci_attach_args *pa, dev_t kdev,
        memset(dev, 0, sizeof(drm_device_t));
        memcpy(&dev->pa, pa, sizeof(dev->pa));
 
+       dev->irq = pa->pa_intrline;
+       dev->pci_domain = 0;
+       dev->pci_bus = pa->pa_bus;
+       dev->pci_slot = pa->pa_device;
+       dev->pci_func = pa->pa_function;
+       dev->dma_tag = pa->pa_dmat;
+
        DRM_INFO("%s", drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), idlist));
        drm_init(dev);
 }
index d0434c4..8c5660c 100644 (file)
@@ -69,6 +69,9 @@ drm_irq_handler_wrap(DRM_IRQ_ARGS)
 int drm_irq_install(drm_device_t *dev)
 {
        int retcode;
+#ifdef __NetBSD__
+       pci_intr_handle_t ih;
+#endif
 
        if (dev->irq == 0 || dev->dev_private == NULL)
                return DRM_ERR(EINVAL);
@@ -109,12 +112,12 @@ int drm_irq_install(drm_device_t *dev)
        if (retcode != 0)
                goto err;
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
-       if (pci_intr_map(&dev->pa, &dev->ih) != 0) {
+       if (pci_intr_map(&dev->pa, &ih) != 0) {
                retcode = ENOENT;
                goto err;
        }
-       dev->irqh = pci_intr_establish(&dev->pa.pa_pc, dev->ih, IPL_TTY,
-           (irqreturn_t (*)(DRM_IRQ_ARGS))dev->irq_handler, dev);
+       dev->irqh = pci_intr_establish(&dev->pa.pa_pc, ih, IPL_TTY,
+           (irqreturn_t (*)(void *))dev->irq_handler, dev);
        if (!dev->irqh) {
                retcode = ENOENT;
                goto err;
@@ -144,14 +147,18 @@ err:
 
 int drm_irq_uninstall(drm_device_t *dev)
 {
+#ifdef __FreeBSD__
        int irqrid;
+#endif
 
        if (!dev->irq_enabled)
                return DRM_ERR(EINVAL);
 
        dev->irq_enabled = 0;
+#ifdef __FreeBSD__
        irqrid = dev->irqrid;
        dev->irqrid = 0;
+#endif
 
        DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
 
index e088cec..6034212 100644 (file)
@@ -141,5 +141,10 @@ DRIVER_MODULE(mga, pci, mga_driver, drm_devclass, 0, 0);
 MODULE_DEPEND(mga, drm, 1, 1, 1);
 
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef _LKM
 CFDRIVER_DECL(mga, DV_TTY, NULL);
+#else
+CFATTACH_DECL(mga, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
+    drm_activate);
+#endif
 #endif
index 37a3324..94f4ce7 100644 (file)
@@ -113,5 +113,10 @@ DRIVER_MODULE(r128, pci, r128_driver, drm_devclass, 0, 0);
 MODULE_DEPEND(r128, drm, 1, 1, 1);
 
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef _LKM
 CFDRIVER_DECL(r128, DV_TTY, NULL);
+#else
+CFATTACH_DECL(r128, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
+    drm_activate);
+#endif
 #endif
index 29f54cd..78079b7 100644 (file)
@@ -115,5 +115,10 @@ DRIVER_MODULE(radeon, pci, radeon_driver, drm_devclass, 0, 0);
 MODULE_DEPEND(radeon, drm, 1, 1, 1);
 
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef _LKM
 CFDRIVER_DECL(radeon, DV_TTY, NULL);
+#else
+CFATTACH_DECL(radeon, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
+    drm_activate);
+#endif
 #endif /* __FreeBSD__ */
index 985dc4b..6aa2593 100644 (file)
@@ -96,5 +96,10 @@ DRIVER_MODULE(sisdrm, pci, sis_driver, drm_devclass, 0, 0);
 MODULE_DEPEND(sisdrm, drm, 1, 1, 1);
 
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef _LKM
 CFDRIVER_DECL(sis, DV_TTY, NULL);
+#else
+CFATTACH_DECL(sis, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
+    drm_activate);
+#endif
 #endif
index 036d8ec..98ae9ae 100644 (file)
@@ -97,5 +97,10 @@ DRIVER_MODULE(tdfx, pci, tdfx_driver, drm_devclass, 0, 0);
 MODULE_DEPEND(tdfx, drm, 1, 1, 1);
 
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef _LKM
 CFDRIVER_DECL(tdfx, DV_TTY, NULL);
+#else
+CFATTACH_DECL(tdfx, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
+    drm_activate);
+#endif
 #endif