ReactOS 0.4.16-dev-1946-g52006dd
resources.h File Reference
Include dependency graph for resources.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  uacpi_resource_convert_instruction
 
struct  uacpi_resource_spec
 

Typedefs

typedef uacpi_iteration_decision(* uacpi_aml_resource_iteration_callback) (void *, uacpi_u8 *data, uacpi_u16 resource_size, const struct uacpi_resource_spec *)
 

Enumerations

enum  uacpi_aml_resource {
  UACPI_AML_RESOURCE_TYPE_INVALID = 0 , UACPI_AML_RESOURCE_IRQ , UACPI_AML_RESOURCE_DMA , UACPI_AML_RESOURCE_START_DEPENDENT ,
  UACPI_AML_RESOURCE_END_DEPENDENT , UACPI_AML_RESOURCE_IO , UACPI_AML_RESOURCE_FIXED_IO , UACPI_AML_RESOURCE_FIXED_DMA ,
  UACPI_AML_RESOURCE_VENDOR_TYPE0 , UACPI_AML_RESOURCE_END_TAG , UACPI_AML_RESOURCE_MEMORY24 , UACPI_AML_RESOURCE_GENERIC_REGISTER ,
  UACPI_AML_RESOURCE_VENDOR_TYPE1 , UACPI_AML_RESOURCE_MEMORY32 , UACPI_AML_RESOURCE_FIXED_MEMORY32 , UACPI_AML_RESOURCE_ADDRESS32 ,
  UACPI_AML_RESOURCE_ADDRESS16 , UACPI_AML_RESOURCE_EXTENDED_IRQ , UACPI_AML_RESOURCE_ADDRESS64 , UACPI_AML_RESOURCE_ADDRESS64_EXTENDED ,
  UACPI_AML_RESOURCE_GPIO_CONNECTION , UACPI_AML_RESOURCE_PIN_FUNCTION , UACPI_AML_RESOURCE_SERIAL_CONNECTION , UACPI_AML_RESOURCE_PIN_CONFIGURATION ,
  UACPI_AML_RESOURCE_PIN_GROUP , UACPI_AML_RESOURCE_PIN_GROUP_FUNCTION , UACPI_AML_RESOURCE_PIN_GROUP_CONFIGURATION , UACPI_AML_RESOURCE_CLOCK_INPUT ,
  UACPI_AML_RESOURCE_MAX = UACPI_AML_RESOURCE_CLOCK_INPUT
}
 
enum  uacpi_aml_resource_size_kind { UACPI_AML_RESOURCE_SIZE_KIND_FIXED , UACPI_AML_RESOURCE_SIZE_KIND_FIXED_OR_ONE_LESS , UACPI_AML_RESOURCE_SIZE_KIND_VARIABLE }
 
enum  uacpi_aml_resource_kind { UACPI_AML_RESOURCE_KIND_SMALL = 0 , UACPI_AML_RESOURCE_KIND_LARGE }
 
