]> git.proxmox.com Git - mirror_qemu.git/blame - tests/acpi-utils.c
nbd sockets vnc: Mark problematic address family tests TODO
[mirror_qemu.git] / tests / acpi-utils.c
CommitLineData
3248f1b4
BW
1/*
2 * ACPI Utility Functions
3 *
4 * Copyright (c) 2013 Red Hat Inc.
5 * Copyright (c) 2017 Skyport Systems
6 *
7 * Authors:
8 * Michael S. Tsirkin <mst@redhat.com>,
9 * Ben Warren <ben@skyportsystems.com>
10 *
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.
13 */
14
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"
22
23uint8_t acpi_calc_checksum(const uint8_t *data, int len)
24{
25 int i;
26 uint8_t sum = 0;
27
28 for (i = 0; i < len; i++) {
29 sum += data[i];
30 }
31
32 return sum;
33}
34
35uint32_t acpi_find_rsdp_address(void)
36{
37 uint32_t off;
38
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;
43
44 for (i = 0; i < sizeof sig - 1; ++i) {
45 sig[i] = readb(off + i);
46 }
47
48 if (!memcmp(sig, "RSD PTR ", sizeof sig)) {
49 break;
50 }
51 }
52 return off;
53}
54
55void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table)
56{
57 ACPI_READ_FIELD(rsdp_table->signature, addr);
58 ACPI_ASSERT_CMP64(rsdp_table->signature, "RSD PTR ");
59
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);
65}