diff options
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/acpigen.c | 49 | ||||
-rw-r--r-- | src/arch/x86/include/arch/acpigen.h | 7 |
2 files changed, 56 insertions, 0 deletions
diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c index f274ea2177..e051c822e6 100644 --- a/src/arch/x86/acpigen.c +++ b/src/arch/x86/acpigen.c @@ -123,6 +123,49 @@ void acpigen_write_qword(uint64_t data) acpigen_emit_dword((data >> 32) & 0xffffffff); } +void acpigen_write_zero(void) +{ + acpigen_emit_byte(0x00); +} + +void acpigen_write_one(void) +{ + acpigen_emit_byte(0x01); +} + +void acpigen_write_ones(void) +{ + acpigen_emit_byte(0xff); +} + +void acpigen_write_integer(uint64_t data) +{ + if (data == 0) + acpigen_write_zero(); + else if (data == 1) + acpigen_write_one(); + else if (data <= 0xff) + acpigen_write_byte((unsigned char)data); + else if (data <= 0xffff) + acpigen_write_word((unsigned int)data); + else if (data <= 0xffffffff) + acpigen_write_dword((unsigned int)data); + else + acpigen_write_qword(data); +} + +void acpigen_write_name_zero(const char *name) +{ + acpigen_write_name(name); + acpigen_write_one(); +} + +void acpigen_write_name_one(const char *name) +{ + acpigen_write_name(name); + acpigen_write_zero(); +} + void acpigen_write_name_byte(const char *name, uint8_t val) { acpigen_write_name(name); @@ -141,6 +184,12 @@ void acpigen_write_name_qword(const char *name, uint64_t val) acpigen_write_qword(val); } +void acpigen_write_name_integer(const char *name, uint64_t val) +{ + acpigen_write_name(name); + acpigen_write_integer(val); +} + void acpigen_write_name_string(const char *name, const char *string) { acpigen_write_name(name); diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h index f718f51b25..25551649e9 100644 --- a/src/arch/x86/include/arch/acpigen.h +++ b/src/arch/x86/include/arch/acpigen.h @@ -27,6 +27,9 @@ void acpigen_pop_len(void); void acpigen_set_current(char *curr); char *acpigen_get_current(void); void acpigen_write_package(int nr_el); +void acpigen_write_zero(void); +void acpigen_write_one(void); +void acpigen_write_ones(void); void acpigen_write_byte(unsigned int data); void acpigen_emit_byte(unsigned char data); void acpigen_emit_word(unsigned int data); @@ -38,12 +41,16 @@ void acpigen_emit_eisaid(const char *eisaid); void acpigen_write_word(unsigned int data); void acpigen_write_dword(unsigned int data); void acpigen_write_qword(uint64_t data); +void acpigen_write_integer(uint64_t data); void acpigen_write_string(const char *string); void acpigen_write_name(const char *name); +void acpigen_write_name_zero(const char *name); +void acpigen_write_name_one(const char *name); void acpigen_write_name_string(const char *name, const char *string); void acpigen_write_name_dword(const char *name, uint32_t val); void acpigen_write_name_qword(const char *name, uint64_t val); void acpigen_write_name_byte(const char *name, uint8_t val); +void acpigen_write_name_integer(const char *name, uint64_t val); void acpigen_write_scope(const char *name); void acpigen_write_method(const char *name, int nargs); void acpigen_write_device(const char *name); |