enum  uacpi_resource_convert_opcode {
  UACPI_RESOURCE_CONVERT_OPCODE_END = 0 , UACPI_RESOURCE_CONVERT_OPCODE_PACKED_ARRAY_8 , UACPI_RESOURCE_CONVERT_OPCODE_PACKED_ARRAY_16 , UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_1 ,
  UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_2 , UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_3 , UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_6 , UACPI_RESOURCE_CONVERT_OPCODE_FIELD_8 ,
  UACPI_RESOURCE_CONVERT_OPCODE_FIELD_16 , UACPI_RESOURCE_CONVERT_OPCODE_FIELD_32 , UACPI_RESOURCE_CONVERT_OPCODE_FIELD_64 , UACPI_RESOURCE_CONVERT_OPCODE_SKIP_IF_AML_SIZE_LESS_THAN ,
  UACPI_RESOURCE_CONVERT_OPCODE_SKIP_IF_NOT_EQUALS , UACPI_RESOURCE_CONVERT_OPCODE_SET_TO_IMM , UACPI_RESOURCE_CONVERT_OPCODE_LOAD_AML_SIZE_32 , UACPI_RESOURCE_CONVERT_OPCODE_LOAD_8_STORE ,
  UACPI_RESOURCE_CONVERT_OPCODE_LOAD_8_NATIVE , UACPI_RESOURCE_CONVERT_OPCODE_LOAD_16_NATIVE , UACPI_RESOURCE_CONVERT_OPCODE_LOAD_IMM , UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_SOURCE ,
  UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_SOURCE_NO_INDEX , UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_LABEL , UACPI_RESOURCE_CONVERT_OPCODE_LOAD_PIN_TABLE_LENGTH , UACPI_RESOURCE_CONVERT_OPCODE_PIN_TABLE ,
  UACPI_RESOURCE_CONVERT_OPCODE_VENDOR_DATA , UACPI_RESOURCE_CONVERT_OPCODE_SERIAL_TYPE_SPECIFIC , UACPI_RESOURCE_CONVERT_OPCODE_UNREACHABLE
}
 

Functions

uacpi_status uacpi_for_each_aml_resource (uacpi_data_view, uacpi_aml_resource_iteration_callback cb, void *user)
 
uacpi_status uacpi_find_aml_resource_end_tag (uacpi_data_view, uacpi_size *out_offset)
 
uacpi_status uacpi_native_resources_from_aml (uacpi_data_view, uacpi_resources **out_resources)
 
uacpi_status uacpi_native_resources_to_aml (uacpi_resources *resources, uacpi_object **out_template)
 

Typedef Documentation

◆ uacpi_aml_resource_iteration_callback

typedef uacpi_iteration_decision(* uacpi_aml_resource_iteration_callback) (void *, uacpi_u8 *data, uacpi_u16 resource_size, const struct uacpi_resource_spec *)

Definition at line 306 of file resources.h.

Enumeration Type Documentation

◆ uacpi_aml_resource

Enumerator
UACPI_AML_RESOURCE_TYPE_INVALID 
UACPI_AML_RESOURCE_IRQ 
UACPI_AML_RESOURCE_DMA 
UACPI_AML_RESOURCE_START_DEPENDENT 
UACPI_AML_RESOURCE_END_DEPENDENT 
UACPI_AML_RESOURCE_IO 
UACPI_AML_RESOURCE_FIXED_IO 
UACPI_AML_RESOURCE_FIXED_DMA 
UACPI_AML_RESOURCE_VENDOR_TYPE0 
UACPI_AML_RESOURCE_END_TAG 
UACPI_AML_RESOURCE_MEMORY24 
UACPI_AML_RESOURCE_GENERIC_REGISTER 
UACPI_AML_RESOURCE_VENDOR_TYPE1 
UACPI_AML_RESOURCE_MEMORY32 
UACPI_AML_RESOURCE_FIXED_MEMORY32 
UACPI_AML_RESOURCE_ADDRESS32 
UACPI_AML_RESOURCE_ADDRESS16 
UACPI_AML_RESOURCE_EXTENDED_IRQ 
UACPI_AML_RESOURCE_ADDRESS64 
UACPI_AML_RESOURCE_ADDRESS64_EXTENDED 
UACPI_AML_RESOURCE_GPIO_CONNECTION 
UACPI_AML_RESOURCE_PIN_FUNCTION 
UACPI_AML_RESOURCE_SERIAL_CONNECTION 
UACPI_AML_RESOURCE_PIN_CONFIGURATION 
UACPI_AML_RESOURCE_PIN_GROUP 
UACPI_AML_RESOURCE_PIN_GROUP_FUNCTION 
UACPI_AML_RESOURCE_PIN_GROUP_CONFIGURATION 
UACPI_AML_RESOURCE_CLOCK_INPUT 
UACPI_AML_RESOURCE_MAX 

Definition at line 8 of file resources.h.

