diff options
author | Igor Mammedov <imammedo@redhat.com> | 2015-02-18 19:14:42 +0000 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-02-26 13:04:16 +0100 |
commit | a7891dacadebb9c02e027c456a1d17ea0bdf6df8 (patch) | |
tree | 25b1f4e8f8936e4ff68dc299d50d94219141bb50 /hw/acpi | |
parent | 3dd156435369153c1c1d890b9ef525f1d033a971 (diff) | |
download | qemu-a7891dacadebb9c02e027c456a1d17ea0bdf6df8.zip qemu-a7891dacadebb9c02e027c456a1d17ea0bdf6df8.tar.gz qemu-a7891dacadebb9c02e027c456a1d17ea0bdf6df8.tar.bz2 |
acpi: add aml_eisaid() term
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/acpi')
-rw-r--r-- | hw/acpi/aml-build.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 9081b49..eeb006f 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -665,3 +665,32 @@ Aml *aml_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len, build_append_byte(var->buf, pblk_len); /* PblkLen */ return var; } + +static uint8_t Hex2Digit(char c) +{ + if (c >= 'A') { + return c - 'A' + 10; + } + + return c - '0'; +} + +/* ACPI 1.0b: 15.2.3.6.4.1 EISAID Macro - Convert EISA ID String To Integer */ +Aml *aml_eisaid(const char *str) +{ + Aml *var = aml_alloc(); + uint32_t id; + + g_assert(strlen(str) == 7); + id = (str[0] - 0x40) << 26 | + (str[1] - 0x40) << 21 | + (str[2] - 0x40) << 16 | + Hex2Digit(str[3]) << 12 | + Hex2Digit(str[4]) << 8 | + Hex2Digit(str[5]) << 4 | + Hex2Digit(str[6]); + + build_append_byte(var->buf, 0x0C); /* DWordPrefix */ + build_append_int_noprefix(var->buf, bswap32(id), sizeof(id)); + return var; +} |