Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_ |
| 14 | #define _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_ |
| 15 | |
| 16 | #include <linux/remote_spinlock.h> |
| 17 | |
| 18 | #include <mach/ramdump.h> |
| 19 | |
| 20 | #define SMEM_SPINLOCK_SMEM_ALLOC "S:3" |
| 21 | extern remote_spinlock_t remote_spinlock; |
Jeff Hugo | b9fb940 | 2013-05-15 09:58:54 -0600 | [diff] [blame] | 22 | extern int spinlocks_initialized; /* only modify in init_smem_remote_spinlock */ |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 23 | |
| 24 | #define SMD_HEAP_SIZE 512 |
| 25 | |
| 26 | struct smem_heap_info { |
| 27 | unsigned initialized; |
| 28 | unsigned free_offset; |
| 29 | unsigned heap_remaining; |
| 30 | unsigned reserved; |
| 31 | }; |
| 32 | |
| 33 | struct smem_heap_entry { |
| 34 | unsigned allocated; |
| 35 | unsigned offset; |
| 36 | unsigned size; |
| 37 | unsigned reserved; /* bits 1:0 reserved, bits 31:2 aux smem base addr */ |
| 38 | }; |
| 39 | #define BASE_ADDR_MASK 0xfffffffc |
| 40 | |
| 41 | struct smem_proc_comm { |
| 42 | unsigned command; |
| 43 | unsigned status; |
| 44 | unsigned data1; |
| 45 | unsigned data2; |
| 46 | }; |
| 47 | |
| 48 | struct smem_shared { |
| 49 | struct smem_proc_comm proc_comm[4]; |
| 50 | unsigned version[32]; |
| 51 | struct smem_heap_info heap_info; |
| 52 | struct smem_heap_entry heap_toc[SMD_HEAP_SIZE]; |
| 53 | }; |
| 54 | |
| 55 | struct smem_area { |
| 56 | phys_addr_t phys_addr; |
| 57 | resource_size_t size; |
| 58 | void __iomem *virt_addr; |
| 59 | }; |
| 60 | |
| 61 | extern uint32_t num_smem_areas; |
| 62 | extern struct smem_area *smem_areas; |
| 63 | |
| 64 | extern struct ramdump_segment *smem_ramdump_segments; |
| 65 | |
| 66 | /* used for unit testing spinlocks */ |
| 67 | remote_spinlock_t *smem_get_remote_spinlock(void); |
Jeff Hugo | b9fb940 | 2013-05-15 09:58:54 -0600 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * used to ensure the remote spinlock is only inited once since local |
| 71 | * spinlock init code appears non-reentrant |
| 72 | */ |
| 73 | int init_smem_remote_spinlock(void); |
Jeff Hugo | 429dc2c | 2013-05-28 15:06:07 -0600 | [diff] [blame] | 74 | |
| 75 | bool smem_initialized_check(void); |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 76 | #endif /* _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_ */ |