diff options
author | Vladimir Serbinenko <phcoder@gmail.com> | 2014-11-05 10:28:28 +0100 |
---|---|---|
committer | Vladimir Serbinenko <phcoder@gmail.com> | 2014-11-19 19:50:51 +0100 |
commit | 80fb8edaea44483ed9fa28bfe060734d771150aa (patch) | |
tree | 9abeeefa3bc276dd6fef42d6f3fb29e7d3d1bd0e /src/arch/x86/boot | |
parent | f9cdb486d182668e053ca16f115cbc49066d7768 (diff) |
acpigen: Add and use acpigen_write_method.
The sequence of bytes to create a method is used several times in codebase.
Put it into a function with logical arguments rather than duplicating magic
bytes everywhere.
Change-Id: I0e55d8dc7d5e8e92a521c7a83117c470d0614008
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-on: http://review.coreboot.org/7347
Tested-by: build bot (Jenkins)
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Diffstat (limited to 'src/arch/x86/boot')
-rw-r--r-- | src/arch/x86/boot/acpigen.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/arch/x86/boot/acpigen.c b/src/arch/x86/boot/acpigen.c index 0689273b0a..0eee78a141 100644 --- a/src/arch/x86/boot/acpigen.c +++ b/src/arch/x86/boot/acpigen.c @@ -395,6 +395,19 @@ int acpigen_write_empty_PTC(void) return len + nlen; } +int acpigen_write_method(const char *name, int nargs) +{ + int len; + + /* method op */ + len = acpigen_emit_byte(0x14); + len += acpigen_write_len_f(); + len += acpigen_emit_namestring(name); + len += acpigen_emit_byte(nargs & 7); + + return len; +} + /* * Generates a func with max supported P-states. */ @@ -407,18 +420,13 @@ int acpigen_write_PPC(u8 nr) } */ int len; - /* method op */ - acpigen_emit_byte(0x14); - len = acpigen_write_len_f(); - len += acpigen_emit_namestring("_PPC"); - /* no fnarg */ - acpigen_emit_byte(0x00); + len = acpigen_write_method("_PPC", 0); /* return */ acpigen_emit_byte(0xa4); /* arg */ len += acpigen_write_byte(nr); /* add all single bytes */ - len += 3; + len += 1; acpigen_patch_len(len - 1); return len; } @@ -436,18 +444,14 @@ int acpigen_write_PPC_NVS(void) } */ int len; - /* method op */ - acpigen_emit_byte(0x14); - len = acpigen_write_len_f(); - len += acpigen_emit_namestring("_PPC"); - /* no fnarg */ - acpigen_emit_byte(0x00); + + len = acpigen_write_method("_PPC", 0); /* return */ acpigen_emit_byte(0xa4); /* arg */ len += acpigen_emit_namestring("PPCM"); /* add all single bytes */ - len += 3; + len += 1; acpigen_patch_len(len - 1); return len; } @@ -463,10 +467,7 @@ int acpigen_write_TPC(const char *gnvs_tpc_limit) */ int len; - len = acpigen_emit_byte(0x14); /* MethodOp */ - len += acpigen_write_len_f(); /* PkgLength */ - len += acpigen_emit_namestring("_TPC"); - len += acpigen_emit_byte(0x00); /* No Arguments */ + len = acpigen_write_method("_TPC", 0); len += acpigen_emit_byte(0xa4); /* ReturnOp */ len += acpigen_emit_namestring(gnvs_tpc_limit); acpigen_patch_len(len - 1); |