arch/x86/acpigen: refactor calls to acpigen_write_register

All of the callers to acpigen_write_register() also make calls to
acpigen_write_resourcetemplate_[header|footer](). This change introduces
acpigen_write_register_resource() to unify all of those trio of calls
into one.  I also made the input parameter const.

Change-Id: I10b336acf9f03c423bee9dc38955b1617e11c025
Signed-off-by: Matt Delco <delco@chromium.org>
Reviewed-on: https://review.coreboot.org/27672
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Matt Delco 2018-07-27 14:01:05 -07:00 committed by Martin Roth
parent 6bbfc5e7dd
commit c3f9d7a4c3
2 changed files with 12 additions and 11 deletions

View File

@ -578,14 +578,10 @@ void acpigen_write_empty_PTC(void)
acpigen_write_package(2); acpigen_write_package(2);
/* ControlRegister */ /* ControlRegister */
acpigen_write_resourcetemplate_header(); acpigen_write_register_resource(&addr);
acpigen_write_register(&addr);
acpigen_write_resourcetemplate_footer();
/* StatusRegister */ /* StatusRegister */
acpigen_write_resourcetemplate_header(); acpigen_write_register_resource(&addr);
acpigen_write_register(&addr);
acpigen_write_resourcetemplate_footer();
acpigen_pop_len(); acpigen_pop_len();
} }
@ -725,9 +721,7 @@ void acpigen_write_PSD_package(u32 domain, u32 numprocs, PSD_coord coordtype)
void acpigen_write_CST_package_entry(acpi_cstate_t *cstate) void acpigen_write_CST_package_entry(acpi_cstate_t *cstate)
{ {
acpigen_write_package(4); acpigen_write_package(4);
acpigen_write_resourcetemplate_header(); acpigen_write_register_resource(&cstate->resource);
acpigen_write_register(&cstate->resource);
acpigen_write_resourcetemplate_footer();
acpigen_write_dword(cstate->ctype); acpigen_write_dword(cstate->ctype);
acpigen_write_dword(cstate->latency); acpigen_write_dword(cstate->latency);
acpigen_write_dword(cstate->power); acpigen_write_dword(cstate->power);
@ -827,7 +821,7 @@ void acpigen_write_mem32fixed(int readwrite, u32 base, u32 size)
acpigen_emit_dword(size); acpigen_emit_dword(size);
} }
void acpigen_write_register(acpi_addr_t *addr) static void acpigen_write_register(const acpi_addr_t *addr)
{ {
acpigen_emit_byte(0x82); /* Register Descriptor */ acpigen_emit_byte(0x82); /* Register Descriptor */
acpigen_emit_byte(0x0c); /* Register Length 7:0 */ acpigen_emit_byte(0x0c); /* Register Length 7:0 */
@ -840,6 +834,13 @@ void acpigen_write_register(acpi_addr_t *addr)
acpigen_emit_dword(addr->addrh); /* Register Address High */ acpigen_emit_dword(addr->addrh); /* Register Address High */
} }
void acpigen_write_register_resource(const acpi_addr_t *addr)
{
acpigen_write_resourcetemplate_header();
acpigen_write_register(addr);
acpigen_write_resourcetemplate_footer();
}
void acpigen_write_irq(u16 mask) void acpigen_write_irq(u16 mask)
{ {
/* /*

View File

@ -228,7 +228,7 @@ void acpigen_write_TSS_package(int entries, acpi_tstate_t *tstate_list);
void acpigen_write_TSD_package(u32 domain, u32 numprocs, PSD_coord coordtype); void acpigen_write_TSD_package(u32 domain, u32 numprocs, PSD_coord coordtype);
void acpigen_write_mem32fixed(int readwrite, u32 base, u32 size); void acpigen_write_mem32fixed(int readwrite, u32 base, u32 size);
void acpigen_write_io16(u16 min, u16 max, u8 align, u8 len, u8 decode16); void acpigen_write_io16(u16 min, u16 max, u8 align, u8 len, u8 decode16);
void acpigen_write_register(acpi_addr_t *addr); void acpigen_write_register_resource(const acpi_addr_t *addr);
void acpigen_write_resourcetemplate_header(void); void acpigen_write_resourcetemplate_header(void);
void acpigen_write_resourcetemplate_footer(void); void acpigen_write_resourcetemplate_footer(void);
void acpigen_write_mainboard_resource_template(void); void acpigen_write_mainboard_resource_template(void);