blob: 422cd8f2b92e9113d579ae88397914b429a86978 [file] [log] [blame]
Erik Schmauss95857632018-03-14 16:13:07 -07001/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/******************************************************************************
3 *
4 * Name: acresrc.h - Resource Manager function prototypes
5 *
Bob Moore840c02c2019-01-14 09:55:25 -08006 * Copyright (C) 2000 - 2019, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
Erik Schmauss95857632018-03-14 16:13:07 -07008 *****************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#ifndef __ACRESRC_H__
11#define __ACRESRC_H__
12
Bob Moore50eca3e2005-09-30 19:03:00 -040013/* Need the AML resource descriptor structs */
14
15#include "amlresrc.h"
16
17/*
Bob Moore08978312005-10-21 00:00:00 -040018 * If possible, pack the following structures to byte alignment, since we
Bob Mooref6dd9222006-07-07 20:44:38 -040019 * don't care about performance for debug output. Two cases where we cannot
20 * pack the structures:
21 *
22 * 1) Hardware does not support misaligned memory transfers
23 * 2) Compiler does not support pointers within packed structures
Bob Moore08978312005-10-21 00:00:00 -040024 */
Bob Mooref6dd9222006-07-07 20:44:38 -040025#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
Bob Moore08978312005-10-21 00:00:00 -040026#pragma pack(1)
27#endif
28
29/*
30 * Individual entry for the resource conversion tables
31 */
32typedef const struct acpi_rsconvert_info {
33 u8 opcode;
34 u8 resource_offset;
35 u8 aml_offset;
36 u8 value;
37
38} acpi_rsconvert_info;
39
40/* Resource conversion opcodes */
41
Lin Minge0fe0a82011-11-16 14:38:13 +080042typedef enum {
43 ACPI_RSC_INITGET = 0,
44 ACPI_RSC_INITSET,
45 ACPI_RSC_FLAGINIT,
46 ACPI_RSC_1BITFLAG,
47 ACPI_RSC_2BITFLAG,
48 ACPI_RSC_3BITFLAG,
49 ACPI_RSC_ADDRESS,
50 ACPI_RSC_BITMASK,
51 ACPI_RSC_BITMASK16,
52 ACPI_RSC_COUNT,
53 ACPI_RSC_COUNT16,
54 ACPI_RSC_COUNT_GPIO_PIN,
55 ACPI_RSC_COUNT_GPIO_RES,
56 ACPI_RSC_COUNT_GPIO_VEN,
57 ACPI_RSC_COUNT_SERIAL_RES,
58 ACPI_RSC_COUNT_SERIAL_VEN,
59 ACPI_RSC_DATA8,
60 ACPI_RSC_EXIT_EQ,
61 ACPI_RSC_EXIT_LE,
62 ACPI_RSC_EXIT_NE,
63 ACPI_RSC_LENGTH,
64 ACPI_RSC_MOVE_GPIO_PIN,
65 ACPI_RSC_MOVE_GPIO_RES,
66 ACPI_RSC_MOVE_SERIAL_RES,
67 ACPI_RSC_MOVE_SERIAL_VEN,
68 ACPI_RSC_MOVE8,
69 ACPI_RSC_MOVE16,
70 ACPI_RSC_MOVE32,
71 ACPI_RSC_MOVE64,
72 ACPI_RSC_SET8,
73 ACPI_RSC_SOURCE,
74 ACPI_RSC_SOURCEX
75} ACPI_RSCONVERT_OPCODES;
Bob Moore08978312005-10-21 00:00:00 -040076
77/* Resource Conversion sub-opcodes */
78
79#define ACPI_RSC_COMPARE_AML_LENGTH 0
80#define ACPI_RSC_COMPARE_VALUE 1
81
82#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (struct acpi_rsconvert_info))
83
84#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
85#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
86
Lin Minge0fe0a82011-11-16 14:38:13 +080087/*
88 * Individual entry for the resource dump tables
89 */
Bob Moore08978312005-10-21 00:00:00 -040090typedef const struct acpi_rsdump_info {
91 u8 opcode;
92 u8 offset;
Bob Moore0dfaaa32016-03-24 09:40:40 +080093 const char *name;
Bob Moore96db2552005-11-02 00:00:00 -050094 const char **pointer;
Bob Moore50eca3e2005-09-30 19:03:00 -040095
Bob Moore08978312005-10-21 00:00:00 -040096} acpi_rsdump_info;
Bob Moore50eca3e2005-09-30 19:03:00 -040097
Bob Moore08978312005-10-21 00:00:00 -040098/* Values for the Opcode field above */
Bob Moore50eca3e2005-09-30 19:03:00 -040099
Lin Minge0fe0a82011-11-16 14:38:13 +0800100typedef enum {
101 ACPI_RSD_TITLE = 0,
102 ACPI_RSD_1BITFLAG,
103 ACPI_RSD_2BITFLAG,
104 ACPI_RSD_3BITFLAG,
105 ACPI_RSD_ADDRESS,
106 ACPI_RSD_DWORDLIST,
107 ACPI_RSD_LITERAL,
108 ACPI_RSD_LONGLIST,
109 ACPI_RSD_SHORTLIST,
110 ACPI_RSD_SHORTLISTX,
111 ACPI_RSD_SOURCE,
112 ACPI_RSD_STRING,
113 ACPI_RSD_UINT8,
114 ACPI_RSD_UINT16,
115 ACPI_RSD_UINT32,
116 ACPI_RSD_UINT64,
Mika Westerbergfdaa0982017-06-05 16:39:25 +0800117 ACPI_RSD_WORDLIST,
118 ACPI_RSD_LABEL,
Mika Westerbergf8a6c862017-06-05 16:39:31 +0800119 ACPI_RSD_SOURCE_LABEL,
Mika Westerbergfdaa0982017-06-05 16:39:25 +0800120
Lin Minge0fe0a82011-11-16 14:38:13 +0800121} ACPI_RSDUMP_OPCODES;
Bob Moore50eca3e2005-09-30 19:03:00 -0400122
Bob Moore08978312005-10-21 00:00:00 -0400123/* restore default alignment */
Bob Moore50eca3e2005-09-30 19:03:00 -0400124
Bob Moore08978312005-10-21 00:00:00 -0400125#pragma pack()
Bob Moore50eca3e2005-09-30 19:03:00 -0400126
Bob Moore08978312005-10-21 00:00:00 -0400127/* Resource tables indexed by internal resource type */
128
129extern const u8 acpi_gbl_aml_resource_sizes[];
Lin Minge0fe0a82011-11-16 14:38:13 +0800130extern const u8 acpi_gbl_aml_resource_serial_bus_sizes[];
Bob Moore08978312005-10-21 00:00:00 -0400131extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
132
133/* Resource tables indexed by raw AML resource descriptor type */
Bob Moore50eca3e2005-09-30 19:03:00 -0400134
Bob Moorec51a4de2005-11-17 13:07:00 -0500135extern const u8 acpi_gbl_resource_struct_sizes[];
Lin Minge0fe0a82011-11-16 14:38:13 +0800136extern const u8 acpi_gbl_resource_struct_serial_bus_sizes[];
Bob Moore96db2552005-11-02 00:00:00 -0500137extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
138
Lin Minge0fe0a82011-11-16 14:38:13 +0800139extern struct acpi_rsconvert_info
140 *acpi_gbl_convert_resource_serial_bus_dispatch[];
141
Bob Moorec51a4de2005-11-17 13:07:00 -0500142struct acpi_vendor_walk_info {
143 struct acpi_vendor_uuid *uuid;
144 struct acpi_buffer *buffer;
145 acpi_status status;
146};
Bob Moore50eca3e2005-09-30 19:03:00 -0400147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148/*
Bob Moore08978312005-10-21 00:00:00 -0400149 * rscreate
150 */
151acpi_status
152acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
153 struct acpi_buffer *output_buffer);
154
155acpi_status
Lv Zheng9a0a3592013-11-21 12:17:34 +0800156acpi_rs_create_aml_resources(struct acpi_buffer *resource_list,
Bob Moore08978312005-10-21 00:00:00 -0400157 struct acpi_buffer *output_buffer);
158
159acpi_status
160acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
161 struct acpi_buffer *output_buffer);
162
163/*
164 * rsutils
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167acpi_status
Bob Moore41195322006-05-26 16:36:00 -0400168acpi_rs_get_prt_method_data(struct acpi_namespace_node *node,
169 struct acpi_buffer *ret_buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171acpi_status
Bob Moore41195322006-05-26 16:36:00 -0400172acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
173 struct acpi_buffer *ret_buffer);
174
175acpi_status
176acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
177 struct acpi_buffer *ret_buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
179acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400180acpi_rs_get_method_data(acpi_handle handle,
Bob Moore0dfaaa32016-03-24 09:40:40 +0800181 const char *path, struct acpi_buffer *ret_buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183acpi_status
Bob Moore41195322006-05-26 16:36:00 -0400184acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
185 struct acpi_buffer *ret_buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Bob Moorea91cdde22011-11-16 14:46:57 +0800187acpi_status
188acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
189 struct acpi_buffer *ret_buffer);
190
Robert Moore44f6c012005-04-18 22:49:35 -0400191/*
192 * rscalc
193 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194acpi_status
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800195acpi_rs_get_list_length(u8 *aml_buffer,
196 u32 aml_buffer_length, acpi_size *size_needed);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
198acpi_status
Lv Zheng9a0a3592013-11-21 12:17:34 +0800199acpi_rs_get_aml_length(struct acpi_resource *resource_list,
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800200 acpi_size resource_list_size, acpi_size *size_needed);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
202acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400203acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800204 acpi_size *buffer_size_needed);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206acpi_status
Bob Moore616861242006-03-17 16:44:00 -0500207acpi_rs_convert_aml_to_resources(u8 * aml,
208 u32 length,
209 u32 offset, u8 resource_index, void **context);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400212acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
213 acpi_size aml_size_needed, u8 * output_buffer);
214
215/*
Bob Moore50eca3e2005-09-30 19:03:00 -0400216 * rsaddr
217 */
Bob Moore08978312005-10-21 00:00:00 -0400218void
219acpi_rs_set_address_common(union aml_resource *aml,
Bob Moore50eca3e2005-09-30 19:03:00 -0400220 struct acpi_resource *resource);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
Bob Moore08978312005-10-21 00:00:00 -0400222u8
223acpi_rs_get_address_common(struct acpi_resource *resource,
Bob Moore50eca3e2005-09-30 19:03:00 -0400224 union aml_resource *aml);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Robert Moorebda663d2005-09-16 16:51:15 -0400226/*
227 * rsmisc
228 */
229acpi_status
Bob Moore08978312005-10-21 00:00:00 -0400230acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
231 union aml_resource *aml,
232 struct acpi_rsconvert_info *info);
Robert Moorebda663d2005-09-16 16:51:15 -0400233
234acpi_status
Bob Moore08978312005-10-21 00:00:00 -0400235acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
236 union aml_resource *aml,
237 struct acpi_rsconvert_info *info);
Bob Moore50eca3e2005-09-30 19:03:00 -0400238
239/*
240 * rsutils
241 */
242void
243acpi_rs_move_data(void *destination,
244 void *source, u16 item_count, u8 move_type);
245
Bob Moore08978312005-10-21 00:00:00 -0400246u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
Bob Moore50eca3e2005-09-30 19:03:00 -0400247
Bob Moore08978312005-10-21 00:00:00 -0400248u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
Bob Moore50eca3e2005-09-30 19:03:00 -0400249
Bob Moore08978312005-10-21 00:00:00 -0400250acpi_rs_length
251acpi_rs_get_resource_source(acpi_rs_length resource_length,
252 acpi_rs_length minimum_length,
Bob Moore50eca3e2005-09-30 19:03:00 -0400253 struct acpi_resource_source *resource_source,
254 union aml_resource *aml, char *string_ptr);
255
Bob Moore08978312005-10-21 00:00:00 -0400256acpi_rsdesc_size
Bob Moore50eca3e2005-09-30 19:03:00 -0400257acpi_rs_set_resource_source(union aml_resource *aml,
Bob Moore08978312005-10-21 00:00:00 -0400258 acpi_rs_length minimum_length,
Bob Moore50eca3e2005-09-30 19:03:00 -0400259 struct acpi_resource_source *resource_source);
260
Bob Moore50eca3e2005-09-30 19:03:00 -0400261void
262acpi_rs_set_resource_header(u8 descriptor_type,
Bob Moore08978312005-10-21 00:00:00 -0400263 acpi_rsdesc_size total_length,
264 union aml_resource *aml);
265
266void
267acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
268 union aml_resource *aml);
Bob Moore50eca3e2005-09-30 19:03:00 -0400269
Bob Moore50eca3e2005-09-30 19:03:00 -0400270/*
Bob Moore39239fe2015-04-13 11:50:08 +0800271 * rsdump - Debugger support
Bob Moore50eca3e2005-09-30 19:03:00 -0400272 */
Bob Moore39239fe2015-04-13 11:50:08 +0800273#ifdef ACPI_DEBUGGER
Bob Moore08978312005-10-21 00:00:00 -0400274void acpi_rs_dump_resource_list(struct acpi_resource *resource);
Bob Moore50eca3e2005-09-30 19:03:00 -0400275
Lv Zheng18ae9022015-04-13 11:48:12 +0800276void acpi_rs_dump_irq_list(u8 *route_table);
Lv Zheng27c481f2015-04-13 11:49:47 +0800277#endif
Bob Moore50eca3e2005-09-30 19:03:00 -0400278
Bob Moore08978312005-10-21 00:00:00 -0400279/*
280 * Resource conversion tables
281 */
282extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
283extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
284extern struct acpi_rsconvert_info acpi_rs_convert_io[];
285extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
286extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
287extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
288extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
289extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
290extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
291extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
292extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
293extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
294extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
295extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
Lin Minge0fe0a82011-11-16 14:38:13 +0800296extern struct acpi_rsconvert_info acpi_rs_convert_gpio[];
297extern struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[];
298extern struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[];
299extern struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[];
300extern struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[];
Mika Westerberg2b726932017-06-05 16:39:14 +0800301extern struct acpi_rsconvert_info acpi_rs_convert_pin_function[];
Mika Westerberg97028ce2017-06-05 16:39:19 +0800302extern struct acpi_rsconvert_info acpi_rs_convert_pin_config[];
Mika Westerbergfdaa0982017-06-05 16:39:25 +0800303extern struct acpi_rsconvert_info acpi_rs_convert_pin_group[];
Mika Westerbergf8a6c862017-06-05 16:39:31 +0800304extern struct acpi_rsconvert_info acpi_rs_convert_pin_group_function[];
Mika Westerberg044b7232017-06-05 16:39:37 +0800305extern struct acpi_rsconvert_info acpi_rs_convert_pin_group_config[];
Bob Moore50eca3e2005-09-30 19:03:00 -0400306
Bob Moore08978312005-10-21 00:00:00 -0400307/* These resources require separate get/set tables */
Bob Moore50eca3e2005-09-30 19:03:00 -0400308
Bob Moore08978312005-10-21 00:00:00 -0400309extern struct acpi_rsconvert_info acpi_rs_get_irq[];
310extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
311extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
312extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
Bob Moore50eca3e2005-09-30 19:03:00 -0400313
Bob Moore08978312005-10-21 00:00:00 -0400314extern struct acpi_rsconvert_info acpi_rs_set_irq[];
315extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
316extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
Bob Moore50eca3e2005-09-30 19:03:00 -0400317
Bob Moore08978312005-10-21 00:00:00 -0400318#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
319/*
320 * rsinfo
321 */
322extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
Lin Minge0fe0a82011-11-16 14:38:13 +0800323extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
Bob Moore50eca3e2005-09-30 19:03:00 -0400324
Bob Moore08978312005-10-21 00:00:00 -0400325/*
Bob Moore42f8fb72013-01-11 13:08:51 +0100326 * rsdumpinfo
Bob Moore08978312005-10-21 00:00:00 -0400327 */
328extern struct acpi_rsdump_info acpi_rs_dump_irq[];
Bob Moore42f8fb72013-01-11 13:08:51 +0100329extern struct acpi_rsdump_info acpi_rs_dump_prt[];
Bob Moore08978312005-10-21 00:00:00 -0400330extern struct acpi_rsdump_info acpi_rs_dump_dma[];
331extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
332extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
333extern struct acpi_rsdump_info acpi_rs_dump_io[];
Bob Moore42f8fb72013-01-11 13:08:51 +0100334extern struct acpi_rsdump_info acpi_rs_dump_io_flags[];
Bob Moore08978312005-10-21 00:00:00 -0400335extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
336extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
337extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
338extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
339extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
Bob Moore42f8fb72013-01-11 13:08:51 +0100340extern struct acpi_rsdump_info acpi_rs_dump_memory_flags[];
Bob Moore08978312005-10-21 00:00:00 -0400341extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
342extern struct acpi_rsdump_info acpi_rs_dump_address16[];
343extern struct acpi_rsdump_info acpi_rs_dump_address32[];
344extern struct acpi_rsdump_info acpi_rs_dump_address64[];
345extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
346extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
347extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
Lin Minge0fe0a82011-11-16 14:38:13 +0800348extern struct acpi_rsdump_info acpi_rs_dump_gpio[];
Mika Westerberg2b726932017-06-05 16:39:14 +0800349extern struct acpi_rsdump_info acpi_rs_dump_pin_function[];
Lin Minge0fe0a82011-11-16 14:38:13 +0800350extern struct acpi_rsdump_info acpi_rs_dump_fixed_dma[];
351extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
352extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
353extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
354extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
Bob Moore42f8fb72013-01-11 13:08:51 +0100355extern struct acpi_rsdump_info acpi_rs_dump_general_flags[];
Mika Westerberg97028ce2017-06-05 16:39:19 +0800356extern struct acpi_rsdump_info acpi_rs_dump_pin_config[];
Mika Westerbergfdaa0982017-06-05 16:39:25 +0800357extern struct acpi_rsdump_info acpi_rs_dump_pin_group[];
Mika Westerbergf8a6c862017-06-05 16:39:31 +0800358extern struct acpi_rsdump_info acpi_rs_dump_pin_group_function[];
Mika Westerberg044b7232017-06-05 16:39:37 +0800359extern struct acpi_rsdump_info acpi_rs_dump_pin_group_config[];
Bob Moore50eca3e2005-09-30 19:03:00 -0400360#endif
Robert Moorebda663d2005-09-16 16:51:15 -0400361
Len Brown4be44fc2005-08-05 00:44:28 -0400362#endif /* __ACRESRC_H__ */