1 // SPDX-License-Identifier: GPL-2.0+
3 * Write an ACPI Core System Resource Table (CSRT)
5 * Copyright 2021 Google LLC
8 #define LOG_CATEGORY LOGC_ACPI
11 #include <tables_csum.h>
12 #include <acpi/acpi_table.h>
14 #include <linux/string.h>
16 __weak int acpi_fill_csrt(struct acpi_ctx *ctx)
21 int acpi_write_csrt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
23 struct acpi_table_header *header;
24 struct acpi_csrt *csrt;
28 header = &csrt->header;
30 memset(csrt, '\0', sizeof(struct acpi_csrt));
32 /* Fill out header fields */
33 acpi_fill_header(header, "CSRT");
35 acpi_inc(ctx, sizeof(*header));
37 ret = acpi_fill_csrt(ctx);
39 return log_msg_ret("fill", ret);
41 /* (Re)calculate length and checksum */
42 header->length = (ulong)ctx->current - (ulong)csrt;
43 header->checksum = table_compute_checksum(csrt, header->length);
45 acpi_add_table(ctx, csrt);
49 ACPI_WRITER(5csrt, "CSRT", acpi_write_csrt, 0);