ReactOS 0.4.16-dev-1946-g52006dd
resources.h
Go to the documentation of this file.
1#pragma once
2
3#include <uacpi/types.h>
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#ifndef UACPI_BAREBONES_MODE
10
11typedef enum uacpi_resource_type {
14
17
20
25
29
32
33 // Up to 7 bytes
35
36 // Up to 2^16 - 1 bytes
38
41
42 // These must always be contiguous in this order
47
53
55
59
60typedef struct uacpi_resource_source {
66
67/*
68 * This applies to IRQ & StartDependent resources only. The DONT_CARE value is
69 * used for deserialization into the AML format to signify that the serializer
70 * is allowed to optimize the length down if possible. Note that this is
71 * generally not allowed unless the resource is generated by the caller:
72 *
73 * -- ACPI 6.5 ------------------------------------------------------------
74 * The resource descriptors in the byte stream argument must be specified
75 * exactly as listed in the _CRS byte stream - meaning that the identical
76 * resource descriptors must appear in the identical order, resulting in a
77 * buffer of exactly the same length. Optimizations such as changing an
78 * IRQ descriptor to an IRQNoFlags descriptor (or vice-versa) must not be
79 * performed. Similarly, changing StartDependentFn to StartDependentFnNoPri
80 * is not allowed.
81 * ------------------------------------------------------------------------
82 */
87};
88
89// triggering fields
90#define UACPI_TRIGGERING_EDGE 1
91#define UACPI_TRIGGERING_LEVEL 0
92
93// polarity
94#define UACPI_POLARITY_ACTIVE_HIGH 0
95#define UACPI_POLARITY_ACTIVE_LOW 1
96#define UACPI_POLARITY_ACTIVE_BOTH 2
97
98// sharing
99#define UACPI_EXCLUSIVE 0
100#define UACPI_SHARED 1
101
102// wake_capability
103#define UACPI_WAKE_CAPABLE 1
104#define UACPI_NOT_WAKE_CAPABLE 0
105
106typedef struct uacpi_resource_irq {
115
126
127// transfer_type
128#define UACPI_TRANSFER_TYPE_8_BIT 0b00
129#define UACPI_TRANSFER_TYPE_8_AND_16_BIT 0b01
130#define UACPI_TRANSFER_TYPE_16_BIT 0b10
131
132// bus_master_status
133#define UACPI_BUS_MASTER 0b1
134
135// channel_speed
136#define UACPI_DMA_COMPATIBILITY 0b00
137#define UACPI_DMA_TYPE_A 0b01
138#define UACPI_DMA_TYPE_B 0b10
139#define UACPI_DMA_TYPE_F 0b11
140
141// transfer_width
142#define UACPI_TRANSFER_WIDTH_8 0x00
143#define UACPI_TRANSFER_WIDTH_16 0x01
144#define UACPI_TRANSFER_WIDTH_32 0x02
145#define UACPI_TRANSFER_WIDTH_64 0x03
146#define UACPI_TRANSFER_WIDTH_128 0x04
147#define UACPI_TRANSFER_WIDTH_256 0x05
148
149typedef struct uacpi_resource_dma {
156
162
163// decode_type
164#define UACPI_DECODE_16 0b1
165#define UACPI_DECODE_10 0b0
166
167typedef struct uacpi_resource_io {
174
179
180// write_status
181#define UACPI_NON_WRITABLE 0
182#define UACPI_WRITABLE 1
183
184// caching
185#define UACPI_NON_CACHEABLE 0
186#define UACPI_CACHEABLE 1
187#define UACPI_CACHEABLE_WRITE_COMBINING 2
188#define UACPI_PREFETCHABLE 3
189
190// range_type
191#define UACPI_RANGE_TYPE_MEMORY 0
192#define UACPI_RANGE_TYPE_RESERVED 1
193#define UACPI_RANGE_TYPE_ACPI 2
194#define UACPI_RANGE_TYPE_NVS 3
195
196// address_common->type
197#define UACPI_RANGE_MEMORY 0
198#define UACPI_RANGE_IO 1
199#define UACPI_RANGE_BUS 2
200
201// translation
202#define UACPI_IO_MEM_TRANSLATION 1
203#define UACPI_IO_MEM_STATIC 0
204
205// translation_type
206#define UACPI_TRANSLATION_DENSE 0
207#define UACPI_TRANSLATION_SPARSE 1
208
209// direction
210#define UACPI_PRODUCER 0
211#define UACPI_CONSUMER 1
212
213// decode_type
214#define UACPI_POISITIVE_DECODE 0
215#define UACPI_SUBTRACTIVE_DECODE 1
216
217// fixed_min_address & fixed_max_address
218#define UACPI_ADDRESS_NOT_FIXED 0
219#define UACPI_ADDRESS_FIXED 1
220
227
228typedef struct uacpi_io_attribute {
233
239
248
258
268
278
289
297
305
311
312// compatibility & performance
313#define UACPI_GOOD 0
314#define UACPI_ACCEPTABLE 1
315#define UACPI_SUB_OPTIMAL 2
316
322
327
334
342
343// type
344#define UACPI_GPIO_CONNECTION_INTERRUPT 0x00
345#define UACPI_GPIO_CONNECTION_IO 0x01
346
353
354// restriction
355#define UACPI_IO_RESTRICTION_NONE 0x0
356#define UACPI_IO_RESTRICTION_INPUT 0x1
357#define UACPI_IO_RESTRICTION_OUTPUT 0x2
358#define UACPI_IO_RESTRICTION_NONE_PRESERVE 0x3
359
364
365// pull_configuration
366#define UACPI_PIN_CONFIG_DEFAULT 0x00
367#define UACPI_PIN_CONFIG_PULL_UP 0x01
368#define UACPI_PIN_CONFIG_PULL_DOWN 0x02
369#define UACPI_PIN_CONFIG_NO_PULL 0x03
370
375
376 union {
380 };
381
391
392// mode
393#define UACPI_MODE_CONTROLLER_INITIATED 0x0
394#define UACPI_MODE_DEVICE_INITIATED 0x1
395
408
409// addressing_mode
410#define UACPI_I2C_7BIT 0x0
411#define UACPI_I2C_10BIT 0x1
412
419
420// wire_mode
421#define UACPI_SPI_4_WIRES 0
422#define UACPI_SPI_3_WIRES 1
423
424// device_polarity
425#define UACPI_SPI_ACTIVE_LOW 0
426#define UACPI_SPI_ACTIVE_HIGH 1
427
428// phase
429#define UACPI_SPI_PHASE_FIRST 0
430#define UACPI_SPI_PHASE_SECOND 1
431
432// polarity
433#define UACPI_SPI_START_LOW 0
434#define UACPI_SPI_START_HIGH 1
435
446
447// stop_bits
448#define UACPI_UART_STOP_BITS_NONE 0b00
449#define UACPI_UART_STOP_BITS_1 0b01
450#define UACPI_UART_STOP_BITS_1_5 0b10
451#define UACPI_UART_STOP_BITS_2 0b11
452
453// data_bits
454#define UACPI_UART_DATA_5BITS 0b000
455#define UACPI_UART_DATA_6BITS 0b001
456#define UACPI_UART_DATA_7BITS 0b010
457#define UACPI_UART_DATA_8BITS 0b011
458#define UACPI_UART_DATA_9BITS 0b100
459
460// endianness
461#define UACPI_UART_LITTLE_ENDIAN 0
462#define UACPI_UART_BIG_ENDIAN 1
463
464// parity
465#define UACPI_UART_PARITY_NONE 0x00
466#define UACPI_UART_PARITY_EVEN 0x01
467#define UACPI_UART_PARITY_ODD 0x02
468#define UACPI_UART_PARITY_MARK 0x03
469#define UACPI_UART_PARITY_SPACE 0x04
470
471// lines_enabled
472#define UACPI_UART_DATA_CARRIER_DETECT (1 << 2)
473#define UACPI_UART_RING_INDICATOR (1 << 3)
474#define UACPI_UART_DATA_SET_READY (1 << 4)
475#define UACPI_UART_DATA_TERMINAL_READY (1 << 5)
476#define UACPI_UART_CLEAR_TO_SEND (1 << 6)
477#define UACPI_UART_REQUEST_TO_SEND (1 << 7)
478
479// flow_control
480#define UACPI_UART_FLOW_CONTROL_NONE 0b00
481#define UACPI_UART_FLOW_CONTROL_HW 0b01
482#define UACPI_UART_FLOW_CONTROL_XON_XOFF 0b10
483
496
497// phy_type
498#define UACPI_CSI2_PHY_C 0b00
499#define UACPI_CSI2_PHY_D 0b01
500
506
518
519// type
520#define UACPI_PIN_CONFIG_DEFAULT 0x00
521#define UACPI_PIN_CONFIG_BIAS_PULL_UP 0x01
522#define UACPI_PIN_CONFIG_BIAS_PULL_DOWN 0x02
523#define UACPI_PIN_CONFIG_BIAS_DEFAULT 0x03
524#define UACPI_PIN_CONFIG_BIAS_DISABLE 0x04
525#define UACPI_PIN_CONFIG_BIAS_HIGH_IMPEDANCE 0x05
526#define UACPI_PIN_CONFIG_BIAS_BUS_HOLD 0x06
527#define UACPI_PIN_CONFIG_DRIVE_OPEN_DRAIN 0x07
528#define UACPI_PIN_CONFIG_DRIVE_OPEN_SOURCE 0x08
529#define UACPI_PIN_CONFIG_DRIVE_PUSH_PULL 0x09
530#define UACPI_PIN_CONFIG_DRIVE_STRENGTH 0x0A
531#define UACPI_PIN_CONFIG_SLEW_RATE 0x0B
532#define UACPI_PIN_CONFIG_INPUT_DEBOUNCE 0x0C
533#define UACPI_PIN_CONFIG_INPUT_SCHMITT_TRIGGER 0x0D
534
547
548typedef struct uacpi_resource_label {
552
562
573
585
586// scale
587#define UACPI_SCALE_HZ 0b00
588#define UACPI_SCALE_KHZ 0b01
589#define UACPI_SCALE_MHZ 0b10
590
591// frequency
592#define UACPI_FREQUENCY_FIXED 0x0
593#define UACPI_FREQUENCY_VARIABLE 0x1
594
603
604typedef struct uacpi_resource {
607
608 union {
638 };
640
641#define UACPI_NEXT_RESOURCE(cur) \
642 ((uacpi_resource*)((uacpi_u8*)(cur) + (cur)->length))
643
644typedef struct uacpi_resources {
649
651 (void *user, uacpi_resource *resource);
652
653/*
654 * Evaluate the _CRS method for a 'device' and get the returned resource list
655 * via 'out_resources'.
656 *
657 * NOTE: the returned buffer must be released via a uacpi_free_resources()
658 */
661);
662
663/*
664 * Evaluate the _PRS method for a 'device' and get the returned resource list
665 * via 'out_resources'.
666 *
667 * NOTE: the returned buffer must be released via uacpi_free_resources()
668 */
671);
672
673/*
674 * Evaluate an arbitrary method that is expected to return an AML resource
675 * buffer for a 'device' and get the returned resource list via 'out_resources'.
676 *
677 * NOTE: the returned buffer must be released via uacpi_free_resources()
678 */
681 uacpi_resources **out_resources
682);
683
684/*
685 * Set the configuration to be used by the 'device' by calling its _SRS method.
686 *
687 * Note that this expects 'resources' in the normal 'uacpi_resources' format,
688 * and not the raw AML resources bytestream, the conversion to the latter is
689 * done automatically by this API. If you want to _SRS a raw AML resources
690 * bytestream, use 'uacpi_execute' or similar API directly.
691 */
694);
695
696/*
697 * A convenience helper for iterating over the resource list returned by any
698 * of the uacpi_get_*_resources functions.
699 */
702);
703
704/*
705 * A shorthand for uacpi_get_device_resources() + uacpi_for_each_resource().
706 *
707 * Use if you don't actually want to save the 'resources' list, but simply want
708 * to iterate it once to extract the resources you care about and then free it
709 * right away.
710 */
714);
715
716/*
717 * Convert a single AML-encoded resource to native format.
718 *
719 * This should be used for converting Connection() fields (passed during IO on
720 * GeneralPurposeIO or GenericSerialBus operation regions) or other similar
721 * buffers with only one resource to native format.
722 *
723 * NOTE: the returned buffer must be released via uacpi_free_resource()
724 */
726 uacpi_data_view aml_buffer, uacpi_resource **out_resource
727);
729
730#endif // !UACPI_BAREBONES_MODE
731
732#ifdef __cplusplus
733}
734#endif
void user(int argc, const char *argv[])
Definition: cmds.c:1350
method
Definition: dragdrop.c:54
size_t uacpi_size
Definition: types.h:37
uint32_t uacpi_u32
Definition: types.h:21
bool uacpi_bool
Definition: types.h:31
uint64_t uacpi_u64
Definition: types.h:22
char uacpi_char
Definition: types.h:44
uint16_t uacpi_u16
Definition: types.h:20
uint8_t uacpi_u8
Definition: types.h:19
uacpi_resource_type
Definition: resources.h:11
@ UACPI_RESOURCE_TYPE_PIN_GROUP_CONFIGURATION
Definition: resources.h:52
@ UACPI_RESOURCE_TYPE_ADDRESS32
Definition: resources.h:22
@ UACPI_RESOURCE_TYPE_START_DEPENDENT
Definition: resources.h:30
@ UACPI_RESOURCE_TYPE_SERIAL_UART_CONNECTION
Definition: resources.h:45
@ UACPI_RESOURCE_TYPE_VENDOR_SMALL
Definition: resources.h:34
@ UACPI_RESOURCE_TYPE_PIN_FUNCTION
Definition: resources.h:48
@ UACPI_RESOURCE_TYPE_EXTENDED_IRQ
Definition: resources.h:13
@ UACPI_RESOURCE_TYPE_MEMORY32
Definition: resources.h:27
@ UACPI_RESOURCE_TYPE_END_DEPENDENT
Definition: resources.h:31
@ UACPI_RESOURCE_TYPE_IO
Definition: resources.h:18
@ UACPI_RESOURCE_TYPE_SERIAL_I2C_CONNECTION
Definition: resources.h:43
@ UACPI_RESOURCE_TYPE_FIXED_DMA
Definition: resources.h:16
@ UACPI_RESOURCE_TYPE_GENERIC_REGISTER
Definition: resources.h:39
@ UACPI_RESOURCE_TYPE_ADDRESS16
Definition: resources.h:21
@ UACPI_RESOURCE_TYPE_SERIAL_SPI_CONNECTION
Definition: resources.h:44
@ UACPI_RESOURCE_TYPE_PIN_GROUP
Definition: resources.h:50
@ UACPI_RESOURCE_TYPE_MAX
Definition: resources.h:57
@ UACPI_RESOURCE_TYPE_IRQ
Definition: resources.h:12
@ UACPI_RESOURCE_TYPE_PIN_CONFIGURATION
Definition: resources.h:49
@ UACPI_RESOURCE_TYPE_FIXED_IO
Definition: resources.h:19
@ UACPI_RESOURCE_TYPE_VENDOR_LARGE
Definition: resources.h:37
@ UACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION
Definition: resources.h:51
@ UACPI_RESOURCE_TYPE_END_TAG
Definition: resources.h:56
@ UACPI_RESOURCE_TYPE_ADDRESS64
Definition: resources.h:23
@ UACPI_RESOURCE_TYPE_CLOCK_INPUT
Definition: resources.h:54
@ UACPI_RESOURCE_TYPE_SERIAL_CSI2_CONNECTION
Definition: resources.h:46
@ UACPI_RESOURCE_TYPE_GPIO_CONNECTION
Definition: resources.h:40
@ UACPI_RESOURCE_TYPE_ADDRESS64_EXTENDED
Definition: resources.h:24
@ UACPI_RESOURCE_TYPE_MEMORY24
Definition: resources.h:26
@ UACPI_RESOURCE_TYPE_FIXED_MEMORY32
Definition: resources.h:28
@ UACPI_RESOURCE_TYPE_DMA
Definition: resources.h:15
uacpi_status uacpi_get_possible_resources(uacpi_namespace_node *device, uacpi_resources **out_resources)
Definition: resources.c:2100
void uacpi_free_resource(uacpi_resource *)
Definition: resources.c:2064
void uacpi_free_resources(uacpi_resources *)
Definition: resources.c:2056
uacpi_status uacpi_get_current_resources(uacpi_namespace_node *device, uacpi_resources **out_resources)
Definition: resources.c:2093
uacpi_status uacpi_for_each_resource(uacpi_resources *resources, uacpi_resource_iteration_callback cb, void *user)
Definition: resources.c:2115
uacpi_resource_length_kind
Definition: resources.h:83
@ UACPI_RESOURCE_LENGTH_KIND_DONT_CARE
Definition: resources.h:84
@ UACPI_RESOURCE_LENGTH_KIND_ONE_LESS
Definition: resources.h:85
@ UACPI_RESOURCE_LENGTH_KIND_FULL
Definition: resources.h:86
uacpi_status uacpi_get_device_resources(uacpi_namespace_node *device, const uacpi_char *method, uacpi_resources **out_resources)
Definition: resources.c:2107
uacpi_iteration_decision(* uacpi_resource_iteration_callback)(void *user, uacpi_resource *resource)
Definition: resources.h:651
uacpi_status uacpi_set_resources(uacpi_namespace_node *device, uacpi_resources *resources)
Definition: resources.c:2543
uacpi_status uacpi_for_each_device_resource(uacpi_namespace_node *device, const uacpi_char *method, uacpi_resource_iteration_callback cb, void *user)
Definition: resources.c:2155
uacpi_status uacpi_get_resource_from_buffer(uacpi_data_view aml_buffer, uacpi_resource **out_resource)
Definition: resources.c:2021
struct uacpi_resource_vendor_defined uacpi_resource_vendor
uacpi_status
Definition: status.h:10
uacpi_iteration_decision
Definition: types.h:28
FxCmResList * resources
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: msctf.idl:532
#define resource
Definition: kernel32.h:9
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
Definition: devices.h:37
uacpi_u8 translation_type
Definition: resources.h:231
uacpi_u8 translation
Definition: resources.h:230
uacpi_u8 range_type
Definition: resources.h:229
uacpi_resource_source source
Definition: resources.h:256
uacpi_resource_address_common common
Definition: resources.h:250
uacpi_u16 translation_offset
Definition: resources.h:254
uacpi_resource_source source
Definition: resources.h:266
uacpi_resource_address_common common
Definition: resources.h:260
uacpi_u32 translation_offset
Definition: resources.h:264
uacpi_resource_address_common common
Definition: resources.h:280
uacpi_resource_address_common common
Definition: resources.h:270
uacpi_resource_source source
Definition: resources.h:276
uacpi_u64 translation_offset
Definition: resources.h:274
uacpi_address_attribute attribute
Definition: resources.h:241
uacpi_resource_source source
Definition: resources.h:601
uacpi_resource_serial_bus_common common
Definition: resources.h:502
uacpi_u8 num_channels
Definition: resources.h:153
uacpi_u8 bus_master_status
Definition: resources.h:151
uacpi_u8 transfer_type
Definition: resources.h:150
uacpi_u8 channels[]
Definition: resources.h:154
uacpi_u8 channel_speed
Definition: resources.h:152
uacpi_resource_source source
Definition: resources.h:123
uacpi_resource_source source
Definition: resources.h:387
uacpi_io_connection_flags io
Definition: resources.h:378
uacpi_interrupt_connection_flags interrupt
Definition: resources.h:377
uacpi_resource_serial_bus_common common
Definition: resources.h:414
uacpi_u16 minimum
Definition: resources.h:169
uacpi_u8 length
Definition: resources.h:172
uacpi_u8 alignment
Definition: resources.h:171
uacpi_u8 decode_type
Definition: resources.h:168
uacpi_u16 maximum
Definition: resources.h:170
uacpi_u8 triggering
Definition: resources.h:108
uacpi_u8 wake_capability
Definition: resources.h:111
uacpi_u8 length_kind
Definition: resources.h:107
uacpi_u8 polarity
Definition: resources.h:109
uacpi_u8 irqs[]
Definition: resources.h:113
uacpi_u8 sharing
Definition: resources.h:110
uacpi_u8 num_irqs
Definition: resources.h:112
const uacpi_char * string
Definition: resources.h:550
uacpi_resource_source source
Definition: resources.h:543
uacpi_resource_source source
Definition: resources.h:514
uacpi_resource_label label
Definition: resources.h:570
uacpi_resource_source source
Definition: resources.h:569
uacpi_u16 vendor_data_length
Definition: resources.h:557
uacpi_u16 pin_table_length
Definition: resources.h:556
uacpi_resource_label label
Definition: resources.h:558
uacpi_resource_source source
Definition: resources.h:405
uacpi_char * string
Definition: resources.h:64
uacpi_bool index_present
Definition: resources.h:62
uacpi_resource_serial_bus_common common
Definition: resources.h:437
uacpi_resource_serial_bus_common common
Definition: resources.h:485
uacpi_resource_memory32 memory32
Definition: resources.h:620
uacpi_resource_pin_configuration pin_configuration
Definition: resources.h:633
uacpi_u32 type
Definition: resources.h:605
uacpi_resource_vendor_typed vendor_typed
Definition: resources.h:624
uacpi_resource_dma dma
Definition: resources.h:611
uacpi_resource_gpio_connection gpio_connection
Definition: resources.h:626
uacpi_resource_memory24 memory24
Definition: resources.h:619
uacpi_resource_start_dependent start_dependent
Definition: resources.h:622
uacpi_u32 length
Definition: resources.h:606
uacpi_resource_pin_function pin_function
Definition: resources.h:632
uacpi_resource_clock_input clock_input
Definition: resources.h:637
uacpi_resource_vendor vendor
Definition: resources.h:623
uacpi_resource_serial_bus_common serial_bus_common
Definition: resources.h:627
uacpi_resource_io io
Definition: resources.h:613
uacpi_resource_fixed_io fixed_io
Definition: resources.h:614
uacpi_resource_address32 address32
Definition: resources.h:616
uacpi_resource_fixed_memory32 fixed_memory32
Definition: resources.h:621
uacpi_resource_extended_irq extended_irq
Definition: resources.h:610
uacpi_resource_pin_group_configuration pin_group_configuration
Definition: resources.h:636
uacpi_resource_address64_extended address64_extended
Definition: resources.h:618
uacpi_resource_generic_register generic_register
Definition: resources.h:625
uacpi_resource_address64 address64
Definition: resources.h:617
uacpi_resource_irq irq
Definition: resources.h:609
uacpi_resource_fixed_dma fixed_dma
Definition: resources.h:612
uacpi_resource_csi2_connection csi2_connection
Definition: resources.h:631
uacpi_resource_pin_group_function pin_group_function
Definition: resources.h:635
uacpi_resource_i2c_connection i2c_connection
Definition: resources.h:628
uacpi_resource_spi_connection spi_connection
Definition: resources.h:629
uacpi_resource_address16 address16
Definition: resources.h:615
uacpi_resource_uart_connection uart_connection
Definition: resources.h:630
uacpi_resource_pin_group pin_group
Definition: resources.h:634
uacpi_size length
Definition: resources.h:645
uacpi_resource * entries
Definition: resources.h:646
uacpi_io_attribute io
Definition: resources.h:236
uacpi_memory_attribute memory
Definition: resources.h:235