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