/* Copyright (c) 2002,2007-2011, Code Aurora Forum. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Code Aurora Forum, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef __KGSL_SHAREDMEM_H #define __KGSL_SHAREDMEM_H #include struct kgsl_pagetable; struct kgsl_device; struct kgsl_process_private; #define KGSL_CACHE_OP_INV 0x01 #define KGSL_CACHE_OP_FLUSH 0x02 #define KGSL_CACHE_OP_CLEAN 0x03 /** Set if the memdesc describes cached memory */ #define KGSL_MEMFLAGS_CACHED 0x00000001 struct kgsl_memdesc; struct kgsl_memdesc_ops { unsigned long (*physaddr)(struct kgsl_memdesc *, unsigned int); void (*outer_cache)(struct kgsl_memdesc *, int); int (*vmflags)(struct kgsl_memdesc *); int (*vmfault)(struct kgsl_memdesc *, struct vm_area_struct *, struct vm_fault *); void (*free)(struct kgsl_memdesc *memdesc); }; /* shared memory allocation */ struct kgsl_memdesc { struct kgsl_pagetable *pagetable; void *hostptr; unsigned int gpuaddr; unsigned int physaddr; unsigned int size; unsigned int priv; struct kgsl_memdesc_ops *ops; }; extern struct kgsl_memdesc_ops kgsl_vmalloc_ops; extern struct kgsl_memdesc_ops kgsl_contig_ops; extern struct kgsl_memdesc_ops kgsl_userptr_ops; int kgsl_sharedmem_vmalloc(struct kgsl_memdesc *memdesc, struct kgsl_pagetable *pagetable, size_t size); int kgsl_sharedmem_vmalloc_user(struct kgsl_memdesc *memdesc, struct kgsl_pagetable *pagetable, size_t size, int flags); int kgsl_sharedmem_alloc_coherent(struct kgsl_memdesc *memdesc, size_t size); void kgsl_sharedmem_free(struct kgsl_memdesc *memdesc); int kgsl_sharedmem_readl(const struct kgsl_memdesc *memdesc, uint32_t *dst, unsigned int offsetbytes); int kgsl_sharedmem_writel(const struct kgsl_memdesc *memdesc, unsigned int offsetbytes, uint32_t src); int kgsl_sharedmem_set(const struct kgsl_memdesc *memdesc, unsigned int offsetbytes, unsigned int value, unsigned int sizebytes); void kgsl_cache_range_op(struct kgsl_memdesc *memdesc, int op); void kgsl_process_init_sysfs(struct kgsl_process_private *private); void kgsl_process_uninit_sysfs(struct kgsl_process_private *private); int kgsl_sharedmem_init_sysfs(void); void kgsl_sharedmem_uninit_sysfs(void); static inline int kgsl_allocate_user(struct kgsl_memdesc *memdesc, struct kgsl_pagetable *pagetable, size_t size, unsigned int flags) { return kgsl_sharedmem_vmalloc_user(memdesc, pagetable, size, flags); } static inline int kgsl_allocate_contig(struct kgsl_memdesc *memdesc, size_t size) { return kgsl_sharedmem_alloc_coherent(memdesc, size); } #endif /* __KGSL_SHAREDMEM_H */