From dbd64953aeac482976a63a8d56adb9562d5a00e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Sun, 16 Jul 2017 16:08:58 +0300 Subject: binaryPI: Add dispatcher for PI blob MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I622d155fce3fa56cd5e24282e22de060fed560c3 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/20624 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/northbridge/amd/agesa/state_machine.c | 44 +++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'src/northbridge/amd') diff --git a/src/northbridge/amd/agesa/state_machine.c b/src/northbridge/amd/agesa/state_machine.c index d16e9adbae..3f61c584aa 100644 --- a/src/northbridge/amd/agesa/state_machine.c +++ b/src/northbridge/amd/agesa/state_machine.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -29,25 +30,64 @@ #include "AMD.h" #include "heapManager.h" -#include "Dispatcher.h" +#if IS_ENABLED(CONFIG_CPU_AMD_AGESA_OPENSOURCE) +#include "Dispatcher.h" +#endif #if ENV_ROMSTAGE #include CONST PSO_ENTRY ROMDATA DefaultPlatformMemoryConfiguration[] = {PSO_END}; #endif +static void agesa_locate_image(AMD_CONFIG_PARAMS *StdHeader) +{ +#if IS_ENABLED(CONFIG_CPU_AMD_AGESA_BINARY_PI) + const char ModuleIdentifier[] = AGESA_ID; + const void *agesa, *image; + size_t file_size; + + agesa = cbfs_boot_map_with_leak((const char *)CONFIG_AGESA_CBFS_NAME, + CBFS_TYPE_RAW, &file_size); + if (agesa == NULL) + return; + + image = LibAmdLocateImage(agesa, agesa + file_size, 4096, + ModuleIdentifier); + StdHeader->ImageBasePtr = (void*) image; +#endif +} + void agesa_set_interface(struct sysinfo *cb) { memset(&cb->StdHeader, 0, sizeof(AMD_CONFIG_PARAMS)); cb->StdHeader.CalloutPtr = GetBiosCallout; + + if (IS_ENABLED(CONFIG_CPU_AMD_AGESA_BINARY_PI)) { + agesa_locate_image(&cb->StdHeader); + AMD_IMAGE_HEADER *image = + (void*)(uintptr_t)cb->StdHeader.ImageBasePtr; + ASSERT(image); + AMD_MODULE_HEADER *module = + (void*)(uintptr_t)image->ModuleInfoOffset; + ASSERT(module && module->ModuleDispatcher); + } } AGESA_STATUS module_dispatch(AGESA_STRUCT_NAME func, AMD_CONFIG_PARAMS *StdHeader) { - MODULE_ENTRY dispatcher = AmdAgesaDispatcher; + MODULE_ENTRY dispatcher; + +#if IS_ENABLED(CONFIG_CPU_AMD_AGESA_OPENSOURCE) + dispatcher = AmdAgesaDispatcher; +#endif +#if IS_ENABLED(CONFIG_CPU_AMD_AGESA_BINARY_PI) + AMD_IMAGE_HEADER *image = (void*)(uintptr_t)StdHeader->ImageBasePtr; + AMD_MODULE_HEADER *module = (void*)(uintptr_t)image->ModuleInfoOffset; + dispatcher = module->ModuleDispatcher; +#endif StdHeader->Func = func; return dispatcher(StdHeader); -- cgit v1.2.3