a1b250b499b25549b25dc45212c7b781876222f2
[reactos.git] / reactos / drivers / bus / acpi / resource / rsxface.c
1 /*******************************************************************************
2 *
3 * Module Name: rsxface - Public interfaces to the ACPI subsystem
4 * $Revision: 1.1 $
5 *
6 ******************************************************************************/
7
8 /*
9 * Copyright (C) 2000, 2001 R. Byron Moore
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26
27 #include "acpi.h"
28 #include "acinterp.h"
29 #include "acnamesp.h"
30 #include "acresrc.h"
31
32 #define _COMPONENT ACPI_RESOURCES
33 MODULE_NAME ("rsxface")
34
35
36 /*******************************************************************************
37 *
38 * FUNCTION: Acpi_get_irq_routing_table
39 *
40 * PARAMETERS: Device_handle - a handle to the Bus device we are querying
41 * Ret_buffer - a pointer to a buffer to receive the
42 * current resources for the device
43 *
44 * RETURN: Status - the status of the call
45 *
46 * DESCRIPTION: This function is called to get the IRQ routing table for a
47 * specific bus. The caller must first acquire a handle for the
48 * desired bus. The routine table is placed in the buffer pointed
49 * to by the Ret_buffer variable parameter.
50 *
51 * If the function fails an appropriate status will be returned
52 * and the value of Ret_buffer is undefined.
53 *
54 * This function attempts to execute the _PRT method contained in
55 * the object indicated by the passed Device_handle.
56 *
57 ******************************************************************************/
58
59 ACPI_STATUS
60 acpi_get_irq_routing_table (
61 ACPI_HANDLE device_handle,
62 ACPI_BUFFER *ret_buffer)
63 {
64 ACPI_STATUS status;
65
66
67 /*
68 * Must have a valid handle and buffer, So we have to have a handle
69 * and a return buffer structure, and if there is a non-zero buffer length
70 * we also need a valid pointer in the buffer. If it's a zero buffer length,
71 * we'll be returning the needed buffer size, so keep going.
72 */
73 if ((!device_handle) ||
74 (!ret_buffer) ||
75 ((!ret_buffer->pointer) && (ret_buffer->length))) {
76 return (AE_BAD_PARAMETER);
77 }
78
79 status = acpi_rs_get_prt_method_data (device_handle, ret_buffer);
80
81 return (status);
82 }
83
84
85 /*******************************************************************************
86 *
87 * FUNCTION: Acpi_get_current_resources
88 *
89 * PARAMETERS: Device_handle - a handle to the device object for the
90 * device we are querying
91 * Ret_buffer - a pointer to a buffer to receive the
92 * current resources for the device
93 *
94 * RETURN: Status - the status of the call
95 *
96 * DESCRIPTION: This function is called to get the current resources for a
97 * specific device. The caller must first acquire a handle for
98 * the desired device. The resource data is placed in the buffer
99 * pointed to by the Ret_buffer variable parameter.
100 *
101 * If the function fails an appropriate status will be returned
102 * and the value of Ret_buffer is undefined.
103 *
104 * This function attempts to execute the _CRS method contained in
105 * the object indicated by the passed Device_handle.
106 *
107 ******************************************************************************/
108
109 ACPI_STATUS
110 acpi_get_current_resources (
111 ACPI_HANDLE device_handle,
112 ACPI_BUFFER *ret_buffer)
113 {
114 ACPI_STATUS status;
115
116
117 /*
118 * Must have a valid handle and buffer, So we have to have a handle
119 * and a return buffer structure, and if there is a non-zero buffer length
120 * we also need a valid pointer in the buffer. If it's a zero buffer length,
121 * we'll be returning the needed buffer size, so keep going.
122 */
123 if ((!device_handle) ||
124 (!ret_buffer) ||
125 ((ret_buffer->length) && (!ret_buffer->pointer))) {
126 return (AE_BAD_PARAMETER);
127 }
128
129 status = acpi_rs_get_crs_method_data (device_handle, ret_buffer);
130
131 return (status);
132 }
133
134
135 /*******************************************************************************
136 *
137 * FUNCTION: Acpi_get_possible_resources
138 *
139 * PARAMETERS: Device_handle - a handle to the device object for the
140 * device we are querying
141 * Ret_buffer - a pointer to a buffer to receive the
142 * resources for the device
143 *
144 * RETURN: Status - the status of the call
145 *
146 * DESCRIPTION: This function is called to get a list of the possible resources
147 * for a specific device. The caller must first acquire a handle
148 * for the desired device. The resource data is placed in the
149 * buffer pointed to by the Ret_buffer variable.
150 *
151 * If the function fails an appropriate status will be returned
152 * and the value of Ret_buffer is undefined.
153 *
154 ******************************************************************************/
155
156 ACPI_STATUS
157 acpi_get_possible_resources (
158 ACPI_HANDLE device_handle,
159 ACPI_BUFFER *ret_buffer)
160 {
161 ACPI_STATUS status;
162
163
164 /*
165 * Must have a valid handle and buffer, So we have to have a handle
166 * and a return buffer structure, and if there is a non-zero buffer length
167 * we also need a valid pointer in the buffer. If it's a zero buffer length,
168 * we'll be returning the needed buffer size, so keep going.
169 */
170 if ((!device_handle) ||
171 (!ret_buffer) ||
172 ((ret_buffer->length) && (!ret_buffer->pointer))) {
173 return (AE_BAD_PARAMETER);
174 }
175
176 status = acpi_rs_get_prs_method_data (device_handle, ret_buffer);
177
178 return (status);
179 }
180
181
182 /*******************************************************************************
183 *
184 * FUNCTION: Acpi_set_current_resources
185 *
186 * PARAMETERS: Device_handle - a handle to the device object for the
187 * device we are changing the resources of
188 * In_buffer - a pointer to a buffer containing the
189 * resources to be set for the device
190 *
191 * RETURN: Status - the status of the call
192 *
193 * DESCRIPTION: This function is called to set the current resources for a
194 * specific device. The caller must first acquire a handle for
195 * the desired device. The resource data is passed to the routine
196 * the buffer pointed to by the In_buffer variable.
197 *
198 ******************************************************************************/
199
200 ACPI_STATUS
201 acpi_set_current_resources (
202 ACPI_HANDLE device_handle,
203 ACPI_BUFFER *in_buffer)
204 {
205 ACPI_STATUS status;
206
207
208 /*
209 * Must have a valid handle and buffer
210 */
211 if ((!device_handle) ||
212 (!in_buffer) ||
213 (!in_buffer->pointer) ||
214 (!in_buffer->length)) {
215 return (AE_BAD_PARAMETER);
216 }
217
218 status = acpi_rs_set_srs_method_data (device_handle, in_buffer);
219
220 return (status);
221 }