1 /******************************************************************************* 2 * Copyright (C) 2018 Cadence Design Systems, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 * "Software"), to use this Software with Cadence processor cores only and 7 * not with any other processors and platforms, subject to 8 * the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included 11 * in all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 17 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 19 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21 ******************************************************************************/ 22 23 /******************************************************************************* 24 * xf-component.h 25 * 26 * Xtensa processing framework component definition 27 * 28 *******************************************************************************/ 29 30 #ifndef __XF_H 31 #error "xf-component.h mustn't be included directly" 32 #endif 33 34 /******************************************************************************* 35 * Types definitions 36 ******************************************************************************/ 37 38 /* ...component literal identifier */ 39 typedef const char * const xf_id_t; 40 41 /* ...component descriptor (base structure) */ 42 typedef struct xf_component 43 { 44 /* ...scheduler node */ 45 xf_task_t task; 46 47 /* ...component id */ 48 u32 id; 49 50 /* ...message-processing function */ 51 int (*entry)(struct xf_component *, xf_message_t *); 52 53 /* ...component destructor function */ 54 int (*exit)(struct xf_component *, xf_message_t *); 55 #ifndef XAF_ENABLE_NON_HIKEY 56 /* ...output port accessor */ 57 xf_output_port_t * (*port)(struct xf_component *, u32); 58 #endif 59 60 } xf_component_t; 61 62 /******************************************************************************* 63 * Helpers 64 ******************************************************************************/ 65 66 /* ...return core-id of the component */ 67 static inline u32 xf_component_core(xf_component_t *component) 68 { 69 return XF_PORT_CORE(component->id); 70 } 71 72 /* ...schedule component execution */ 73 #define xf_component_schedule(c, dts) \ 74 ({ \ 75 xf_sched_t *__sched = &XF_CORE_DATA(xf_component_core((c)))->sched; \ 76 xf_sched_put(__sched, &(c)->task, xf_sched_timestamp(__sched) + (dts)); \ 77 }) 78 79 /* ...cancel component execution */ 80 #define xf_component_cancel(c) \ 81 ({ \ 82 xf_sched_t *__sched = &XF_CORE_DATA(xf_component_core((c)))->sched; \ 83 xf_sched_cancel(__sched, &(c)->task); \ 84 }) 85 86 /******************************************************************************* 87 * API functions 88 ******************************************************************************/ 89 90 /* ...component factory */ 91 extern xf_component_t * xf_component_factory(u32 core, xf_id_t id, u32 length); 92