1 | /*␊ |
2 | * aml_generator.c␊ |
3 | * Chameleon␊ |
4 | *␊ |
5 | * Created by Mozodojo on 20/07/10.␊ |
6 | * Copyright 2010 mozo. All rights reserved.␊ |
7 | *␊ |
8 | */␊ |
9 | ␊ |
10 | #include "aml_generator.h"␊ |
11 | ␊ |
12 | bool aml_add_to_parent(struct aml_chunk* parent, struct aml_chunk* node)␊ |
13 | {␊ |
14 | ␉if (parent && node)␊ |
15 | ␉{␊ |
16 | ␉␉switch (parent->Type) ␊ |
17 | ␉␉{␊ |
18 | ␉␉␉case AML_CHUNK_NONE:␊ |
19 | ␉␉␉case AML_CHUNK_BYTE:␊ |
20 | ␉␉␉case AML_CHUNK_WORD:␊ |
21 | ␉␉␉case AML_CHUNK_DWORD:␊ |
22 | ␉␉␉case AML_CHUNK_QWORD:␊ |
23 | ␉␉␉case AML_CHUNK_ALIAS:␊ |
24 | ␉␉␉␉verbose("aml_add_to_parent: Node doesn't support child nodes!\n");␊ |
25 | ␉␉␉␉return false;␊ |
26 | ␉␉␉case AML_CHUNK_NAME:␊ |
27 | ␉␉␉␉if (parent->First) ␊ |
28 | ␉␉␉␉{␊ |
29 | ␉␉␉␉␉verbose("aml_add_to_parent: Name node supports only one child node!\n");␊ |
30 | ␉␉␉␉␉return false;␊ |
31 | ␉␉␉␉}␊ |
32 | ␉␉␉␉break;␊ |
33 | ␊ |
34 | ␉␉␉default:␊ |
35 | ␉␉␉␉break;␊ |
36 | ␉␉}␊ |
37 | ␉␉␊ |
38 | ␉␉if (!parent->First)␊ |
39 | ␉␉␉parent->First = node;␊ |
40 | ␉␉␊ |
41 | ␉␉if (parent->Last)␊ |
42 | ␉␉␉parent->Last->Next = node;␊ |
43 | ␉␉␊ |
44 | ␉␉parent->Last = node;␊ |
45 | ␉␉␊ |
46 | ␉␉return true;␊ |
47 | ␉}␊ |
48 | ␉␊ |
49 | ␉return false;␊ |
50 | }␊ |
51 | ␊ |
52 | struct aml_chunk* aml_create_node(struct aml_chunk* parent)␊ |
53 | {␊ |
54 | ␉struct aml_chunk* node = (struct aml_chunk*)malloc(sizeof(struct aml_chunk));␊ |
55 | ␉␊ |
56 | ␉aml_add_to_parent(parent, node);␊ |
57 | ␉␊ |
58 | ␉return node;␊ |
59 | }␊ |
60 | ␊ |
61 | void aml_destroy_node(struct aml_chunk* node)␊ |
62 | {␊ |
63 | ␉// Delete child nodes␊ |
64 | ␉struct aml_chunk* child = node->First;␊ |
65 | ␉␊ |
66 | ␉while (child) ␊ |
67 | ␉{␊ |
68 | ␉␉struct aml_chunk* next = child->Next;␊ |
69 | ␉␉␊ |
70 | ␉␉if (child->Buffer)␊ |
71 | ␉␉␉free(child->Buffer);␊ |
72 | ␉␉␊ |
73 | ␉␉free(child);␊ |
74 | ␉␉␊ |
75 | ␉␉child = next;␊ |
76 | ␉}␊ |
77 | ␉␊ |
78 | ␉// Free node␊ |
79 | ␉if (node->Buffer)␊ |
80 | ␉␉free(node->Buffer);␊ |
81 | ␉␊ |
82 | ␉free(node);␊ |
83 | }␊ |
84 | ␊ |
85 | struct aml_chunk* aml_add_buffer(struct aml_chunk* parent, const char* buffer, unsigned int size)␊ |
86 | {␊ |
87 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
88 | ␉␊ |
89 | ␉if (node) ␊ |
90 | ␉{␊ |
91 | ␉␉node->Type = AML_CHUNK_NONE;␊ |
92 | ␉␉node->Length = size;␊ |
93 | ␉␉node->Buffer = malloc(node->Length);␊ |
94 | ␉␉memcpy(node->Buffer, buffer, node->Length);␊ |
95 | ␉}␊ |
96 | ␉␊ |
97 | ␉return node;␊ |
98 | }␊ |
99 | ␊ |
100 | struct aml_chunk* aml_add_byte(struct aml_chunk* parent, unsigned char value)␊ |
101 | {␊ |
102 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
103 | ␉␊ |
104 | ␉if (node) ␊ |
105 | ␉{␊ |
106 | ␉␉node->Type = AML_CHUNK_BYTE;␊ |
107 | ␉␉␊ |
108 | ␉␉node->Length = 1;␊ |
109 | ␉␉node->Buffer = malloc(node->Length);␊ |
110 | ␉␉node->Buffer[0] = value;␊ |
111 | ␉}␊ |
112 | ␉␊ |
113 | ␉return node;␊ |
114 | }␊ |
115 | ␊ |
116 | struct aml_chunk* aml_add_word(struct aml_chunk* parent, unsigned int value)␊ |
117 | {␊ |
118 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
119 | ␉␊ |
120 | ␉if (node) ␊ |
121 | ␉{␊ |
122 | ␉␉node->Type = AML_CHUNK_WORD;␊ |
123 | ␉␉node->Length = 2;␊ |
124 | ␉␉node->Buffer = malloc(node->Length);␊ |
125 | ␉␉node->Buffer[0] = value & 0xff;␊ |
126 | ␉␉node->Buffer[1] = value >> 8;␊ |
127 | ␉}␊ |
128 | ␉␊ |
129 | ␉return node;␊ |
130 | }␊ |
131 | ␊ |
132 | struct aml_chunk* aml_add_dword(struct aml_chunk* parent, unsigned long value)␊ |
133 | {␊ |
134 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
135 | ␉␊ |
136 | ␉if (node) ␊ |
137 | ␉{␊ |
138 | ␉␉node->Type = AML_CHUNK_DWORD;␊ |
139 | ␉␉node->Length = 4;␊ |
140 | ␉␉node->Buffer = malloc(node->Length);␊ |
141 | ␉␉node->Buffer[0] = value & 0xff;␊ |
142 | ␉␉node->Buffer[1] = (value >> 8) & 0xff;␊ |
143 | ␉␉node->Buffer[2] = (value >> 16) & 0xff;␊ |
144 | ␉␉node->Buffer[3] = (value >> 24) & 0xff;␊ |
145 | ␉}␊ |
146 | ␉␊ |
147 | ␉return node;␊ |
148 | }␊ |
149 | ␊ |
150 | struct aml_chunk* aml_add_qword(struct aml_chunk* parent, unsigned long long value)␊ |
151 | {␊ |
152 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
153 | ␉␊ |
154 | ␉if (node) ␊ |
155 | ␉{␊ |
156 | ␉␉node->Type = AML_CHUNK_QWORD;␊ |
157 | ␉␉node->Length = 8;␊ |
158 | ␉␉node->Buffer = malloc(node->Length);␊ |
159 | ␉␉node->Buffer[0] = value & 0xff;␊ |
160 | ␉␉node->Buffer[1] = (value >> 8) & 0xff;␊ |
161 | ␉␉node->Buffer[2] = (value >> 16) & 0xff;␊ |
162 | ␉␉node->Buffer[3] = (value >> 24) & 0xff;␊ |
163 | ␉␉node->Buffer[4] = (value >> 32) & 0xff;␊ |
164 | ␉␉node->Buffer[5] = (value >> 40) & 0xff;␊ |
165 | ␉␉node->Buffer[6] = (value >> 48) & 0xff;␊ |
166 | ␉␉node->Buffer[7] = (value >> 56) & 0xff;␊ |
167 | ␉}␊ |
168 | ␉␊ |
169 | ␉return node;␊ |
170 | }␊ |
171 | ␊ |
172 | unsigned int aml_fill_simple_name(char* buffer, const char* name)␊ |
173 | {␊ |
174 | ␉if (strlen(name) < 4) ␊ |
175 | ␉{␊ |
176 | ␉␉verbose("aml_fill_simple_name: simple name %s has incorrect lengh! Must be 4.\n", name);␊ |
177 | ␉␉return 0;␊ |
178 | ␉}␊ |
179 | ␉␊ |
180 | ␉memcpy(buffer, name, 4);␊ |
181 | ␉return 4;␊ |
182 | }␊ |
183 | ␊ |
184 | unsigned int aml_fill_name(struct aml_chunk* node, const char* name)␊ |
185 | {␊ |
186 | ␉if (!node) ␊ |
187 | ␉␉return 0;␊ |
188 | ␉␊ |
189 | ␉int len = strlen(name), offset = 0, count = len / 4;␊ |
190 | ␉␊ |
191 | ␉if ((len % 4) > 1 || count == 0) ␊ |
192 | ␉{␊ |
193 | ␉␉verbose("aml_fill_name: pathname %s has incorrect length! Must be 4, 8, 12, 16, etc...\n", name);␊ |
194 | ␉␉return 0;␊ |
195 | ␉}␊ |
196 | ␉␊ |
197 | ␉unsigned int root = 0;␊ |
198 | ␊ |
199 | ␉if (((len % 4) == 1) && (name[0] == '\\'))␊ |
200 | ␉␉root++;␊ |
201 | ␉␉␉␊ |
202 | ␉if (count == 1) ␊ |
203 | ␉{␊ |
204 | ␉␉node->Length = 4 + root;␊ |
205 | ␉␉node->Buffer = malloc(node->Length);␊ |
206 | ␉␉memcpy(node->Buffer, name, 4 + root);␊ |
207 | ␊ |
208 | ␉␉return node->Length;␊ |
209 | ␉}␊ |
210 | ␉␊ |
211 | ␉if (count == 2) ␊ |
212 | ␉{␊ |
213 | ␉␉node->Length = 2 + 8;␊ |
214 | ␉␉node->Buffer = malloc(node->Length);␊ |
215 | ␉␉node->Buffer[offset++] = 0x5c; // Root Char␊ |
216 | ␉␉node->Buffer[offset++] = 0x2e; // Double name␊ |
217 | ␉␉memcpy(node->Buffer+offset, name + root, 8);␊ |
218 | ␉␉return node->Length;␊ |
219 | ␉}␊ |
220 | ␉␊ |
221 | ␉node->Length = 3 + count*4;␊ |
222 | ␉node->Buffer = malloc(node->Length);␊ |
223 | ␉node->Buffer[offset++] = 0x5c; // Root Char␊ |
224 | ␉node->Buffer[offset++] = 0x2f; // Multi name␊ |
225 | ␉node->Buffer[offset++] = count; // Names count␊ |
226 | ␉memcpy(node->Buffer+offset, name + root, count*4);␊ |
227 | ␉␊ |
228 | ␉return node->Length;␊ |
229 | }␊ |
230 | ␊ |
231 | struct aml_chunk* aml_add_scope(struct aml_chunk* parent, const char* name)␊ |
232 | {␊ |
233 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
234 | ␉␊ |
235 | ␉if (node)␊ |
236 | ␉{␊ |
237 | ␉␉node->Type = AML_CHUNK_SCOPE;␊ |
238 | ␉␉␊ |
239 | ␉␉aml_fill_name(node, name);␊ |
240 | ␉}␊ |
241 | ␉␊ |
242 | ␉return node;␊ |
243 | }␊ |
244 | ␊ |
245 | struct aml_chunk* aml_add_name(struct aml_chunk* parent, const char* name)␊ |
246 | {␊ |
247 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
248 | ␉␊ |
249 | ␉if (node)␊ |
250 | ␉{␊ |
251 | ␉␉node->Type = AML_CHUNK_NAME;␊ |
252 | ␉␉␊ |
253 | ␉␉aml_fill_name(node, name);␊ |
254 | ␉}␊ |
255 | ␉␊ |
256 | ␉return node;␊ |
257 | }␊ |
258 | ␊ |
259 | struct aml_chunk* aml_add_package(struct aml_chunk* parent)␊ |
260 | {␊ |
261 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
262 | ␉␊ |
263 | ␉if (node)␊ |
264 | ␉{␊ |
265 | ␉␉node->Type = AML_CHUNK_PACKAGE;␊ |
266 | ␉␉␊ |
267 | ␉␉node->Length = 1;␊ |
268 | ␉␉node->Buffer = malloc(node->Length);␊ |
269 | ␉}␊ |
270 | ␉␊ |
271 | ␉return node;␊ |
272 | }␊ |
273 | ␊ |
274 | struct aml_chunk* aml_add_alias(struct aml_chunk* parent, const char* name1, const char* name2)␊ |
275 | {␊ |
276 | ␉struct aml_chunk* node = aml_create_node(parent);␊ |
277 | ␉␊ |
278 | ␉if (node)␊ |
279 | ␉{␊ |
280 | ␉␉node->Type = AML_CHUNK_ALIAS;␊ |
281 | ␊ |
282 | ␉␉node->Length = 8;␊ |
283 | ␉␉node->Buffer = malloc(node->Length);␊ |
284 | ␉␉aml_fill_simple_name(node->Buffer, name1);␊ |
285 | ␉␉aml_fill_simple_name(node->Buffer+4, name2);␊ |
286 | ␉}␊ |
287 | ␊ |
288 | ␉return node;␊ |
289 | }␊ |
290 | ␊ |
291 | unsigned char aml_get_size_length(unsigned int size)␊ |
292 | {␊ |
293 | ␉if (size + 1 <= 0x3f)␊ |
294 | ␉␉return 1;␊ |
295 | ␉else if (size + 2 <= 0xfff) /* Encode in 4 bits and 1 byte */␊ |
296 | ␉␉return 2;␊ |
297 | ␉else if (size + 3 <= 0xfffff) /* Encode in 4 bits and 2 bytes */␊ |
298 | ␉␉return 3;␊ |
299 | ␉␊ |
300 | ␉return 4; /* Encode 0xfffffff in 4 bits and 2 bytes */␊ |
301 | }␊ |
302 | ␊ |
303 | unsigned int aml_calculate_size(struct aml_chunk* node)␊ |
304 | {␊ |
305 | ␉if (node)␊ |
306 | ␉{␊ |
307 | ␉␉node->Size = 0;␊ |
308 | ␉␉␊ |
309 | ␉␉// Calculate child nodes size␊ |
310 | ␉␉struct aml_chunk* child = node->First;␊ |
311 | ␉␉unsigned char child_count = 0;␊ |
312 | ␉␉␊ |
313 | ␉␉while (child) ␊ |
314 | ␉␉{␊ |
315 | ␉␉␉child_count++;␊ |
316 | ␉␉␉␊ |
317 | ␉␉␉node->Size += aml_calculate_size(child);␊ |
318 | ␉␉␉␊ |
319 | ␉␉␉child = child->Next;␊ |
320 | ␉␉}␊ |
321 | ␉␉␊ |
322 | ␉␉switch (node->Type) ␊ |
323 | ␉␉{␊ |
324 | ␉␉␉case AML_CHUNK_NONE:␊ |
325 | ␉␉␉␉node->Size += node->Length;␊ |
326 | ␉␉␉␉break;␊ |
327 | ␉␉␉case AML_CHUNK_SCOPE:␊ |
328 | ␉␉␉␉node->Size += 1 + node->Length;␊ |
329 | ␉␉␉␉node->Size += aml_get_size_length(node->Size);␊ |
330 | ␉␉␉␉break;␊ |
331 | ␉␉␉case AML_CHUNK_PACKAGE:␊ |
332 | ␉␉␉␉node->Buffer[0] = child_count;␊ |
333 | ␉␉␉␉node->Size += 1 + node->Length;␊ |
334 | ␉␉␉␉node->Size += aml_get_size_length(node->Size);␊ |
335 | ␉␉␉␉break;␊ |
336 | ␉␉␉␉␊ |
337 | ␉␉␉case AML_CHUNK_BYTE:␊ |
338 | ␉␉␉␉if (node->Buffer[0] == 0x0 || node->Buffer[0] == 0x1) ␊ |
339 | ␉␉␉␉{␊ |
340 | ␉␉␉␉␉node->Size += node->Length;␊ |
341 | ␉␉␉␉}␊ |
342 | ␉␉␉␉else ␊ |
343 | ␉␉␉␉{␊ |
344 | ␉␉␉␉␉node->Size += 1 + node->Length;␊ |
345 | ␉␉␉␉}␊ |
346 | ␉␉␉␉␊ |
347 | ␉␉␉␉break;␊ |
348 | ␉␉␉␉␊ |
349 | ␉␉␉case AML_CHUNK_WORD:␊ |
350 | ␉␉␉case AML_CHUNK_DWORD:␊ |
351 | ␉␉␉case AML_CHUNK_QWORD:␊ |
352 | ␉␉␉case AML_CHUNK_ALIAS:␊ |
353 | ␉␉␉case AML_CHUNK_NAME:␊ |
354 | ␉␉␉␉node->Size += 1 + node->Length;␊ |
355 | ␉␉␉␉break;␊ |
356 | ␉␉}␊ |
357 | ␉␉␊ |
358 | ␉␉return node->Size;␊ |
359 | ␉}␊ |
360 | ␉␊ |
361 | ␉return 0;␊ |
362 | }␊ |
363 | ␊ |
364 | unsigned int aml_write_byte(unsigned char value, char* buffer, unsigned int offset)␊ |
365 | {␊ |
366 | ␉buffer[offset++] = value;␊ |
367 | ␉␊ |
368 | ␉return offset;␊ |
369 | }␊ |
370 | ␊ |
371 | unsigned int aml_write_word(unsigned int value, char* buffer, unsigned int offset)␊ |
372 | {␊ |
373 | ␉buffer[offset++] = value & 0xff;␊ |
374 | ␉buffer[offset++] = value >> 8;␊ |
375 | ␉␊ |
376 | ␉return offset;␊ |
377 | }␊ |
378 | ␊ |
379 | unsigned int aml_write_dword(unsigned long value, char* buffer, unsigned int offset)␊ |
380 | {␊ |
381 | ␉buffer[offset++] = value & 0xff;␊ |
382 | ␉buffer[offset++] = (value >> 8) & 0xff;␊ |
383 | ␉buffer[offset++] = (value >> 16) & 0xff;␊ |
384 | ␉buffer[offset++] = (value >> 24) & 0xff;␊ |
385 | ␉␊ |
386 | ␉return offset;␊ |
387 | }␊ |
388 | ␊ |
389 | unsigned int aml_write_qword(unsigned long long value, char* buffer, unsigned int offset)␊ |
390 | {␊ |
391 | ␉buffer[offset++] = value & 0xff;␊ |
392 | ␉buffer[offset++] = (value >> 8) & 0xff;␊ |
393 | ␉buffer[offset++] = (value >> 16) & 0xff;␊ |
394 | ␉buffer[offset++] = (value >> 24) & 0xff;␊ |
395 | ␉buffer[offset++] = (value >> 32) & 0xff;␊ |
396 | ␉buffer[offset++] = (value >> 40) & 0xff;␊ |
397 | ␉buffer[offset++] = (value >> 48) & 0xff;␊ |
398 | ␉buffer[offset++] = (value >> 56) & 0xff;␊ |
399 | ␉␊ |
400 | ␉return offset;␊ |
401 | }␊ |
402 | ␊ |
403 | unsigned int aml_write_buffer(const char* value, unsigned int size, char* buffer, unsigned int offset)␊ |
404 | {␊ |
405 | ␉if (size > 0)␊ |
406 | ␉{␊ |
407 | ␉␉memcpy(buffer + offset, value, size);␊ |
408 | ␉}␊ |
409 | ␉␊ |
410 | ␉return offset + size;␊ |
411 | }␊ |
412 | ␊ |
413 | unsigned int aml_write_size(unsigned int size, char* buffer, unsigned int offset)␊ |
414 | {␊ |
415 | ␉if (size <= 0x3f) /* simple 1 byte length in 6 bits */␊ |
416 | ␉{␊ |
417 | ␉␉buffer[offset++] = size;␊ |
418 | ␉}␊ |
419 | ␉else if (size <= 0xfff) ␊ |
420 | ␉{␊ |
421 | ␉␉buffer[offset++] = 0x40 | (size & 0xf); /* 0x40 is type, 0x0X is first nibble of length */␊ |
422 | ␉␉buffer[offset++] = (size >> 4) & 0xff; /* +1 bytes for rest length */␊ |
423 | ␉}␊ |
424 | ␉else if (size <= 0xfffff) ␊ |
425 | ␉{␊ |
426 | ␉␉buffer[offset++] = 0x80 | (size & 0xf); /* 0x80 is type, 0x0X is first nibble of length */␊ |
427 | ␉␉buffer[offset++] = (size >> 4) & 0xff; /* +2 bytes for rest length */␊ |
428 | ␉␉buffer[offset++] = (size >> 12) & 0xff;␊ |
429 | ␉}␊ |
430 | else ␊ |
431 | ␉{␊ |
432 | ␉␉buffer[offset++] = 0xc0 | (size & 0xf); /* 0xC0 is type, 0x0X is first nibble of length */␊ |
433 | ␉␉buffer[offset++] = (size >> 4) & 0xff; /* +3 bytes for rest length */␊ |
434 | ␉␉buffer[offset++] = (size >> 12) & 0xff;␊ |
435 | ␉␉buffer[offset++] = (size >> 20) & 0xff;␊ |
436 | ␉}␊ |
437 | ␉␊ |
438 | ␉return offset;␊ |
439 | }␊ |
440 | ␊ |
441 | unsigned int aml_write_node(struct aml_chunk* node, char* buffer, unsigned int offset)␊ |
442 | {␊ |
443 | ␉if (node && buffer) ␊ |
444 | ␉{␊ |
445 | ␉␉unsigned int old = offset;␊ |
446 | ␉␉␊ |
447 | ␉␉switch (node->Type) ␊ |
448 | ␉␉{␊ |
449 | ␉␉␉case AML_CHUNK_NONE:␊ |
450 | ␉␉␉␉offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);␊ |
451 | ␉␉␉␉break;␊ |
452 | ␊ |
453 | ␉␉␉case AML_CHUNK_SCOPE:␊ |
454 | ␉␉␉case AML_CHUNK_PACKAGE:␊ |
455 | ␉␉␉␉offset = aml_write_byte(node->Type, buffer, offset);␊ |
456 | ␉␉␉␉offset = aml_write_size(node->Size-1, buffer, offset);␊ |
457 | ␉␉␉␉offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);␊ |
458 | ␉␉␉␉break;␊ |
459 | ␉␉␉␉␊ |
460 | ␉␉␉case AML_CHUNK_BYTE:␊ |
461 | ␉␉␉␉if (node->Buffer[0] == 0x0 || node->Buffer[0] == 0x1) ␊ |
462 | ␉␉␉␉{␊ |
463 | ␉␉␉␉␉offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);␊ |
464 | ␉␉␉␉}␊ |
465 | ␉␉␉␉else ␊ |
466 | ␉␉␉␉{␊ |
467 | ␉␉␉␉␉offset = aml_write_byte(node->Type, buffer, offset);␊ |
468 | ␉␉␉␉␉offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);␊ |
469 | ␉␉␉␉}␊ |
470 | ␉␉␉␉break;␊ |
471 | ␉␉␉␉␊ |
472 | ␉␉␉case AML_CHUNK_WORD:␊ |
473 | ␉␉␉case AML_CHUNK_DWORD:␊ |
474 | ␉␉␉case AML_CHUNK_QWORD:␊ |
475 | ␉␉␉case AML_CHUNK_ALIAS:␊ |
476 | ␉␉␉case AML_CHUNK_NAME:␊ |
477 | ␉␉␉␉offset = aml_write_byte(node->Type, buffer, offset);␊ |
478 | ␉␉␉␉offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);␊ |
479 | ␉␉␉␉break;␊ |
480 | ␉␉␉␉␊ |
481 | ␉␉␉default:␊ |
482 | ␉␉␉␉break;␊ |
483 | ␉␉}␊ |
484 | ␊ |
485 | ␉␉struct aml_chunk* child = node->First;␊ |
486 | ␉␉␊ |
487 | ␉␉while (child) ␊ |
488 | ␉␉{␊ |
489 | ␉␉␉offset = aml_write_node(child, buffer, offset);␊ |
490 | ␉␉␉␊ |
491 | ␉␉␉child = child->Next;␊ |
492 | ␉␉}␊ |
493 | ␉␉␊ |
494 | ␉␉if (offset - old != node->Size) ␊ |
495 | ␉␉␉verbose("Node size incorrect: type=0x%x size=%x offset=%x\n",␊ |
496 | ␉␉␉node->Type, node->Size, (offset - old));␊ |
497 | ␉}␊ |
498 | ␉␊ |
499 | ␉return offset;␊ |
500 | }␊ |
501 | |