8 {
10
11 // Small resources
21
22 // Large resources
42};
@ UACPI_AML_RESOURCE_END_TAG
Definition: resources.h:20
@ UACPI_AML_RESOURCE_PIN_GROUP
Definition: resources.h:37
@ UACPI_AML_RESOURCE_FIXED_MEMORY32
Definition: resources.h:27
@ UACPI_AML_RESOURCE_ADDRESS32
Definition: resources.h:28
@ UACPI_AML_RESOURCE_PIN_CONFIGURATION
Definition: resources.h:36
@ UACPI_AML_RESOURCE_FIXED_IO
Definition: resources.h:17
@ UACPI_AML_RESOURCE_MEMORY24
Definition: resources.h:23
@ UACPI_AML_RESOURCE_TYPE_INVALID
Definition: resources.h:9
@ UACPI_AML_RESOURCE_VENDOR_TYPE0
Definition: resources.h:19
@ UACPI_AML_RESOURCE_PIN_FUNCTION
Definition: resources.h:34
@ UACPI_AML_RESOURCE_IO
Definition: resources.h:16
@ UACPI_AML_RESOURCE_FIXED_DMA
Definition: resources.h:18
@ UACPI_AML_RESOURCE_DMA
Definition: resources.h:13
@ UACPI_AML_RESOURCE_PIN_GROUP_FUNCTION
Definition: resources.h:38
@ UACPI_AML_RESOURCE_GPIO_CONNECTION
Definition: resources.h:33
@ UACPI_AML_RESOURCE_EXTENDED_IRQ
Definition: resources.h:30
@ UACPI_AML_RESOURCE_GENERIC_REGISTER
Definition: resources.h:24
@ UACPI_AML_RESOURCE_END_DEPENDENT
Definition: resources.h:15
@ UACPI_AML_RESOURCE_VENDOR_TYPE1
Definition: resources.h:25
@ UACPI_AML_RESOURCE_IRQ
Definition: resources.h:12
@ UACPI_AML_RESOURCE_ADDRESS64_EXTENDED
Definition: resources.h:32
@ UACPI_AML_RESOURCE_ADDRESS64
Definition: resources.h:31
@ UACPI_AML_RESOURCE_ADDRESS16
Definition: resources.h:29
@ UACPI_AML_RESOURCE_START_DEPENDENT
Definition: resources.h:14
@ UACPI_AML_RESOURCE_CLOCK_INPUT
Definition: resources.h:40
@ UACPI_AML_RESOURCE_SERIAL_CONNECTION
Definition: resources.h:35
@ UACPI_AML_RESOURCE_PIN_GROUP_CONFIGURATION
Definition: resources.h:39
@ UACPI_AML_RESOURCE_MEMORY32
Definition: resources.h:26
@ UACPI_AML_RESOURCE_MAX
Definition: resources.h:41

◆ uacpi_aml_resource_kind

Enumerator
UACPI_AML_RESOURCE_KIND_SMALL 
UACPI_AML_RESOURCE_KIND_LARGE 

Definition at line 50 of file resources.h.

50 {
53};
@ UACPI_AML_RESOURCE_KIND_LARGE
Definition: resources.h:52
@ UACPI_AML_RESOURCE_KIND_SMALL
Definition: resources.h:51

◆ uacpi_aml_resource_size_kind

Enumerator
UACPI_AML_RESOURCE_SIZE_KIND_FIXED 
UACPI_AML_RESOURCE_SIZE_KIND_FIXED_OR_ONE_LESS 
UACPI_AML_RESOURCE_SIZE_KIND_VARIABLE 

Definition at line 44 of file resources.h.

44 {
48};
@ UACPI_AML_RESOURCE_SIZE_KIND_FIXED
Definition: resources.h:45
@ UACPI_AML_RESOURCE_SIZE_KIND_FIXED_OR_ONE_LESS
Definition: resources.h:46
@ UACPI_AML_RESOURCE_SIZE_KIND_VARIABLE
Definition: resources.h:47

