utalloc.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: utalloc - local memory allocation routines
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer #define __UTALLOC_C__
45 1.1.1.2.2.2 bouyer
46 1.1.1.2.2.2 bouyer #include "acpi.h"
47 1.1.1.2.2.2 bouyer #include "accommon.h"
48 1.1.1.2.2.2 bouyer #include "acdebug.h"
49 1.1.1.2.2.2 bouyer
50 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_UTILITIES
51 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("utalloc")
52 1.1.1.2.2.2 bouyer
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer /*******************************************************************************
55 1.1.1.2.2.2 bouyer *
56 1.1.1.2.2.2 bouyer * FUNCTION: AcpiUtCreateCaches
57 1.1.1.2.2.2 bouyer *
58 1.1.1.2.2.2 bouyer * PARAMETERS: None
59 1.1.1.2.2.2 bouyer *
60 1.1.1.2.2.2 bouyer * RETURN: Status
61 1.1.1.2.2.2 bouyer *
62 1.1.1.2.2.2 bouyer * DESCRIPTION: Create all local caches
63 1.1.1.2.2.2 bouyer *
64 1.1.1.2.2.2 bouyer ******************************************************************************/
65 1.1.1.2.2.2 bouyer
66 1.1.1.2.2.2 bouyer ACPI_STATUS
67 1.1.1.2.2.2 bouyer AcpiUtCreateCaches (
68 1.1.1.2.2.2 bouyer void)
69 1.1.1.2.2.2 bouyer {
70 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
71 1.1.1.2.2.2 bouyer
72 1.1.1.2.2.2 bouyer
73 1.1.1.2.2.2 bouyer /* Object Caches, for frequently used objects */
74 1.1.1.2.2.2 bouyer
75 1.1.1.2.2.2 bouyer Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE),
76 1.1.1.2.2.2 bouyer ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache);
77 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
78 1.1.1.2.2.2 bouyer {
79 1.1.1.2.2.2 bouyer return (Status);
80 1.1.1.2.2.2 bouyer }
81 1.1.1.2.2.2 bouyer
82 1.1.1.2.2.2 bouyer Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE),
83 1.1.1.2.2.2 bouyer ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache);
84 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
85 1.1.1.2.2.2 bouyer {
86 1.1.1.2.2.2 bouyer return (Status);
87 1.1.1.2.2.2 bouyer }
88 1.1.1.2.2.2 bouyer
89 1.1.1.2.2.2 bouyer Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON),
90 1.1.1.2.2.2 bouyer ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache);
91 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
92 1.1.1.2.2.2 bouyer {
93 1.1.1.2.2.2 bouyer return (Status);
94 1.1.1.2.2.2 bouyer }
95 1.1.1.2.2.2 bouyer
96 1.1.1.2.2.2 bouyer Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED),
97 1.1.1.2.2.2 bouyer ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache);
98 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
99 1.1.1.2.2.2 bouyer {
100 1.1.1.2.2.2 bouyer return (Status);
101 1.1.1.2.2.2 bouyer }
102 1.1.1.2.2.2 bouyer
103 1.1.1.2.2.2 bouyer Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT),
104 1.1.1.2.2.2 bouyer ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache);
105 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
106 1.1.1.2.2.2 bouyer {
107 1.1.1.2.2.2 bouyer return (Status);
108 1.1.1.2.2.2 bouyer }
109 1.1.1.2.2.2 bouyer
110 1.1.1.2.2.2 bouyer
111 1.1.1.2.2.2 bouyer #ifdef ACPI_DBG_TRACK_ALLOCATIONS
112 1.1.1.2.2.2 bouyer
113 1.1.1.2.2.2 bouyer /* Memory allocation lists */
114 1.1.1.2.2.2 bouyer
115 1.1.1.2.2.2 bouyer Status = AcpiUtCreateList ("Acpi-Global", 0,
116 1.1.1.2.2.2 bouyer &AcpiGbl_GlobalList);
117 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
118 1.1.1.2.2.2 bouyer {
119 1.1.1.2.2.2 bouyer return (Status);
120 1.1.1.2.2.2 bouyer }
121 1.1.1.2.2.2 bouyer
122 1.1.1.2.2.2 bouyer Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE),
123 1.1.1.2.2.2 bouyer &AcpiGbl_NsNodeList);
124 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
125 1.1.1.2.2.2 bouyer {
126 1.1.1.2.2.2 bouyer return (Status);
127 1.1.1.2.2.2 bouyer }
128 1.1.1.2.2.2 bouyer #endif
129 1.1.1.2.2.2 bouyer
130 1.1.1.2.2.2 bouyer return (AE_OK);
131 1.1.1.2.2.2 bouyer }
132 1.1.1.2.2.2 bouyer
133 1.1.1.2.2.2 bouyer
134 1.1.1.2.2.2 bouyer /*******************************************************************************
135 1.1.1.2.2.2 bouyer *
136 1.1.1.2.2.2 bouyer * FUNCTION: AcpiUtDeleteCaches
137 1.1.1.2.2.2 bouyer *
138 1.1.1.2.2.2 bouyer * PARAMETERS: None
139 1.1.1.2.2.2 bouyer *
140 1.1.1.2.2.2 bouyer * RETURN: Status
141 1.1.1.2.2.2 bouyer *
142 1.1.1.2.2.2 bouyer * DESCRIPTION: Purge and delete all local caches
143 1.1.1.2.2.2 bouyer *
144 1.1.1.2.2.2 bouyer ******************************************************************************/
145 1.1.1.2.2.2 bouyer
146 1.1.1.2.2.2 bouyer ACPI_STATUS
147 1.1.1.2.2.2 bouyer AcpiUtDeleteCaches (
148 1.1.1.2.2.2 bouyer void)
149 1.1.1.2.2.2 bouyer {
150 1.1.1.2.2.2 bouyer #ifdef ACPI_DBG_TRACK_ALLOCATIONS
151 1.1.1.2.2.2 bouyer char Buffer[7];
152 1.1.1.2.2.2 bouyer
153 1.1.1.2.2.2 bouyer if (AcpiGbl_DisplayFinalMemStats)
154 1.1.1.2.2.2 bouyer {
155 1.1.1.2.2.2 bouyer ACPI_STRCPY (Buffer, "MEMORY");
156 1.1.1.2.2.2 bouyer (void) AcpiDbDisplayStatistics (Buffer);
157 1.1.1.2.2.2 bouyer }
158 1.1.1.2.2.2 bouyer #endif
159 1.1.1.2.2.2 bouyer
160 1.1.1.2.2.2 bouyer (void) AcpiOsDeleteCache (AcpiGbl_NamespaceCache);
161 1.1.1.2.2.2 bouyer AcpiGbl_NamespaceCache = NULL;
162 1.1.1.2.2.2 bouyer
163 1.1.1.2.2.2 bouyer (void) AcpiOsDeleteCache (AcpiGbl_StateCache);
164 1.1.1.2.2.2 bouyer AcpiGbl_StateCache = NULL;
165 1.1.1.2.2.2 bouyer
166 1.1.1.2.2.2 bouyer (void) AcpiOsDeleteCache (AcpiGbl_OperandCache);
167 1.1.1.2.2.2 bouyer AcpiGbl_OperandCache = NULL;
168 1.1.1.2.2.2 bouyer
169 1.1.1.2.2.2 bouyer (void) AcpiOsDeleteCache (AcpiGbl_PsNodeCache);
170 1.1.1.2.2.2 bouyer AcpiGbl_PsNodeCache = NULL;
171 1.1.1.2.2.2 bouyer
172 1.1.1.2.2.2 bouyer (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache);
173 1.1.1.2.2.2 bouyer AcpiGbl_PsNodeExtCache = NULL;
174 1.1.1.2.2.2 bouyer
175 1.1.1.2.2.2 bouyer
176 1.1.1.2.2.2 bouyer #ifdef ACPI_DBG_TRACK_ALLOCATIONS
177 1.1.1.2.2.2 bouyer
178 1.1.1.2.2.2 bouyer /* Debug only - display leftover memory allocation, if any */
179 1.1.1.2.2.2 bouyer
180 1.1.1.2.2.2 bouyer AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL);
181 1.1.1.2.2.2 bouyer
182 1.1.1.2.2.2 bouyer /* Free memory lists */
183 1.1.1.2.2.2 bouyer
184 1.1.1.2.2.2 bouyer AcpiOsFree (AcpiGbl_GlobalList);
185 1.1.1.2.2.2 bouyer AcpiGbl_GlobalList = NULL;
186 1.1.1.2.2.2 bouyer
187 1.1.1.2.2.2 bouyer AcpiOsFree (AcpiGbl_NsNodeList);
188 1.1.1.2.2.2 bouyer AcpiGbl_NsNodeList = NULL;
189 1.1.1.2.2.2 bouyer #endif
190 1.1.1.2.2.2 bouyer
191 1.1.1.2.2.2 bouyer return (AE_OK);
192 1.1.1.2.2.2 bouyer }
193 1.1.1.2.2.2 bouyer
194 1.1.1.2.2.2 bouyer
195 1.1.1.2.2.2 bouyer /*******************************************************************************
196 1.1.1.2.2.2 bouyer *
197 1.1.1.2.2.2 bouyer * FUNCTION: AcpiUtValidateBuffer
198 1.1.1.2.2.2 bouyer *
199 1.1.1.2.2.2 bouyer * PARAMETERS: Buffer - Buffer descriptor to be validated
200 1.1.1.2.2.2 bouyer *
201 1.1.1.2.2.2 bouyer * RETURN: Status
202 1.1.1.2.2.2 bouyer *
203 1.1.1.2.2.2 bouyer * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
204 1.1.1.2.2.2 bouyer *
205 1.1.1.2.2.2 bouyer ******************************************************************************/
206 1.1.1.2.2.2 bouyer
207 1.1.1.2.2.2 bouyer ACPI_STATUS
208 1.1.1.2.2.2 bouyer AcpiUtValidateBuffer (
209 1.1.1.2.2.2 bouyer ACPI_BUFFER *Buffer)
210 1.1.1.2.2.2 bouyer {
211 1.1.1.2.2.2 bouyer
212 1.1.1.2.2.2 bouyer /* Obviously, the structure pointer must be valid */
213 1.1.1.2.2.2 bouyer
214 1.1.1.2.2.2 bouyer if (!Buffer)
215 1.1.1.2.2.2 bouyer {
216 1.1.1.2.2.2 bouyer return (AE_BAD_PARAMETER);
217 1.1.1.2.2.2 bouyer }
218 1.1.1.2.2.2 bouyer
219 1.1.1.2.2.2 bouyer /* Special semantics for the length */
220 1.1.1.2.2.2 bouyer
221 1.1.1.2.2.2 bouyer if ((Buffer->Length == ACPI_NO_BUFFER) ||
222 1.1.1.2.2.2 bouyer (Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
223 1.1.1.2.2.2 bouyer (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
224 1.1.1.2.2.2 bouyer {
225 1.1.1.2.2.2 bouyer return (AE_OK);
226 1.1.1.2.2.2 bouyer }
227 1.1.1.2.2.2 bouyer
228 1.1.1.2.2.2 bouyer /* Length is valid, the buffer pointer must be also */
229 1.1.1.2.2.2 bouyer
230 1.1.1.2.2.2 bouyer if (!Buffer->Pointer)
231 1.1.1.2.2.2 bouyer {
232 1.1.1.2.2.2 bouyer return (AE_BAD_PARAMETER);
233 1.1.1.2.2.2 bouyer }
234 1.1.1.2.2.2 bouyer
235 1.1.1.2.2.2 bouyer return (AE_OK);
236 1.1.1.2.2.2 bouyer }
237 1.1.1.2.2.2 bouyer
238 1.1.1.2.2.2 bouyer
239 1.1.1.2.2.2 bouyer /*******************************************************************************
240 1.1.1.2.2.2 bouyer *
241 1.1.1.2.2.2 bouyer * FUNCTION: AcpiUtInitializeBuffer
242 1.1.1.2.2.2 bouyer *
243 1.1.1.2.2.2 bouyer * PARAMETERS: Buffer - Buffer to be validated
244 1.1.1.2.2.2 bouyer * RequiredLength - Length needed
245 1.1.1.2.2.2 bouyer *
246 1.1.1.2.2.2 bouyer * RETURN: Status
247 1.1.1.2.2.2 bouyer *
248 1.1.1.2.2.2 bouyer * DESCRIPTION: Validate that the buffer is of the required length or
249 1.1.1.2.2.2 bouyer * allocate a new buffer. Returned buffer is always zeroed.
250 1.1.1.2.2.2 bouyer *
251 1.1.1.2.2.2 bouyer ******************************************************************************/
252 1.1.1.2.2.2 bouyer
253 1.1.1.2.2.2 bouyer ACPI_STATUS
254 1.1.1.2.2.2 bouyer AcpiUtInitializeBuffer (
255 1.1.1.2.2.2 bouyer ACPI_BUFFER *Buffer,
256 1.1.1.2.2.2 bouyer ACPI_SIZE RequiredLength)
257 1.1.1.2.2.2 bouyer {
258 1.1.1.2.2.2 bouyer ACPI_SIZE InputBufferLength;
259 1.1.1.2.2.2 bouyer
260 1.1.1.2.2.2 bouyer
261 1.1.1.2.2.2 bouyer /* Parameter validation */
262 1.1.1.2.2.2 bouyer
263 1.1.1.2.2.2 bouyer if (!Buffer || !RequiredLength)
264 1.1.1.2.2.2 bouyer {
265 1.1.1.2.2.2 bouyer return (AE_BAD_PARAMETER);
266 1.1.1.2.2.2 bouyer }
267 1.1.1.2.2.2 bouyer
268 1.1.1.2.2.2 bouyer /*
269 1.1.1.2.2.2 bouyer * Buffer->Length is used as both an input and output parameter. Get the
270 1.1.1.2.2.2 bouyer * input actual length and set the output required buffer length.
271 1.1.1.2.2.2 bouyer */
272 1.1.1.2.2.2 bouyer InputBufferLength = Buffer->Length;
273 1.1.1.2.2.2 bouyer Buffer->Length = RequiredLength;
274 1.1.1.2.2.2 bouyer
275 1.1.1.2.2.2 bouyer /*
276 1.1.1.2.2.2 bouyer * The input buffer length contains the actual buffer length, or the type
277 1.1.1.2.2.2 bouyer * of buffer to be allocated by this routine.
278 1.1.1.2.2.2 bouyer */
279 1.1.1.2.2.2 bouyer switch (InputBufferLength)
280 1.1.1.2.2.2 bouyer {
281 1.1.1.2.2.2 bouyer case ACPI_NO_BUFFER:
282 1.1.1.2.2.2 bouyer
283 1.1.1.2.2.2 bouyer /* Return the exception (and the required buffer length) */
284 1.1.1.2.2.2 bouyer
285 1.1.1.2.2.2 bouyer return (AE_BUFFER_OVERFLOW);
286 1.1.1.2.2.2 bouyer
287 1.1.1.2.2.2 bouyer case ACPI_ALLOCATE_BUFFER:
288 1.1.1.2.2.2 bouyer
289 1.1.1.2.2.2 bouyer /* Allocate a new buffer */
290 1.1.1.2.2.2 bouyer
291 1.1.1.2.2.2 bouyer Buffer->Pointer = AcpiOsAllocate (RequiredLength);
292 1.1.1.2.2.2 bouyer break;
293 1.1.1.2.2.2 bouyer
294 1.1.1.2.2.2 bouyer case ACPI_ALLOCATE_LOCAL_BUFFER:
295 1.1.1.2.2.2 bouyer
296 1.1.1.2.2.2 bouyer /* Allocate a new buffer with local interface to allow tracking */
297 1.1.1.2.2.2 bouyer
298 1.1.1.2.2.2 bouyer Buffer->Pointer = ACPI_ALLOCATE (RequiredLength);
299 1.1.1.2.2.2 bouyer break;
300 1.1.1.2.2.2 bouyer
301 1.1.1.2.2.2 bouyer default:
302 1.1.1.2.2.2 bouyer
303 1.1.1.2.2.2 bouyer /* Existing buffer: Validate the size of the buffer */
304 1.1.1.2.2.2 bouyer
305 1.1.1.2.2.2 bouyer if (InputBufferLength < RequiredLength)
306 1.1.1.2.2.2 bouyer {
307 1.1.1.2.2.2 bouyer return (AE_BUFFER_OVERFLOW);
308 1.1.1.2.2.2 bouyer }
309 1.1.1.2.2.2 bouyer break;
310 1.1.1.2.2.2 bouyer }
311 1.1.1.2.2.2 bouyer
312 1.1.1.2.2.2 bouyer /* Validate allocation from above or input buffer pointer */
313 1.1.1.2.2.2 bouyer
314 1.1.1.2.2.2 bouyer if (!Buffer->Pointer)
315 1.1.1.2.2.2 bouyer {
316 1.1.1.2.2.2 bouyer return (AE_NO_MEMORY);
317 1.1.1.2.2.2 bouyer }
318 1.1.1.2.2.2 bouyer
319 1.1.1.2.2.2 bouyer /* Have a valid buffer, clear it */
320 1.1.1.2.2.2 bouyer
321 1.1.1.2.2.2 bouyer ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
322 1.1.1.2.2.2 bouyer return (AE_OK);
323 1.1.1.2.2.2 bouyer }
324 1.1.1.2.2.2 bouyer
325 1.1.1.2.2.2 bouyer
326 1.1.1.2.2.2 bouyer /*******************************************************************************
327 1.1.1.2.2.2 bouyer *
328 1.1.1.2.2.2 bouyer * FUNCTION: AcpiUtAllocate
329 1.1.1.2.2.2 bouyer *
330 1.1.1.2.2.2 bouyer * PARAMETERS: Size - Size of the allocation
331 1.1.1.2.2.2 bouyer * Component - Component type of caller
332 1.1.1.2.2.2 bouyer * Module - Source file name of caller
333 1.1.1.2.2.2 bouyer * Line - Line number of caller
334 1.1.1.2.2.2 bouyer *
335 1.1.1.2.2.2 bouyer * RETURN: Address of the allocated memory on success, NULL on failure.
336 1.1.1.2.2.2 bouyer *
337 1.1.1.2.2.2 bouyer * DESCRIPTION: Subsystem equivalent of malloc.
338 1.1.1.2.2.2 bouyer *
339 1.1.1.2.2.2 bouyer ******************************************************************************/
340 1.1.1.2.2.2 bouyer
341 1.1.1.2.2.2 bouyer void *
342 1.1.1.2.2.2 bouyer AcpiUtAllocate (
343 1.1.1.2.2.2 bouyer ACPI_SIZE Size,
344 1.1.1.2.2.2 bouyer UINT32 Component,
345 1.1.1.2.2.2 bouyer const char *Module,
346 1.1.1.2.2.2 bouyer UINT32 Line)
347 1.1.1.2.2.2 bouyer {
348 1.1.1.2.2.2 bouyer void *Allocation;
349 1.1.1.2.2.2 bouyer
350 1.1.1.2.2.2 bouyer
351 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size);
352 1.1.1.2.2.2 bouyer
353 1.1.1.2.2.2 bouyer
354 1.1.1.2.2.2 bouyer /* Check for an inadvertent size of zero bytes */
355 1.1.1.2.2.2 bouyer
356 1.1.1.2.2.2 bouyer if (!Size)
357 1.1.1.2.2.2 bouyer {
358 1.1.1.2.2.2 bouyer ACPI_WARNING ((Module, Line,
359 1.1.1.2.2.2 bouyer "Attempt to allocate zero bytes, allocating 1 byte"));
360 1.1.1.2.2.2 bouyer Size = 1;
361 1.1.1.2.2.2 bouyer }
362 1.1.1.2.2.2 bouyer
363 1.1.1.2.2.2 bouyer Allocation = AcpiOsAllocate (Size);
364 1.1.1.2.2.2 bouyer if (!Allocation)
365 1.1.1.2.2.2 bouyer {
366 1.1.1.2.2.2 bouyer /* Report allocation error */
367 1.1.1.2.2.2 bouyer
368 1.1.1.2.2.2 bouyer ACPI_WARNING ((Module, Line,
369 1.1.1.2.2.2 bouyer "Could not allocate size %u", (UINT32) Size));
370 1.1.1.2.2.2 bouyer
371 1.1.1.2.2.2 bouyer return_PTR (NULL);
372 1.1.1.2.2.2 bouyer }
373 1.1.1.2.2.2 bouyer
374 1.1.1.2.2.2 bouyer return_PTR (Allocation);
375 1.1.1.2.2.2 bouyer }
376 1.1.1.2.2.2 bouyer
377 1.1.1.2.2.2 bouyer
378 1.1.1.2.2.2 bouyer /*******************************************************************************
379 1.1.1.2.2.2 bouyer *
380 1.1.1.2.2.2 bouyer * FUNCTION: AcpiUtAllocateZeroed
381 1.1.1.2.2.2 bouyer *
382 1.1.1.2.2.2 bouyer * PARAMETERS: Size - Size of the allocation
383 1.1.1.2.2.2 bouyer * Component - Component type of caller
384 1.1.1.2.2.2 bouyer * Module - Source file name of caller
385 1.1.1.2.2.2 bouyer * Line - Line number of caller
386 1.1.1.2.2.2 bouyer *
387 1.1.1.2.2.2 bouyer * RETURN: Address of the allocated memory on success, NULL on failure.
388 1.1.1.2.2.2 bouyer *
389 1.1.1.2.2.2 bouyer * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
390 1.1.1.2.2.2 bouyer *
391 1.1.1.2.2.2 bouyer ******************************************************************************/
392 1.1.1.2.2.2 bouyer
393 1.1.1.2.2.2 bouyer void *
394 1.1.1.2.2.2 bouyer AcpiUtAllocateZeroed (
395 1.1.1.2.2.2 bouyer ACPI_SIZE Size,
396 1.1.1.2.2.2 bouyer UINT32 Component,
397 1.1.1.2.2.2 bouyer const char *Module,
398 1.1.1.2.2.2 bouyer UINT32 Line)
399 1.1.1.2.2.2 bouyer {
400 1.1.1.2.2.2 bouyer void *Allocation;
401 1.1.1.2.2.2 bouyer
402 1.1.1.2.2.2 bouyer
403 1.1.1.2.2.2 bouyer ACPI_FUNCTION_ENTRY ();
404 1.1.1.2.2.2 bouyer
405 1.1.1.2.2.2 bouyer
406 1.1.1.2.2.2 bouyer Allocation = AcpiUtAllocate (Size, Component, Module, Line);
407 1.1.1.2.2.2 bouyer if (Allocation)
408 1.1.1.2.2.2 bouyer {
409 1.1.1.2.2.2 bouyer /* Clear the memory block */
410 1.1.1.2.2.2 bouyer
411 1.1.1.2.2.2 bouyer ACPI_MEMSET (Allocation, 0, Size);
412 1.1.1.2.2.2 bouyer }
413 1.1.1.2.2.2 bouyer
414 1.1.1.2.2.2 bouyer return (Allocation);
415 1.1.1.2.2.2 bouyer }
416 1.1.1.2.2.2 bouyer
417