vnc: simple clean up
[qemu/ar7.git] / tests / acpi-utils.c
blob41dc1ea9b4aa47cf2fb421b05b3f6ce030774c4c
1 /*
2 * ACPI Utility Functions
4 * Copyright (c) 2013 Red Hat Inc.
5 * Copyright (c) 2017 Skyport Systems
7 * Authors:
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)
25 int i;
26 uint8_t sum = 0;
28 for (i = 0; i < len; i++) {
29 sum += data[i];
32 return sum;
35 uint32_t acpi_find_rsdp_address(void)
37 uint32_t off;
39 /* RSDP location can vary across a narrow range */
40 for (off = 0xf0000; off < 0x100000; off += 0x10) {
41 uint8_t sig[] = "RSD PTR ";
42 int i;
44 for (i = 0; i < sizeof sig - 1; ++i) {
45 sig[i] = readb(off + i);
48 if (!memcmp(sig, "RSD PTR ", sizeof sig)) {
49 break;
52 return off;
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);