◆ uacpi_resource_convert_opcode

Enumerator
UACPI_RESOURCE_CONVERT_OPCODE_END 
UACPI_RESOURCE_CONVERT_OPCODE_PACKED_ARRAY_8 
UACPI_RESOURCE_CONVERT_OPCODE_PACKED_ARRAY_16 
UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_1 
UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_2 
UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_3 
UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_6 
UACPI_RESOURCE_CONVERT_OPCODE_FIELD_8 
UACPI_RESOURCE_CONVERT_OPCODE_FIELD_16 
UACPI_RESOURCE_CONVERT_OPCODE_FIELD_32 
UACPI_RESOURCE_CONVERT_OPCODE_FIELD_64 
UACPI_RESOURCE_CONVERT_OPCODE_SKIP_IF_AML_SIZE_LESS_THAN 
UACPI_RESOURCE_CONVERT_OPCODE_SKIP_IF_NOT_EQUALS 
UACPI_RESOURCE_CONVERT_OPCODE_SET_TO_IMM 
UACPI_RESOURCE_CONVERT_OPCODE_LOAD_AML_SIZE_32 
UACPI_RESOURCE_CONVERT_OPCODE_LOAD_8_STORE 
UACPI_RESOURCE_CONVERT_OPCODE_LOAD_8_NATIVE 
UACPI_RESOURCE_CONVERT_OPCODE_LOAD_16_NATIVE 
UACPI_RESOURCE_CONVERT_OPCODE_LOAD_IMM 
UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_SOURCE 
UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_SOURCE_NO_INDEX 
UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_LABEL 
UACPI_RESOURCE_CONVERT_OPCODE_LOAD_PIN_TABLE_LENGTH 
UACPI_RESOURCE_CONVERT_OPCODE_PIN_TABLE 
UACPI_RESOURCE_CONVERT_OPCODE_VENDOR_DATA 
UACPI_RESOURCE_CONVERT_OPCODE_SERIAL_TYPE_SPECIFIC 
UACPI_RESOURCE_CONVERT_OPCODE_UNREACHABLE 

Definition at line 55 of file resources.h.

