1#pragma once
2
3#include <uacpi/types.h>
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9typedef enum uacpi_resource_type {
10 UACPI_RESOURCE_TYPE_IRQ,
11 UACPI_RESOURCE_TYPE_EXTENDED_IRQ,
12
13 UACPI_RESOURCE_TYPE_DMA,
14 UACPI_RESOURCE_TYPE_FIXED_DMA,
15
16 UACPI_RESOURCE_TYPE_IO,
17 UACPI_RESOURCE_TYPE_FIXED_IO,
18
19 UACPI_RESOURCE_TYPE_ADDRESS16,
20 UACPI_RESOURCE_TYPE_ADDRESS32,
21 UACPI_RESOURCE_TYPE_ADDRESS64,
22 UACPI_RESOURCE_TYPE_ADDRESS64_EXTENDED,
23
24 UACPI_RESOURCE_TYPE_MEMORY24,
25 UACPI_RESOURCE_TYPE_MEMORY32,
26 UACPI_RESOURCE_TYPE_FIXED_MEMORY32,
27
28 UACPI_RESOURCE_TYPE_START_DEPENDENT,
29 UACPI_RESOURCE_TYPE_END_DEPENDENT,
30
31 // Up to 7 bytes
32 UACPI_RESOURCE_TYPE_VENDOR_SMALL,
33
34 // Up to 2^16 - 1 bytes
35 UACPI_RESOURCE_TYPE_VENDOR_LARGE,
36
37 UACPI_RESOURCE_TYPE_GENERIC_REGISTER,
38 UACPI_RESOURCE_TYPE_GPIO_CONNECTION,
39
40 // These must always be contiguous in this order
41 UACPI_RESOURCE_TYPE_SERIAL_I2C_CONNECTION,
42 UACPI_RESOURCE_TYPE_SERIAL_SPI_CONNECTION,
43 UACPI_RESOURCE_TYPE_SERIAL_UART_CONNECTION,
44 UACPI_RESOURCE_TYPE_SERIAL_CSI2_CONNECTION,
45
46 UACPI_RESOURCE_TYPE_PIN_FUNCTION,
47 UACPI_RESOURCE_TYPE_PIN_CONFIGURATION,
48 UACPI_RESOURCE_TYPE_PIN_GROUP,
49 UACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION,
50 UACPI_RESOURCE_TYPE_PIN_GROUP_CONFIGURATION,
51
52 UACPI_RESOURCE_TYPE_CLOCK_INPUT,
53
54 UACPI_RESOURCE_TYPE_END_TAG,
55 UACPI_RESOURCE_TYPE_MAX = UACPI_RESOURCE_TYPE_END_TAG,
56} uacpi_resource_type;
57
58typedef struct uacpi_resource_source {
59 uacpi_u8 index;
60 uacpi_bool index_present;
61 uacpi_u16 length;
62 uacpi_char *string;
63} uacpi_resource_source;
64
65/*
66 * This applies to IRQ & StartDependent resources only. The DONT_CARE value is
67 * used for deserialization into the AML format to signify that the serializer
68 * is allowed to optimize the length down if possible. Note that this is
69 * generally not allowed unless the resource is generated by the caller:
70 *
71 * -- ACPI 6.5 ------------------------------------------------------------
72 * The resource descriptors in the byte stream argument must be specified
73 * exactly as listed in the _CRS byte stream - meaning that the identical
74 * resource descriptors must appear in the identical order, resulting in a
75 * buffer of exactly the same length. Optimizations such as changing an
76 * IRQ descriptor to an IRQNoFlags descriptor (or vice-versa) must not be
77 * performed. Similarly, changing StartDependentFn to StartDependentFnNoPri
78 * is not allowed.
79 * ------------------------------------------------------------------------
80 */
81enum uacpi_resource_length_kind {
82 UACPI_RESOURCE_LENGTH_KIND_DONT_CARE = 0,
83 UACPI_RESOURCE_LENGTH_KIND_ONE_LESS,
84 UACPI_RESOURCE_LENGTH_KIND_FULL,
85};
86
87// triggering fields
88#define UACPI_TRIGGERING_EDGE 1
89#define UACPI_TRIGGERING_LEVEL 0
90
91// polarity
92#define UACPI_POLARITY_ACTIVE_HIGH 0
93#define UACPI_POLARITY_ACTIVE_LOW 1
94#define UACPI_POLARITY_ACTIVE_BOTH 2
95
96// sharing
97#define UACPI_EXCLUSIVE 0
98#define UACPI_SHARED 1
99
100// wake_capability
101#define UACPI_WAKE_CAPABLE 1
102#define UACPI_NOT_WAKE_CAPABLE 0
103
104typedef struct uacpi_resource_irq {
105 uacpi_u8 length_kind;
106 uacpi_u8 triggering;
107 uacpi_u8 polarity;
108 uacpi_u8 sharing;
109 uacpi_u8 wake_capability;
110 uacpi_u8 num_irqs;
111 uacpi_u8 irqs[];
112} uacpi_resource_irq;
113
114typedef struct uacpi_resource_extended_irq {
115 uacpi_u8 direction;
116 uacpi_u8 triggering;
117 uacpi_u8 polarity;
118 uacpi_u8 sharing;
119 uacpi_u8 wake_capability;
120 uacpi_u8 num_irqs;
121 uacpi_resource_source source;
122 uacpi_u32 irqs[];
123} uacpi_resource_extended_irq;
124
125// transfer_type
126#define UACPI_TRANSFER_TYPE_8_BIT 0b00
127#define UACPI_TRANSFER_TYPE_8_AND_16_BIT 0b01
128#define UACPI_TRANSFER_TYPE_16_BIT 0b10
129
130// bus_master_status
131#define UACPI_BUS_MASTER 0b1
132
133// channel_speed
134#define UACPI_DMA_COMPATIBILITY 0b00
135#define UACPI_DMA_TYPE_A 0b01
136#define UACPI_DMA_TYPE_B 0b10
137#define UACPI_DMA_TYPE_F 0b11
138
139// transfer_width
140#define UACPI_TRANSFER_WIDTH_8 0x00
141#define UACPI_TRANSFER_WIDTH_16 0x01
142#define UACPI_TRANSFER_WIDTH_32 0x02
143#define UACPI_TRANSFER_WIDTH_64 0x03
144#define UACPI_TRANSFER_WIDTH_128 0x04
145#define UACPI_TRANSFER_WIDTH_256 0x05
146
147typedef struct uacpi_resource_dma {
148 uacpi_u8 transfer_type;
149 uacpi_u8 bus_master_status;
150 uacpi_u8 channel_speed;
151 uacpi_u8 num_channels;
152 uacpi_u8 channels[];
153} uacpi_resource_dma;
154
155typedef struct uacpi_resource_fixed_dma {
156 uacpi_u16 request_line;
157 uacpi_u16 channel;
158 uacpi_u8 transfer_width;
159} uacpi_resource_fixed_dma;
160
161// decode_type
162#define UACPI_DECODE_16 0b1
163#define UACPI_DECODE_10 0b0
164
165typedef struct uacpi_resource_io {
166 uacpi_u8 decode_type;
167 uacpi_u16 minimum;
168 uacpi_u16 maximum;
169 uacpi_u8 alignment;
170 uacpi_u8 length;
171} uacpi_resource_io;
172
173typedef struct uacpi_resource_fixed_io {
174 uacpi_u16 address;
175 uacpi_u8 length;
176} uacpi_resource_fixed_io;
177
178// write_status
179#define UACPI_NON_WRITABLE 0
180#define UACPI_WRITABLE 1
181
182// caching
183#define UACPI_NON_CACHEABLE 0
184#define UACPI_CACHEABLE 1
185#define UACPI_CACHEABLE_WRITE_COMBINING 2
186#define UACPI_PREFETCHABLE 3
187
188// range_type
189#define UACPI_RANGE_TYPE_MEMORY 0
190#define UACPI_RANGE_TYPE_RESERVED 1
191#define UACPI_RANGE_TYPE_ACPI 2
192#define UACPI_RANGE_TYPE_NVS 3
193
194// address_common->type
195#define UACPI_RANGE_MEMORY 0
196#define UACPI_RANGE_IO 1
197#define UACPI_RANGE_BUS 2
198
199// translation
200#define UACPI_IO_MEM_TRANSLATION 1
201#define UACPI_IO_MEM_STATIC 0
202
203// translation_type
204#define UACPI_TRANSLATION_DENSE 0
205#define UACPI_TRANSLATION_SPARSE 1
206
207// direction
208#define UACPI_PRODUCER 0
209#define UACPI_CONSUMER 1
210
211// decode_type
212#define UACPI_POISITIVE_DECODE 0
213#define UACPI_SUBTRACTIVE_DECODE 1
214
215// fixed_min_address & fixed_max_address
216#define UACPI_ADDRESS_NOT_FIXED 0
217#define UACPI_ADDRESS_FIXED 1
218
219typedef struct uacpi_memory_attribute {
220 uacpi_u8 write_status;
221 uacpi_u8 caching;
222 uacpi_u8 range_type;
223 uacpi_u8 translation;
224} uacpi_memory_attribute;
225
226typedef struct uacpi_io_attribute {
227 uacpi_u8 range_type;
228 uacpi_u8 translation;
229 uacpi_u8 translation_type;
230} uacpi_io_attribute;
231
232typedef union uacpi_address_attribute {
233 uacpi_memory_attribute memory;
234 uacpi_io_attribute io;
235 uacpi_u8 type_specific;
236} uacpi_address_attribute;
237
238typedef struct uacpi_resource_address_common {
239 uacpi_address_attribute attribute;
240 uacpi_u8 type;
241 uacpi_u8 direction;
242 uacpi_u8 decode_type;
243 uacpi_u8 fixed_min_address;
244 uacpi_u8 fixed_max_address;
245} uacpi_resource_address_common;
246
247typedef struct uacpi_resource_address16 {
248 uacpi_resource_address_common common;
249 uacpi_u16 granularity;
250 uacpi_u16 minimum;
251 uacpi_u16 maximum;
252 uacpi_u16 translation_offset;
253 uacpi_u16 address_length;
254 uacpi_resource_source source;
255} uacpi_resource_address16;
256
257typedef struct uacpi_resource_address32 {
258 uacpi_resource_address_common common;
259 uacpi_u32 granularity;
260 uacpi_u32 minimum;
261 uacpi_u32 maximum;
262 uacpi_u32 translation_offset;
263 uacpi_u32 address_length;
264 uacpi_resource_source source;
265} uacpi_resource_address32;
266
267typedef struct uacpi_resource_address64 {
268 uacpi_resource_address_common common;
269 uacpi_u64 granularity;
270 uacpi_u64 minimum;
271 uacpi_u64 maximum;
272 uacpi_u64 translation_offset;
273 uacpi_u64 address_length;
274 uacpi_resource_source source;
275} uacpi_resource_address64;
276
277typedef struct uacpi_resource_address64_extended {
278 uacpi_resource_address_common common;
279 uacpi_u8 revision_id;
280 uacpi_u64 granularity;
281 uacpi_u64 minimum;
282 uacpi_u64 maximum;
283 uacpi_u64 translation_offset;
284 uacpi_u64 address_length;
285 uacpi_u64 attributes;
286} uacpi_resource_address64_extended;
287
288typedef struct uacpi_resource_memory24 {
289 uacpi_u8 write_status;
290 uacpi_u16 minimum;
291 uacpi_u16 maximum;
292 uacpi_u16 alignment;
293 uacpi_u16 length;
294} uacpi_resource_memory24;
295
296typedef struct uacpi_resource_memory32 {
297 uacpi_u8 write_status;
298 uacpi_u32 minimum;
299 uacpi_u32 maximum;
300 uacpi_u32 alignment;
301 uacpi_u32 length;
302} uacpi_resource_memory32;
303
304typedef struct uacpi_resource_fixed_memory32 {
305 uacpi_u8 write_status;
306 uacpi_u32 address;
307 uacpi_u32 length;
308} uacpi_resource_fixed_memory32;
309
310// compatibility & performance
311#define UACPI_GOOD 0
312#define UACPI_ACCEPTABLE 1
313#define UACPI_SUB_OPTIMAL 2
314
315typedef struct uacpi_resource_start_dependent {
316 uacpi_u8 length_kind;
317 uacpi_u8 compatibility;
318 uacpi_u8 performance;
319} uacpi_resource_start_dependent;
320
321typedef struct uacpi_resource_vendor_defined {
322 uacpi_u8 length;
323 uacpi_u8 data[];
324} uacpi_resource_vendor;
325
326typedef struct uacpi_resource_vendor_typed {
327 uacpi_u16 length;
328 uacpi_u8 sub_type;
329 uacpi_u8 uuid[16];
330 uacpi_u8 data[];
331} uacpi_resource_vendor_typed;
332
333typedef struct uacpi_resource_generic_register {
334 uacpi_u8 address_space_id;
335 uacpi_u8 bit_width;
336 uacpi_u8 bit_offset;
337 uacpi_u8 access_size;
338 uacpi_u64 address;
339} uacpi_resource_generic_register;
340
341// type
342#define UACPI_GPIO_CONNECTION_INTERRUPT 0x00
343#define UACPI_GPIO_CONNECTION_IO 0x01
344
345typedef struct uacpi_interrupt_connection_flags {
346 uacpi_u8 triggering;
347 uacpi_u8 polarity;
348 uacpi_u8 sharing;
349 uacpi_u8 wake_capability;
350} uacpi_interrupt_connection_flags;
351
352// restriction
353#define UACPI_IO_RESTRICTION_NONE 0x0
354#define UACPI_IO_RESTRICTION_INPUT 0x1
355#define UACPI_IO_RESTRICTION_OUTPUT 0x2
356#define UACPI_IO_RESTRICTION_NONE_PRESERVE 0x3
357
358typedef struct uacpi_io_connection_flags {
359 uacpi_u8 restriction;
360 uacpi_u8 sharing;
361} uacpi_io_connection_flags;
362
363// pull_configuration
364#define UACPI_PIN_CONFIG_DEFAULT 0x00
365#define UACPI_PIN_CONFIG_PULL_UP 0x01
366#define UACPI_PIN_CONFIG_PULL_DOWN 0x02
367#define UACPI_PIN_CONFIG_NO_PULL 0x03
368
369typedef struct uacpi_resource_gpio_connection {
370 uacpi_u8 revision_id;
371 uacpi_u8 type;
372 uacpi_u8 direction;
373
374 union {
375 uacpi_interrupt_connection_flags interrupt;
376 uacpi_io_connection_flags io;
377 uacpi_u16 type_specific;
378 };
379
380 uacpi_u8 pull_configuration;
381 uacpi_u16 drive_strength;
382 uacpi_u16 debounce_timeout;
383 uacpi_u16 vendor_data_length;
384 uacpi_u16 pin_table_length;
385 uacpi_resource_source source;
386 uacpi_u16 *pin_table;
387 uacpi_u8 *vendor_data;
388} uacpi_resource_gpio_connection;
389
390// mode
391#define UACPI_MODE_CONTROLLER_INITIATED 0x0
392#define UACPI_MODE_DEVICE_INITIATED 0x1
393
394typedef struct uacpi_resource_serial_bus_common {
395 uacpi_u8 revision_id;
396 uacpi_u8 type;
397 uacpi_u8 mode;
398 uacpi_u8 direction;
399 uacpi_u8 sharing;
400 uacpi_u8 type_revision_id;
401 uacpi_u16 type_data_length;
402 uacpi_u16 vendor_data_length;
403 uacpi_resource_source source;
404 uacpi_u8 *vendor_data;
405} uacpi_resource_serial_bus_common;
406
407// addressing_mode
408#define UACPI_I2C_7BIT 0x0
409#define UACPI_I2C_10BIT 0x1
410
411typedef struct uacpi_resource_i2c_connection {
412 uacpi_resource_serial_bus_common common;
413 uacpi_u8 addressing_mode;
414 uacpi_u16 slave_address;
415 uacpi_u32 connection_speed;
416} uacpi_resource_i2c_connection;
417
418// wire_mode
419#define UACPI_SPI_4_WIRES 0
420#define UACPI_SPI_3_WIRES 1
421
422// device_polarity
423#define UACPI_SPI_ACTIVE_LOW 0
424#define UACPI_SPI_ACTIVE_HIGH 1
425
426// phase
427#define UACPI_SPI_PHASE_FIRST 0
428#define UACPI_SPI_PHASE_SECOND 0
429
430// polarity
431#define UACPI_SPI_START_LOW 0
432#define UACPI_SPI_START_HIGH 1
433
434typedef struct uacpi_resource_spi_connection {
435 uacpi_resource_serial_bus_common common;
436 uacpi_u8 wire_mode;
437 uacpi_u8 device_polarity;
438 uacpi_u8 data_bit_length;
439 uacpi_u8 phase;
440 uacpi_u8 polarity;
441 uacpi_u16 device_selection;
442 uacpi_u32 connection_speed;
443} uacpi_resource_spi_connection;
444
445// stop_bits
446#define UACPI_UART_STOP_BITS_NONE 0b00
447#define UACPI_UART_STOP_BITS_1 0b01
448#define UACPI_UART_STOP_BITS_1_5 0b10
449#define UACPI_UART_STOP_BITS_2 0b11
450
451// data_bits
452#define UACPI_UART_DATA_5BITS 0b000
453#define UACPI_UART_DATA_6BITS 0b001
454#define UACPI_UART_DATA_7BITS 0b010
455#define UACPI_UART_DATA_8BITS 0b011
456#define UACPI_UART_DATA_9BITS 0b100
457
458// endianness
459#define UACPI_UART_LITTLE_ENDIAN 0
460#define UACPI_UART_BIG_ENDIAN 1
461
462// parity
463#define UACPI_UART_PARITY_NONE 0x00
464#define UACPI_UART_PARITY_EVEN 0x01
465#define UACPI_UART_PARITY_ODD 0x02
466#define UACPI_UART_PARITY_MARK 0x03
467#define UACPI_UART_PARITY_SPACE 0x04
468
469// lines_enabled
470#define UACPI_UART_DATA_CARRIER_DETECT (1 << 2)
471#define UACPI_UART_RING_INDICATOR (1 << 3)
472#define UACPI_UART_DATA_SET_READY (1 << 4)
473#define UACPI_UART_DATA_TERMINAL_READY (1 << 5)
474#define UACPI_UART_CLEAR_TO_SEND (1 << 6)
475#define UACPI_UART_REQUEST_TO_SEND (1 << 7)
476
477// flow_control
478#define UACPI_UART_FLOW_CONTROL_NONE 0b00
479#define UACPI_UART_FLOW_CONTROL_HW 0b01
480#define UACPI_UART_FLOW_CONTROL_XON_XOFF 0b10
481
482typedef struct uacpi_resource_uart_connection {
483 uacpi_resource_serial_bus_common common;
484 uacpi_u8 stop_bits;
485 uacpi_u8 data_bits;
486 uacpi_u8 endianness;
487 uacpi_u8 parity;
488 uacpi_u8 lines_enabled;
489 uacpi_u8 flow_control;
490 uacpi_u32 baud_rate;
491 uacpi_u16 rx_fifo;
492 uacpi_u16 tx_fifo;
493} uacpi_resource_uart_connection;
494
495// phy_type
496#define UACPI_CSI2_PHY_C 0b00
497#define UACPI_CSI2_PHY_D 0b01
498
499typedef struct uacpi_resource_csi2_connection {
500 uacpi_resource_serial_bus_common common;
501 uacpi_u8 phy_type;
502 uacpi_u8 local_port;
503} uacpi_resource_csi2_connection;
504
505typedef struct uacpi_resource_pin_function {
506 uacpi_u8 revision_id;
507 uacpi_u8 sharing;
508 uacpi_u8 pull_configuration;
509 uacpi_u16 function_number;
510 uacpi_u16 pin_table_length;
511 uacpi_u16 vendor_data_length;
512 uacpi_resource_source source;
513 uacpi_u16 *pin_table;
514 uacpi_u8 *vendor_data;
515} uacpi_resource_pin_function;
516
517// type
518#define UACPI_PIN_CONFIG_DEFAULT 0x00
519#define UACPI_PIN_CONFIG_BIAS_PULL_UP 0x01
520#define UACPI_PIN_CONFIG_BIAS_PULL_DOWN 0x02
521#define UACPI_PIN_CONFIG_BIAS_DEFAULT 0x03
522#define UACPI_PIN_CONFIG_BIAS_DISABLE 0x04
523#define UACPI_PIN_CONFIG_BIAS_HIGH_IMPEDANCE 0x05
524#define UACPI_PIN_CONFIG_BIAS_BUS_HOLD 0x06
525#define UACPI_PIN_CONFIG_DRIVE_OPEN_DRAIN 0x07
526#define UACPI_PIN_CONFIG_DRIVE_OPEN_SOURCE 0x08
527#define UACPI_PIN_CONFIG_DRIVE_PUSH_PULL 0x09
528#define UACPI_PIN_CONFIG_DRIVE_STRENGTH 0x0A
529#define UACPI_PIN_CONFIG_SLEW_RATE 0x0B
530#define UACPI_PIN_CONFIG_INPUT_DEBOUNCE 0x0C
531#define UACPI_PIN_CONFIG_INPUT_SCHMITT_TRIGGER 0x0D
532
533typedef struct uacpi_resource_pin_configuration {
534 uacpi_u8 revision_id;
535 uacpi_u8 sharing;
536 uacpi_u8 direction;
537 uacpi_u8 type;
538 uacpi_u32 value;
539 uacpi_u16 pin_table_length;
540 uacpi_u16 vendor_data_length;
541 uacpi_resource_source source;
542 uacpi_u16 *pin_table;
543 uacpi_u8 *vendor_data;
544} uacpi_resource_pin_configuration;
545
546typedef struct uacpi_resource_label {
547 uacpi_u16 length;
548 const uacpi_char *string;
549} uacpi_resource_label;
550
551typedef struct uacpi_resource_pin_group {
552 uacpi_u8 revision_id;
553 uacpi_u8 direction;
554 uacpi_u16 pin_table_length;
555 uacpi_u16 vendor_data_length;
556 uacpi_resource_label label;
557 uacpi_u16 *pin_table;
558 uacpi_u8 *vendor_data;
559} uacpi_resource_pin_group;
560
561typedef struct uacpi_resource_pin_group_function {
562 uacpi_u8 revision_id;
563 uacpi_u8 sharing;
564 uacpi_u8 direction;
565 uacpi_u16 function;
566 uacpi_u16 vendor_data_length;
567 uacpi_resource_source source;
568 uacpi_resource_label label;
569 uacpi_u8 *vendor_data;
570} uacpi_resource_pin_group_function;
571
572typedef struct uacpi_resource_pin_group_configuration {
573 uacpi_u8 revision_id;
574 uacpi_u8 sharing;
575 uacpi_u8 direction;
576 uacpi_u8 type;
577 uacpi_u32 value;
578 uacpi_u16 vendor_data_length;
579 uacpi_resource_source source;
580 uacpi_resource_label label;
581 uacpi_u8 *vendor_data;
582} uacpi_resource_pin_group_configuration;
583
584// scale
585#define UACPI_SCALE_HZ 0b00
586#define UACPI_SCALE_KHZ 0b01
587#define UACPI_SCALE_MHZ 0b10
588
589// frequency
590#define UACPI_FREQUENCY_FIXED 0x0
591#define UACPI_FREQUENCY_VARIABLE 0x1
592
593typedef struct uacpi_resource_clock_input {
594 uacpi_u8 revision_id;
595 uacpi_u8 frequency;
596 uacpi_u8 scale;
597 uacpi_u16 divisor;
598 uacpi_u32 numerator;
599 uacpi_resource_source source;
600} uacpi_resource_clock_input;
601
602typedef struct uacpi_resource {
603 uacpi_u32 type;
604 uacpi_u32 length;
605
606 union {
607 uacpi_resource_irq irq;
608 uacpi_resource_extended_irq extended_irq;
609 uacpi_resource_dma dma;
610 uacpi_resource_fixed_dma fixed_dma;
611 uacpi_resource_io io;
612 uacpi_resource_fixed_io fixed_io;
613 uacpi_resource_address16 address16;
614 uacpi_resource_address32 address32;
615 uacpi_resource_address64 address64;
616 uacpi_resource_address64_extended address64_extended;
617 uacpi_resource_memory24 memory24;
618 uacpi_resource_memory32 memory32;
619 uacpi_resource_fixed_memory32 fixed_memory32;
620 uacpi_resource_start_dependent start_dependent;
621 uacpi_resource_vendor vendor;
622 uacpi_resource_vendor_typed vendor_typed;
623 uacpi_resource_generic_register generic_register;
624 uacpi_resource_gpio_connection gpio_connection;
625 uacpi_resource_serial_bus_common serial_bus_common;
626 uacpi_resource_i2c_connection i2c_connection;
627 uacpi_resource_spi_connection spi_connection;
628 uacpi_resource_uart_connection uart_connection;
629 uacpi_resource_csi2_connection csi2_connection;
630 uacpi_resource_pin_function pin_function;
631 uacpi_resource_pin_configuration pin_configuration;
632 uacpi_resource_pin_group pin_group;
633 uacpi_resource_pin_group_function pin_group_function;
634 uacpi_resource_pin_group_configuration pin_group_configuration;
635 uacpi_resource_clock_input clock_input;
636 };
637} uacpi_resource;
638
639#define UACPI_NEXT_RESOURCE(cur) \
640 ((uacpi_resource*)((uacpi_u8*)(cur) + (cur)->length))
641
642typedef struct uacpi_resources {
643 uacpi_size length;
644 uacpi_resource *entries;
645} uacpi_resources;
646void uacpi_free_resources(uacpi_resources*);
647
648typedef enum uacpi_resource_iteration_decision {
649 UACPI_RESOURCE_ITERATION_ABORT,
650 UACPI_RESOURCE_ITERATION_CONTINUE,
651} uacpi_resource_iteration_decision;
652
653typedef uacpi_resource_iteration_decision
654 (*uacpi_resource_iteration_callback)(void *user, uacpi_resource *resource);
655
656uacpi_status uacpi_get_current_resources(
657 uacpi_namespace_node *device, uacpi_resources **out_resources
658);
659
660uacpi_status uacpi_get_possible_resources(
661 uacpi_namespace_node *device, uacpi_resources **out_resources
662);
663
664uacpi_status uacpi_set_resources(
665 uacpi_namespace_node *device, uacpi_resources *resources
666);
667
668uacpi_status uacpi_for_each_resource(
669 uacpi_resources *resources, uacpi_resource_iteration_callback cb, void *user
670);
671
672uacpi_status uacpi_for_each_device_resource(
673 uacpi_namespace_node *device, const uacpi_char *method,
674 uacpi_resource_iteration_callback cb, void *user
675);
676
677#ifdef __cplusplus
678}
679#endif
680