Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/76092?usp=email )
Change subject: [SKETCH] acpigen: Pipe data in acpigen_dsm_uuid_enum_functions() ......................................................................
[SKETCH] acpigen: Pipe data in acpigen_dsm_uuid_enum_functions()
Change-Id: Iad15af08c39d0ddb477216bc3e93bc799899bb0e Signed-off-by: Nico Huber nico.h@gmx.de --- M src/acpi/acpigen.c 1 file changed, 20 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/92/76092/1
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index fb92b89..051bc67 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1670,13 +1670,18 @@ acpigen_emit_byte(dst_op); }
+static void acpigen_start_byte_buffer(size_t size) +{ + acpigen_emit_byte(BUFFER_OP); + acpigen_write_len_f(); + acpigen_write_integer(size); +} + void acpigen_write_byte_buffer(uint8_t *arr, size_t size) { size_t i;
- acpigen_emit_byte(BUFFER_OP); - acpigen_write_len_f(); - acpigen_write_integer(size); + acpigen_start_byte_buffer(size);
for (i = 0; i < size; i++) acpigen_emit_byte(arr[i]); @@ -1767,28 +1772,33 @@ static void acpigen_dsm_uuid_enum_functions(const struct dsm_uuid *id) { const size_t bytes = DIV_ROUND_UP(id->count, BITS_PER_BYTE); - uint8_t *buffer = alloca(bytes); - bool set = false; size_t cb_idx = 0; + bool set = false;
- memset(buffer, 0, bytes); + acpigen_emit_byte(RETURN_OP); + acpigen_start_byte_buffer(bytes); + + /* Keep byte0 location for later patching. */ + uint8_t *const byte0 = (uint8_t *)acpigen_get_current();
for (size_t i = 0; i < bytes; i++) { + uint8_t byte = 0; for (size_t j = 0; j < BITS_PER_BYTE; j++) { if (cb_idx >= id->count) break;
if (id->callbacks[cb_idx++]) { set = true; - buffer[i] |= BIT(j); + byte |= BIT(j); } } + acpigen_emit_byte(byte); }
- if (set) - buffer[0] |= BIT(0); + /* Patch bit0 */ + *byte0 |= set;
- acpigen_write_return_byte_buffer(buffer, bytes); + acpigen_pop_len(); }
static void acpigen_write_dsm_uuid(struct dsm_uuid *id)