summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/sys/gfx_private.h64
-rw-r--r--usr/src/uts/i86pc/io/gfx_private/gfxp_vgatext.c51
-rw-r--r--usr/src/uts/i86pc/io/gfx_private/gfxp_vm.c140
3 files changed, 255 insertions, 0 deletions
diff --git a/usr/src/uts/common/sys/gfx_private.h b/usr/src/uts/common/sys/gfx_private.h
index cf48724926..ddd91e5758 100644
--- a/usr/src/uts/common/sys/gfx_private.h
+++ b/usr/src/uts/common/sys/gfx_private.h
@@ -23,6 +23,13 @@
* Use is subject to license terms.
*/
+/*
+ * This file defines interfaces consumed by the AGP kernel modules,
+ * and indirectly by the DRM system. Please consider everything in
+ * this file to be a "contract private interface", and keep in sync
+ * with the consumers in the "DRM" gate.
+ */
+
#ifndef _GFX_PRIVATE_H
#define _GFX_PRIVATE_H
@@ -94,6 +101,63 @@ extern int gfxp_munlock_user_memory(caddr_t address, size_t length);
extern int gfxp_vgatext_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off,
size_t len, size_t *maplen, uint_t model, void *ptr);
+
+/*
+ * Updated "glue" for newer libdrm code.
+ * See: kernel/drm/src/drm_fb_helper.c
+ */
+
+/* Same as: gfxp_vgatext_softc_ptr_t; */
+typedef char *gfxp_fb_softc_ptr_t;
+
+/*
+ * Used by drm_register_fbops().
+ * Note: only setmode is supplied.
+ */
+struct gfxp_blt_ops {
+ int (*blt)(void *);
+ int (*copy) (void *);
+ int (*clear) (void *);
+ int (*setmode) (int);
+};
+
+extern void gfxp_bm_register_fbops(gfxp_fb_softc_ptr_t,
+ struct gfxp_blt_ops *);
+
+/* See: kernel/drm/src/drm_fb_helper.c */
+
+struct gfxp_bm_fb_info {
+ uint16_t xres;
+ uint16_t yres;
+ uint8_t bpp;
+ uint8_t depth;
+};
+
+void gfxp_bm_getfb_info(gfxp_fb_softc_ptr_t, struct gfxp_bm_fb_info *);
+
+/* See: kernel/drm/src/drm_bufs.c etc */
+
+caddr_t gfxp_alloc_kernel_space(size_t size); /* vmem_alloc heap_arena */
+void gfxp_free_kernel_space(caddr_t address, size_t size);
+
+void gfxp_load_kernel_space(uint64_t start, size_t size,
+ uint32_t mode, caddr_t cvaddr);
+void gfxp_unload_kernel_space(caddr_t address, size_t size);
+
+/*
+ * Note that "mempool" is optional and normally disabled in drm_gem.c
+ * (see HAS_MEM_POOL). Let's just stub these out so we can reduce
+ * changes from the upstream in the DRM driver code.
+ */
+struct gfxp_pmem_cookie {
+ ulong_t a, b, c;
+};
+void gfxp_mempool_init(void);
+void gfxp_mempool_destroy(void);
+int gfxp_alloc_from_mempool(struct gfxp_pmem_cookie *, caddr_t *,
+ pfn_t *, pgcnt_t, int);
+void gfxp_free_mempool(struct gfxp_pmem_cookie *, caddr_t, size_t);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/i86pc/io/gfx_private/gfxp_vgatext.c b/usr/src/uts/i86pc/io/gfx_private/gfxp_vgatext.c
index 9b7badd5f2..c445062abd 100644
--- a/usr/src/uts/i86pc/io/gfx_private/gfxp_vgatext.c
+++ b/usr/src/uts/i86pc/io/gfx_private/gfxp_vgatext.c
@@ -1386,3 +1386,54 @@ vgatext_return_pointers(struct vgatext_softc *softc, struct vgaregmap *fbs,
regss->handle = softc->regs.handle;
regss->mapped = softc->regs.mapped;
}
+
+
+/*
+ * ****************************************************************
+ * If we had a "bitmap" console implementation, it could
+ * use the functions below to cooperate with DRM.
+ */
+
+
+/*
+ * If we had "bitmap" console support, this would
+ * register call-back functions: drm_gfxp_setmode,
+ * (and maybe others for blt, copy, clear) for the
+ * "bitmap" console to use.
+ *
+ * The current (text) console doesn't need it.
+ */
+/* ARGSUSED */
+void
+gfxp_bm_register_fbops(gfxp_fb_softc_ptr_t softc,
+ struct gfxp_blt_ops *ops)
+{
+}
+
+/*
+ * This is patchable with mdb, i.e.:
+ * $ mdb -w /platform/i86pc/kernel/misc/amd64/gfx_private
+ * > gfxp_fb_info?ddVV
+ * 1024 768 32 24
+ */
+struct gfxp_bm_fb_info gfxp_fb_info = {
+ .xres = 1024,
+ .yres = 768,
+ .bpp = 32,
+ .depth = 24,
+};
+
+/*
+ * If we had "bitmap" console support, this would
+ * ask the size of it. (how is TBD)
+ *
+ * Just guess (for now)
+ */
+void
+gfxp_bm_getfb_info(gfxp_fb_softc_ptr_t softc,
+ struct gfxp_bm_fb_info *fbip)
+{
+ _NOTE(ARGUNUSED(softc))
+
+ *fbip = gfxp_fb_info;
+}
diff --git a/usr/src/uts/i86pc/io/gfx_private/gfxp_vm.c b/usr/src/uts/i86pc/io/gfx_private/gfxp_vm.c
index 247e5cf555..4934de54e6 100644
--- a/usr/src/uts/i86pc/io/gfx_private/gfxp_vm.c
+++ b/usr/src/uts/i86pc/io/gfx_private/gfxp_vm.c
@@ -254,3 +254,143 @@ gfxp_convert_addr(paddr_t paddr)
return ((gfx_maddr_t)paddr);
#endif
}
+
+/*
+ * Support getting VA space separately from pages
+ */
+
+/*
+ * A little like gfxp_map_kernel_space, but
+ * just the vmem_alloc part.
+ */
+caddr_t
+gfxp_alloc_kernel_space(size_t size)
+{
+ caddr_t cvaddr;
+ pgcnt_t npages;
+
+ npages = btopr(size);
+ cvaddr = vmem_alloc(heap_arena, ptob(npages), VM_NOSLEEP);
+ return (cvaddr);
+}
+
+/*
+ * Like gfxp_unmap_kernel_space, but
+ * just the vmem_free part.
+ */
+void
+gfxp_free_kernel_space(caddr_t address, size_t size)
+{
+
+ uint_t pgoffset;
+ caddr_t base;
+ pgcnt_t npages;
+
+ if (size == 0 || address == NULL)
+ return;
+
+ pgoffset = (uintptr_t)address & PAGEOFFSET;
+ base = (caddr_t)address - pgoffset;
+ npages = btopr(size + pgoffset);
+ vmem_free(heap_arena, base, ptob(npages));
+}
+
+/*
+ * Like gfxp_map_kernel_space, but
+ * just the hat_devload part.
+ */
+void
+gfxp_load_kernel_space(uint64_t start, size_t size,
+ uint32_t mode, caddr_t cvaddr)
+{
+ uint_t pgoffset;
+ uint64_t base;
+ pgcnt_t npages;
+ int hat_flags;
+ uint_t hat_attr;
+ pfn_t pfn;
+
+ if (size == 0)
+ return;
+
+#ifdef __xpv
+ /*
+ * The hypervisor doesn't allow r/w mappings to some pages, such as
+ * page tables, gdt, etc. Detect %cr3 to notify users of this interface.
+ */
+ if (start == mmu_ptob(mmu_btop(getcr3())))
+ return;
+#endif
+
+ if (mode == GFXP_MEMORY_CACHED)
+ hat_attr = HAT_STORECACHING_OK;
+ else if (mode == GFXP_MEMORY_WRITECOMBINED)
+ hat_attr = HAT_MERGING_OK | HAT_PLAT_NOCACHE;
+ else /* GFXP_MEMORY_UNCACHED */
+ hat_attr = HAT_STRICTORDER | HAT_PLAT_NOCACHE;
+ hat_flags = HAT_LOAD_LOCK;
+
+ pgoffset = start & PAGEOFFSET;
+ base = start - pgoffset;
+ npages = btopr(size + pgoffset);
+
+#ifdef __xpv
+ ASSERT(DOMAIN_IS_INITDOMAIN(xen_info));
+ pfn = xen_assign_pfn(mmu_btop(base));
+#else
+ pfn = btop(base);
+#endif
+
+ hat_devload(kas.a_hat, cvaddr, ptob(npages), pfn,
+ PROT_READ|PROT_WRITE|hat_attr, hat_flags);
+}
+
+/*
+ * Like gfxp_unmap_kernel_space, but
+ * just the had_unload part.
+ */
+void
+gfxp_unload_kernel_space(caddr_t address, size_t size)
+{
+ uint_t pgoffset;
+ caddr_t base;
+ pgcnt_t npages;
+
+ if (size == 0 || address == NULL)
+ return;
+
+ pgoffset = (uintptr_t)address & PAGEOFFSET;
+ base = (caddr_t)address - pgoffset;
+ npages = btopr(size + pgoffset);
+ hat_unload(kas.a_hat, base, ptob(npages), HAT_UNLOAD_UNLOCK);
+}
+
+/*
+ * Note that "mempool" is optional and normally disabled in drm_gem.c
+ * (see HAS_MEM_POOL). Let's just stub these out so we can reduce
+ * changes from the upstream in the DRM driver code.
+ */
+
+void
+gfxp_mempool_init(void)
+{
+}
+
+void
+gfxp_mempool_destroy(void)
+{
+}
+
+/* ARGSUSED */
+int
+gfxp_alloc_from_mempool(struct gfxp_pmem_cookie *cookie, caddr_t *kva,
+ pfn_t *pgarray, pgcnt_t alen, int flags)
+{
+ return (-1);
+}
+
+/* ARGSUSED */
+void
+gfxp_free_mempool(struct gfxp_pmem_cookie *cookie, caddr_t kva, size_t len)
+{
+}