diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/x86/acpigen.c | 72 | ||||
-rw-r--r-- | src/arch/x86/include/arch/acpigen.h | 48 |
2 files changed, 79 insertions, 41 deletions
diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c index 00f8bd01d9..27fa07ac24 100644 --- a/src/arch/x86/acpigen.c +++ b/src/arch/x86/acpigen.c @@ -73,6 +73,12 @@ void acpigen_emit_byte(unsigned char b) (*gencurrent++) = b; } +void acpigen_emit_ext_op(uint8_t op) +{ + acpigen_emit_byte(EXT_OP_PREFIX); + acpigen_emit_byte(op); +} + void acpigen_emit_word(unsigned int data) { acpigen_emit_byte(data & 0xff); @@ -90,8 +96,7 @@ void acpigen_emit_dword(unsigned int data) char *acpigen_write_package(int nr_el) { char *p; - /* package op */ - acpigen_emit_byte(0x12); + acpigen_emit_byte(PACKAGE_OP); acpigen_write_len_f(); p = acpigen_get_current(); acpigen_emit_byte(nr_el); @@ -100,46 +105,42 @@ char *acpigen_write_package(int nr_el) void acpigen_write_byte(unsigned int data) { - /* byte op */ - acpigen_emit_byte(0xa); + acpigen_emit_byte(BYTE_PREFIX); acpigen_emit_byte(data & 0xff); } void acpigen_write_word(unsigned int data) { - /* word op */ - acpigen_emit_byte(0xb); + acpigen_emit_byte(WORD_PREFIX); acpigen_emit_word(data); } void acpigen_write_dword(unsigned int data) { - /* dword op */ - acpigen_emit_byte(0xc); + acpigen_emit_byte(DWORD_PREFIX); acpigen_emit_dword(data); } void acpigen_write_qword(uint64_t data) { - /* qword op */ - acpigen_emit_byte(0xe); + acpigen_emit_byte(QWORD_PREFIX); acpigen_emit_dword(data & 0xffffffff); acpigen_emit_dword((data >> 32) & 0xffffffff); } void acpigen_write_zero(void) { - acpigen_emit_byte(0x00); + acpigen_emit_byte(ZERO_OP); } void acpigen_write_one(void) { - acpigen_emit_byte(0x01); + acpigen_emit_byte(ONE_OP); } void acpigen_write_ones(void) { - acpigen_emit_byte(0xff); + acpigen_emit_byte(ONES_OP); } void acpigen_write_integer(uint64_t data) @@ -216,7 +217,7 @@ void acpigen_emit_string(const char *string) void acpigen_write_string(const char *string) { - acpigen_emit_byte(0x0d); + acpigen_emit_byte(STRING_PREFIX); acpigen_emit_string(string); } @@ -251,8 +252,7 @@ static void acpigen_emit_simple_namestring(const char *name) { } static void acpigen_emit_double_namestring(const char *name, int dotpos) { - /* mark dual name prefix */ - acpigen_emit_byte(0x2e); + acpigen_emit_byte(DUAL_NAME_PREFIX); acpigen_emit_simple_namestring(name); acpigen_emit_simple_namestring(&name[dotpos + 1]); } @@ -260,9 +260,8 @@ static void acpigen_emit_double_namestring(const char *name, int dotpos) { static void acpigen_emit_multi_namestring(const char *name) { int count = 0; unsigned char *pathlen; - /* mark multi name prefix */ - acpigen_emit_byte(0x2f); - acpigen_emit_byte(0x0); + acpigen_emit_byte(MULTI_NAME_PREFIX); + acpigen_emit_byte(ZERO_OP); pathlen = ((unsigned char *) acpigen_get_current()) - 1; while (name[0] != '\0') { @@ -299,7 +298,7 @@ void acpigen_emit_namestring(const char *namepath) { /* If we have only \\ or only ^...^. Then we need to put a null name (0x00). */ if (namepath[0] == '\0') { - acpigen_emit_byte(0x00); + acpigen_emit_byte(ZERO_OP); return; } @@ -323,15 +322,13 @@ void acpigen_emit_namestring(const char *namepath) { void acpigen_write_name(const char *name) { - /* name op */ - acpigen_emit_byte(0x8); + acpigen_emit_byte(NAME_OP); acpigen_emit_namestring(name); } void acpigen_write_scope(const char *name) { - /* scope op */ - acpigen_emit_byte(0x10); + acpigen_emit_byte(SCOPE_OP); acpigen_write_len_f(); acpigen_emit_namestring(name); } @@ -343,9 +340,7 @@ void acpigen_write_processor(u8 cpuindex, u32 pblock_addr, u8 pblock_len) { */ char pscope[16]; - /* processor op */ - acpigen_emit_byte(0x5b); - acpigen_emit_byte(0x83); + acpigen_emit_ext_op(PROCESSOR_OP); acpigen_write_len_f(); snprintf(pscope, sizeof(pscope), @@ -445,8 +440,7 @@ void acpigen_write_empty_PTC(void) void acpigen_write_method(const char *name, int nargs) { - /* method op */ - acpigen_emit_byte(0x14); + acpigen_emit_byte(METHOD_OP); acpigen_write_len_f(); acpigen_emit_namestring(name); acpigen_emit_byte(nargs & 7); @@ -454,9 +448,7 @@ void acpigen_write_method(const char *name, int nargs) void acpigen_write_device(const char *name) { - /* device op */ - acpigen_emit_byte(0x5b); - acpigen_emit_byte(0x82); + acpigen_emit_ext_op(DEVICE_OP); acpigen_write_len_f(); acpigen_emit_namestring(name); } @@ -467,7 +459,7 @@ void acpigen_write_STA(uint8_t status) * Method (_STA, 0, NotSerialized) { Return (status) } */ acpigen_write_method("_STA", 0); - acpigen_emit_byte(0xa4); + acpigen_emit_byte(RETURN_OP); acpigen_write_byte(status); acpigen_pop_len(); } @@ -484,8 +476,7 @@ void acpigen_write_PPC(u8 nr) } */ acpigen_write_method("_PPC", 0); - /* return */ - acpigen_emit_byte(0xa4); + acpigen_emit_byte(RETURN_OP); /* arg */ acpigen_write_byte(nr); acpigen_pop_len(); @@ -504,8 +495,7 @@ void acpigen_write_PPC_NVS(void) } */ acpigen_write_method("_PPC", 0); - /* return */ - acpigen_emit_byte(0xa4); + acpigen_emit_byte(RETURN_OP); /* arg */ acpigen_emit_namestring("PPCM"); acpigen_pop_len(); @@ -521,7 +511,7 @@ void acpigen_write_TPC(const char *gnvs_tpc_limit) } */ acpigen_write_method("_TPC", 0); - acpigen_emit_byte(0xa4); /* ReturnOp */ + acpigen_emit_byte(RETURN_OP); acpigen_emit_namestring(gnvs_tpc_limit); acpigen_pop_len(); } @@ -731,9 +721,9 @@ void acpigen_write_resourcetemplate_header(void) * resource items, terminated by the end tag. * (small item 0xf, len 1) */ - acpigen_emit_byte(0x11); /* Buffer opcode */ + acpigen_emit_byte(BUFFER_OP); acpigen_write_len_f(); - acpigen_emit_byte(0x0b); /* Word opcode */ + acpigen_emit_byte(WORD_PREFIX); len_stack[ltop++] = acpigen_get_current(); acpigen_emit_byte(0x00); acpigen_emit_byte(0x00); @@ -862,7 +852,7 @@ void acpigen_write_uuid(const char *uuid) return; /* BufferOp */ - acpigen_emit_byte(0x11); + acpigen_emit_byte(BUFFER_OP); acpigen_write_len_f(); /* Buffer length in bytes */ diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h index f513698f26..4e8456dc09 100644 --- a/src/arch/x86/include/arch/acpigen.h +++ b/src/arch/x86/include/arch/acpigen.h @@ -34,6 +34,53 @@ ACPI_STATUS_DEVICE_SHOW_IN_UI |\ ACPI_STATUS_DEVICE_STATE_OK) +/* ACPI Op/Prefix Codes */ +enum { + ZERO_OP = 0x00, + ONE_OP = 0x01, + NAME_OP = 0x08, + SCOPE_OP = 0x10, + BUFFER_OP = 0x11, + BYTE_PREFIX = 0x0A, + WORD_PREFIX = 0x0B, + DWORD_PREFIX = 0x0C, + STRING_PREFIX = 0x0D, + QWORD_PREFIX = 0x0E, + PACKAGE_OP = 0x12, + METHOD_OP = 0x14, + DUAL_NAME_PREFIX = 0x2E, + MULTI_NAME_PREFIX = 0x2F, + EXT_OP_PREFIX = 0x5B, + SLEEP_OP = 0x22, + DEBUG_OP = 0x31, + DEVICE_OP = 0x82, + PROCESSOR_OP = 0x83, + POWER_RES_OP = 0x84, + LOCAL0_OP = 0x60, + LOCAL1_OP = 0x61, + LOCAL2_OP = 0x62, + LOCAL3_OP = 0x63, + LOCAL4_OP = 0x64, + LOCAL5_OP = 0x65, + LOCAL6_OP = 0x66, + LOCAL7_OP = 0x67, + ARG0_OP = 0x68, + ARG1_OP = 0x69, + ARG2_OP = 0x6A, + ARG3_OP = 0x6B, + ARG4_OP = 0x6C, + ARG5_OP = 0x6D, + ARG6_OP = 0x6E, + STORE_OP = 0x70, + AND_OP = 0x7B, + OR_OP = 0x7D, + NOT_OP = 0x80, + IF_OP = 0xA0, + ELSE_OP = 0xA1, + RETURN_OP = 0xA4, + ONES_OP = 0xFF, +}; + void acpigen_write_len_f(void); void acpigen_pop_len(void); void acpigen_set_current(char *curr); @@ -44,6 +91,7 @@ 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_ext_op(uint8_t op); void acpigen_emit_word(unsigned int data); void acpigen_emit_dword(unsigned int data); void acpigen_emit_stream(const char *data, int size); |