ReactOS 0.4.15-dev-7953-g1f49173
exstorob.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
Include dependency graph for exstorob.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EXECUTER
 

Functions

ACPI_STATUS AcpiExStoreBufferToBuffer (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
 
ACPI_STATUS AcpiExStoreStringToString (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 49 of file exstorob.c.

Function Documentation

◆ AcpiExStoreBufferToBuffer()

ACPI_STATUS AcpiExStoreBufferToBuffer ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT TargetDesc 
)

Definition at line 67 of file exstorob.c.

70{
73
74
75 ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc);
76
77
78 /* If Source and Target are the same, just return */
79
80 if (SourceDesc == TargetDesc)
81 {
83 }
84
85 /* We know that SourceDesc is a buffer by now */
86
87 Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer);
88 Length = SourceDesc->Buffer.Length;
89
90 /*
91 * If target is a buffer of length zero or is a static buffer,
92 * allocate a new buffer of the proper length
93 */
94 if ((TargetDesc->Buffer.Length == 0) ||
95 (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))
96 {
97 TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length);
98 if (!TargetDesc->Buffer.Pointer)
99 {
101 }
102
103 TargetDesc->Buffer.Length = Length;
104 }
105
106 /* Copy source buffer to target buffer */
107
108 if (Length <= TargetDesc->Buffer.Length)
109 {
110 /* Clear existing buffer and copy in the new one */
111
112 memset (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
113 memcpy (TargetDesc->Buffer.Pointer, Buffer, Length);
114
115#ifdef ACPI_OBSOLETE_BEHAVIOR
116 /*
117 * NOTE: ACPI versions up to 3.0 specified that the buffer must be
118 * truncated if the string is smaller than the buffer. However, "other"
119 * implementations of ACPI never did this and thus became the defacto
120 * standard. ACPI 3.0A changes this behavior such that the buffer
121 * is no longer truncated.
122 */
123
124 /*
125 * OBSOLETE BEHAVIOR:
126 * If the original source was a string, we must truncate the buffer,
127 * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
128 * copy must not truncate the original buffer.
129 */
130 if (OriginalSrcType == ACPI_TYPE_STRING)
131 {
132 /* Set the new length of the target */
133
134 TargetDesc->Buffer.Length = Length;
135 }
136#endif
137 }
138 else
139 {
140 /* Truncate the source, copy only what will fit */
141
142 memcpy (TargetDesc->Buffer.Pointer, Buffer,
143 TargetDesc->Buffer.Length);
144
146 "Truncating source buffer from %X to %X\n",
147 Length, TargetDesc->Buffer.Length));
148 }
149
150 /* Copy flags */
151
152 TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags;
153 TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
155}
unsigned char UINT8
unsigned int UINT32
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_OK
Definition: acexcep.h:97
#define AOPOBJ_STATIC_POINTER
Definition: acobject.h:95
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_ALLOCATE(a)
Definition: actypes.h:384
Definition: bufpool.h:45
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define memset(x, y, z)
Definition: compat.h:39
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522

Referenced by AcpiExStoreObjectToObject().

◆ AcpiExStoreStringToString()

ACPI_STATUS AcpiExStoreStringToString ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT TargetDesc 
)

Definition at line 172 of file exstorob.c.

175{
177 UINT8 *Buffer;
178
179
180 ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc);
181
182
183 /* If Source and Target are the same, just return */
184
185 if (SourceDesc == TargetDesc)
186 {
188 }
189
190 /* We know that SourceDesc is a string by now */
191
192 Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer);
193 Length = SourceDesc->String.Length;
194
195 /*
196 * Replace existing string value if it will fit and the string
197 * pointer is not a static pointer (part of an ACPI table)
198 */
199 if ((Length < TargetDesc->String.Length) &&
200 (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
201 {
202 /*
203 * String will fit in existing non-static buffer.
204 * Clear old string and copy in the new one
205 */
206 memset (TargetDesc->String.Pointer, 0,
207 (ACPI_SIZE) TargetDesc->String.Length + 1);
208 memcpy (TargetDesc->String.Pointer, Buffer, Length);
209 }
210 else
211 {
212 /*
213 * Free the current buffer, then allocate a new buffer
214 * large enough to hold the value
215 */
216 if (TargetDesc->String.Pointer &&
217 (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
218 {
219 /* Only free if not a pointer into the DSDT */
220
221 ACPI_FREE (TargetDesc->String.Pointer);
222 }
223
224 TargetDesc->String.Pointer =
225 ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
226
227 if (!TargetDesc->String.Pointer)
228 {
230 }
231
232 TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
233 memcpy (TargetDesc->String.Pointer, Buffer, Length);
234 }
235
236 /* Set the new target length */
237
238 TargetDesc->String.Length = Length;
240}
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
ACPI_OBJECT_STRING String
Definition: acobject.h:521
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by AcpiExStoreObjectToObject().