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 | |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 20 | #define SMD_HEAP_SIZE 512 |
| 21 | |
| 22 | struct smem_heap_info { |
| 23 | unsigned initialized; |
| 24 | unsigned free_offset; |
| 25 | unsigned heap_remaining; |
| 26 | unsigned reserved; |
| 27 | }; |
| 28 | |
| 29 | struct smem_heap_entry { |
| 30 | unsigned allocated; |
| 31 | unsigned offset; |
| 32 | unsigned size; |
| 33 | unsigned reserved; /* bits 1:0 reserved, bits 31:2 aux smem base addr */ |
| 34 | }; |
| 35 | #define BASE_ADDR_MASK 0xfffffffc |
| 36 | |
| 37 | struct smem_proc_comm { |
| 38 | unsigned command; |
| 39 | unsigned status; |
| 40 | unsigned data1; |
| 41 | unsigned data2; |
| 42 | }; |
| 43 | |
| 44 | struct smem_shared { |
| 45 | struct smem_proc_comm proc_comm[4]; |
| 46 | unsigned version[32]; |
| 47 | struct smem_heap_info heap_info; |
| 48 | struct smem_heap_entry heap_toc[SMD_HEAP_SIZE]; |
| 49 | }; |
| 50 | |
| 51 | struct smem_area { |
| 52 | phys_addr_t phys_addr; |
| 53 | resource_size_t size; |
| 54 | void __iomem *virt_addr; |
| 55 | }; |
| 56 | |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 57 | /* used for unit testing spinlocks */ |
| 58 | remote_spinlock_t *smem_get_remote_spinlock(void); |
Jeff Hugo | b9fb940 | 2013-05-15 09:58:54 -0600 | [diff] [blame] | 59 | |
Jeff Hugo | 429dc2c | 2013-05-28 15:06:07 -0600 | [diff] [blame] | 60 | bool smem_initialized_check(void); |
Jeff Hugo | 7cc06b1 | 2013-06-17 16:13:18 -0600 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * smem_module_init_notifier_register() - Register a smem module |
| 64 | * init notifier block |
| 65 | * @nb: Notifier block to be registered |
| 66 | * |
| 67 | * In order to mark the dependency on SMEM Driver module initialization |
| 68 | * register a notifier using this API. Once the smem module_init is |
| 69 | * done, notification will be passed to the registered module. |
| 70 | */ |
| 71 | int smem_module_init_notifier_register(struct notifier_block *nb); |
| 72 | |
| 73 | /** |
| 74 | * smem_module_init_notifier_register() - Unregister a smem module |
| 75 | * init notifier block |
| 76 | * @nb: Notifier block to be unregistered |
| 77 | */ |
| 78 | int smem_module_init_notifier_unregister(struct notifier_block *nb); |
Jeff Hugo | 830785d | 2013-08-27 13:20:10 -0600 | [diff] [blame^] | 79 | |
| 80 | /** |
| 81 | * smem_get_free_space() - Get the available allocation free space for a |
| 82 | * partition |
| 83 | * |
| 84 | * @to_proc: remote SMEM host. Determines the applicable partition |
| 85 | * @returns: size in bytes available to allocate |
| 86 | * |
| 87 | * Helper function for SMD so that SMD only scans the channel allocation |
| 88 | * table for a partition when it is reasonably certain that a channel has |
| 89 | * actually been created, because scanning can be expensive. Creating a channel |
| 90 | * will consume some of the free space in a partition, so SMD can compare the |
| 91 | * last free space size against the current free space size to determine if |
| 92 | * a channel may have been created. SMD can't do this directly, because the |
| 93 | * necessary partition internals are restricted to just SMEM. |
| 94 | */ |
| 95 | unsigned smem_get_free_space(unsigned to_proc); |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 96 | #endif /* _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_ */ |