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