This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ex_store_string_to_string
1
2
3
4
5
6
7
8
9
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "acinterp.h"
13
14 #define _COMPONENT ACPI_EXECUTER
15 ACPI_MODULE_NAME("exstorob")
16
17
18
19
20
21
22
23
24
25
26
27
28
29 acpi_status
30 acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
31 union acpi_operand_object *target_desc)
32 {
33 u32 length;
34 u8 *buffer;
35
36 ACPI_FUNCTION_TRACE_PTR(ex_store_buffer_to_buffer, source_desc);
37
38
39
40 if (source_desc == target_desc) {
41 return_ACPI_STATUS(AE_OK);
42 }
43
44
45
46 buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer);
47 length = source_desc->buffer.length;
48
49
50
51
52
53 if ((target_desc->buffer.length == 0) ||
54 (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) {
55 target_desc->buffer.pointer = ACPI_ALLOCATE(length);
56 if (!target_desc->buffer.pointer) {
57 return_ACPI_STATUS(AE_NO_MEMORY);
58 }
59
60 target_desc->buffer.length = length;
61 }
62
63
64
65 if (length <= target_desc->buffer.length) {
66
67
68
69 memset(target_desc->buffer.pointer, 0,
70 target_desc->buffer.length);
71 memcpy(target_desc->buffer.pointer, buffer, length);
72
73 #ifdef ACPI_OBSOLETE_BEHAVIOR
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 if (original_src_type == ACPI_TYPE_STRING) {
89
90
91
92 target_desc->buffer.length = length;
93 }
94 #endif
95 } else {
96
97
98 memcpy(target_desc->buffer.pointer, buffer,
99 target_desc->buffer.length);
100
101 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
102 "Truncating source buffer from %X to %X\n",
103 length, target_desc->buffer.length));
104 }
105
106
107
108 target_desc->buffer.flags = source_desc->buffer.flags;
109 target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
110 return_ACPI_STATUS(AE_OK);
111 }
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126 acpi_status
127 acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
128 union acpi_operand_object *target_desc)
129 {
130 u32 length;
131 u8 *buffer;
132
133 ACPI_FUNCTION_TRACE_PTR(ex_store_string_to_string, source_desc);
134
135
136
137 if (source_desc == target_desc) {
138 return_ACPI_STATUS(AE_OK);
139 }
140
141
142
143 buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer);
144 length = source_desc->string.length;
145
146
147
148
149
150 if ((length < target_desc->string.length) &&
151 (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
152
153
154
155
156 memset(target_desc->string.pointer, 0,
157 (acpi_size)target_desc->string.length + 1);
158 memcpy(target_desc->string.pointer, buffer, length);
159 } else {
160
161
162
163
164 if (target_desc->string.pointer &&
165 (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) {
166
167
168
169 ACPI_FREE(target_desc->string.pointer);
170 }
171
172 target_desc->string.pointer =
173 ACPI_ALLOCATE_ZEROED((acpi_size)length + 1);
174
175 if (!target_desc->string.pointer) {
176 return_ACPI_STATUS(AE_NO_MEMORY);
177 }
178
179 target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
180 memcpy(target_desc->string.pointer, buffer, length);
181 }
182
183
184
185 target_desc->string.length = length;
186 return_ACPI_STATUS(AE_OK);
187 }