ACPICA: adding SPDX headers
[linux-2.6-block.git] / drivers / acpi / acpica / acresrc.h
CommitLineData
95857638 1/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
1da177e4
LT
2/******************************************************************************
3 *
4 * Name: acresrc.h - Resource Manager function prototypes
5 *
da6f8320 6 * Copyright (C) 2000 - 2018, Intel Corp.
1da177e4 7 *
95857638 8 *****************************************************************************/
1da177e4
LT
9
10#ifndef __ACRESRC_H__
11#define __ACRESRC_H__
12
50eca3eb
BM
13/* Need the AML resource descriptor structs */
14
15#include "amlresrc.h"
16
0897831b
BM
17/*
18 * If possible, pack the following structures to byte alignment, since we
f6dd9221
BM
19 * 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
0897831b 24 */
f6dd9221 25#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
0897831b
BM
26#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
e0fe0a8d
LM
42typedef 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;
0897831b
BM
76
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
e0fe0a8d
LM
87/*
88 * Individual entry for the resource dump tables
89 */
0897831b
BM
90typedef const struct acpi_rsdump_info {
91 u8 opcode;
92 u8 offset;
0dfaaa3d 93 const char *name;
96db255c 94 const char **pointer;
50eca3eb 95
0897831b 96} acpi_rsdump_info;
50eca3eb 97
0897831b 98/* Values for the Opcode field above */
50eca3eb 99
e0fe0a8d
LM
100typedef 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,
fdaa0980
MW
117 ACPI_RSD_WORDLIST,
118 ACPI_RSD_LABEL,
f8a6c866 119 ACPI_RSD_SOURCE_LABEL,
fdaa0980 120
e0fe0a8d 121} ACPI_RSDUMP_OPCODES;
50eca3eb 122
0897831b 123/* restore default alignment */
50eca3eb 124
0897831b 125#pragma pack()
50eca3eb 126
0897831b 127/* Resource tables indexed by internal resource type */
50eca3eb 128
0897831b 129extern const u8 acpi_gbl_aml_resource_sizes[];
e0fe0a8d 130extern const u8 acpi_gbl_aml_resource_serial_bus_sizes[];
0897831b
BM
131extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
132
133/* Resource tables indexed by raw AML resource descriptor type */
50eca3eb 134
c51a4de8 135extern const u8 acpi_gbl_resource_struct_sizes[];
e0fe0a8d 136extern const u8 acpi_gbl_resource_struct_serial_bus_sizes[];
96db255c
BM
137extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
138
e0fe0a8d
LM
139extern struct acpi_rsconvert_info
140 *acpi_gbl_convert_resource_serial_bus_dispatch[];
141
c51a4de8
BM
142struct acpi_vendor_walk_info {
143 struct acpi_vendor_uuid *uuid;
144 struct acpi_buffer *buffer;
145 acpi_status status;
146};
0897831b
BM
147
148/*
149 * rscreate
150 */
151acpi_status
152acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
153 struct acpi_buffer *output_buffer);
154
155acpi_status
9a0a3597 156acpi_rs_create_aml_resources(struct acpi_buffer *resource_list,
0897831b
BM
157 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);
50eca3eb 162
1da177e4 163/*
0897831b 164 * rsutils
1da177e4 165 */
4119532c 166
1da177e4 167acpi_status
4119532c
BM
168acpi_rs_get_prt_method_data(struct acpi_namespace_node *node,
169 struct acpi_buffer *ret_buffer);
1da177e4
LT
170
171acpi_status
4119532c
BM
172acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
173 struct acpi_buffer *ret_buffer);
1da177e4 174
1da177e4 175acpi_status
4119532c
BM
176acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
177 struct acpi_buffer *ret_buffer);
1da177e4
LT
178
179acpi_status
4be44fcd 180acpi_rs_get_method_data(acpi_handle handle,
0dfaaa3d 181 const char *path, struct acpi_buffer *ret_buffer);
1da177e4
LT
182
183acpi_status
4119532c
BM
184acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
185 struct acpi_buffer *ret_buffer);
1da177e4 186
a91cdde2
BM
187acpi_status
188acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
189 struct acpi_buffer *ret_buffer);
190
44f6c012
RM
191/*
192 * rscalc
193 */
1da177e4 194acpi_status
f5c1e1c5
LZ
195acpi_rs_get_list_length(u8 *aml_buffer,
196 u32 aml_buffer_length, acpi_size *size_needed);
1da177e4
LT
197
198acpi_status
9a0a3597 199acpi_rs_get_aml_length(struct acpi_resource *resource_list,
f5c1e1c5 200 acpi_size resource_list_size, acpi_size *size_needed);
1da177e4
LT
201
202acpi_status
4be44fcd 203acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
f5c1e1c5 204 acpi_size *buffer_size_needed);
1da177e4
LT
205
206acpi_status
61686124
BM
207acpi_rs_convert_aml_to_resources(u8 * aml,
208 u32 length,
209 u32 offset, u8 resource_index, void **context);
1da177e4
LT
210
211acpi_status
50eca3eb
BM
212acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
213 acpi_size aml_size_needed, u8 * output_buffer);
1da177e4 214
50eca3eb
BM
215/*
216 * rsaddr
217 */
0897831b
BM
218void
219acpi_rs_set_address_common(union aml_resource *aml,
50eca3eb 220 struct acpi_resource *resource);
1da177e4 221
0897831b
BM
222u8
223acpi_rs_get_address_common(struct acpi_resource *resource,
50eca3eb 224 union aml_resource *aml);
1da177e4 225
50eca3eb
BM
226/*
227 * rsmisc
228 */
1da177e4 229acpi_status
0897831b
BM
230acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
231 union aml_resource *aml,
232 struct acpi_rsconvert_info *info);
1da177e4
LT
233
234acpi_status
0897831b
BM
235acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
236 union aml_resource *aml,
237 struct acpi_rsconvert_info *info);
50eca3eb
BM
238
239/*
240 * rsutils
241 */
242void
243acpi_rs_move_data(void *destination,
244 void *source, u16 item_count, u8 move_type);
245
0897831b 246u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
50eca3eb 247
0897831b 248u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
50eca3eb 249
0897831b
BM
250acpi_rs_length
251acpi_rs_get_resource_source(acpi_rs_length resource_length,
252 acpi_rs_length minimum_length,
50eca3eb
BM
253 struct acpi_resource_source *resource_source,
254 union aml_resource *aml, char *string_ptr);
255
0897831b 256acpi_rsdesc_size
50eca3eb 257acpi_rs_set_resource_source(union aml_resource *aml,
0897831b 258 acpi_rs_length minimum_length,
50eca3eb 259 struct acpi_resource_source *resource_source);
1da177e4 260
50eca3eb
BM
261void
262acpi_rs_set_resource_header(u8 descriptor_type,
0897831b
BM
263 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);
50eca3eb 269
bda663d3 270/*
39239fed 271 * rsdump - Debugger support
bda663d3 272 */
39239fed 273#ifdef ACPI_DEBUGGER
0897831b 274void acpi_rs_dump_resource_list(struct acpi_resource *resource);
50eca3eb 275
18ae9021 276void acpi_rs_dump_irq_list(u8 *route_table);
27c481f3 277#endif
50eca3eb 278
0897831b
BM
279/*
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[];
e0fe0a8d
LM
296extern 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[];
2b726930 301extern struct acpi_rsconvert_info acpi_rs_convert_pin_function[];
97028ce6 302extern struct acpi_rsconvert_info acpi_rs_convert_pin_config[];
fdaa0980 303extern struct acpi_rsconvert_info acpi_rs_convert_pin_group[];
f8a6c866 304extern struct acpi_rsconvert_info acpi_rs_convert_pin_group_function[];
044b7239 305extern struct acpi_rsconvert_info acpi_rs_convert_pin_group_config[];
0897831b
BM
306
307/* These resources require separate get/set tables */
308
309extern 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[];
313
314extern 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[];
50eca3eb 317
0897831b
BM
318#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
319/*
320 * rsinfo
321 */
322extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
e0fe0a8d 323extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
50eca3eb 324
0897831b 325/*
42f8fb75 326 * rsdumpinfo
0897831b
BM
327 */
328extern struct acpi_rsdump_info acpi_rs_dump_irq[];
42f8fb75 329extern struct acpi_rsdump_info acpi_rs_dump_prt[];
0897831b
BM
330extern 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[];
42f8fb75 334extern struct acpi_rsdump_info acpi_rs_dump_io_flags[];
0897831b
BM
335extern 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[];
42f8fb75 340extern struct acpi_rsdump_info acpi_rs_dump_memory_flags[];
0897831b
BM
341extern 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[];
e0fe0a8d 348extern struct acpi_rsdump_info acpi_rs_dump_gpio[];
2b726930 349extern struct acpi_rsdump_info acpi_rs_dump_pin_function[];
e0fe0a8d
LM
350extern 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[];
42f8fb75 355extern struct acpi_rsdump_info acpi_rs_dump_general_flags[];
97028ce6 356extern struct acpi_rsdump_info acpi_rs_dump_pin_config[];
fdaa0980 357extern struct acpi_rsdump_info acpi_rs_dump_pin_group[];
f8a6c866 358extern struct acpi_rsdump_info acpi_rs_dump_pin_group_function[];
044b7239 359extern struct acpi_rsdump_info acpi_rs_dump_pin_group_config[];
50eca3eb 360#endif
bda663d3 361
4be44fcd 362#endif /* __ACRESRC_H__ */