Rebecca Schultz | a4ff0e8 | 2008-07-24 11:22:53 -0700 | [diff] [blame^] | 1 | /* include/linux/android_pmem.h |
| 2 | * |
| 3 | * Copyright (C) 2007 Google, Inc. |
| 4 | * |
| 5 | * This software is licensed under the terms of the GNU General Public |
| 6 | * License version 2, as published by the Free Software Foundation, and |
| 7 | * may be copied, distributed, and modified under those terms. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #ifndef _ANDROID_PMEM_H_ |
| 17 | #define _ANDROID_PMEM_H_ |
| 18 | |
| 19 | #define PMEM_IOCTL_MAGIC 'p' |
| 20 | #define PMEM_GET_PHYS _IOW(PMEM_IOCTL_MAGIC, 1, unsigned int) |
| 21 | #define PMEM_MAP _IOW(PMEM_IOCTL_MAGIC, 2, unsigned int) |
| 22 | #define PMEM_GET_SIZE _IOW(PMEM_IOCTL_MAGIC, 3, unsigned int) |
| 23 | #define PMEM_UNMAP _IOW(PMEM_IOCTL_MAGIC, 4, unsigned int) |
| 24 | /* This ioctl will allocate pmem space, backing the file, it will fail |
| 25 | * if the file already has an allocation, pass it the len as the argument |
| 26 | * to the ioctl */ |
| 27 | #define PMEM_ALLOCATE _IOW(PMEM_IOCTL_MAGIC, 5, unsigned int) |
| 28 | /* This will connect a one pmem file to another, pass the file that is already |
| 29 | * backed in memory as the argument to the ioctl |
| 30 | */ |
| 31 | #define PMEM_CONNECT _IOW(PMEM_IOCTL_MAGIC, 6, unsigned int) |
| 32 | /* Returns the total size of the pmem region it is sent to as a pmem_region |
| 33 | * struct (with offset set to 0). |
| 34 | */ |
| 35 | #define PMEM_GET_TOTAL_SIZE _IOW(PMEM_IOCTL_MAGIC, 7, unsigned int) |
| 36 | #define PMEM_CACHE_FLUSH _IOW(PMEM_IOCTL_MAGIC, 8, unsigned int) |
| 37 | |
| 38 | struct android_pmem_platform_data |
| 39 | { |
| 40 | const char* name; |
| 41 | /* starting physical address of memory region */ |
| 42 | unsigned long start; |
| 43 | /* size of memory region */ |
| 44 | unsigned long size; |
| 45 | /* set to indicate the region should not be managed with an allocator */ |
| 46 | unsigned no_allocator; |
| 47 | /* set to indicate maps of this region should be cached, if a mix of |
| 48 | * cached and uncached is desired, set this and open the device with |
| 49 | * O_SYNC to get an uncached region */ |
| 50 | unsigned cached; |
| 51 | /* The MSM7k has bits to enable a write buffer in the bus controller*/ |
| 52 | unsigned buffered; |
| 53 | }; |
| 54 | |
| 55 | struct pmem_region { |
| 56 | unsigned long offset; |
| 57 | unsigned long len; |
| 58 | }; |
| 59 | |
| 60 | #ifdef CONFIG_ANDROID_PMEM |
| 61 | int is_pmem_file(struct file *file); |
| 62 | int get_pmem_file(int fd, unsigned long *start, unsigned long *vstart, |
| 63 | unsigned long *end, struct file **filp); |
| 64 | int get_pmem_user_addr(struct file *file, unsigned long *start, |
| 65 | unsigned long *end); |
| 66 | void put_pmem_file(struct file* file); |
| 67 | void flush_pmem_file(struct file *file, unsigned long start, unsigned long len); |
| 68 | int pmem_setup(struct android_pmem_platform_data *pdata, |
| 69 | long (*ioctl)(struct file *, unsigned int, unsigned long), |
| 70 | int (*release)(struct inode *, struct file *)); |
| 71 | int pmem_remap(struct pmem_region *region, struct file *file, |
| 72 | unsigned operation); |
| 73 | |
| 74 | #else |
| 75 | static inline int is_pmem_file(struct file *file) { return 0; } |
| 76 | static inline int get_pmem_file(int fd, unsigned long *start, |
| 77 | unsigned long *vstart, unsigned long *end, |
| 78 | struct file **filp) { return -ENOSYS; } |
| 79 | static inline int get_pmem_user_addr(struct file *file, unsigned long *start, |
| 80 | unsigned long *end) { return -ENOSYS; } |
| 81 | static inline void put_pmem_file(struct file* file) { return; } |
| 82 | static inline void flush_pmem_file(struct file *file, unsigned long start, |
| 83 | unsigned long len) { return; } |
| 84 | static inline int pmem_setup(struct android_pmem_platform_data *pdata, |
| 85 | long (*ioctl)(struct file *, unsigned int, unsigned long), |
| 86 | int (*release)(struct inode *, struct file *)) { return -ENOSYS; } |
| 87 | |
| 88 | static inline int pmem_remap(struct pmem_region *region, struct file *file, |
| 89 | unsigned operation) { return -ENOSYS; } |
| 90 | #endif |
| 91 | |
| 92 | #endif //_ANDROID_PPP_H_ |
| 93 | |