55 {
57
58 /*
59 * AML -> native:
60 * Take the mask at 'aml_offset' and convert to an array of uacpi_u8
61 * at 'native_offset' with the value corresponding to the bit index.
62 * The array size is written to the byte at offset 'arg2'.
63 *
64 * native -> AML:
65 * Walk each element of the array at 'native_offset' and set the
66 * corresponding bit in the mask at 'aml_offset' to 1. The array size is
67 * read from the byte at offset 'arg2'.
68 */
71
72 /*
73 * AML -> native:
74 * Grab the bits at the byte at 'aml_offset' + 'bit_index', and copy its
75 * value into the byte at 'native_offset'.
76 *
77 * native -> AML:
78 * Grab first N bits at 'native_offset' and copy to 'aml_offset' starting
79 * at the 'bit_index'.
80 *
81 * NOTE:
82 * These must be contiguous in this order.
83 */
89
90 /*
91 * AML -> native:
92 * Copy N bytes at 'aml_offset' to 'native_offset'.
93 *
94 * native -> AML:
95 * Copy N bytes at 'native_offset' to 'aml_offset'.
96 *
97 * 'imm' is added to the accumulator.
98 *
99 * NOTE: These are affected by the current value in the accumulator. If it's
100 * set to 0 at the time of evalution, this is executed once, N times
101 * otherwise. 0xFF is considered a special value, which resets the
102 * accumulator to 0 unconditionally.
103 */
108
109 /*
110 * If the length of the current resource is less than 'arg0', then skip
111 * 'imm' instructions.
112 */
114
115 /*
116 * Skip 'imm' instructions if 'arg0' is not equal to the value in the
117 * accumulator.
118 */
120
121 /*
122 * AML -> native:
123 * Set the byte at 'native_offset' to 'imm'.
124 *
125 * native -> AML:
126 * Set the byte at 'aml_offset' to 'imm'.
127 */
129
130 /*
131 * AML -> native:
132 * Load the AML resoruce length into the accumulator as well as the field at
133 * 'native_offset' of width N.
134 *
135 * native -> AML:
136 * Load the resource length into the accumulator.
137 */
139
140 /*
141 * AML -> native:
142 * Load the 8 bit field at 'aml_offset' into the accumulator and store at
143 * 'native_offset'.
144 *
145 * native -> AML:
146 * Load the 8 bit field at 'native_offset' into the accumulator and store
147 * at 'aml_offset'.
148 *
149 * The accumulator is multiplied by 'imm' unless it's set to zero.
150 */
152
153 /*
154 * Load the N bit field at 'native_offset' into the accumulator
155 */
158
159 /*
160 * Load 'imm' into the accumulator.
161 */
163
164 /*
165 * AML -> native:
166 * Load the resource source at offset = aml size + accumulator into the
167 * uacpi_resource_source struct at 'native_offset'. The string bytes are
168 * written to the offset at resource size + accumulator. The presence is
169 * detected by comparing the length of the resource to the offset,
170 * 'arg2' optionally specifies the offset to the upper bound of the string.
171 *
172 * native -> AML:
173 * Load the resource source from the uacpi_resource_source struct at
174 * 'native_offset' to aml_size + accumulator. aml_size + accumulator is
175 * optionally written to 'aml_offset' if it's specified.
176 */
180
181 /*
182 * AML -> native:
183 * Load the pin table with upper bound specified at 'aml_offset'.
184 * The table length is calculated by subtracting the upper bound from
185 * aml_size and is written into the accumulator.
186 *
187 * native -> AML:
188 * Load the pin table length from 'native_offset' and multiply by 2, store
189 * the result in the accumulator.
190 */
192
193 /*
194 * AML -> native:
195 * Store the accumulator divided by 2 at 'native_offset'.
196 * The table is copied to the offset at resource size from offset at
197 * aml_size with the pointer written to the offset at 'arg2'.
198 *
199 * native -> AML:
200 * Read the pin table from resource size offset, write aml_size to
201 * 'aml_offset'. Copy accumulator bytes to the offset at aml_size.
202 */
204
205 /*
206 * AML -> native:
207 * Load vendor data with offset stored at 'aml_offset'. The length is
208 * calculated as aml_size - aml_offset and is written to 'native_offset'.
209 * The data is written to offset - aml_size with the pointer written back
210 * to the offset at 'arg2'.
211 *
212 * native -> AML:
213 * Read vendor data from the pointer at offset 'arg2' and size at
214 * 'native_offset', the offset to write to is calculated as the difference
215 * between the data pointer and the native resource end pointer.
216 * offset + aml_size is written to 'aml_offset' and the data is copied
217 * there as well.
218 */
220
221 /*
222 * AML -> native:
223 * Read the serial type from the byte at 'aml_offset' and write it to the
224 * type field of the uacpi_resource_serial_bus_common structure. Convert
225 * the serial type to native and set the resource type to it. Copy the
226 * vendor data to the offset at native size, the length is calculated
227 * as type_data_length - extra-type-specific-size, and is written to
228 * vendor_data_length, as well as the accumulator. The data pointer is
229 * written to vendor_data.
230 *
231 * native -> AML:
232 * Set the serial type at 'aml_offset' to the value stored at
233 * 'native_offset'. Load the vendor data to the offset at aml_size,
234 * the length is read from 'vendor_data_length', and the data is copied from
235 * 'vendor_data'.
236 */
238
239 /*
240 * Produces an error if encountered in the instruction stream.
241 * Used to trap invalid/unexpected code flow.
242 */
244};
@ UACPI_RESOURCE_CONVERT_OPCODE_FIELD_8
Definition: resources.h:104
@ UACPI_RESOURCE_CONVERT_OPCODE_PACKED_ARRAY_8
Definition: resources.h:69
@ UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_2
Definition: resources.h:85
@ UACPI_RESOURCE_CONVERT_OPCODE_FIELD_32
Definition: resources.h:106
@ UACPI_RESOURCE_CONVERT_OPCODE_UNREACHABLE
Definition: resources.h:243
@ UACPI_RESOURCE_CONVERT_OPCODE_LOAD_8_NATIVE
Definition: resources.h:156
@ UACPI_RESOURCE_CONVERT_OPCODE_PIN_TABLE
Definition: resources.h:203
@ UACPI_RESOURCE_CONVERT_OPCODE_FIELD_16
Definition: resources.h:105
@ UACPI_RESOURCE_CONVERT_OPCODE_SKIP_IF_AML_SIZE_LESS_THAN
Definition: resources.h:113
@ UACPI_RESOURCE_CONVERT_OPCODE_PACKED_ARRAY_16
Definition: resources.h:70
@ UACPI_RESOURCE_CONVERT_OPCODE_SET_TO_IMM
Definition: resources.h:128
@ UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_1
Definition: resources.h:84
@ UACPI_RESOURCE_CONVERT_OPCODE_FIELD_64
Definition: resources.h:107
@ UACPI_RESOURCE_CONVERT_OPCODE_SKIP_IF_NOT_EQUALS
Definition: resources.h:119
@ UACPI_RESOURCE_CONVERT_OPCODE_LOAD_8_STORE
Definition: resources.h:151
@ UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_3
Definition: resources.h:86
@ UACPI_RESOURCE_CONVERT_OPCODE_BIT_FIELD_6
Definition: resources.h:87
@ UACPI_RESOURCE_CONVERT_OPCODE_LOAD_AML_SIZE_32
Definition: resources.h:138
@ UACPI_RESOURCE_CONVERT_OPCODE_LOAD_IMM
Definition: resources.h:162
@ UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_LABEL
Definition: resources.h:179
@ UACPI_RESOURCE_CONVERT_OPCODE_LOAD_16_NATIVE
Definition: resources.h:157
@ UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_SOURCE_NO_INDEX
Definition: resources.h:178
@ UACPI_RESOURCE_CONVERT_OPCODE_LOAD_PIN_TABLE_LENGTH
Definition: resources.h:191
@ UACPI_RESOURCE_CONVERT_OPCODE_SERIAL_TYPE_SPECIFIC
Definition: resources.h:237
@ UACPI_RESOURCE_CONVERT_OPCODE_RESOURCE_SOURCE
Definition: resources.h:177
@ UACPI_RESOURCE_CONVERT_OPCODE_END
Definition: resources.h:56
@ UACPI_RESOURCE_CONVERT_OPCODE_VENDOR_DATA
Definition: resources.h:219

