csrt.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Write an ACPI Core System Resource Table (CSRT)
  4. *
  5. * Copyright 2021 Google LLC
  6. */
  7. #define LOG_CATEGORY LOGC_ACPI
  8. #include <common.h>
  9. #include <mapmem.h>
  10. #include <tables_csum.h>
  11. #include <acpi/acpi_table.h>
  12. #include <dm/acpi.h>
  13. __weak int acpi_fill_csrt(struct acpi_ctx *ctx)
  14. {
  15. return 0;
  16. }
  17. int acpi_write_csrt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
  18. {
  19. struct acpi_table_header *header;
  20. struct acpi_csrt *csrt;
  21. int ret;
  22. csrt = ctx->current;
  23. header = &csrt->header;
  24. memset(csrt, '\0', sizeof(struct acpi_csrt));
  25. /* Fill out header fields */
  26. acpi_fill_header(header, "CSRT");
  27. header->revision = 0;
  28. acpi_inc(ctx, sizeof(*header));
  29. ret = acpi_fill_csrt(ctx);
  30. if (ret)
  31. return log_msg_ret("fill", ret);
  32. /* (Re)calculate length and checksum */
  33. header->length = (ulong)ctx->current - (ulong)csrt;
  34. header->checksum = table_compute_checksum(csrt, header->length);
  35. acpi_add_table(ctx, csrt);
  36. return 0;
  37. }
  38. ACPI_WRITER(5csrt, "CSRT", acpi_write_csrt, 0);