f9d06d345a05fb799fe0d8a0fa8098695487d2b0
1 /******************************************************************************
2 * FILE PURPOSE: Using FC-RMAN
3 ******************************************************************************
4 * FILE NAME: appRman.c
5 *
6 * (C) Copyright 2013, Texas Instruments Incorporated.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
18 * distribution.
19 *
20 * Neither the name of Texas Instruments Incorporated nor the names of
21 * its contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37 #include <xdc/std.h>
38 #include <ti/xdais/ires.h>
40 #include <ti/sdo/fc/edma3/edma3_config.h>
41 #include <ti/sdo/fc/rman/rman.h>
43 /* Get globals from cfg header */
44 #include <xdc/cfg/global.h>
46 //#define FC_TRACE
47 #ifdef FC_TRACE
48 #include <ti/sdo/fc/global/FCSettings.h>
49 #include <xdc/runtime/Diags.h>
50 #endif
51 /*********************************************************************************
52 * FUNCTION PURPOSE: Init RMAN resources
53 *********************************************************************************
54 DESCRIPTION: This function initializes RMAN resouces
56 Parameters : Inputs: edmaInstanceId : ID of EDMA instance to be used
57 coreId : core ID
58 Output: TRUE if initialization successful; FALSE otherwise
59 *********************************************************************************/
60 extern const EDMA3_InstanceInitConfig C6678_config[][EDMA3_MAX_REGIONS];
61 Bool app_rman_init(unsigned int edmaInstanceId, unsigned int coreId)
62 {
63 EDMA3_PARAMS.regionConfig = (EDMA3_InstanceInitConfig *)&C6678_config[edmaInstanceId][coreId];
64 IRES_Status ires_status;
66 #ifdef FC_TRACE
67 /* Set default mask for FC modules */
68 FCSettings_init();
69 Diags_setMask(FCSETTINGS_MODNAME"+EX1234567");
70 #endif
72 /* specify EDMA instance ID */
73 ti_sdo_fc_edma3_EDMA3_physicalId = edmaInstanceId;
75 /* RMAN init */
76 ires_status = RMAN_init();
78 if (IRES_OK != ires_status) {
79 return FALSE;
80 }
81 return TRUE;
82 }
84 /*********************************************************************************
85 * FUNCTION PURPOSE: Assign and activate RMAN resources
86 *********************************************************************************
87 DESCRIPTION: This function assigns and activates RMAN resouces
89 Parameters : Inputs: algHandle : alg handle
90 resFxns : IRES function pointers
91 Output: TRUE if initialization successful; FALSE otherwise
92 *********************************************************************************/
93 Bool app_rman_assign_resources(void* algHandle, void* resFxns)
94 {
95 IRES_Status ires_status;
96 Int scratchId = 0;
98 /* RMAN assign resource */
99 ires_status = RMAN_assignResources((IALG_Handle)algHandle, (IRES_Fxns*)resFxns, scratchId);
100 if (ires_status != IRES_OK) {
101 return FALSE;
102 }
104 /* RMAN activate all resource */
105 RMAN_activateAllResources((IALG_Handle)algHandle, (IRES_Fxns*)resFxns, scratchId);
106 return TRUE;
107 }
109 /*********************************************************************************
110 * FUNCTION PURPOSE: Free RMAN resources
111 *********************************************************************************
112 DESCRIPTION: This function frees RMAN resouces
114 Parameters : Inputs: algHandle : alg handle
115 resFxns : IRES function pointers
116 Output: TRUE if free is successful; FALSE otherwise
117 *********************************************************************************/
118 Bool app_rman_free_resources(void* algHandle, void* resFxns)
119 {
120 IRES_Status ires_status;
121 Int scratchId = 0;
123 /* RMAN free resource */
124 ires_status = RMAN_freeResources((IALG_Handle)algHandle, (IRES_Fxns*)resFxns, scratchId);
125 if (ires_status != IRES_OK) {
126 return FALSE;
127 }
129 return TRUE;
130 }