/src/qemu/hw/acpi/utils.c
Line | Count | Source |
1 | | /* |
2 | | * Utilities for generating ACPI tables and passing them to Guests |
3 | | * |
4 | | * Copyright (C) 2019 Intel Corporation |
5 | | * Copyright (C) 2019 Red Hat Inc |
6 | | * |
7 | | * Author: Wei Yang <richardw.yang@linux.intel.com> |
8 | | * Author: Michael S. Tsirkin <mst@redhat.com> |
9 | | * |
10 | | * This program is free software; you can redistribute it and/or modify |
11 | | * it under the terms of the GNU General Public License as published by |
12 | | * the Free Software Foundation; either version 2 of the License, or |
13 | | * (at your option) any later version. |
14 | | |
15 | | * This program is distributed in the hope that it will be useful, |
16 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | | * GNU General Public License for more details. |
19 | | |
20 | | * You should have received a copy of the GNU General Public License along |
21 | | * with this program; if not, see <http://www.gnu.org/licenses/>. |
22 | | */ |
23 | | |
24 | | #include "qemu/osdep.h" |
25 | | #include "hw/acpi/aml-build.h" |
26 | | #include "hw/acpi/utils.h" |
27 | | #include "hw/core/loader.h" |
28 | | |
29 | | MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque, |
30 | | GArray *blob, const char *name) |
31 | 189 | { |
32 | 189 | uint64_t max_size; |
33 | | |
34 | | /* Reserve RAM space for tables: add another order of magnitude. */ |
35 | 189 | if (!strcmp(name, ACPI_BUILD_TABLE_FILE)) { |
36 | 63 | max_size = 0x200000; |
37 | 126 | } else if (!strcmp(name, ACPI_BUILD_LOADER_FILE)) { |
38 | 63 | max_size = 0x10000; |
39 | 63 | } else if (!strcmp(name, ACPI_BUILD_RSDP_FILE)) { |
40 | 63 | max_size = 0x1000; |
41 | 63 | } else { |
42 | 0 | g_assert_not_reached(); |
43 | 0 | } |
44 | 189 | g_assert(acpi_data_len(blob) <= max_size); |
45 | | |
46 | 189 | return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1, |
47 | 189 | name, update, opaque, NULL, true); |
48 | 189 | } |