mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 18:44:58 -06:00
acpi: add aml_int() term
* factor out ACPI const int packing out of build_append_value() and rename build_append_value() to build_append_int_noprefix() it will be reused for adding a plain integer value into AML. will be used by is aml_processor() and CRS macro helpers * extend build_append_int{_noprefix}() to support 64-bit values it will be used PCI for generating 64bit _CRS entries 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:
parent
3c054bd51a
commit
295a515df0
3 changed files with 30 additions and 29 deletions
|
@ -218,44 +218,34 @@ void build_extop_package(GArray *package, uint8_t op)
|
|||
build_prepend_byte(package, 0x5B); /* ExtOpPrefix */
|
||||
}
|
||||
|
||||
void build_append_value(GArray *table, uint32_t value, int size)
|
||||
static void build_append_int_noprefix(GArray *table, uint64_t value, int size)
|
||||
{
|
||||
uint8_t prefix;
|
||||
int i;
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
prefix = 0x0A; /* BytePrefix */
|
||||
break;
|
||||
case 2:
|
||||
prefix = 0x0B; /* WordPrefix */
|
||||
break;
|
||||
case 4:
|
||||
prefix = 0x0C; /* DWordPrefix */
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
build_append_byte(table, prefix);
|
||||
for (i = 0; i < size; ++i) {
|
||||
build_append_byte(table, value & 0xFF);
|
||||
value = value >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
void build_append_int(GArray *table, uint32_t value)
|
||||
void build_append_int(GArray *table, uint64_t value)
|
||||
{
|
||||
if (value == 0x00) {
|
||||
build_append_byte(table, 0x00); /* ZeroOp */
|
||||
} else if (value == 0x01) {
|
||||
build_append_byte(table, 0x01); /* OneOp */
|
||||
} else if (value <= 0xFF) {
|
||||
build_append_value(table, value, 1);
|
||||
build_append_byte(table, 0x0A); /* BytePrefix */
|
||||
build_append_int_noprefix(table, value, 1);
|
||||
} else if (value <= 0xFFFF) {
|
||||
build_append_value(table, value, 2);
|
||||
build_append_byte(table, 0x0B); /* WordPrefix */
|
||||
build_append_int_noprefix(table, value, 2);
|
||||
} else if (value <= 0xFFFFFFFF) {
|
||||
build_append_byte(table, 0x0C); /* DWordPrefix */
|
||||
build_append_int_noprefix(table, value, 4);
|
||||
} else {
|
||||
build_append_value(table, value, 4);
|
||||
build_append_byte(table, 0x0E); /* QWordPrefix */
|
||||
build_append_int_noprefix(table, value, 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,6 +355,17 @@ Aml *aml_scope(const char *name_format, ...)
|
|||
return var;
|
||||
}
|
||||
|
||||
/*
|
||||
* ACPI 1.0b: 16.2.3 Data Objects Encoding:
|
||||
* encodes: ByteConst, WordConst, DWordConst, QWordConst, ZeroOp, OneOp
|
||||
*/
|
||||
Aml *aml_int(const uint64_t val)
|
||||
{
|
||||
Aml *var = aml_alloc();
|
||||
build_append_int(var->buf, val);
|
||||
return var;
|
||||
}
|
||||
|
||||
/*
|
||||
* helper to construct NameString, which returns Aml object
|
||||
* for using with aml_append or other aml_* terms
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue