static u8 acpi_hw_get_access_bit_width(struct acpi_generic_address *reg, u8 max_bit_width) { u64 address; if (!reg->access_width) { /* * Detect old register descriptors where only the bit_width field * makes senses. The target address is copied to handle possible * alignment issues. */ ACPI_MOVE_64_TO_64(&address, ®->address); if (!reg->bit_offset && reg->bit_width && ACPI_IS_POWER_OF_TWO(reg->bit_width) && ACPI_IS_ALIGNED(reg->bit_width, 8) && ACPI_IS_ALIGNED(address, reg->bit_width)) { return (reg->bit_width); } else { if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { return (32); } else { return (max_bit_width); } } } else { return (1 << (reg->access_width + 2)); } }
static u8 acpi_hw_get_access_bit_width(u64 address, struct acpi_generic_address *reg, u8 max_bit_width) { u8 access_bit_width; /* * GAS format "register", used by FADT: * 1. Detected if bit_offset is 0 and bit_width is 8/16/32/64; * 2. access_size field is ignored and bit_width field is used for * determining the boundary of the IO accesses. * GAS format "region", used by APEI registers: * 1. Detected if bit_offset is not 0 or bit_width is not 8/16/32/64; * 2. access_size field is used for determining the boundary of the * IO accesses; * 3. bit_offset/bit_width fields are used to describe the "region". * * Note: This algorithm assumes that the "Address" fields should always * contain aligned values. */ if (!reg->bit_offset && reg->bit_width && ACPI_IS_POWER_OF_TWO(reg->bit_width) && ACPI_IS_ALIGNED(reg->bit_width, 8)) { access_bit_width = reg->bit_width; } else if (reg->access_width) { access_bit_width = ACPI_ACCESS_BIT_WIDTH(reg->access_width); } else { access_bit_width = ACPI_ROUND_UP_POWER_OF_TWO_8(reg->bit_offset + reg->bit_width); if (access_bit_width <= 8) { access_bit_width = 8; } else { while (!ACPI_IS_ALIGNED(address, access_bit_width >> 3)) { access_bit_width >>= 1; } } } /* Maximum IO port access bit width is 32 */ if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { max_bit_width = 32; } /* * Return access width according to the requested maximum access bit width, * as the caller should know the format of the register and may enforce * a 32-bit accesses. */ if (access_bit_width < max_bit_width) { return (access_bit_width); } return (max_bit_width); }
static u8 acpi_hw_get_access_bit_width(struct acpi_generic_address *reg, u8 max_bit_width) { if (!reg->access_width) { if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { max_bit_width = 32; } /* * Detect old register descriptors where only the bit_width field * makes senses. */ if (reg->bit_width < max_bit_width && !reg->bit_offset && reg->bit_width && ACPI_IS_POWER_OF_TWO(reg->bit_width) && ACPI_IS_ALIGNED(reg->bit_width, 8)) { return (reg->bit_width); } return (max_bit_width); } else { return (1 << (reg->access_width + 2)); } }
static UINT8 AcpiHwGetAccessBitWidth ( UINT64 Address, ACPI_GENERIC_ADDRESS *Reg, UINT8 MaxBitWidth) { UINT8 AccessBitWidth; /* * GAS format "register", used by FADT: * 1. Detected if BitOffset is 0 and BitWidth is 8/16/32/64; * 2. AccessSize field is ignored and BitWidth field is used for * determining the boundary of the IO accesses. * GAS format "region", used by APEI registers: * 1. Detected if BitOffset is not 0 or BitWidth is not 8/16/32/64; * 2. AccessSize field is used for determining the boundary of the * IO accesses; * 3. BitOffset/BitWidth fields are used to describe the "region". * * Note: This algorithm assumes that the "Address" fields should always * contain aligned values. */ if (!Reg->BitOffset && Reg->BitWidth && ACPI_IS_POWER_OF_TWO (Reg->BitWidth) && ACPI_IS_ALIGNED (Reg->BitWidth, 8)) { AccessBitWidth = Reg->BitWidth; } else if (Reg->AccessWidth) { AccessBitWidth = ACPI_ACCESS_BIT_WIDTH (Reg->AccessWidth); } else { AccessBitWidth = ACPI_ROUND_UP_POWER_OF_TWO_8 ( Reg->BitOffset + Reg->BitWidth); if (AccessBitWidth <= 8) { AccessBitWidth = 8; } else { while (!ACPI_IS_ALIGNED (Address, AccessBitWidth >> 3)) { AccessBitWidth >>= 1; } } } /* Maximum IO port access bit width is 32 */ if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) { MaxBitWidth = 32; } /* * Return access width according to the requested maximum access bit width, * as the caller should know the format of the register and may enforce * a 32-bit accesses. */ if (AccessBitWidth < MaxBitWidth) { return (AccessBitWidth); } return (MaxBitWidth); }