Function Documentation

◆ uacpi_find_aml_resource_end_tag()

uacpi_status uacpi_find_aml_resource_end_tag ( uacpi_data_view  buffer,
uacpi_size out_offset 
)

Definition at line 1526 of file resources.c.

1529{
1530 uacpi_u8 *end_tag_ptr = UACPI_NULL;
1532
1533 if (buffer.length == 0) {
1534 *out_offset = 0;
1535 return UACPI_STATUS_OK;
1536 }
1537
1538 /*
1539 * This returning UACPI_STATUS_OK guarantees that end_tag_ptr is set to
1540 * a valid value because a missing end tag would produce a
1541 * UACPI_STATUS_NO_RESOURCE_END_TAG error.
1542 */
1545 return ret;
1546
1547 *out_offset = end_tag_ptr - buffer.bytes;
1548 return UACPI_STATUS_OK;
1549}
#define UACPI_NULL
Definition: types.h:33
uint8_t uacpi_u8
Definition: types.h:19
#define uacpi_unlikely_error(expr)
Definition: status.h:49
uacpi_status
Definition: status.h:10
@ UACPI_STATUS_OK
Definition: status.h:11
return ret
Definition: mutex.c:146
uacpi_status uacpi_for_each_aml_resource(uacpi_data_view buffer, uacpi_aml_resource_iteration_callback cb, void *user)
Definition: resources.c:1423
static uacpi_iteration_decision find_end(void *opaque, uacpi_u8 *data, uacpi_u16 resource_size, const struct uacpi_resource_spec *spec)
Definition: resources.c:1499
GLuint buffer
Definition: glext.h:5915

