tools: amldecode: add parsing support for more AML opcodes
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "opcode.h"
|
||||
#include "object.h"
|
||||
#include "value.h"
|
||||
#include "../table.h"
|
||||
|
||||
void aml_parser_init(struct aml_parser *parser, void *p, size_t len)
|
||||
{
|
||||
@@ -116,6 +117,7 @@ void aml_parser_add_object(struct aml_parser *parser, struct acpi_object *object
|
||||
}
|
||||
|
||||
tok = next_tok;
|
||||
cur = next;
|
||||
}
|
||||
|
||||
strncpy(object->name, tok, sizeof object->name - 1);
|
||||
@@ -192,12 +194,14 @@ static bool should_pop_current_scope(struct aml_parser *parser)
|
||||
enum parse_status aml_parser_parse_into_namespace(struct aml_parser *parser, struct acpi_namespace *ns)
|
||||
{
|
||||
parser->ns = ns;
|
||||
aml_parser_push_scope(parser, ns->root);
|
||||
enum parse_status status = PARSE_OK;
|
||||
|
||||
while (1) {
|
||||
struct aml_value value;
|
||||
enum parse_status status = parse_opcode(parser, &value);
|
||||
status = parse_opcode(parser, &value);
|
||||
if (status != PARSE_OK) {
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
|
||||
if (value.type == AML_VALUE_OBJECT) {
|
||||
@@ -210,7 +214,16 @@ enum parse_status aml_parser_parse_into_namespace(struct aml_parser *parser, str
|
||||
}
|
||||
}
|
||||
|
||||
return PARSE_OK;
|
||||
if (status == PARSE_EOF && !parser->cur_scope->next) {
|
||||
status = PARSE_OK;
|
||||
}
|
||||
|
||||
if (status != PARSE_OK) {
|
||||
fprintf(stderr, "parse error at 0x%04lx: %s\n",
|
||||
aml_parser_cursorpos(parser) + sizeof(struct acpi_table), parse_status_string(status));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
struct acpi_object *aml_parser_resolve_path(struct aml_parser *parser, const char *path)
|
||||
@@ -223,10 +236,16 @@ struct acpi_object *aml_parser_resolve_path(struct aml_parser *parser, const cha
|
||||
|
||||
size_t path_len = strlen(path);
|
||||
char *rpath = malloc(path_len + 1);
|
||||
char *token_buf = rpath;
|
||||
strcpy(rpath, path);
|
||||
|
||||
while (*token_buf == '^') {
|
||||
cur = cur->parent;
|
||||
token_buf++;
|
||||
}
|
||||
|
||||
char *sp;
|
||||
char *tok = strtok_r(rpath, ".", &sp);
|
||||
char *tok = strtok_r(token_buf, ".", &sp);
|
||||
if (tok && object_name_is_always_root(tok)) {
|
||||
cur = parser->ns->root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user