Lines Matching +full:shared +full:- +full:memory +full:- +full:size

4  * SPDX-License-Identifier: Apache-2.0
56 struct esp32_ipm_data *dev_data = (struct esp32_ipm_data *)dev->data; in esp32_ipm_isr()
57 uint32_t core_id = dev_data->this_core_id; in esp32_ipm_isr()
74 /* first of all take the own of the shared memory */ in esp32_ipm_isr()
75 while (!atomic_cas(&dev_data->control->lock, ESP32_IPM_LOCK_FREE_VAL, in esp32_ipm_isr()
76 dev_data->this_core_id)) { in esp32_ipm_isr()
80 if (dev_data->cb) { in esp32_ipm_isr()
82 volatile void *shm = dev_data->shm.pro_cpu_shm; in esp32_ipm_isr()
85 shm = dev_data->shm.app_cpu_shm; in esp32_ipm_isr()
88 dev_data->cb(dev, in esp32_ipm_isr()
89 dev_data->user_data, in esp32_ipm_isr()
90 dev_data->control->dest_cpu_msg_id[core_id], in esp32_ipm_isr()
94 /* unlock the shared memory */ in esp32_ipm_isr()
95 atomic_set(&dev_data->control->lock, ESP32_IPM_LOCK_FREE_VAL); in esp32_ipm_isr()
99 const void *data, int size) in esp32_ipm_send() argument
101 struct esp32_ipm_data *dev_data = (struct esp32_ipm_data *)dev->data; in esp32_ipm_send()
103 if (size > 0 && data == NULL) { in esp32_ipm_send()
105 return -EINVAL; in esp32_ipm_send()
110 return -EINVAL; in esp32_ipm_send()
113 if (dev_data->shm_size < size) { in esp32_ipm_send()
114 LOG_ERR("Not enough memory in IPM channel"); in esp32_ipm_send()
115 return -ENOMEM; in esp32_ipm_send()
120 /* try to lock the shared memory */ in esp32_ipm_send()
121 while (!atomic_cas(&dev_data->control->lock, in esp32_ipm_send()
123 dev_data->this_core_id)) { in esp32_ipm_send()
127 if ((wait != -1) && (wait > 0)) { in esp32_ipm_send()
129 wait--; in esp32_ipm_send()
133 return -ETIMEDOUT; in esp32_ipm_send()
139 dev_data->control->dest_cpu_msg_id[dev_data->other_core_id] = (uint16_t)(id & 0xFFFF); in esp32_ipm_send()
142 if (dev_data->this_core_id == 0) { in esp32_ipm_send()
143 memcpy(dev_data->shm.app_cpu_shm, data, size); in esp32_ipm_send()
144 atomic_set(&dev_data->control->lock, ESP32_IPM_LOCK_FREE_VAL); in esp32_ipm_send()
153 memcpy(dev_data->shm.pro_cpu_shm, data, size); in esp32_ipm_send()
154 atomic_set(&dev_data->control->lock, ESP32_IPM_LOCK_FREE_VAL); in esp32_ipm_send()
172 struct esp32_ipm_data *data = (struct esp32_ipm_data *)dev->data; in esp32_ipm_register_callback()
176 data->cb = cb; in esp32_ipm_register_callback()
177 data->user_data = user_data; in esp32_ipm_register_callback()
184 struct esp32_ipm_data *data = (struct esp32_ipm_data *)dev->data; in esp32_ipm_max_data_size_get()
186 return data->shm_size; in esp32_ipm_max_data_size_get()
211 struct esp32_ipm_data *data = (struct esp32_ipm_data *)dev->data; in esp32_ipm_init()
212 struct esp32_ipm_config *cfg = (struct esp32_ipm_config *)dev->config; in esp32_ipm_init()
215 data->this_core_id = esp_core_id(); in esp32_ipm_init()
216 data->other_core_id = (data->this_core_id == 0) ? 1 : 0; in esp32_ipm_init()
218 LOG_DBG("Size of IPM shared memory: %d", data->shm_size); in esp32_ipm_init()
219 LOG_DBG("Address of PRO_CPU IPM shared memory: %p", (void *)data->shm.pro_cpu_shm); in esp32_ipm_init()
220 LOG_DBG("Address of APP_CPU IPM shared memory: %p", (void *)data->shm.app_cpu_shm); in esp32_ipm_init()
221 LOG_DBG("Address of IPM control structure: %p", (void *)data->control); in esp32_ipm_init()
223 /* pro_cpu is responsible to initialize the lock of shared memory */ in esp32_ipm_init()
224 if (data->this_core_id == 0) { in esp32_ipm_init()
225 ret = esp_intr_alloc(cfg->irq_source_pro_cpu, in esp32_ipm_init()
226 ESP_PRIO_TO_FLAGS(cfg->irq_priority_pro_cpu) | in esp32_ipm_init()
227 ESP_INT_FLAGS_CHECK(cfg->irq_flags_pro_cpu) | in esp32_ipm_init()
238 atomic_set(&data->control->lock, ESP32_IPM_LOCK_FREE_VAL); in esp32_ipm_init()
243 ret = esp_intr_alloc(cfg->irq_source_app_cpu, in esp32_ipm_init()
244 ESP_PRIO_TO_FLAGS(cfg->irq_priority_app_cpu) | in esp32_ipm_init()
245 ESP_INT_FLAGS_CHECK(cfg->irq_flags_app_cpu) | in esp32_ipm_init()
257 while (!atomic_cas(&data->control->lock, in esp32_ipm_init()
258 ESP32_IPM_LOCK_FREE_VAL, data->this_core_id)) { in esp32_ipm_init()
262 atomic_set(&data->control->lock, ESP32_IPM_LOCK_FREE_VAL); in esp32_ipm_init()