Referenced by handle_concatenate_res().

◆ uacpi_for_each_aml_resource()

uacpi_status uacpi_for_each_aml_resource ( uacpi_data_view  buffer,
uacpi_aml_resource_iteration_callback  cb,
void user 
)

Definition at line 1423 of file resources.c.

1426{
1428 uacpi_iteration_decision decision;
1429 uacpi_u8 *data;
1430 uacpi_size bytes_left;
1431 uacpi_u16 resource_size;
1433 const struct uacpi_resource_spec *spec;
1434
1435 bytes_left = buffer.length;
1436 data = buffer.bytes;
1437
1438 while (bytes_left) {
1442
1443 ret = get_aml_resource_size(data, bytes_left, &resource_size);
1445 return ret;
1446
1447 spec = &aml_resources[type];
1448 switch (spec->size_kind) {
1450 if (resource_size != spec->aml_size)
1452 break;
1454 if (resource_size < spec->aml_size)
1456 break;
1458 if (resource_size != spec->aml_size &&
1459 resource_size != (spec->aml_size - 1))
1461 break;
1462 default:
1464 }
1465
1467 struct acpi_resource_serial *serial;
1468
1469 serial = (struct acpi_resource_serial*)data;
1470
1473 return ret;
1474 }
1475
1476 decision = cb(user, data, resource_size, spec);
1477 switch (decision) {
1479 return UACPI_STATUS_OK;
1481 uacpi_size total_size = resource_size;
1482
1484 data += total_size;
1485 bytes_left -= total_size;
1486 break;
1487 }
1488 default:
1490 }
1491
1493 return UACPI_STATUS_OK;
1494 }
1495
1497}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
uacpi_aml_resource
Definition: resources.h:8
#define uacpi_unlikely(expr)
Definition: compiler.h:58
size_t uacpi_size
Definition: types.h:37
uint16_t uacpi_u16
Definition: types.h:20
@ UACPI_STATUS_INTERNAL_ERROR
Definition: status.h:21
@ UACPI_STATUS_AML_INVALID_RESOURCE
Definition: status.h:42
@ UACPI_STATUS_NO_RESOURCE_END_TAG
Definition: status.h:26
uacpi_iteration_decision
Definition: types.h:28
@ UACPI_ITERATION_DECISION_BREAK
Definition: types.h:30
@ UACPI_ITERATION_DECISION_CONTINUE
Definition: types.h:29
const struct uacpi_resource_spec aml_resources[UACPI_AML_RESOURCE_MAX+1]
Definition: resources.c:1095
static enum uacpi_aml_resource get_aml_resource_type(uacpi_u8 raw_byte)
Definition: resources.c:1367
static uacpi_status get_aml_resource_size(uacpi_u8 *data, uacpi_size bytes_left, uacpi_u16 *out_size)
Definition: resources.c:1380
static uacpi_status validate_aml_serial_type(uacpi_u8 type)
Definition: resources.c:1412
static const uacpi_u8 aml_resource_kind_to_header_size[2]
Definition: resources.c:120
uint32_t serial
Definition: fsck.fat.h:29
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
uacpi_u16 aml_size
Definition: resources.h:276
uacpi_u8 size_kind
Definition: resources.h:270
uacpi_u8 resource_kind
Definition: resources.h:269

Referenced by uacpi_find_aml_resource_end_tag(), uacpi_get_resource_from_buffer(), and uacpi_native_resources_from_aml().

◆ uacpi_native_resources_from_aml()

