]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/acpi-utils.c
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(QTestState
*qts
)
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
] = qtest_readb(qts
, off
+ i
);
48 if (!memcmp(sig
, "RSD PTR ", sizeof sig
)) {
55 void acpi_parse_rsdp_table(QTestState
*qts
, uint32_t addr
,
56 AcpiRsdpDescriptor
*rsdp_table
)
58 ACPI_READ_FIELD(qts
, rsdp_table
->signature
, addr
);
59 ACPI_ASSERT_CMP64(rsdp_table
->signature
, "RSD PTR ");
61 ACPI_READ_FIELD(qts
, rsdp_table
->checksum
, addr
);
62 ACPI_READ_ARRAY(qts
, rsdp_table
->oem_id
, addr
);
63 ACPI_READ_FIELD(qts
, rsdp_table
->revision
, addr
);
64 ACPI_READ_FIELD(qts
, rsdp_table
->rsdt_physical_address
, addr
);
65 ACPI_READ_FIELD(qts
, rsdp_table
->length
, addr
);