acpi: add aml_string() 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>
This commit is contained in:
Igor Mammedov 2015-02-18 19:14:37 +00:00 committed by Michael S. Tsirkin
parent b8a5d6894d
commit d5e5830f56
2 changed files with 26 additions and 0 deletions

View File

@ -597,6 +597,31 @@ Aml *aml_field(const char *name, AmlFieldFlags flags)
return var;
}
/* ACPI 1.0b: 16.2.3 Data Objects Encoding: String */
Aml *aml_string(const char *name_format, ...)
{
Aml *var = aml_opcode(0x0D /* StringPrefix */);
va_list ap, va_len;
char *s;
int len;
va_start(ap, name_format);
va_copy(va_len, ap);
len = vsnprintf(NULL, 0, name_format, va_len);
va_end(va_len);
len += 1;
s = g_new0(typeof(*s), len);
len = vsnprintf(s, len, name_format, ap);
va_end(ap);
g_array_append_vals(var->buf, s, len);
build_append_byte(var->buf, 0x0); /* NullChar */
g_free(s);
return var;
}
/* ACPI 1.0b: 16.2.6.2 Local Objects Encoding */
Aml *aml_local(int num)
{

View File

@ -92,6 +92,7 @@ Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
uint32_t offset, uint32_t len);
Aml *aml_named_field(const char *name, unsigned length);
Aml *aml_local(int num);
Aml *aml_string(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
/* Block AML object primitives */
Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2);