uacpi_status uacpi_native_resources_from_aml ( uacpi_data_view  aml_buffer,
uacpi_resources **  out_resources 
)

Definition at line 1978 of file resources.c.

1981{
1983 struct resource_conversion_ctx ctx = { 0 };
1985
1988 );
1990 return ret;
1991
1992 if (uacpi_unlikely_error(ctx.st))
1993 return ctx.st;
1994
1995 // Realistically any resource buffer bigger than this is probably a bug
1996 if (uacpi_unlikely(ctx.size > (5 * 1024u * 1024u))) {
1997 uacpi_error("bug: bogus native resource buffer size %zu\n", ctx.size);
1999 }
2000
2004 resources->length = ctx.size;
2005 resources->entries = UACPI_PTR_ADD(resources, sizeof(uacpi_resources));
2006
2007 ctx = (struct resource_conversion_ctx) {
2008 .buf = resources->entries,
2009 };
2010
2014 return ret;
2015 }
2016
2017 *out_resources = resources;
2018 return ret;
2019}
#define uacpi_error(...)
Definition: log.h:21
#define uacpi_kernel_alloc_zeroed
Definition: stdlib.h:127
@ UACPI_STATUS_OUT_OF_MEMORY
Definition: status.h:13
static uacpi_iteration_decision accumulate_native_buffer_size(void *opaque, uacpi_u8 *data, uacpi_u16 resource_size, const struct uacpi_resource_spec *spec)
Definition: resources.c:1938
static uacpi_iteration_decision do_aml_resource_to_native(void *opaque, uacpi_u8 *data, uacpi_u16 aml_size, const struct uacpi_resource_spec *spec)
Definition: resources.c:1673
void uacpi_free_resources(uacpi_resources *resources)
Definition: resources.c:2056
FxCmResList * resources
#define UACPI_PTR_ADD(ptr, value)
Definition: utilities.h:23

Referenced by extract_native_resources_from_method().

◆ uacpi_native_resources_to_aml()

uacpi_status uacpi_native_resources_to_aml ( uacpi_resources resources,
uacpi_object **  out_template 
)

Definition at line 2491 of file resources.c.

2494{
2497 void *buffer;
2498 struct resource_conversion_ctx ctx = { 0 };
2499
2502 );
2504 // An end tag is always included
2507 }
2509 return ret;
2510 if (uacpi_unlikely_error(ctx.st))
2511 return ctx.st;
2512
2513 // Same reasoning as native_resource_from_aml
2514 if (uacpi_unlikely(ctx.size > (5 * 1024u * 1024u))) {
2515 uacpi_error("bug: bogus target aml resource buffer size %zu\n",
2516 ctx.size);
2518 }
2519
2523
2525 if (uacpi_unlikely(obj == UACPI_NULL)) {
2526 uacpi_free(buffer, ctx.size);
2528 }
2529
2530 obj->buffer->data = buffer;
2531 obj->buffer->size = ctx.size;
2532
2536
2537 if (ret == UACPI_STATUS_OK)
2538 *out_template = obj;
2539
2540 return ret;
2541}
#define uacpi_free(mem, _)
Definition: stdlib.h:96
uacpi_object * uacpi_create_object(uacpi_object_type type)
Definition: types.c:327
@ UACPI_OBJECT_BUFFER
Definition: types.h:108
void uacpi_object_unref(uacpi_object *obj)
Definition: types.c:755
uacpi_status uacpi_for_each_resource(uacpi_resources *resources, uacpi_resource_iteration_callback cb, void *user)
Definition: resources.c:2115
static uacpi_iteration_decision accumulate_aml_buffer_size(void *opaque, uacpi_resource *resource)
Definition: resources.c:2468
static uacpi_status native_resources_to_aml(uacpi_resources *native_resources, void *aml_buffer)
Definition: resources.c:2445
#define INLINE_END_TAG
Definition: resources.c:2443

Referenced by uacpi_set_resources().