Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/executer/exstorob.c
+++ new/usr/src/common/acpica/components/executer/exstorob.c
1 -
2 1 /******************************************************************************
3 2 *
4 3 * Module Name: exstorob - AML Interpreter object store support, store to object
5 4 *
6 5 *****************************************************************************/
7 6
8 7 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, Intel Corp.
10 9 * All rights reserved.
11 10 *
12 11 * Redistribution and use in source and binary forms, with or without
13 12 * modification, are permitted provided that the following conditions
14 13 * are met:
15 14 * 1. Redistributions of source code must retain the above copyright
16 15 * notice, this list of conditions, and the following disclaimer,
17 16 * without modification.
18 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 18 * substantially similar to the "NO WARRANTY" disclaimer below
20 19 * ("Disclaimer") and any redistribution must be conditioned upon
21 20 * including a substantially similar Disclaimer requirement for further
22 21 * binary redistribution.
23 22 * 3. Neither the names of the above-listed copyright holders nor the names
24 23 * of any contributors may be used to endorse or promote products derived
25 24 * from this software without specific prior written permission.
26 25 *
27 26 * Alternatively, this software may be distributed under the terms of the
28 27 * GNU General Public License ("GPL") version 2 as published by the Free
29 28 * Software Foundation.
30 29 *
31 30 * NO WARRANTY
32 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 41 * POSSIBILITY OF SUCH DAMAGES.
43 42 */
44 43
45 44 #define __EXSTOROB_C__
46 45
47 46 #include "acpi.h"
48 47 #include "accommon.h"
49 48 #include "acinterp.h"
50 49
51 50
52 51 #define _COMPONENT ACPI_EXECUTER
53 52 ACPI_MODULE_NAME ("exstorob")
54 53
55 54
56 55 /*******************************************************************************
57 56 *
58 57 * FUNCTION: AcpiExStoreBufferToBuffer
59 58 *
60 59 * PARAMETERS: SourceDesc - Source object to copy
61 60 * TargetDesc - Destination object of the copy
62 61 *
63 62 * RETURN: Status
64 63 *
65 64 * DESCRIPTION: Copy a buffer object to another buffer object.
66 65 *
67 66 ******************************************************************************/
68 67
69 68 ACPI_STATUS
70 69 AcpiExStoreBufferToBuffer (
71 70 ACPI_OPERAND_OBJECT *SourceDesc,
72 71 ACPI_OPERAND_OBJECT *TargetDesc)
73 72 {
74 73 UINT32 Length;
75 74 UINT8 *Buffer;
76 75
77 76
78 77 ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc);
79 78
80 79
81 80 /* If Source and Target are the same, just return */
82 81
83 82 if (SourceDesc == TargetDesc)
84 83 {
85 84 return_ACPI_STATUS (AE_OK);
86 85 }
87 86
88 87 /* We know that SourceDesc is a buffer by now */
89 88
90 89 Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer);
91 90 Length = SourceDesc->Buffer.Length;
92 91
93 92 /*
94 93 * If target is a buffer of length zero or is a static buffer,
95 94 * allocate a new buffer of the proper length
96 95 */
97 96 if ((TargetDesc->Buffer.Length == 0) ||
98 97 (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))
99 98 {
100 99 TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length);
101 100 if (!TargetDesc->Buffer.Pointer)
102 101 {
103 102 return_ACPI_STATUS (AE_NO_MEMORY);
104 103 }
105 104
106 105 TargetDesc->Buffer.Length = Length;
107 106 }
108 107
109 108 /* Copy source buffer to target buffer */
110 109
↓ open down ↓ |
91 lines elided |
↑ open up ↑ |
111 110 if (Length <= TargetDesc->Buffer.Length)
112 111 {
113 112 /* Clear existing buffer and copy in the new one */
114 113
115 114 ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
116 115 ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length);
117 116
118 117 #ifdef ACPI_OBSOLETE_BEHAVIOR
119 118 /*
120 119 * NOTE: ACPI versions up to 3.0 specified that the buffer must be
121 - * truncated if the string is smaller than the buffer. However, "other"
120 + * truncated if the string is smaller than the buffer. However, "other"
122 121 * implementations of ACPI never did this and thus became the defacto
123 122 * standard. ACPI 3.0A changes this behavior such that the buffer
124 123 * is no longer truncated.
125 124 */
126 125
127 126 /*
128 127 * OBSOLETE BEHAVIOR:
129 128 * If the original source was a string, we must truncate the buffer,
130 - * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
129 + * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
131 130 * copy must not truncate the original buffer.
132 131 */
133 132 if (OriginalSrcType == ACPI_TYPE_STRING)
134 133 {
135 134 /* Set the new length of the target */
136 135
137 136 TargetDesc->Buffer.Length = Length;
138 137 }
139 138 #endif
140 139 }
141 140 else
142 141 {
143 142 /* Truncate the source, copy only what will fit */
144 143
145 144 ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer,
146 145 TargetDesc->Buffer.Length);
147 146
148 147 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
149 148 "Truncating source buffer from %X to %X\n",
150 149 Length, TargetDesc->Buffer.Length));
151 150 }
152 151
153 152 /* Copy flags */
154 153
155 154 TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags;
156 155 TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
157 156 return_ACPI_STATUS (AE_OK);
158 157 }
159 158
160 159
161 160 /*******************************************************************************
162 161 *
163 162 * FUNCTION: AcpiExStoreStringToString
164 163 *
165 164 * PARAMETERS: SourceDesc - Source object to copy
166 165 * TargetDesc - Destination object of the copy
167 166 *
168 167 * RETURN: Status
169 168 *
170 169 * DESCRIPTION: Copy a String object to another String object
171 170 *
172 171 ******************************************************************************/
173 172
174 173 ACPI_STATUS
175 174 AcpiExStoreStringToString (
176 175 ACPI_OPERAND_OBJECT *SourceDesc,
177 176 ACPI_OPERAND_OBJECT *TargetDesc)
178 177 {
179 178 UINT32 Length;
180 179 UINT8 *Buffer;
181 180
182 181
183 182 ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc);
184 183
185 184
186 185 /* If Source and Target are the same, just return */
187 186
188 187 if (SourceDesc == TargetDesc)
189 188 {
190 189 return_ACPI_STATUS (AE_OK);
191 190 }
192 191
193 192 /* We know that SourceDesc is a string by now */
194 193
195 194 Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer);
196 195 Length = SourceDesc->String.Length;
197 196
198 197 /*
199 198 * Replace existing string value if it will fit and the string
200 199 * pointer is not a static pointer (part of an ACPI table)
201 200 */
202 201 if ((Length < TargetDesc->String.Length) &&
203 202 (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
204 203 {
205 204 /*
206 205 * String will fit in existing non-static buffer.
207 206 * Clear old string and copy in the new one
208 207 */
209 208 ACPI_MEMSET (TargetDesc->String.Pointer, 0,
210 209 (ACPI_SIZE) TargetDesc->String.Length + 1);
211 210 ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
212 211 }
213 212 else
214 213 {
215 214 /*
216 215 * Free the current buffer, then allocate a new buffer
217 216 * large enough to hold the value
218 217 */
219 218 if (TargetDesc->String.Pointer &&
220 219 (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
221 220 {
222 221 /* Only free if not a pointer into the DSDT */
223 222
224 223 ACPI_FREE (TargetDesc->String.Pointer);
225 224 }
226 225
227 226 TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED (
228 227 (ACPI_SIZE) Length + 1);
229 228 if (!TargetDesc->String.Pointer)
230 229 {
231 230 return_ACPI_STATUS (AE_NO_MEMORY);
232 231 }
↓ open down ↓ |
92 lines elided |
↑ open up ↑ |
233 232
234 233 TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
235 234 ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
236 235 }
237 236
238 237 /* Set the new target length */
239 238
240 239 TargetDesc->String.Length = Length;
241 240 return_ACPI_STATUS (AE_OK);
242 241 }
243 -
244 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX