1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* 27 * This file defines interfaces consumed by the AGP kernel modules, 28 * and indirectly by the DRM system. Please consider everything in 29 * this file to be a "contract private interface", and keep in sync 30 * with the consumers in the "DRM" gate. 31 */ 32 33 #ifndef _GFX_PRIVATE_H 34 #define _GFX_PRIVATE_H 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 41 /* 42 * Updated "glue" for newer libdrm code. 43 * See: kernel/drm/src/drm_fb_helper.c 44 */ 45 46 typedef char *gfxp_fb_softc_ptr_t; 47 48 /* Memory cache attributes */ 49 #define GFXP_MEMORY_CACHED 0 50 #define GFXP_MEMORY_UNCACHED 1 51 #define GFXP_MEMORY_WRITECOMBINED 2 52 53 typedef uint64_t gfx_maddr_t; 54 typedef char *gfxp_acc_handle_t; 55 56 extern int gfxp_ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, 57 caddr_t *addrp, off_t len, uint_t prot, uint_t maxprot, uint_t flags, 58 cred_t *cred, ddi_device_acc_attr_t *accattrp, uint_t rnumber); 59 60 extern ddi_umem_cookie_t gfxp_umem_cookie_init(caddr_t kva, size_t size); 61 extern void gfxp_umem_cookie_destroy(ddi_umem_cookie_t cookie); 62 extern int gfxp_devmap_umem_setup(devmap_cookie_t dhc, dev_info_t *dip, 63 struct devmap_callback_ctl *callbackops, ddi_umem_cookie_t cookie, 64 offset_t off, size_t len, uint_t maxprot, uint_t flags, 65 ddi_device_acc_attr_t *accattrp); 66 extern void gfxp_map_devmem(devmap_cookie_t dhc, gfx_maddr_t maddr, 67 size_t length, ddi_device_acc_attr_t *attrp); 68 69 extern gfxp_acc_handle_t gfxp_pci_init_handle(uint8_t bus, uint8_t slot, 70 uint8_t function, uint16_t *vendor, uint16_t *device); 71 extern uint8_t gfxp_pci_read_byte(gfxp_acc_handle_t handle, uint16_t offset); 72 extern uint16_t gfxp_pci_read_word(gfxp_acc_handle_t handle, uint16_t offset); 73 extern uint32_t gfxp_pci_read_dword(gfxp_acc_handle_t handle, uint16_t offset); 74 extern void gfxp_pci_write_byte(gfxp_acc_handle_t handle, uint16_t offset, 75 uint8_t value); 76 extern void gfxp_pci_write_word(gfxp_acc_handle_t handle, uint16_t offset, 77 uint16_t value); 78 extern void gfxp_pci_write_dword(gfxp_acc_handle_t handle, uint16_t offset, 79 uint32_t value); 80 extern int gfxp_pci_device_present(uint16_t vendor, uint16_t device); 81 82 typedef char *gfxp_kva_t; 83 extern gfxp_kva_t gfxp_map_kernel_space(uint64_t start, size_t size, 84 uint32_t mode); 85 extern void gfxp_unmap_kernel_space(gfxp_kva_t address, size_t size); 86 extern int gfxp_va2pa(struct as *as, caddr_t addr, uint64_t *pa); 87 extern void gfxp_fix_mem_cache_attrs(caddr_t kva_start, size_t length, 88 int cache_attr); 89 extern gfx_maddr_t gfxp_convert_addr(paddr_t paddr); 90 91 extern gfxp_fb_softc_ptr_t gfxp_fb_softc_alloc(void); 92 extern void gfxp_fb_softc_free(gfxp_fb_softc_ptr_t ptr); 93 extern int gfxp_fb_attach(dev_info_t *devi, ddi_attach_cmd_t cmd, 94 gfxp_fb_softc_ptr_t ptr); 95 extern int gfxp_fb_detach(dev_info_t *devi, ddi_detach_cmd_t cmd, 96 gfxp_fb_softc_ptr_t ptr); 97 extern int gfxp_fb_open(dev_t *devp, int flag, int otyp, cred_t *cred, 98 gfxp_fb_softc_ptr_t ptr); 99 extern int gfxp_fb_close(dev_t devp, int flag, int otyp, cred_t *cred, 100 gfxp_fb_softc_ptr_t ptr); 101 extern int gfxp_fb_ioctl(dev_t dev, int cmd, intptr_t data, int mode, 102 cred_t *cred, int *rval, gfxp_fb_softc_ptr_t ptr); 103 104 extern int gfxp_mlock_user_memory(caddr_t address, size_t length); 105 extern int gfxp_munlock_user_memory(caddr_t address, size_t length); 106 extern int gfxp_fb_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, 107 size_t len, size_t *maplen, uint_t model, void *ptr); 108 109 /* 110 * Used by drm_register_fbops(). 111 * Note: only setmode is supplied. 112 */ 113 struct gfxp_blt_ops { 114 int (*blt)(void *); 115 int (*copy) (void *); 116 int (*clear) (void *); 117 int (*setmode) (int); 118 }; 119 120 extern void gfxp_bm_register_fbops(gfxp_fb_softc_ptr_t, 121 struct gfxp_blt_ops *); 122 123 /* See: kernel/drm/src/drm_fb_helper.c */ 124 125 struct gfxp_bm_fb_info { 126 uint16_t xres; 127 uint16_t yres; 128 uint8_t bpp; 129 uint8_t depth; 130 }; 131 132 void gfxp_bm_getfb_info(gfxp_fb_softc_ptr_t, struct gfxp_bm_fb_info *); 133 134 /* See: kernel/drm/src/drm_bufs.c etc */ 135 136 caddr_t gfxp_alloc_kernel_space(size_t size); /* vmem_alloc heap_arena */ 137 void gfxp_free_kernel_space(caddr_t address, size_t size); 138 139 void gfxp_load_kernel_space(uint64_t start, size_t size, 140 uint32_t mode, caddr_t cvaddr); 141 void gfxp_unload_kernel_space(caddr_t address, size_t size); 142 143 /* 144 * Note that "mempool" is optional and normally disabled in drm_gem.c 145 * (see HAS_MEM_POOL). Let's just stub these out so we can reduce 146 * changes from the upstream in the DRM driver code. 147 */ 148 struct gfxp_pmem_cookie { 149 ulong_t a, b, c; 150 }; 151 void gfxp_mempool_init(void); 152 void gfxp_mempool_destroy(void); 153 int gfxp_alloc_from_mempool(struct gfxp_pmem_cookie *, caddr_t *, 154 pfn_t *, pgcnt_t, int); 155 void gfxp_free_mempool(struct gfxp_pmem_cookie *, caddr_t, size_t); 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif /* _GFX_PRIVATE_H */ 162