2 * ACPI Utility Functions
4 * Copyright (c) 2013 Red Hat Inc.
5 * Copyright (c) 2017 Skyport Systems
8 * Michael S. Tsirkin <mst@redhat.com>,
9 * Ben Warren <ben@skyportsystems.com>
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include <glib/gstdio.h>
17 #include "qemu-common.h"
18 #include "hw/smbios/smbios.h"
19 #include "qemu/bitmap.h"
20 #include "acpi-utils.h"
21 #include "boot-sector.h"
23 uint8_t acpi_calc_checksum(const uint8_t *data
, int len
)
28 for (i
= 0; i
< len
; i
++) {
35 uint32_t acpi_find_rsdp_address(void)
39 /* RSDP location can vary across a narrow range */
40 for (off
= 0xf0000; off
< 0x100000; off
+= 0x10) {
41 uint8_t sig
[] = "RSD PTR ";
44 for (i
= 0; i
< sizeof sig
- 1; ++i
) {
45 sig
[i
] = readb(off
+ i
);
48 if (!memcmp(sig
, "RSD PTR ", sizeof sig
)) {
55 void acpi_parse_rsdp_table(uint32_t addr
, AcpiRsdpDescriptor
*rsdp_table
)
57 ACPI_READ_FIELD(rsdp_table
->signature
, addr
);
58 ACPI_ASSERT_CMP64(rsdp_table
->signature
, "RSD PTR ");
60 ACPI_READ_FIELD(rsdp_table
->checksum
, addr
);
61 ACPI_READ_ARRAY(rsdp_table
->oem_id
, addr
);
62 ACPI_READ_FIELD(rsdp_table
->revision
, addr
);
63 ACPI_READ_FIELD(rsdp_table
->rsdt_physical_address
, addr
);
64 ACPI_READ_FIELD(rsdp_table
->length
, addr
);