cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

acresrc.h (11128B)


      1/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
      2/******************************************************************************
      3 *
      4 * Name: acresrc.h - Resource Manager function prototypes
      5 *
      6 * Copyright (C) 2000 - 2022, Intel Corp.
      7 *
      8 *****************************************************************************/
      9
     10#ifndef __ACRESRC_H__
     11#define __ACRESRC_H__
     12
     13/* Need the AML resource descriptor structs */
     14
     15#include "amlresrc.h"
     16
     17/*
     18 * If possible, pack the following structures to byte alignment, since we
     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
     24 */
     25#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
     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
     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_6BITFLAG,
     50	ACPI_RSC_ADDRESS,
     51	ACPI_RSC_BITMASK,
     52	ACPI_RSC_BITMASK16,
     53	ACPI_RSC_COUNT,
     54	ACPI_RSC_COUNT16,
     55	ACPI_RSC_COUNT_GPIO_PIN,
     56	ACPI_RSC_COUNT_GPIO_RES,
     57	ACPI_RSC_COUNT_GPIO_VEN,
     58	ACPI_RSC_COUNT_SERIAL_RES,
     59	ACPI_RSC_COUNT_SERIAL_VEN,
     60	ACPI_RSC_DATA8,
     61	ACPI_RSC_EXIT_EQ,
     62	ACPI_RSC_EXIT_LE,
     63	ACPI_RSC_EXIT_NE,
     64	ACPI_RSC_LENGTH,
     65	ACPI_RSC_MOVE_GPIO_PIN,
     66	ACPI_RSC_MOVE_GPIO_RES,
     67	ACPI_RSC_MOVE_SERIAL_RES,
     68	ACPI_RSC_MOVE_SERIAL_VEN,
     69	ACPI_RSC_MOVE8,
     70	ACPI_RSC_MOVE16,
     71	ACPI_RSC_MOVE32,
     72	ACPI_RSC_MOVE64,
     73	ACPI_RSC_SET8,
     74	ACPI_RSC_SOURCE,
     75	ACPI_RSC_SOURCEX
     76} ACPI_RSCONVERT_OPCODES;
     77
     78/* Resource Conversion sub-opcodes */
     79
     80#define ACPI_RSC_COMPARE_AML_LENGTH     0
     81#define ACPI_RSC_COMPARE_VALUE          1
     82
     83#define ACPI_RSC_TABLE_SIZE(d)          (sizeof (d) / sizeof (struct acpi_rsconvert_info))
     84
     85#define ACPI_RS_OFFSET(f)               (u8) ACPI_OFFSET (struct acpi_resource,f)
     86#define AML_OFFSET(f)                   (u8) ACPI_OFFSET (union aml_resource,f)
     87
     88/*
     89 * Individual entry for the resource dump tables
     90 */
     91typedef const struct acpi_rsdump_info {
     92	u8 opcode;
     93	u8 offset;
     94	const char *name;
     95	const char **pointer;
     96
     97} acpi_rsdump_info;
     98
     99/* Values for the Opcode field above */
    100
    101typedef enum {
    102	ACPI_RSD_TITLE = 0,
    103	ACPI_RSD_1BITFLAG,
    104	ACPI_RSD_2BITFLAG,
    105	ACPI_RSD_3BITFLAG,
    106	ACPI_RSD_6BITFLAG,
    107	ACPI_RSD_ADDRESS,
    108	ACPI_RSD_DWORDLIST,
    109	ACPI_RSD_LITERAL,
    110	ACPI_RSD_LONGLIST,
    111	ACPI_RSD_SHORTLIST,
    112	ACPI_RSD_SHORTLISTX,
    113	ACPI_RSD_SOURCE,
    114	ACPI_RSD_STRING,
    115	ACPI_RSD_UINT8,
    116	ACPI_RSD_UINT16,
    117	ACPI_RSD_UINT32,
    118	ACPI_RSD_UINT64,
    119	ACPI_RSD_WORDLIST,
    120	ACPI_RSD_LABEL,
    121	ACPI_RSD_SOURCE_LABEL,
    122
    123} ACPI_RSDUMP_OPCODES;
    124
    125/* restore default alignment */
    126
    127#pragma pack()
    128
    129/* Resource tables indexed by internal resource type */
    130
    131extern const u8 acpi_gbl_aml_resource_sizes[];
    132extern const u8 acpi_gbl_aml_resource_serial_bus_sizes[];
    133extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
    134
    135/* Resource tables indexed by raw AML resource descriptor type */
    136
    137extern const u8 acpi_gbl_resource_struct_sizes[];
    138extern const u8 acpi_gbl_resource_struct_serial_bus_sizes[];
    139extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
    140
    141extern struct acpi_rsconvert_info
    142    *acpi_gbl_convert_resource_serial_bus_dispatch[];
    143
    144struct acpi_vendor_walk_info {
    145	struct acpi_vendor_uuid *uuid;
    146	struct acpi_buffer *buffer;
    147	acpi_status status;
    148};
    149
    150/*
    151 * rscreate
    152 */
    153acpi_status
    154acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
    155			     struct acpi_buffer *output_buffer);
    156
    157acpi_status
    158acpi_rs_create_aml_resources(struct acpi_buffer *resource_list,
    159			     struct acpi_buffer *output_buffer);
    160
    161acpi_status
    162acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
    163				 struct acpi_buffer *output_buffer);
    164
    165/*
    166 * rsutils
    167 */
    168
    169acpi_status
    170acpi_rs_get_prt_method_data(struct acpi_namespace_node *node,
    171			    struct acpi_buffer *ret_buffer);
    172
    173acpi_status
    174acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
    175			    struct acpi_buffer *ret_buffer);
    176
    177acpi_status
    178acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
    179			    struct acpi_buffer *ret_buffer);
    180
    181acpi_status
    182acpi_rs_get_method_data(acpi_handle handle,
    183			const char *path, struct acpi_buffer *ret_buffer);
    184
    185acpi_status
    186acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
    187			    struct acpi_buffer *ret_buffer);
    188
    189acpi_status
    190acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
    191			    struct acpi_buffer *ret_buffer);
    192
    193/*
    194 * rscalc
    195 */
    196acpi_status
    197acpi_rs_get_list_length(u8 *aml_buffer,
    198			u32 aml_buffer_length, acpi_size *size_needed);
    199
    200acpi_status
    201acpi_rs_get_aml_length(struct acpi_resource *resource_list,
    202		       acpi_size resource_list_size, acpi_size *size_needed);
    203
    204acpi_status
    205acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
    206				     acpi_size *buffer_size_needed);
    207
    208acpi_status
    209acpi_rs_convert_aml_to_resources(u8 * aml,
    210				 u32 length,
    211				 u32 offset, u8 resource_index, void **context);
    212
    213acpi_status
    214acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
    215				 acpi_size aml_size_needed, u8 * output_buffer);
    216
    217/*
    218 * rsaddr
    219 */
    220void
    221acpi_rs_set_address_common(union aml_resource *aml,
    222			   struct acpi_resource *resource);
    223
    224u8
    225acpi_rs_get_address_common(struct acpi_resource *resource,
    226			   union aml_resource *aml);
    227
    228/*
    229 * rsmisc
    230 */
    231acpi_status
    232acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
    233				union aml_resource *aml,
    234				struct acpi_rsconvert_info *info);
    235
    236acpi_status
    237acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
    238				union aml_resource *aml,
    239				struct acpi_rsconvert_info *info);
    240
    241/*
    242 * rsutils
    243 */
    244void
    245acpi_rs_move_data(void *destination,
    246		  void *source, u16 item_count, u8 move_type);
    247
    248u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
    249
    250u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
    251
    252acpi_rs_length
    253acpi_rs_get_resource_source(acpi_rs_length resource_length,
    254			    acpi_rs_length minimum_length,
    255			    struct acpi_resource_source *resource_source,
    256			    union aml_resource *aml, char *string_ptr);
    257
    258acpi_rsdesc_size
    259acpi_rs_set_resource_source(union aml_resource *aml,
    260			    acpi_rs_length minimum_length,
    261			    struct acpi_resource_source *resource_source);
    262
    263void
    264acpi_rs_set_resource_header(u8 descriptor_type,
    265			    acpi_rsdesc_size total_length,
    266			    union aml_resource *aml);
    267
    268void
    269acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
    270			    union aml_resource *aml);
    271
    272/*
    273 * rsdump - Debugger support
    274 */
    275#ifdef ACPI_DEBUGGER
    276void acpi_rs_dump_resource_list(struct acpi_resource *resource);
    277
    278void acpi_rs_dump_irq_list(u8 *route_table);
    279#endif
    280
    281/*
    282 * Resource conversion tables
    283 */
    284extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
    285extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
    286extern struct acpi_rsconvert_info acpi_rs_convert_io[];
    287extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
    288extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
    289extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
    290extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
    291extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
    292extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
    293extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
    294extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
    295extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
    296extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
    297extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
    298extern struct acpi_rsconvert_info acpi_rs_convert_gpio[];
    299extern struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[];
    300extern struct acpi_rsconvert_info acpi_rs_convert_csi2_serial_bus[];
    301extern struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[];
    302extern struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[];
    303extern struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[];
    304extern struct acpi_rsconvert_info acpi_rs_convert_pin_function[];
    305extern struct acpi_rsconvert_info acpi_rs_convert_pin_config[];
    306extern struct acpi_rsconvert_info acpi_rs_convert_pin_group[];
    307extern struct acpi_rsconvert_info acpi_rs_convert_pin_group_function[];
    308extern struct acpi_rsconvert_info acpi_rs_convert_pin_group_config[];
    309
    310/* These resources require separate get/set tables */
    311
    312extern struct acpi_rsconvert_info acpi_rs_get_irq[];
    313extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
    314extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
    315extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
    316
    317extern struct acpi_rsconvert_info acpi_rs_set_irq[];
    318extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
    319extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
    320
    321#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
    322/*
    323 * rsinfo
    324 */
    325extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
    326extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
    327
    328/*
    329 * rsdumpinfo
    330 */
    331extern struct acpi_rsdump_info acpi_rs_dump_irq[];
    332extern struct acpi_rsdump_info acpi_rs_dump_prt[];
    333extern struct acpi_rsdump_info acpi_rs_dump_dma[];
    334extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
    335extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
    336extern struct acpi_rsdump_info acpi_rs_dump_io[];
    337extern struct acpi_rsdump_info acpi_rs_dump_io_flags[];
    338extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
    339extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
    340extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
    341extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
    342extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
    343extern struct acpi_rsdump_info acpi_rs_dump_memory_flags[];
    344extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
    345extern struct acpi_rsdump_info acpi_rs_dump_address16[];
    346extern struct acpi_rsdump_info acpi_rs_dump_address32[];
    347extern struct acpi_rsdump_info acpi_rs_dump_address64[];
    348extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
    349extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
    350extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
    351extern struct acpi_rsdump_info acpi_rs_dump_gpio[];
    352extern struct acpi_rsdump_info acpi_rs_dump_pin_function[];
    353extern struct acpi_rsdump_info acpi_rs_dump_fixed_dma[];
    354extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
    355extern struct acpi_rsdump_info acpi_rs_dump_csi2_serial_bus[];
    356extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
    357extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
    358extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
    359extern struct acpi_rsdump_info acpi_rs_dump_general_flags[];
    360extern struct acpi_rsdump_info acpi_rs_dump_pin_config[];
    361extern struct acpi_rsdump_info acpi_rs_dump_pin_group[];
    362extern struct acpi_rsdump_info acpi_rs_dump_pin_group_function[];
    363extern struct acpi_rsdump_info acpi_rs_dump_pin_group_config[];
    364#endif
    365
    366#endif				/* __ACRESRC_H__ */