]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/intc_v3_2/src/xintc_options.c
d366b42d4566eb8738e1952a2af0721572295dfd
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / intc_v3_2 / src / xintc_options.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2002 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xintc_options.c
36 *
37 * Contains option functions for the XIntc driver. These functions allow the
38 * user to configure an instance of the XIntc driver.  This file requires other
39 * files of the component to be linked in also.
40 *
41 * <pre>
42 * MODIFICATION HISTORY:
43 *
44 * Ver   Who  Date     Changes
45 * ----- ---- -------- -----------------------------------------------------
46 * 1.00b jhl  02/21/02 First release
47 * 1.00c rpm  10/17/03 New release. Support the relocation of the options flag
48 *                     from the instance structure to the xintc_g.c
49 *                     configuration table.
50 * 1.10c mta  03/21/07 Updated to new coding style
51 * 2.00a ktn  10/20/09 Updated to use HAL Processor APIs
52 * 2.06a bss  01/28/13 To support Cascade mode:
53 *                     Modified XIntc_SetOptions API.
54 * </pre>
55 *
56 ******************************************************************************/
57
58 /***************************** Include Files *********************************/
59
60 #include "xil_types.h"
61 #include "xil_assert.h"
62 #include "xintc.h"
63
64 /************************** Constant Definitions *****************************/
65
66
67 /**************************** Type Definitions *******************************/
68
69
70 /***************** Macros (Inline Functions) Definitions *********************/
71
72
73 /************************** Function Prototypes ******************************/
74
75
76 /************************** Variable Definitions *****************************/
77
78
79 /*****************************************************************************/
80 /**
81 *
82 * Set the options for the interrupt controller driver. In Cascade mode same
83 * Option is set to Slave controllers.
84 *
85 * @param        InstancePtr is a pointer to the XIntc instance to be worked on.
86 * @param        Options to be set. The available options are described in
87 *               xintc.h.
88 *
89 * @return
90 *               - XST_SUCCESS if the options were set successfully
91 *               - XST_INVALID_PARAM if the specified option was not valid
92 *
93 * @note         None.
94 *
95 ****************************************************************************/
96 int XIntc_SetOptions(XIntc * InstancePtr, u32 Options)
97 {
98         XIntc_Config *CfgPtr;
99
100         Xil_AssertNonvoid(InstancePtr != NULL);
101         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
102
103         /*
104          * Make sure option request is valid
105          */
106         if ((Options == XIN_SVC_SGL_ISR_OPTION) ||
107             (Options == XIN_SVC_ALL_ISRS_OPTION)) {
108                 InstancePtr->CfgPtr->Options = Options;
109                 /* If Cascade mode set the option for all Slaves */
110                 if (InstancePtr->CfgPtr->IntcType != XIN_INTC_NOCASCADE) {
111                         int Index;
112                         for (Index = 1; Index <= XPAR_XINTC_NUM_INSTANCES - 1;
113                                                                 Index++) {
114                                 CfgPtr = XIntc_LookupConfig(Index);
115                                 CfgPtr->Options = Options;
116                         }
117                 }
118                 return XST_SUCCESS;
119         }
120         else {
121                 return XST_INVALID_PARAM;
122         }
123 }
124
125 /*****************************************************************************/
126 /**
127 *
128 * Return the currently set options.
129 *
130 * @param        InstancePtr is a pointer to the XIntc instance to be worked on.
131 *
132 * @return       The currently set options. The options are described in xintc.h.
133 *
134 * @note         None.
135 *
136 ****************************************************************************/
137 u32 XIntc_GetOptions(XIntc * InstancePtr)
138 {
139         /*
140          * Assert the arguments
141          */
142         Xil_AssertNonvoid(InstancePtr != NULL);
143         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
144
145         return InstancePtr->CfgPtr->Options;
146 }