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 #ifndef _GFX_PRIVATE_H 27 #define _GFX_PRIVATE_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 /* Memory cache attributes */ 36 #define GFXP_MEMORY_CACHED 0 37 #define GFXP_MEMORY_UNCACHED 1 38 #define GFXP_MEMORY_WRITECOMBINED 2 39 40 typedef uint64_t gfx_maddr_t; 41 42 extern int gfxp_ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, 43 caddr_t *addrp, off_t len, uint_t prot, uint_t maxprot, uint_t flags, 44 cred_t *cred, ddi_device_acc_attr_t *accattrp, uint_t rnumber); 45 46 extern ddi_umem_cookie_t gfxp_umem_cookie_init(caddr_t kva, size_t size); 47 extern void gfxp_umem_cookie_destroy(ddi_umem_cookie_t cookie); 48 extern int gfxp_devmap_umem_setup(devmap_cookie_t dhc, dev_info_t *dip, 49 struct devmap_callback_ctl *callbackops, ddi_umem_cookie_t cookie, 50 offset_t off, size_t len, uint_t maxprot, uint_t flags, 51 ddi_device_acc_attr_t *accattrp); 52 extern void gfxp_map_devmem(devmap_cookie_t dhc, gfx_maddr_t maddr, 53 size_t length, ddi_device_acc_attr_t *attrp); 54 55 56 typedef char *gfxp_acc_handle_t; 57 extern gfxp_acc_handle_t gfxp_pci_init_handle(uint8_t bus, uint8_t slot, 58 uint8_t function, uint16_t *vendor, uint16_t *device); 59 extern uint8_t gfxp_pci_read_byte(gfxp_acc_handle_t handle, uint16_t offset); 60 extern uint16_t gfxp_pci_read_word(gfxp_acc_handle_t handle, uint16_t offset); 61 extern uint32_t gfxp_pci_read_dword(gfxp_acc_handle_t handle, uint16_t offset); 62 extern void gfxp_pci_write_byte(gfxp_acc_handle_t handle, uint16_t offset, 63 uint8_t value); 64 extern void gfxp_pci_write_word(gfxp_acc_handle_t handle, uint16_t offset, 65 uint16_t value); 66 extern void gfxp_pci_write_dword(gfxp_acc_handle_t handle, uint16_t offset, 67 uint32_t value); 68 extern int gfxp_pci_device_present(uint16_t vendor, uint16_t device); 69 70 typedef char *gfxp_kva_t; 71 extern gfxp_kva_t gfxp_map_kernel_space(uint64_t start, size_t size, 72 uint32_t mode); 73 extern void gfxp_unmap_kernel_space(gfxp_kva_t address, size_t size); 74 extern int gfxp_va2pa(struct as *as, caddr_t addr, uint64_t *pa); 75 extern void gfxp_fix_mem_cache_attrs(caddr_t kva_start, size_t length, 76 int cache_attr); 77 extern gfx_maddr_t gfxp_convert_addr(paddr_t paddr); 78 79 typedef char *gfxp_vgatext_softc_ptr_t; 80 81 extern gfxp_vgatext_softc_ptr_t gfxp_vgatext_softc_alloc(void); 82 extern void gfxp_vgatext_softc_free(gfxp_vgatext_softc_ptr_t ptr); 83 extern int gfxp_vgatext_attach(dev_info_t *devi, ddi_attach_cmd_t cmd, 84 gfxp_vgatext_softc_ptr_t ptr); 85 extern int gfxp_vgatext_detach(dev_info_t *devi, ddi_detach_cmd_t cmd, 86 gfxp_vgatext_softc_ptr_t ptr); 87 extern int gfxp_vgatext_open(dev_t *devp, int flag, int otyp, cred_t *cred, 88 gfxp_vgatext_softc_ptr_t ptr); 89 extern int gfxp_vgatext_close(dev_t devp, int flag, int otyp, cred_t *cred, 90 gfxp_vgatext_softc_ptr_t ptr); 91 extern int gfxp_vgatext_ioctl(dev_t dev, int cmd, intptr_t data, int mode, 92 cred_t *cred, int *rval, gfxp_vgatext_softc_ptr_t ptr); 93 94 extern int gfxp_mlock_user_memory(caddr_t address, size_t length); 95 extern int gfxp_munlock_user_memory(caddr_t address, size_t length); 96 extern int gfxp_vgatext_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, 97 size_t len, size_t *maplen, uint_t model, void *ptr); 98 99 #ifdef __cplusplus 100 } 101 #endif 102 103 #endif /* _GFX_PRIVATE_H */ 104