xref: /openbmc/qemu/hw/acpi/utils.c (revision 97414988490de91673c51e6aa88a9f507e6a1edc)
182f76c67SWei Yang /*
282f76c67SWei Yang  * Utilities for generating ACPI tables and passing them to Guests
382f76c67SWei Yang  *
482f76c67SWei Yang  * Copyright (C) 2019 Intel Corporation
582f76c67SWei Yang  * Copyright (C) 2019 Red Hat Inc
682f76c67SWei Yang  *
782f76c67SWei Yang  * Author: Wei Yang <richardw.yang@linux.intel.com>
882f76c67SWei Yang  * Author: Michael S. Tsirkin <mst@redhat.com>
982f76c67SWei Yang  *
1082f76c67SWei Yang  * This program is free software; you can redistribute it and/or modify
1182f76c67SWei Yang  * it under the terms of the GNU General Public License as published by
1282f76c67SWei Yang  * the Free Software Foundation; either version 2 of the License, or
1382f76c67SWei Yang  * (at your option) any later version.
1482f76c67SWei Yang 
1582f76c67SWei Yang  * This program is distributed in the hope that it will be useful,
1682f76c67SWei Yang  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1782f76c67SWei Yang  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1882f76c67SWei Yang  * GNU General Public License for more details.
1982f76c67SWei Yang 
2082f76c67SWei Yang  * You should have received a copy of the GNU General Public License along
2182f76c67SWei Yang  * with this program; if not, see <http://www.gnu.org/licenses/>.
2282f76c67SWei Yang  */
2382f76c67SWei Yang 
2482f76c67SWei Yang #include "qemu/osdep.h"
2582f76c67SWei Yang #include "hw/acpi/aml-build.h"
2682f76c67SWei Yang #include "hw/acpi/utils.h"
2782f76c67SWei Yang #include "hw/loader.h"
2882f76c67SWei Yang 
acpi_add_rom_blob(FWCfgCallback update,void * opaque,GArray * blob,const char * name)2982f76c67SWei Yang MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque,
306930ba0dSDavid Hildenbrand                                 GArray *blob, const char *name)
3182f76c67SWei Yang {
32*50337286SDavid Hildenbrand     uint64_t max_size;
336930ba0dSDavid Hildenbrand 
346930ba0dSDavid Hildenbrand     /* Reserve RAM space for tables: add another order of magnitude. */
356930ba0dSDavid Hildenbrand     if (!strcmp(name, ACPI_BUILD_TABLE_FILE)) {
366930ba0dSDavid Hildenbrand         max_size = 0x200000;
376930ba0dSDavid Hildenbrand     } else if (!strcmp(name, ACPI_BUILD_LOADER_FILE)) {
386930ba0dSDavid Hildenbrand         max_size = 0x10000;
39*50337286SDavid Hildenbrand     } else if (!strcmp(name, ACPI_BUILD_RSDP_FILE)) {
40*50337286SDavid Hildenbrand         max_size = 0x1000;
41*50337286SDavid Hildenbrand     } else {
42*50337286SDavid Hildenbrand         g_assert_not_reached();
436930ba0dSDavid Hildenbrand     }
44*50337286SDavid Hildenbrand     g_assert(acpi_data_len(blob) <= max_size);
456930ba0dSDavid Hildenbrand 
4682f76c67SWei Yang     return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
4782f76c67SWei Yang                         name, update, opaque, NULL, true);
4882f76c67SWei Yang }
49