Chameleon

Chameleon Commit Details

Date:2012-12-16 13:54:54 (11 years 4 months ago)
Author:ErmaC
Commit:2144
Parents: 2143
Message:aml generator update and improvements (credits to Slice and all Clover Team)
Changes:
M/branches/ErmaC/MainTrunkPatch/i386/libsaio/aml_generator.h
M/branches/ErmaC/MainTrunkPatch/i386/libsaio/aml_generator.c

File differences

branches/ErmaC/MainTrunkPatch/i386/libsaio/aml_generator.c
99
1010
1111
12
12
1313
1414
1515
......
2121
2222
2323
24
24
2525
2626
2727
2828
29
29
3030
3131
3232
......
4949
5050
5151
52
52
5353
54
54
5555
5656
5757
5858
5959
6060
61
61
6262
6363
64
64
6565
6666
6767
68
68
6969
7070
7171
......
8282
8383
8484
85
85
8686
87
87
8888
8989
9090
9191
92
92
9393
9494
9595
......
9797
9898
9999
100
100
101101
102
102
103103
104104
105105
......
113113
114114
115115
116
116
117117
118
118
119119
120120
121121
......
129129
130130
131131
132
132
133133
134
134
135135
136136
137137
......
147147
148148
149149
150
150
151151
152
152
153153
154154
155155
......
169169
170170
171171
172
172
173173
174174
175175
......
181181
182182
183183
184
184
185185
186
186
187
188
189
190
187191
188
189
190
192
193
194
195
196
197
191198
192199
193200
194201
195202
196203
197
198
199
204
200205
201206
202207
203208
204
205
209
210
206211
207
212
213
208214
209215
210216
211217
212218
213
219
214220
215221
216222
217
223
224
218225
219226
220
221
227
228
222229
223230
224
231
225232
226
227
233
234
228235
229236
230
237
231238
232
239
233240
234241
235242
......
241248
242249
243250
244
251
245252
246
253
247254
248255
249256
......
255262
256263
257264
258
265
259266
260
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
261284
262285
263286
......
270293
271294
272295
273
296
274297
275
298
276299
277300
278301
279302
280
303
281304
282305
283306
284307
285308
286
309
287310
288311
289312
290
313
291314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
292448
293449
294
450
295451
296
452
297453
298454
299
455
300456
301457
302
458
303459
304460
305461
306
307
308462
309
310
463
464
311465
466
312467
313468
314469
315470
316
471
317472
318473
319474
......
321476
322477
323478
479
480
324481
325482
483
484
326485
486
327487
328488
329489
490
491
492
493
494
495
330496
331497
332498
......
350516
351517
352518
519
520
353521
354522
355523
......
360528
361529
362530
363
531
364532
365533
366534
367535
368536
369537
370
538
371539
372540
373541
......
375543
376544
377545
378
546
379547
380548
381549
......
385553
386554
387555
388
556
389557
390558
391559
......
399567
400568
401569
402
570
403571
404572
405573
......
409577
410578
411579
412
580
413581
414
582
415583
416
584
417585
418
586
419587
420
421
588
589
422590
423
591
424592
425
426
593
594
427595
428596
429597
430598
431
432
599
600
433601
434602
435603
......
437605
438606
439607
440
608
441609
442610
443611
444
612
613
445614
446615
447616
......
449618
450619
451620
621
622
623
624
625
626
627
628
629
630
631
632
452633
634
453635
636
454637
455638
456639
......
473656
474657
475658
659
660
476661
477662
478663
......
481666
482667
483668
484
485
486669
487670
488671
......
491674
492675
493676
494
677
678
495679
496680
497681
#include "aml_generator.h"
bool aml_add_to_parent(struct aml_chunk* parent, struct aml_chunk* node)
bool aml_add_to_parent(AML_CHUNK* parent, AML_CHUNK* node)
{
if (parent && node)
{
case AML_CHUNK_DWORD:
case AML_CHUNK_QWORD:
case AML_CHUNK_ALIAS:
verbose("aml_add_to_parent: node doesn't support child nodes!\n");
verbose("aml_add_to_parent: Node doesn't support child nodes!\n");
return false;
case AML_CHUNK_NAME:
if (parent->First)
{
verbose("aml_add_to_parent: name node supports only one child node!\n");
verbose("aml_add_to_parent: Name node supports only one child node!\n");
return false;
}
break;
return false;
}
struct aml_chunk* aml_create_node(struct aml_chunk* parent)
AML_CHUNK* aml_create_node(AML_CHUNK* parent)
{
struct aml_chunk* node = (struct aml_chunk*)malloc(sizeof(struct aml_chunk));
AML_CHUNK* node = (AML_CHUNK*)malloc(sizeof(AML_CHUNK));
aml_add_to_parent(parent, node);
return node;
}
void aml_destroy_node(struct aml_chunk* node)
void aml_destroy_node(AML_CHUNK* node)
{
// Delete child nodes
struct aml_chunk* child = node->First;
AML_CHUNK* child = node->First;
while (child)
{
struct aml_chunk* next = child->Next;
AML_CHUNK* next = child->Next;
if (child->Buffer)
free(child->Buffer);
free(node);
}
struct aml_chunk* aml_add_buffer(struct aml_chunk* parent, const char* buffer, unsigned int size)
AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, const char* buffer, uint32_t size)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_CHUNK_NONE;
node->Length = size;
node->Length = (uint16_t)size;
node->Buffer = malloc(node->Length);
memcpy(node->Buffer, buffer, node->Length);
}
return node;
}
struct aml_chunk* aml_add_byte(struct aml_chunk* parent, unsigned char value)
AML_CHUNK* aml_add_byte(AML_CHUNK* parent, unsigned char value)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
return node;
}
struct aml_chunk* aml_add_word(struct aml_chunk* parent, unsigned int value)
AML_CHUNK* aml_add_word(AML_CHUNK* parent, uint16_t value)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
return node;
}
struct aml_chunk* aml_add_dword(struct aml_chunk* parent, unsigned long value)
AML_CHUNK* aml_add_dword(AML_CHUNK* parent, uint32_t value)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
return node;
}
struct aml_chunk* aml_add_qword(struct aml_chunk* parent, unsigned long long value)
AML_CHUNK* aml_add_qword(AML_CHUNK* parent, uint64_t value)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
return node;
}
unsigned int aml_fill_simple_name(char* buffer, const char* name)
uint32_t aml_fill_simple_name(char* buffer, const char* name)
{
if (strlen(name) < 4)
{
return 4;
}
unsigned int aml_fill_name(struct aml_chunk* node, const char* name)
uint32_t aml_fill_name(AML_CHUNK* node, const char* name)
{
if (!node)
int len, offset, count;
uint32_t root = 0;
if (!node)
{
return 0;
int len = strlen(name), offset = 0, count = len / 4;
}
len = strlen(name);
offset = 0;
count = len >> 2;
if ((len % 4) > 1 || count == 0)
{
verbose("aml_fill_name: pathname %s has incorrect length! Must be 4, 8, 12, 16, etc...\n", name);
return 0;
}
unsigned int root = 0;
if ((len % 4) == 1 && name[0] == '\\')
if (((len % 4) == 1) && (name[0] == '\\'))
root++;
if (count == 1)
{
node->Length = 4 + root;
node->Buffer = malloc(node->Length);
node->Length = (uint16_t)(4 + root);
node->Buffer = malloc(node->Length+4);
memcpy(node->Buffer, name, 4 + root);
return node->Length;
offset += 4 + root;
return (uint32_t)offset;
}
if (count == 2)
{
node->Length = 2 + 8;
node->Buffer = malloc(node->Length);
node->Buffer = malloc(node->Length+4);
node->Buffer[offset++] = 0x5c; // Root Char
node->Buffer[offset++] = 0x2e; // Double name
memcpy(node->Buffer+offset, name + root, 8);
return node->Length;
offset += 8;
return (uint32_t)offset;
}
node->Length = 3 + count*4;
node->Buffer = malloc(node->Length);
node->Length = (uint16_t)(3 + (count << 2));
node->Buffer = malloc(node->Length+4);
node->Buffer[offset++] = 0x5c; // Root Char
node->Buffer[offset++] = 0x2f; // Multi name
node->Buffer[offset++] = count; // Names count
node->Buffer[offset++] = (char)count; // Names count
memcpy(node->Buffer+offset, name + root, count*4);
return node->Length;
offset += count*4;
return (uint32_t)offset;
}
struct aml_chunk* aml_add_scope(struct aml_chunk* parent, const char* name)
AML_CHUNK* aml_add_scope(AML_CHUNK* parent, const char* name)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
return node;
}
struct aml_chunk* aml_add_name(struct aml_chunk* parent, const char* name)
AML_CHUNK* aml_add_name(AML_CHUNK* parent, const char* name)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
return node;
}
struct aml_chunk* aml_add_package(struct aml_chunk* parent)
AML_CHUNK* aml_add_method(AML_CHUNK* parent, const char* name, uint8_t args)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
int offset = aml_fill_name(node, name);
node->Type = AML_CHUNK_METHOD;
node->Length++;
node->Buffer[offset] = args;
}
return node;
}
AML_CHUNK* aml_add_package(AML_CHUNK* parent)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
return node;
}
struct aml_chunk* aml_add_alias(struct aml_chunk* parent, const char* name1, const char* name2)
AML_CHUNK* aml_add_alias(AML_CHUNK* parent, const char* name1, const char* name2)
{
struct aml_chunk* node = aml_create_node(parent);
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_CHUNK_ALIAS;
node->Length = 8;
node->Buffer = malloc(node->Length);
aml_fill_simple_name(node->Buffer, name1);
aml_fill_simple_name(node->Buffer+4, name2);
}
return node;
}
unsigned char aml_get_size_length(unsigned int size)
AML_CHUNK* aml_add_return_name(AML_CHUNK* parent, const char* name)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_CHUNK_RETURN;
aml_fill_name(node, name);
}
return node;
}
AML_CHUNK* aml_add_return_byte(AML_CHUNK* parent, uint8_t value)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_CHUNK_RETURN;
aml_add_byte(node, value);
}
return node;
}
AML_CHUNK* aml_add_device(AML_CHUNK* parent, const char* name)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_CHUNK_DEVICE;
aml_fill_name(node, name);
}
return node;
}
AML_CHUNK* aml_add_local0(AML_CHUNK* parent)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_CHUNK_LOCAL0;
node->Length = 1;
}
return node;
}
AML_CHUNK* aml_add_store(AML_CHUNK* parent)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_STORE_OP;
node->Length = 1;
}
return node;
}
AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, const char* data, uint32_t size)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
int offset = 0;
node->Type = AML_CHUNK_BUFFER;
node->Length = (uint8_t)(size + 2);
node->Buffer = malloc (node->Length);
node->Buffer[offset++] = AML_CHUNK_BYTE;
node->Buffer[offset++] = (char)size;
memcpy(node->Buffer+offset,data, node->Length);
}
return node;
}
AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, const char* string)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
unsigned int offset=0;
unsigned int len = strlen(string);
node->Type = AML_CHUNK_BUFFER;
node->Length = (uint8_t)(len + 3);
node->Buffer = malloc (node->Length);
node->Buffer[offset++] = AML_CHUNK_BYTE;
node->Buffer[offset++] = (char)len;
memcpy(node->Buffer+offset,string, len);
node->Buffer[offset+len] = '\0';
}
return node;
}
AML_CHUNK* aml_add_string(AML_CHUNK* parent, const char* string)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
int len = strlen(string);
node->Type = AML_CHUNK_STRING;
node->Length = (uint8_t)(len + 1);
node->Buffer = malloc (len);
memcpy(node->Buffer,string, len);
node->Buffer[len] = '\0';
}
return node;
}
AML_CHUNK* aml_add_return(AML_CHUNK* parent)
{
AML_CHUNK* node = aml_create_node(parent);
if (node)
{
node->Type = AML_CHUNK_RETURN;
//aml_add_byte(node, value);
}
return node;
}
uint8_t aml_get_size_length(uint32_t size)
{
if (size + 1 <= 0x3f)
return 1;
else if (size + 2 <= 0x3fff)
else if (size + 2 <= 0xfff) /* Encode in 4 bits and 1 byte */
return 2;
else if (size + 3 <= 0x3fffff)
else if (size + 3 <= 0xfffff) /* Encode in 4 bits and 2 bytes */
return 3;
return 4;
return 4; /* Encode 0xfffffff in 4 bits and 2 bytes */
}
unsigned int aml_calculate_size(struct aml_chunk* node)
uint32_t aml_calculate_size(AML_CHUNK* node)
{
if (node)
{
node->Size = 0;
// Calculate child nodes size
struct aml_chunk* child = node->First;
unsigned char child_count = 0;
AML_CHUNK* child = node->First;
uint8_t child_count = 0;
node->Size = 0;
while (child)
{
child_count++;
node->Size += aml_calculate_size(child);
node->Size += (uint16_t)aml_calculate_size(child);
child = child->Next;
}
switch (node->Type)
{
case AML_CHUNK_NONE:
case AML_STORE_OP:
case AML_CHUNK_LOCAL0:
node->Size += node->Length;
break;
case AML_CHUNK_METHOD:
case AML_CHUNK_SCOPE:
case AML_CHUNK_BUFFER:
node->Size += 1 + node->Length;
node->Size += aml_get_size_length(node->Size);
break;
case AML_CHUNK_DEVICE:
node->Size += 2 + node->Length;
node->Size += aml_get_size_length(node->Size);
break;
case AML_CHUNK_PACKAGE:
node->Buffer[0] = child_count;
node->Size += 1 + node->Length;
case AML_CHUNK_QWORD:
case AML_CHUNK_ALIAS:
case AML_CHUNK_NAME:
case AML_CHUNK_RETURN:
case AML_CHUNK_STRING:
node->Size += 1 + node->Length;
break;
}
return 0;
}
unsigned int aml_write_byte(unsigned char value, char* buffer, unsigned int offset)
uint32_t aml_write_byte(uint8_t value, char* buffer, uint32_t offset)
{
buffer[offset++] = value;
return offset;
}
unsigned int aml_write_word(unsigned int value, char* buffer, unsigned int offset)
uint32_t aml_write_word(uint16_t value, char* buffer, uint32_t offset)
{
buffer[offset++] = value & 0xff;
buffer[offset++] = value >> 8;
return offset;
}
unsigned int aml_write_dword(unsigned long value, char* buffer, unsigned int offset)
uint32_t aml_write_dword(uint32_t value, char* buffer, uint32_t offset)
{
buffer[offset++] = value & 0xff;
buffer[offset++] = (value >> 8) & 0xff;
return offset;
}
unsigned int aml_write_qword(unsigned long long value, char* buffer, unsigned int offset)
uint32_t aml_write_qword(uint64_t value, char* buffer, uint32_t offset)
{
buffer[offset++] = value & 0xff;
buffer[offset++] = (value >> 8) & 0xff;
return offset;
}
unsigned int aml_write_buffer(const char* value, unsigned int size, char* buffer, unsigned int offset)
uint32_t aml_write_buffer(const char* value, uint32_t size, char* buffer, uint32_t offset)
{
if (size > 0)
{
return offset + size;
}
unsigned int aml_write_size(unsigned int size, char* buffer, unsigned int offset)
uint32_t aml_write_size(uint32_t size, char* buffer, uint32_t offset)
{
if (size <= 0x3f)
if (size <= 0x3f) /* simple 1 byte length in 6 bits */
{
buffer[offset++] = size;
buffer[offset++] = (char)size;
}
else if (size <= 0x3fff)
else if (size <= 0xfff)
{
buffer[offset++] = 0x40 | (size & 0xf);
buffer[offset++] = (size >> 4) & 0xff;
buffer[offset++] = 0x40 | (size & 0xf); /* 0x40 is type, 0x0X is first nibble of length */
buffer[offset++] = (size >> 4) & 0xff; /* +1 bytes for rest length */
}
else if (size <= 0x3fffff)
else if (size <= 0xfffff)
{
buffer[offset++] = 0x80 | (size & 0xf);
buffer[offset++] = (size >> 4) & 0xff;
buffer[offset++] = 0x80 | (size & 0xf); /* 0x80 is type, 0x0X is first nibble of length */
buffer[offset++] = (size >> 4) & 0xff; /* +2 bytes for rest length */
buffer[offset++] = (size >> 12) & 0xff;
}
else
{
buffer[offset++] = 0xc0 | (size & 0xf);
buffer[offset++] = (size >> 4) & 0xff;
buffer[offset++] = 0xc0 | (size & 0xf); /* 0xC0 is type, 0x0X is first nibble of length */
buffer[offset++] = (size >> 4) & 0xff; /* +3 bytes for rest length */
buffer[offset++] = (size >> 12) & 0xff;
buffer[offset++] = (size >> 20) & 0xff;
}
return offset;
}
unsigned int aml_write_node(struct aml_chunk* node, char* buffer, unsigned int offset)
uint32_t aml_write_node(AML_CHUNK* node, char* buffer, uint32_t offset)
{
if (node && buffer)
{
unsigned int old = offset;
uint32_t old = offset;
AML_CHUNK* child = node->First;
switch (node->Type)
{
offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);
break;
case AML_CHUNK_LOCAL0:
case AML_STORE_OP:
offset = aml_write_byte(node->Type, buffer, offset);
break;
case AML_CHUNK_DEVICE:
offset = aml_write_byte(AML_CHUNK_OP, buffer, offset);
offset = aml_write_byte(node->Type, buffer, offset);
offset = aml_write_size(node->Size-3, buffer, offset);
offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);
break;
case AML_CHUNK_SCOPE:
case AML_CHUNK_METHOD:
case AML_CHUNK_PACKAGE:
case AML_CHUNK_BUFFER:
offset = aml_write_byte(node->Type, buffer, offset);
offset = aml_write_size(node->Size-1, buffer, offset);
offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);
case AML_CHUNK_QWORD:
case AML_CHUNK_ALIAS:
case AML_CHUNK_NAME:
case AML_CHUNK_RETURN:
case AML_CHUNK_STRING:
offset = aml_write_byte(node->Type, buffer, offset);
offset = aml_write_buffer(node->Buffer, node->Length, buffer, offset);
break;
break;
}
struct aml_chunk* child = node->First;
while (child)
{
offset = aml_write_node(child, buffer, offset);
}
if (offset - old != node->Size)
verbose("Node size incorrect: 0x%x\n", node->Type);
verbose("Node size incorrect: type=0x%x size=%x offset=%x\n",
node->Type, node->Size, (offset - old));
}
return offset;
branches/ErmaC/MainTrunkPatch/i386/libsaio/aml_generator.h
1212
1313
1414
15
16
17
18
19
20
21
22
23
24
25
26
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
2759
28
60
2961
30
31
32
33
34
35
62
63
64
65
3666
3767
3868
3969
4070
71
72
4173
4274
4375
4476
4577
46
47
48
49
50
51
52
53
54
55
56
57
58
59
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
60103
61
104
#include "libsaio.h"
#defineAML_CHUNK_NONE0xff
#defineAML_CHUNK_ZERO0x00
#defineAML_CHUNK_ONE0x01
#defineAML_CHUNK_ALIAS0x06
#defineAML_CHUNK_NAME0x08
#defineAML_CHUNK_BYTE0x0A
#defineAML_CHUNK_WORD0x0B
#defineAML_CHUNK_DWORD0x0C
#defineAML_CHUNK_STRING0x0D
#defineAML_CHUNK_QWORD0x0E
#defineAML_CHUNK_SCOPE0x10
#defineAML_CHUNK_PACKAGE0x12
//
// Primary OpCode
//
#defineAML_CHUNK_ZERO 0x00 // AML_ZERO_OP
#defineAML_CHUNK_ONE 0x01 // AML_ONE_OP
#defineAML_CHUNK_ALIAS 0x06 // AML_ALIAS_OP
#defineAML_CHUNK_NAME 0x08 // AML_NAME_OP
#defineAML_CHUNK_BYTE 0x0A // AML_BYTE_PREFIX
#defineAML_CHUNK_WORD 0x0B // AML_WORD_PREFIX
#defineAML_CHUNK_DWORD 0x0C // AML_DWORD_PREFIX
#defineAML_CHUNK_STRING 0x0D // AML_STRING_PREFIX
#defineAML_CHUNK_QWORD 0x0E // AML_QWORD_PREFIX
#defineAML_CHUNK_SCOPE 0x10 // AML_SCOPE_OP
#define AML_CHUNK_BUFFER 0x11 // AML_BUFFER_OP
#defineAML_CHUNK_PACKAGE 0x12 // AML_PACKAGE_OP
#define AML_CHUNK_VAR_PACKAGE 0x13 // AML_VAR_PACKAGE_OP
#defineAML_CHUNK_METHOD 0x14 // AML_METHOD_OP
#define AML_CHUNK_STRING_BUFFER0x15 //
#define AML_CHUNK_LOCAL0 0x60 // AML_LOCAL0
#define AML_CHUNK_LOCAL1 0x61 // AML_LOCAL1
#define AML_CHUNK_LOCAL2 0x62 // AML_LOCAL2
#define AML_CHUNK_LOCAL3 0x63 // AML_LOCAL3
#define AML_CHUNK_LOCAL4 0x64 // AML_LOCAL4
#define AML_CHUNK_LOCAL5 0x65 // AML_LOCAL5
#define AML_CHUNK_LOCAL6 0x66 // AML_LOCAL6
#define AML_CHUNK_LOCAL7 0x67 // AML_LOCAL7
#define AML_CHUNK_ARG0 0x68 // AML_ARG0
#define AML_CHUNK_ARG1 0x69 // AML_ARG1
#define AML_CHUNK_ARG2 0x6A // AML_ARG2
#define AML_CHUNK_ARG3 0x6B // AML_ARG3
#define AML_CHUNK_ARG4 0x6C // AML_ARG4
#define AML_CHUNK_ARG5 0x6D // AML_ARG5
#define AML_CHUNK_ARG6 0x6E // AML_ARG6
#define AML_STORE_OP 0x70 // AML_STORE_OP
#define AML_CHUNK_REFOF 0x71 // AML_REF_OF_OP
#define AML_CHUNK_RETURN 0xA4 // AML_RETURN_OP
#define AML_CHUNK_BRECK 0xA5 // AML_BREAK_OP
#defineAML_CHUNK_NONE 0xff // AML_ONES_OP
//
// Extended OpCode
//
#define AML_CHUNK_OP 0x5B // AML_EXT_OP
#define AML_CHUNK_DEVICE 0x82 // AML_EXT_DEVICE_OP
#define AML_CHUNK_PROCESSOR 0x83 // AML_EXT_PROCESSOR_OP
struct aml_chunk
struct aml_chunk
{
unsigned charType;
unsigned intLength;
char*Buffer;
unsigned intSize;
uint8_tType;
uint16_tLength;
char*Buffer;
uint16_tSize;
struct aml_chunk*Next;
struct aml_chunk*First;
struct aml_chunk*Last;
};
typedef struct aml_chunk AML_CHUNK;
static inline bool aml_isvalidchar(char c)
{
return isupper(c) || isdigit(c) || c == '_';
};
bool aml_add_to_parent(struct aml_chunk* parent, struct aml_chunk* node);
struct aml_chunk* aml_create_node(struct aml_chunk* parent);
void aml_destroy_node(struct aml_chunk* node);
struct aml_chunk* aml_add_buffer(struct aml_chunk* parent, const char* buffer, unsigned int size);
struct aml_chunk* aml_add_byte(struct aml_chunk* parent, unsigned char value);
struct aml_chunk* aml_add_word(struct aml_chunk* parent, unsigned int value);
struct aml_chunk* aml_add_dword(struct aml_chunk* parent, unsigned long value);
struct aml_chunk* aml_add_qword(struct aml_chunk* parent, unsigned long long value);
struct aml_chunk* aml_add_scope(struct aml_chunk* parent, const char* name);
struct aml_chunk* aml_add_name(struct aml_chunk* parent, const char* name);
struct aml_chunk* aml_add_package(struct aml_chunk* parent);
struct aml_chunk* aml_add_alias(struct aml_chunk* parent, const char* name1, const char* name2);
unsigned int aml_calculate_size(struct aml_chunk* node);
unsigned int aml_write_node(struct aml_chunk* node, char* buffer, unsigned int offset);
bool aml_add_to_parent(AML_CHUNK* parent, AML_CHUNK* node);
AML_CHUNK* aml_create_node(AML_CHUNK* parent);
void aml_destroy_node(AML_CHUNK* node);
AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, const char* buffer, uint32_t size);
AML_CHUNK* aml_add_byte(AML_CHUNK* parent, uint8_t value);
AML_CHUNK* aml_add_word(AML_CHUNK* parent, uint16_t value);
AML_CHUNK* aml_add_dword(AML_CHUNK* parent, uint32_t value);
AML_CHUNK* aml_add_qword(AML_CHUNK* parent, uint64_t value);
AML_CHUNK* aml_add_scope(AML_CHUNK* parent, const char* name);
AML_CHUNK* aml_add_name(AML_CHUNK* parent, const char* name);
AML_CHUNK* aml_add_method(AML_CHUNK* parent, const char* name, uint8_t args);
AML_CHUNK* aml_add_return_name(AML_CHUNK* parent, const char* name);
AML_CHUNK* aml_add_return_byte(AML_CHUNK* parent, uint8_t value);
AML_CHUNK* aml_add_package(AML_CHUNK* parent);
AML_CHUNK* aml_add_alias(AML_CHUNK* parent, const char* name1, const char* name2);
uint32_t aml_calculate_size(AML_CHUNK* node);
uint32_t aml_write_node(AML_CHUNK* node, char* buffer, uint32_t offset);
uint32_t aml_write_size(uint32_t size, char* buffer, uint32_t offset);
AML_CHUNK* aml_add_string(AML_CHUNK* parent, const char* string);
AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, const char* data, uint32_t size);
AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, const char* string);
AML_CHUNK* aml_add_device(AML_CHUNK* parent, const char* name);
AML_CHUNK* aml_add_local0(AML_CHUNK* parent);
AML_CHUNK* aml_add_store(AML_CHUNK* parent);
AML_CHUNK* aml_add_return(AML_CHUNK* parent);
#endif /* !__LIBSAIO_AML_GENERATOR_H */
#endif /* !__LIBSAIO_AML_GENERATOR_H */

Archive Download the corresponding diff file

Revision: 2144