Root/
Source at commit HEAD created 5 years 6 days ago. By ifabio, Few update to kernelPatcher (Credits to CrazyBirdy) | |
---|---|
1 | /*␊ |
2 | * aml_generator.h␊ |
3 | * Chameleon␊ |
4 | *␊ |
5 | * Created by Mozodojo on 20/07/10.␊ |
6 | * Copyright 2010 mozo. All rights reserved.␊ |
7 | *␊ |
8 | */␊ |
9 | ␊ |
10 | #ifndef __LIBSAIO_AML_GENERATOR_H␊ |
11 | #define __LIBSAIO_AML_GENERATOR_H␊ |
12 | ␊ |
13 | #include "libsaio.h"␊ |
14 | ␊ |
15 | //␊ |
16 | // Primary OpCode␊ |
17 | //␊ |
18 | #define␉AML_CHUNK_ZERO 0x00 // AML_ZERO_OP␊ |
19 | #define␉AML_CHUNK_ONE 0x01 // AML_ONE_OP␊ |
20 | #define␉AML_CHUNK_ALIAS 0x06 // AML_ALIAS_OP␊ |
21 | #define␉AML_CHUNK_NAME 0x08 // AML_NAME_OP␊ |
22 | #define␉AML_CHUNK_BYTE 0x0A // AML_BYTE_PREFIX␊ |
23 | #define␉AML_CHUNK_WORD 0x0B // AML_WORD_PREFIX␊ |
24 | #define␉AML_CHUNK_DWORD 0x0C // AML_DWORD_PREFIX␊ |
25 | #define␉AML_CHUNK_STRING 0x0D // AML_STRING_PREFIX␊ |
26 | #define␉AML_CHUNK_QWORD 0x0E // AML_QWORD_PREFIX␊ |
27 | #define␉AML_CHUNK_SCOPE 0x10 // AML_SCOPE_OP␊ |
28 | #define AML_CHUNK_BUFFER 0x11 // AML_BUFFER_OP␊ |
29 | #define␉AML_CHUNK_PACKAGE 0x12 // AML_PACKAGE_OP␊ |
30 | #define AML_CHUNK_VAR_PACKAGE 0x13 // AML_VAR_PACKAGE_OP␊ |
31 | #define␉AML_CHUNK_METHOD 0x14 // AML_METHOD_OP␊ |
32 | #define AML_CHUNK_STRING_BUFFER␉0x15 //␊ |
33 | #define AML_CHUNK_LOCAL0 0x60 // AML_LOCAL0␊ |
34 | #define AML_CHUNK_LOCAL1 0x61 // AML_LOCAL1␊ |
35 | #define AML_CHUNK_LOCAL2 0x62 // AML_LOCAL2␊ |
36 | #define AML_CHUNK_LOCAL3 0x63 // AML_LOCAL3␊ |
37 | #define AML_CHUNK_LOCAL4 0x64 // AML_LOCAL4␊ |
38 | #define AML_CHUNK_LOCAL5 0x65 // AML_LOCAL5␊ |
39 | #define AML_CHUNK_LOCAL6 0x66 // AML_LOCAL6␊ |
40 | #define AML_CHUNK_LOCAL7 0x67 // AML_LOCAL7␊ |
41 | #define AML_CHUNK_ARG0 0x68 // AML_ARG0␊ |
42 | #define AML_CHUNK_ARG1 0x69 // AML_ARG1␊ |
43 | #define AML_CHUNK_ARG2 0x6A // AML_ARG2␊ |
44 | #define AML_CHUNK_ARG3 0x6B // AML_ARG3␊ |
45 | #define AML_CHUNK_ARG4 0x6C // AML_ARG4␊ |
46 | #define AML_CHUNK_ARG5 0x6D // AML_ARG5␊ |
47 | #define AML_CHUNK_ARG6 0x6E // AML_ARG6␊ |
48 | #define AML_STORE_OP 0x70 // AML_STORE_OP␊ |
49 | #define AML_CHUNK_REFOF 0x71 // AML_REF_OF_OP␊ |
50 | #define AML_CHUNK_RETURN 0xA4 // AML_RETURN_OP␊ |
51 | #define AML_CHUNK_BRECK 0xA5 // AML_BREAK_OP␊ |
52 | #define␉AML_CHUNK_NONE 0xff // AML_ONES_OP␊ |
53 | //␊ |
54 | // Extended OpCode␊ |
55 | //␊ |
56 | #define AML_CHUNK_OP 0x5B // AML_EXT_OP␊ |
57 | #define AML_CHUNK_DEVICE 0x82 // AML_EXT_DEVICE_OP␊ |
58 | #define AML_CHUNK_PROCESSOR 0x83 // AML_EXT_PROCESSOR_OP␊ |
59 | ␊ |
60 | struct aml_chunk {␊ |
61 | ␉uint8_t␉␉␉Type;␊ |
62 | ␉uint16_t␉␉Length;␊ |
63 | ␉char*␉␉␉Buffer;␊ |
64 | ␉uint16_t␉␉Size;␊ |
65 | ␉struct aml_chunk*␉Next;␊ |
66 | ␉struct aml_chunk*␉First;␊ |
67 | ␉struct aml_chunk*␉Last;␊ |
68 | };␊ |
69 | ␊ |
70 | typedef struct aml_chunk AML_CHUNK;␊ |
71 | ␊ |
72 | static inline bool aml_isvalidchar(char c)␊ |
73 | {␊ |
74 | ␉return isupper(c) || isdigit(c) || c == '_';␊ |
75 | };␊ |
76 | ␊ |
77 | bool aml_add_to_parent(AML_CHUNK* parent, AML_CHUNK* node);␊ |
78 | AML_CHUNK* aml_create_node(AML_CHUNK* parent);␊ |
79 | void aml_destroy_node(AML_CHUNK* node);␊ |
80 | AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, const char* buffer, uint32_t size);␊ |
81 | AML_CHUNK* aml_add_byte(AML_CHUNK* parent, uint8_t value);␊ |
82 | AML_CHUNK* aml_add_word(AML_CHUNK* parent, uint16_t value);␊ |
83 | AML_CHUNK* aml_add_dword(AML_CHUNK* parent, uint32_t value);␊ |
84 | AML_CHUNK* aml_add_qword(AML_CHUNK* parent, uint64_t value);␊ |
85 | AML_CHUNK* aml_add_scope(AML_CHUNK* parent, char* name);␊ |
86 | AML_CHUNK* aml_add_name(AML_CHUNK* parent, char* name);␊ |
87 | AML_CHUNK* aml_add_method(AML_CHUNK* parent, char* name, uint8_t args);␊ |
88 | AML_CHUNK* aml_add_return_name(AML_CHUNK* parent, char* name);␊ |
89 | AML_CHUNK* aml_add_return_byte(AML_CHUNK* parent, uint8_t value);␊ |
90 | AML_CHUNK* aml_add_package(AML_CHUNK* parent);␊ |
91 | AML_CHUNK* aml_add_alias(AML_CHUNK* parent, char* name1, char* name2);␊ |
92 | uint32_t aml_calculate_size(AML_CHUNK* node);␊ |
93 | uint32_t aml_write_node(AML_CHUNK* node, char* buffer, uint32_t offset);␊ |
94 | uint32_t aml_write_size(uint32_t size, char* buffer, uint32_t offset);␊ |
95 | ␊ |
96 | AML_CHUNK* aml_add_string(AML_CHUNK* parent, char* string);␊ |
97 | AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, char* data, uint32_t size);␊ |
98 | AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, char* string);␊ |
99 | AML_CHUNK* aml_add_device(AML_CHUNK* parent, char* name);␊ |
100 | AML_CHUNK* aml_add_local0(AML_CHUNK* parent);␊ |
101 | AML_CHUNK* aml_add_store(AML_CHUNK* parent);␊ |
102 | AML_CHUNK* aml_add_return(AML_CHUNK* parent);␊ |
103 | ␊ |
104 | int32_t FindBin (uint8_t *dsdt, uint32_t len, uint8_t *bin, unsigned int N);␊ |
105 | uint32_t get_size(uint8_t* Buffer, uint32_t adr);␊ |
106 | ␊ |
107 | #endif /* !__LIBSAIO_AML_GENERATOR_H */␊ |
108 |