summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Noland <rnoland@2hip.net>2009-03-16 01:07:15 -0500
committerRobert Noland <rnoland@2hip.net>2009-03-16 01:17:00 -0500
commite8d34762558224bb76862425de965c47858f2afd (patch)
tree0d3cbcfd0fe10ceee2e1253e04de4e0393ad4dce
parentdec955d728505f060afccd047ff2b572cb4ba3c1 (diff)
FreeBSD: Set up the nouveau build infrastructure
disabled by default until the rest of the patches are in.
-rw-r--r--bsd-core/Makefile2
l---------bsd-core/nouveau/@1
-rw-r--r--bsd-core/nouveau/Makefile33
l---------bsd-core/nouveau/machine1
l---------bsd-core/nouveau_dma.c1
l---------bsd-core/nouveau_dma.h1
l---------bsd-core/nouveau_drm.h1
-rw-r--r--bsd-core/nouveau_drv.c148
l---------bsd-core/nouveau_drv.h1
l---------bsd-core/nouveau_fifo.c1
l---------bsd-core/nouveau_irq.c1
l---------bsd-core/nouveau_mem.c1
l---------bsd-core/nouveau_notifier.c1
l---------bsd-core/nouveau_object.c1
l---------bsd-core/nouveau_reg.h1
-rw-r--r--bsd-core/nouveau_sgdma.c357
l---------bsd-core/nouveau_state.c1
l---------bsd-core/nouveau_swmthd.c1
l---------bsd-core/nouveau_swmthd.h1
l---------bsd-core/nv04_fb.c1
l---------bsd-core/nv04_fifo.c1
l---------bsd-core/nv04_graph.c1
l---------bsd-core/nv04_instmem.c1
l---------bsd-core/nv04_mc.c1
l---------bsd-core/nv04_timer.c1
l---------bsd-core/nv10_fb.c1
l---------bsd-core/nv10_fifo.c1
l---------bsd-core/nv10_graph.c1
l---------bsd-core/nv20_graph.c1
l---------bsd-core/nv40_fb.c1
l---------bsd-core/nv40_fifo.c1
l---------bsd-core/nv40_graph.c1
l---------bsd-core/nv40_mc.c1
l---------bsd-core/nv50_fifo.c1
l---------bsd-core/nv50_graph.c1
l---------bsd-core/nv50_grctx.h1
l---------bsd-core/nv50_instmem.c1
l---------bsd-core/nv50_mc.c1
38 files changed, 573 insertions, 1 deletions
diff --git a/bsd-core/Makefile b/bsd-core/Makefile
index a58ac0a5..0e0332df 100644
--- a/bsd-core/Makefile
+++ b/bsd-core/Makefile
@@ -1,6 +1,6 @@
SHARED= ../shared-core
-SUBDIR = drm mach64 mga r128 radeon savage sis tdfx i915 # via
+SUBDIR = drm mach64 mga r128 radeon savage sis tdfx i915 #nouveau
.include <bsd.obj.mk>
diff --git a/bsd-core/nouveau/@ b/bsd-core/nouveau/@
new file mode 120000
index 00000000..8fd4e8f4
--- /dev/null
+++ b/bsd-core/nouveau/@
@@ -0,0 +1 @@
+/usr/src/sys \ No newline at end of file
diff --git a/bsd-core/nouveau/Makefile b/bsd-core/nouveau/Makefile
new file mode 100644
index 00000000..b0d72c90
--- /dev/null
+++ b/bsd-core/nouveau/Makefile
@@ -0,0 +1,33 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/..
+KMOD = nouveau
+NO_MAN = YES
+SRCS = nouveau_drv.c nouveau_state.c nouveau_mem.c nouveau_object.c \
+ nouveau_sgdma.c nouveau_fifo.c nouveau_notifier.c nouveau_dma.c \
+ nouveau_irq.c nouveau_swmthd.c \
+ nv04_timer.c \
+ nv04_mc.c nv40_mc.c nv50_mc.c \
+ nv04_fb.c nv10_fb.c nv40_fb.c \
+ nv04_fifo.c nv10_fifo.c nv40_fifo.c nv50_fifo.c \
+ nv04_graph.c nv10_graph.c nv20_graph.c \
+ nv40_graph.c nv50_graph.c \
+ nv04_instmem.c nv50_instmem.c
+# nouveau_bo.c nouveau_fence.c \
+SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
+CFLAGS += ${DEBUG_FLAGS} -I. -I..
+
+.if defined(DRM_DEBUG)
+DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
+.endif
+
+.if !defined(DRM_NOLINUX)
+DRM_LINUX_OPT= "\#define DRM_LINUX 1"
+.endif
+
+opt_drm.h:
+ touch opt_drm.h
+ echo $(DRM_DEBUG_OPT) >> opt_drm.h
+ echo $(DRM_LINUX_OPT) >> opt_drm.h
+
+.include <bsd.kmod.mk>
diff --git a/bsd-core/nouveau/machine b/bsd-core/nouveau/machine
new file mode 120000
index 00000000..f5ca0131
--- /dev/null
+++ b/bsd-core/nouveau/machine
@@ -0,0 +1 @@
+/usr/src/sys/amd64/include \ No newline at end of file
diff --git a/bsd-core/nouveau_dma.c b/bsd-core/nouveau_dma.c
new file mode 120000
index 00000000..f8e0bdc3
--- /dev/null
+++ b/bsd-core/nouveau_dma.c
@@ -0,0 +1 @@
+../shared-core/nouveau_dma.c \ No newline at end of file
diff --git a/bsd-core/nouveau_dma.h b/bsd-core/nouveau_dma.h
new file mode 120000
index 00000000..a545e387
--- /dev/null
+++ b/bsd-core/nouveau_dma.h
@@ -0,0 +1 @@
+../shared-core/nouveau_dma.h \ No newline at end of file
diff --git a/bsd-core/nouveau_drm.h b/bsd-core/nouveau_drm.h
new file mode 120000
index 00000000..d300ae06
--- /dev/null
+++ b/bsd-core/nouveau_drm.h
@@ -0,0 +1 @@
+../shared-core/nouveau_drm.h \ No newline at end of file
diff --git a/bsd-core/nouveau_drv.c b/bsd-core/nouveau_drv.c
new file mode 100644
index 00000000..28b3f9a3
--- /dev/null
+++ b/bsd-core/nouveau_drv.c
@@ -0,0 +1,148 @@
+/* nouveau_drv.c.c -- nouveau nouveau driver -*- linux-c -*-
+ * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
+ */
+/*-
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include "drmP.h"
+#include "drm.h"
+#include "nouveau_drv.h"
+#include "drm_pciids.h"
+
+extern struct drm_ioctl_desc nouveau_ioctls[];
+extern int nouveau_max_ioctl;
+
+/* drv_PCI_IDs for nouveau is just to match the vendor id */
+static struct drm_pci_id_list nouveau_pciidlist[] = {
+ {0x10DE, 0, 0, "NVidia Display Adapter"}, \
+ {0, 0, 0, NULL}
+};
+
+static void nouveau_configure(struct drm_device *dev)
+{
+ dev->driver->driver_features =
+ DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_IRQ;
+
+ dev->driver->buf_priv_size = sizeof(struct drm_nouveau_private);
+ dev->driver->load = nouveau_load;
+ dev->driver->unload = nouveau_unload;
+ dev->driver->firstopen = nouveau_firstopen;
+ dev->driver->preclose = nouveau_preclose;
+ dev->driver->lastclose = nouveau_lastclose;
+ dev->driver->irq_preinstall = nouveau_irq_preinstall;
+ dev->driver->irq_postinstall = nouveau_irq_postinstall;
+ dev->driver->irq_uninstall = nouveau_irq_uninstall;
+ dev->driver->irq_handler = nouveau_irq_handler;
+
+ dev->driver->ioctls = nouveau_ioctls;
+ dev->driver->max_ioctl = nouveau_max_ioctl;
+
+ dev->driver->name = DRIVER_NAME;
+ dev->driver->desc = DRIVER_DESC;
+ dev->driver->date = DRIVER_DATE;
+ dev->driver->major = DRIVER_MAJOR;
+ dev->driver->minor = DRIVER_MINOR;
+ dev->driver->patchlevel = DRIVER_PATCHLEVEL;
+}
+
+static int
+nouveau_probe(device_t kdev)
+{
+ int vendor;
+
+ if (pci_get_class(kdev) == PCIC_DISPLAY) {
+ vendor = pci_get_vendor(kdev);
+ if (vendor == 0x10de) {
+
+ const char *ident;
+ char model[64];
+
+ if (pci_get_vpd_ident(kdev, &ident) == 0) {
+ snprintf(model, 64, "%s", ident);
+ device_set_desc_copy(kdev, model);
+ DRM_DEBUG("VPD : %s\n", model);
+ }
+
+ return drm_probe(kdev, nouveau_pciidlist);
+ }
+ }
+ return ENXIO;
+}
+
+static int
+nouveau_attach(device_t kdev)
+{
+ struct drm_device *dev = device_get_softc(kdev);
+
+ dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
+ M_WAITOK | M_ZERO);
+
+ nouveau_configure(dev);
+
+ return drm_attach(kdev, nouveau_pciidlist);
+}
+
+static int
+nouveau_detach(device_t kdev)
+{
+ struct drm_device *dev = device_get_softc(kdev);
+ int ret;
+
+ ret = drm_detach(kdev);
+
+ free(dev->driver, DRM_MEM_DRIVER);
+
+ return ret;
+}
+
+static device_method_t nouveau_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, nouveau_probe),
+ DEVMETHOD(device_attach, nouveau_attach),
+ DEVMETHOD(device_detach, nouveau_detach),
+
+ { 0, 0 }
+};
+
+static driver_t nouveau_driver = {
+#if __FreeBSD_version >= 700010
+ "drm",
+#else
+ "drmsub",
+#endif
+ nouveau_methods,
+ sizeof(struct drm_device)
+};
+
+extern devclass_t drm_devclass;
+#if __FreeBSD_version >= 700010
+DRIVER_MODULE(nouveau, vgapci, nouveau_driver, drm_devclass, 0, 0);
+#else
+DRIVER_MODULE(nouveau, agp, nouveau_driver, drm_devclass, 0, 0);
+#endif
+MODULE_DEPEND(nouveau, drm, 1, 1, 1);
diff --git a/bsd-core/nouveau_drv.h b/bsd-core/nouveau_drv.h
new file mode 120000
index 00000000..8852e264
--- /dev/null
+++ b/bsd-core/nouveau_drv.h
@@ -0,0 +1 @@
+../shared-core/nouveau_drv.h \ No newline at end of file
diff --git a/bsd-core/nouveau_fifo.c b/bsd-core/nouveau_fifo.c
new file mode 120000
index 00000000..60759a57
--- /dev/null
+++ b/bsd-core/nouveau_fifo.c
@@ -0,0 +1 @@
+../shared-core/nouveau_fifo.c \ No newline at end of file
diff --git a/bsd-core/nouveau_irq.c b/bsd-core/nouveau_irq.c
new file mode 120000
index 00000000..3137b813
--- /dev/null
+++ b/bsd-core/nouveau_irq.c
@@ -0,0 +1 @@
+../shared-core/nouveau_irq.c \ No newline at end of file
diff --git a/bsd-core/nouveau_mem.c b/bsd-core/nouveau_mem.c
new file mode 120000
index 00000000..a0085200
--- /dev/null
+++ b/bsd-core/nouveau_mem.c
@@ -0,0 +1 @@
+../shared-core/nouveau_mem.c \ No newline at end of file
diff --git a/bsd-core/nouveau_notifier.c b/bsd-core/nouveau_notifier.c
new file mode 120000
index 00000000..285469c5
--- /dev/null
+++ b/bsd-core/nouveau_notifier.c
@@ -0,0 +1 @@
+../shared-core/nouveau_notifier.c \ No newline at end of file
diff --git a/bsd-core/nouveau_object.c b/bsd-core/nouveau_object.c
new file mode 120000
index 00000000..1c1426e3
--- /dev/null
+++ b/bsd-core/nouveau_object.c
@@ -0,0 +1 @@
+../shared-core/nouveau_object.c \ No newline at end of file
diff --git a/bsd-core/nouveau_reg.h b/bsd-core/nouveau_reg.h
new file mode 120000
index 00000000..2ad07397
--- /dev/null
+++ b/bsd-core/nouveau_reg.h
@@ -0,0 +1 @@
+../shared-core/nouveau_reg.h \ No newline at end of file
diff --git a/bsd-core/nouveau_sgdma.c b/bsd-core/nouveau_sgdma.c
new file mode 100644
index 00000000..99f854fe
--- /dev/null
+++ b/bsd-core/nouveau_sgdma.c
@@ -0,0 +1,357 @@
+#include "drmP.h"
+#include "nouveau_drv.h"
+
+#define NV_CTXDMA_PAGE_SHIFT 12
+#define NV_CTXDMA_PAGE_SIZE (1 << NV_CTXDMA_PAGE_SHIFT)
+#define NV_CTXDMA_PAGE_MASK (NV_CTXDMA_PAGE_SIZE - 1)
+
+#if 0
+struct nouveau_sgdma_be {
+ struct drm_ttm_backend backend;
+ struct drm_device *dev;
+
+ int pages;
+ int pages_populated;
+ dma_addr_t *pagelist;
+ int is_bound;
+
+ unsigned int pte_start;
+};
+
+static int
+nouveau_sgdma_needs_ub_cache_adjust(struct drm_ttm_backend *be)
+{
+ return ((be->flags & DRM_BE_FLAG_BOUND_CACHED) ? 0 : 1);
+}
+
+static int
+nouveau_sgdma_populate(struct drm_ttm_backend *be, unsigned long num_pages,
+ struct page **pages, struct page *dummy_read_page)
+{
+ struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)be;
+ int p, d, o;
+
+ DRM_DEBUG("num_pages = %ld\n", num_pages);
+
+ if (nvbe->pagelist)
+ return -EINVAL;
+ nvbe->pages = (num_pages << PAGE_SHIFT) >> NV_CTXDMA_PAGE_SHIFT;
+ nvbe->pagelist = drm_alloc(nvbe->pages*sizeof(dma_addr_t),
+ DRM_MEM_PAGES);
+
+ nvbe->pages_populated = d = 0;
+ for (p = 0; p < num_pages; p++) {
+ for (o = 0; o < PAGE_SIZE; o += NV_CTXDMA_PAGE_SIZE) {
+ struct page *page = pages[p];
+ if (!page)
+ page = dummy_read_page;
+#ifdef __linux__
+ nvbe->pagelist[d] = pci_map_page(nvbe->dev->pdev,
+ page, o,
+ NV_CTXDMA_PAGE_SIZE,
+ PCI_DMA_BIDIRECTIONAL);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
+ if (pci_dma_mapping_error(nvbe->dev->pdev, nvbe->pagelist[d])) {
+#else
+ if (pci_dma_mapping_error(nvbe->pagelist[d])) {
+#endif
+ be->func->clear(be);
+ DRM_ERROR("pci_map_page failed\n");
+ return -EINVAL;
+ }
+#endif
+ nvbe->pages_populated = ++d;
+ }
+ }
+
+ return 0;
+}
+
+static void
+nouveau_sgdma_clear(struct drm_ttm_backend *be)
+{
+ struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)be;
+#ifdef __linux__
+ int d;
+#endif
+ DRM_DEBUG("\n");
+
+ if (nvbe && nvbe->pagelist) {
+ if (nvbe->is_bound)
+ be->func->unbind(be);
+#ifdef __linux__
+ for (d = 0; d < nvbe->pages_populated; d++) {
+ pci_unmap_page(nvbe->dev->pdev, nvbe->pagelist[d],
+ NV_CTXDMA_PAGE_SIZE,
+ PCI_DMA_BIDIRECTIONAL);
+ }
+#endif
+ drm_free(nvbe->pagelist, nvbe->pages*sizeof(dma_addr_t),
+ DRM_MEM_PAGES);
+ }
+}
+
+static int
+nouveau_sgdma_bind(struct drm_ttm_backend *be, struct drm_bo_mem_reg *mem)
+{
+ struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)be;
+ struct drm_nouveau_private *dev_priv = nvbe->dev->dev_private;
+ struct nouveau_gpuobj *gpuobj = dev_priv->gart_info.sg_ctxdma;
+ uint64_t offset = (mem->mm_node->start << PAGE_SHIFT);
+ uint32_t i;
+
+ DRM_DEBUG("pg=0x%lx (0x%llx), cached=%d\n", mem->mm_node->start,
+ (unsigned long long)offset,
+ (mem->flags & DRM_BO_FLAG_CACHED) == 1);
+
+ if (offset & NV_CTXDMA_PAGE_MASK)
+ return -EINVAL;
+ nvbe->pte_start = (offset >> NV_CTXDMA_PAGE_SHIFT);
+ if (dev_priv->card_type < NV_50)
+ nvbe->pte_start += 2; /* skip ctxdma header */
+
+ for (i = nvbe->pte_start; i < nvbe->pte_start + nvbe->pages; i++) {
+ uint64_t pteval = nvbe->pagelist[i - nvbe->pte_start];
+
+ if (pteval & NV_CTXDMA_PAGE_MASK) {
+ DRM_ERROR("Bad pteval 0x%llx\n",
+ (unsigned long long)pteval);
+ return -EINVAL;
+ }
+
+ if (dev_priv->card_type < NV_50) {
+ INSTANCE_WR(gpuobj, i, pteval | 3);
+ } else {
+ INSTANCE_WR(gpuobj, (i<<1)+0, pteval | 0x21);
+ INSTANCE_WR(gpuobj, (i<<1)+1, 0x00000000);
+ }
+ }
+
+ nvbe->is_bound = 1;
+ return 0;
+}
+
+static int
+nouveau_sgdma_unbind(struct drm_ttm_backend *be)
+{
+ struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)be;
+ struct drm_nouveau_private *dev_priv = nvbe->dev->dev_private;
+
+ DRM_DEBUG("\n");
+
+ if (nvbe->is_bound) {
+ struct nouveau_gpuobj *gpuobj = dev_priv->gart_info.sg_ctxdma;
+ unsigned int pte;
+
+ pte = nvbe->pte_start;
+ while (pte < (nvbe->pte_start + nvbe->pages)) {
+ uint64_t pteval = dev_priv->gart_info.sg_dummy_bus;
+
+ if (dev_priv->card_type < NV_50) {
+ INSTANCE_WR(gpuobj, pte, pteval | 3);
+ } else {
+ INSTANCE_WR(gpuobj, (pte<<1)+0, pteval | 0x21);
+ INSTANCE_WR(gpuobj, (pte<<1)+1, 0x00000000);
+ }
+
+ pte++;
+ }
+
+ nvbe->is_bound = 0;
+ }
+
+ return 0;
+}
+
+static void
+nouveau_sgdma_destroy(struct drm_ttm_backend *be)
+{
+ DRM_DEBUG("\n");
+ if (be) {
+ struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)be;
+ if (nvbe) {
+ if (nvbe->pagelist)
+ be->func->clear(be);
+ drm_ctl_free(nvbe, sizeof(*nvbe), DRM_MEM_TTM);
+ }
+ }
+}
+
+static struct drm_ttm_backend_func nouveau_sgdma_backend = {
+ .needs_ub_cache_adjust = nouveau_sgdma_needs_ub_cache_adjust,
+ .populate = nouveau_sgdma_populate,
+ .clear = nouveau_sgdma_clear,
+ .bind = nouveau_sgdma_bind,
+ .unbind = nouveau_sgdma_unbind,
+ .destroy = nouveau_sgdma_destroy
+};
+
+struct drm_ttm_backend *
+nouveau_sgdma_init_ttm(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_sgdma_be *nvbe;
+
+ if (!dev_priv->gart_info.sg_ctxdma)
+ return NULL;
+
+ nvbe = drm_ctl_calloc(1, sizeof(*nvbe), DRM_MEM_TTM);
+ if (!nvbe)
+ return NULL;
+
+ nvbe->dev = dev;
+
+ nvbe->backend.func = &nouveau_sgdma_backend;
+
+ return &nvbe->backend;
+}
+#endif
+
+int
+nouveau_sgdma_init(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_gpuobj *gpuobj = NULL;
+ uint32_t aper_size, obj_size;
+ int i, ret;
+
+ if (dev_priv->card_type < NV_50) {
+ aper_size = (64 * 1024 * 1024);
+ obj_size = (aper_size >> NV_CTXDMA_PAGE_SHIFT) * 4;
+ obj_size += 8; /* ctxdma header */
+ } else {
+ /* 1 entire VM page table */
+ aper_size = (512 * 1024 * 1024);
+ obj_size = (aper_size >> NV_CTXDMA_PAGE_SHIFT) * 8;
+ }
+
+ if ((ret = nouveau_gpuobj_new(dev, NULL, obj_size, 16,
+ NVOBJ_FLAG_ALLOW_NO_REFS |
+ NVOBJ_FLAG_ZERO_ALLOC |
+ NVOBJ_FLAG_ZERO_FREE, &gpuobj))) {
+ DRM_ERROR("Error creating sgdma object: %d\n", ret);
+ return ret;
+ }
+#ifdef __linux__
+ dev_priv->gart_info.sg_dummy_page =
+ alloc_page(GFP_KERNEL|__GFP_DMA32);
+ set_page_locked(dev_priv->gart_info.sg_dummy_page);
+ dev_priv->gart_info.sg_dummy_bus =
+ pci_map_page(dev->pdev, dev_priv->gart_info.sg_dummy_page, 0,
+ PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
+#endif
+ if (dev_priv->card_type < NV_50) {
+ /* Maybe use NV_DMA_TARGET_AGP for PCIE? NVIDIA do this, and
+ * confirmed to work on c51. Perhaps means NV_DMA_TARGET_PCIE
+ * on those cards? */
+ INSTANCE_WR(gpuobj, 0, NV_CLASS_DMA_IN_MEMORY |
+ (1 << 12) /* PT present */ |
+ (0 << 13) /* PT *not* linear */ |
+ (NV_DMA_ACCESS_RW << 14) |
+ (NV_DMA_TARGET_PCI << 16));
+ INSTANCE_WR(gpuobj, 1, aper_size - 1);
+ for (i=2; i<2+(aper_size>>12); i++) {
+ INSTANCE_WR(gpuobj, i,
+ dev_priv->gart_info.sg_dummy_bus | 3);
+ }
+ } else {
+ for (i=0; i<obj_size; i+=8) {
+ INSTANCE_WR(gpuobj, (i+0)/4,
+ dev_priv->gart_info.sg_dummy_bus | 0x21);
+ INSTANCE_WR(gpuobj, (i+4)/4, 0);
+ }
+ }
+
+ dev_priv->gart_info.type = NOUVEAU_GART_SGDMA;
+ dev_priv->gart_info.aper_base = 0;
+ dev_priv->gart_info.aper_size = aper_size;
+ dev_priv->gart_info.sg_ctxdma = gpuobj;
+ return 0;
+}
+
+void
+nouveau_sgdma_takedown(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+ if (dev_priv->gart_info.sg_dummy_page) {
+#ifdef __linux__
+ pci_unmap_page(dev->pdev, dev_priv->gart_info.sg_dummy_bus,
+ NV_CTXDMA_PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
+ unlock_page(dev_priv->gart_info.sg_dummy_page);
+ __free_page(dev_priv->gart_info.sg_dummy_page);
+#endif
+ dev_priv->gart_info.sg_dummy_page = NULL;
+ dev_priv->gart_info.sg_dummy_bus = 0;
+ }
+
+ nouveau_gpuobj_del(dev, &dev_priv->gart_info.sg_ctxdma);
+}
+
+#if 0
+int
+nouveau_sgdma_nottm_hack_init(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct drm_ttm_backend *be;
+ struct drm_scatter_gather sgreq;
+ struct drm_mm_node mm_node;
+ struct drm_bo_mem_reg mem;
+ int ret;
+
+ dev_priv->gart_info.sg_be = nouveau_sgdma_init_ttm(dev);
+ if (!dev_priv->gart_info.sg_be)
+ return -ENOMEM;
+ be = dev_priv->gart_info.sg_be;
+
+ /* Hack the aperture size down to the amount of system memory
+ * we're going to bind into it.
+ */
+ if (dev_priv->gart_info.aper_size > 32*1024*1024)
+ dev_priv->gart_info.aper_size = 32*1024*1024;
+
+ sgreq.size = dev_priv->gart_info.aper_size;
+ if ((ret = drm_sg_alloc(dev, &sgreq))) {
+ DRM_ERROR("drm_sg_alloc failed: %d\n", ret);
+ return ret;
+ }
+ dev_priv->gart_info.sg_handle = sgreq.handle;
+
+ if ((ret = be->func->populate(be, dev->sg->pages, dev->sg->pagelist, dev->bm.dummy_read_page))) {
+ DRM_ERROR("failed populate: %d\n", ret);
+ return ret;
+ }
+
+ mm_node.start = 0;
+ mem.mm_node = &mm_node;
+
+ if ((ret = be->func->bind(be, &mem))) {
+ DRM_ERROR("failed bind: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+void
+nouveau_sgdma_nottm_hack_takedown(struct drm_device *dev)
+{
+}
+#endif
+
+int
+nouveau_sgdma_get_page(struct drm_device *dev, uint32_t offset, uint32_t *page)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_gpuobj *gpuobj = dev_priv->gart_info.sg_ctxdma;
+ int pte;
+
+ pte = (offset >> NV_CTXDMA_PAGE_SHIFT);
+ if (dev_priv->card_type < NV_50) {
+ *page = INSTANCE_RD(gpuobj, (pte + 2)) & ~NV_CTXDMA_PAGE_MASK;
+ return 0;
+ }
+
+ DRM_ERROR("Unimplemented on NV50\n");
+ return -EINVAL;
+}
diff --git a/bsd-core/nouveau_state.c b/bsd-core/nouveau_state.c
new file mode 120000
index 00000000..b304f6bb
--- /dev/null
+++ b/bsd-core/nouveau_state.c
@@ -0,0 +1 @@
+../shared-core/nouveau_state.c \ No newline at end of file
diff --git a/bsd-core/nouveau_swmthd.c b/bsd-core/nouveau_swmthd.c
new file mode 120000
index 00000000..c5390801
--- /dev/null
+++ b/bsd-core/nouveau_swmthd.c
@@ -0,0 +1 @@
+../shared-core/nouveau_swmthd.c \ No newline at end of file
diff --git a/bsd-core/nouveau_swmthd.h b/bsd-core/nouveau_swmthd.h
new file mode 120000
index 00000000..33425dcd
--- /dev/null
+++ b/bsd-core/nouveau_swmthd.h
@@ -0,0 +1 @@
+../shared-core/nouveau_swmthd.h \ No newline at end of file
diff --git a/bsd-core/nv04_fb.c b/bsd-core/nv04_fb.c
new file mode 120000
index 00000000..867e2007
--- /dev/null
+++ b/bsd-core/nv04_fb.c
@@ -0,0 +1 @@
+../shared-core/nv04_fb.c \ No newline at end of file
diff --git a/bsd-core/nv04_fifo.c b/bsd-core/nv04_fifo.c
new file mode 120000
index 00000000..d10beb19
--- /dev/null
+++ b/bsd-core/nv04_fifo.c
@@ -0,0 +1 @@
+../shared-core/nv04_fifo.c \ No newline at end of file
diff --git a/bsd-core/nv04_graph.c b/bsd-core/nv04_graph.c
new file mode 120000
index 00000000..0d7a0b35
--- /dev/null
+++ b/bsd-core/nv04_graph.c
@@ -0,0 +1 @@
+../shared-core/nv04_graph.c \ No newline at end of file
diff --git a/bsd-core/nv04_instmem.c b/bsd-core/nv04_instmem.c
new file mode 120000
index 00000000..e720fb5b
--- /dev/null
+++ b/bsd-core/nv04_instmem.c
@@ -0,0 +1 @@
+../shared-core/nv04_instmem.c \ No newline at end of file
diff --git a/bsd-core/nv04_mc.c b/bsd-core/nv04_mc.c
new file mode 120000
index 00000000..32e91825
--- /dev/null
+++ b/bsd-core/nv04_mc.c
@@ -0,0 +1 @@
+../shared-core/nv04_mc.c \ No newline at end of file
diff --git a/bsd-core/nv04_timer.c b/bsd-core/nv04_timer.c
new file mode 120000
index 00000000..11108b2b
--- /dev/null
+++ b/bsd-core/nv04_timer.c
@@ -0,0 +1 @@
+../shared-core/nv04_timer.c \ No newline at end of file
diff --git a/bsd-core/nv10_fb.c b/bsd-core/nv10_fb.c
new file mode 120000
index 00000000..f858c7c6
--- /dev/null
+++ b/bsd-core/nv10_fb.c
@@ -0,0 +1 @@
+../shared-core/nv10_fb.c \ No newline at end of file
diff --git a/bsd-core/nv10_fifo.c b/bsd-core/nv10_fifo.c
new file mode 120000
index 00000000..8630ad04
--- /dev/null
+++ b/bsd-core/nv10_fifo.c
@@ -0,0 +1 @@
+../shared-core/nv10_fifo.c \ No newline at end of file
diff --git a/bsd-core/nv10_graph.c b/bsd-core/nv10_graph.c
new file mode 120000
index 00000000..0d5a0eb4
--- /dev/null
+++ b/bsd-core/nv10_graph.c
@@ -0,0 +1 @@
+../shared-core/nv10_graph.c \ No newline at end of file
diff --git a/bsd-core/nv20_graph.c b/bsd-core/nv20_graph.c
new file mode 120000
index 00000000..73049914
--- /dev/null
+++ b/bsd-core/nv20_graph.c
@@ -0,0 +1 @@
+../shared-core/nv20_graph.c \ No newline at end of file
diff --git a/bsd-core/nv40_fb.c b/bsd-core/nv40_fb.c
new file mode 120000
index 00000000..4a816b13
--- /dev/null
+++ b/bsd-core/nv40_fb.c
@@ -0,0 +1 @@
+../shared-core/nv40_fb.c \ No newline at end of file
diff --git a/bsd-core/nv40_fifo.c b/bsd-core/nv40_fifo.c
new file mode 120000
index 00000000..cc71e7a4
--- /dev/null
+++ b/bsd-core/nv40_fifo.c
@@ -0,0 +1 @@
+../shared-core/nv40_fifo.c \ No newline at end of file
diff --git a/bsd-core/nv40_graph.c b/bsd-core/nv40_graph.c
new file mode 120000
index 00000000..2fe59919
--- /dev/null
+++ b/bsd-core/nv40_graph.c
@@ -0,0 +1 @@
+../shared-core/nv40_graph.c \ No newline at end of file
diff --git a/bsd-core/nv40_mc.c b/bsd-core/nv40_mc.c
new file mode 120000
index 00000000..fff26494
--- /dev/null
+++ b/bsd-core/nv40_mc.c
@@ -0,0 +1 @@
+../shared-core/nv40_mc.c \ No newline at end of file
diff --git a/bsd-core/nv50_fifo.c b/bsd-core/nv50_fifo.c
new file mode 120000
index 00000000..4c9990a9
--- /dev/null
+++ b/bsd-core/nv50_fifo.c
@@ -0,0 +1 @@
+../shared-core/nv50_fifo.c \ No newline at end of file
diff --git a/bsd-core/nv50_graph.c b/bsd-core/nv50_graph.c
new file mode 120000
index 00000000..03f69e68
--- /dev/null
+++ b/bsd-core/nv50_graph.c
@@ -0,0 +1 @@
+../shared-core/nv50_graph.c \ No newline at end of file
diff --git a/bsd-core/nv50_grctx.h b/bsd-core/nv50_grctx.h
new file mode 120000
index 00000000..d40b9a86
--- /dev/null
+++ b/bsd-core/nv50_grctx.h
@@ -0,0 +1 @@
+../shared-core/nv50_grctx.h \ No newline at end of file
diff --git a/bsd-core/nv50_instmem.c b/bsd-core/nv50_instmem.c
new file mode 120000
index 00000000..4e45344a
--- /dev/null
+++ b/bsd-core/nv50_instmem.c
@@ -0,0 +1 @@
+../shared-core/nv50_instmem.c \ No newline at end of file
diff --git a/bsd-core/nv50_mc.c b/bsd-core/nv50_mc.c
new file mode 120000
index 00000000..f4bb369e
--- /dev/null
+++ b/bsd-core/nv50_mc.c
@@ -0,0 +1 @@
+../shared-core/nv50_mc.c \ No newline at end of file