From b2f2b53fb2f30b8ba9d87d35b68020994589f048 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Thu, 11 May 2023 22:22:06 +0200 Subject: acpi/acpigen: add comment about byte 0 in acpigen_resource_*word MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since it's not obvious, add comments to acpigen_resource_word, acpigen_resource_dword and acpigen_resource_qword to clarify out what the magic number in byte 0 means. The most significant bit of byte 0 indicates if it is a small or large resource data type. In the case of the MSB being 0, it's a small resource data type (aka type 0), and the other bits encode bit the type and size of the item; if the MSB is 1, it's a large resource data type (aka type 1), and the other bits just encode the type and there are two separate bytes to encode the size. Beware that the large resource's data type values in the ACPI specification don't include the MSB that's set, but only the 7 lower bits. Signed-off-by: Felix Held Change-Id: Ia6a6c9fb1bcde232122bb5899b9a0983ef48e12b Reviewed-on: https://review.coreboot.org/c/coreboot/+/75158 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Kyösti Mälkki --- src/acpi/acpigen.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/acpi') diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index 9a9f5c52bd..b85acbc9b4 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -2167,6 +2167,7 @@ void acpigen_get_tx_gpio(const struct acpi_gpio *gpio) void acpigen_resource_word(u16 res_type, u16 gen_flags, u16 type_flags, u16 gran, u16 range_min, u16 range_max, u16 translation, u16 length) { + /* Byte 0: Type 1, Large Item Value 0x8: Word Address Space Descriptor */ acpigen_emit_byte(0x88); /* Byte 1+2: length (0x000d) */ acpigen_emit_byte(0x0d); @@ -2190,6 +2191,7 @@ void acpigen_resource_word(u16 res_type, u16 gen_flags, u16 type_flags, u16 gran void acpigen_resource_dword(u16 res_type, u16 gen_flags, u16 type_flags, u32 gran, u32 range_min, u32 range_max, u32 translation, u32 length) { + /* Byte 0: Type 1, Large Item Value 0x7: DWord Address Space Descriptor */ acpigen_emit_byte(0x87); /* Byte 1+2: length (0023) */ acpigen_emit_byte(23); @@ -2219,6 +2221,7 @@ static void acpigen_emit_qword(u64 data) void acpigen_resource_qword(u16 res_type, u16 gen_flags, u16 type_flags, u64 gran, u64 range_min, u64 range_max, u64 translation, u64 length) { + /* Byte 0: Type 1, Large Item Value 0xa: QWord Address Space Descriptor */ acpigen_emit_byte(0x8a); /* Byte 1+2: length (0x002b) */ acpigen_emit_byte(0x2b); -- cgit v1.2.3