From patchwork Tue Jul 18 17:17:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 790420 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xBn2R57pRz9s4s for ; Wed, 19 Jul 2017 03:19:11 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6A8AFC21DFA; Tue, 18 Jul 2017 17:19:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E7313C21C5E; Tue, 18 Jul 2017 17:19:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 83CDCC21C5E; Tue, 18 Jul 2017 17:19:04 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lists.denx.de (Postfix) with ESMTPS id 346CEC21C38 for ; Tue, 18 Jul 2017 17:19:04 +0000 (UTC) Received: from [192.168.123.55] ([84.118.154.110]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LlDb4-1e5CjD44u6-00b3Qw; Tue, 18 Jul 2017 19:18:22 +0200 To: Alexander Graf References: <20170711200625.7108-1-xypron.glpk@gmx.de> <20170711200625.7108-2-xypron.glpk@gmx.de> <64da2027-a360-face-de8b-3d7c7ed14c3b@suse.de> From: Heinrich Schuchardt Message-ID: <4e1e60af-a0ad-322b-c7dc-311f233c38c7@gmx.de> Date: Tue, 18 Jul 2017 19:17:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <64da2027-a360-face-de8b-3d7c7ed14c3b@suse.de> X-Provags-ID: V03:K0:+5rqAU3YJiaurOOpXlzE7h3c0Hj5pKZ2+yyRo8M1jHrxhpef/Pw lVSdDCmcWAYKi0imAI89r+vL/I7zV/TS4zivT9T01C9QlHDYaT0Wg/zKI37wg+PL/F+PTAp ZiTJ7Vlk70Ni/uTasUYKb1vbz5OxL/kNuAACQTwLfRutC8NYechsF3dQ1nWMsMhVbCRvr7W NyQHDkztCYycTuTVnSh5w== X-UI-Out-Filterresults: notjunk:1; V01:K0:I2RC4Ighs30=:qaHkOAWyZuMknE3blIO091 boU1tPTFq3/4qqqWo9NuMoSOG1pt2bEm7FJzrDln/fck59iFoBFdeKYtNq7d//JITKYTmItRP tCObH2H0Ia5/BqfU1MUXyLjAOSaj12Qr54xQ+SCyGMoqnnUKc3J31gSAKiVowpiVW788/Y6rZ davI68w5COY1fT/+GEdKNkytq72gGq6OmfCy6LAyEPd89dpT1Wzt/6RHVyAD5y128c8OXDwj/ iP0If3ji1wanu1yiu7PiQrAlQmX85iBgiOp546xN+LXEsmxH1gE/Deksl/SzRQMCbY334LRlE GZ6cnAm5johCfiO5GkrC3CcTyXZzPWP8Pgi4AVPnJn7uNXOccLKgXvtM7iFK1P9sqy8ZKvhYY 5ncLhU60kYzB7y2Gnp8YsAw4bv/pIMjU2nPnwnUMK7fOvn2izNW/0SsJH2mo2+ewr7TtZBUWh sU37wKTpkNyMS+kAa+eTTFA12kSA2VX49jUMYFPN5+yLTL3Wl4l1iIvKHuq/xnuEH7I6GMPhe 2XYsLWL6lv2niWOvCbP1egHUx7rzKkelKbe4S/a7ZZQYj1/YKoR2hrWWgabxiLdH8G2iv1fGW 3JAlS4no1J1VlsS84qdRfMDwmWTZxKndRIVMaU0um1vuAq9kT8X3ssKyNTTADdjnkF8//KrOt 4M5AtIeXUTCsf1jW38jX5RokxwQ/BXfa9jqobAQA+SEGDZJL1V8SCqEMcZ5luhDANE6+4joTt pdpXFmFtNmyL8r6tcPocfY74J8fqRtPluoQnn6EqKvdjzXKLn8GkBKsigJhdddQC4PcsdnMzx IaHEPh5YUC2MPnXi+A+gYnGBUdyKCnquVicrDfn88Iy5n9hH4M= Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH v2 01/12] efi_loader: refactor efi_open_protocol X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" On 07/18/2017 03:12 PM, Alexander Graf wrote: > On 07/11/2017 10:06 PM, Heinrich Schuchardt wrote: >> efi_open_protocol was implemented to call a protocol specific open >> function to retrieve the protocol interface. >> >> The UEFI specification does not know of such a function. >> >> It is not possible to implement InstallProtocolInterface with the >> current design. >> >> With the patch the protocol interface itself is stored in the list >> of installed protocols of an efi_object instead of an open function. >> >> Signed-off-by: Heinrich Schuchardt >> --- >> v2 >> Remove implementation of efi_return_handle. >> --- >> cmd/bootefi.c | 14 +++----------- >> include/efi_loader.h | 17 ++--------------- >> lib/efi_loader/efi_boottime.c | 18 ++++++++++++++---- >> lib/efi_loader/efi_disk.c | 29 +++-------------------------- >> lib/efi_loader/efi_gop.c | 2 +- >> lib/efi_loader/efi_image_loader.c | 8 -------- >> lib/efi_loader/efi_net.c | 30 +++--------------------------- >> 7 files changed, 26 insertions(+), 92 deletions(-) >> >> diff --git a/cmd/bootefi.c b/cmd/bootefi.c >> index 7ddeead671..7cf0129a18 100644 >> --- a/cmd/bootefi.c >> +++ b/cmd/bootefi.c >> @@ -54,14 +54,6 @@ static struct efi_device_path_file_path >> bootefi_device_path[] = { >> } >> }; >> -static efi_status_t EFIAPI bootefi_open_dp(void *handle, efi_guid_t >> *protocol, >> - void **protocol_interface, void *agent_handle, >> - void *controller_handle, uint32_t attributes) >> -{ >> - *protocol_interface = bootefi_device_path; >> - return EFI_SUCCESS; >> -} >> - >> /* The EFI loaded_image interface for the image executed via >> "bootefi" */ >> static struct efi_loaded_image loaded_image_info = { >> .device_handle = bootefi_device_path, >> @@ -78,7 +70,7 @@ static struct efi_object loaded_image_info_obj = { >> * return handle which points to loaded_image_info >> */ >> .guid = &efi_guid_loaded_image, >> - .open = &efi_return_handle, >> + .protocol_interface = &loaded_image_info, >> }, >> { >> /* >> @@ -86,7 +78,7 @@ static struct efi_object loaded_image_info_obj = { >> * bootefi_device_path >> */ >> .guid = &efi_guid_device_path, >> - .open = &bootefi_open_dp, >> + .protocol_interface = bootefi_device_path, >> }, >> }, >> }; >> @@ -99,7 +91,7 @@ static struct efi_object bootefi_device_obj = { >> /* When asking for the device path interface, return >> * bootefi_device_path */ >> .guid = &efi_guid_device_path, >> - .open = &bootefi_open_dp, >> + .protocol_interface = bootefi_device_path >> } >> }, >> }; >> diff --git a/include/efi_loader.h b/include/efi_loader.h >> index 99619f53a9..c620652307 100644 >> --- a/include/efi_loader.h >> +++ b/include/efi_loader.h >> @@ -49,15 +49,10 @@ struct efi_class_map { >> /* >> * When the UEFI payload wants to open a protocol on an object to >> get its >> * interface (usually a struct with callback functions), this struct >> maps the >> - * protocol GUID to the respective protocol handler open function for >> that >> - * object protocol combination. >> - */ >> + * protocol GUID to the respective protocol interface */ >> struct efi_handler { >> const efi_guid_t *guid; >> - efi_status_t (EFIAPI *open)(void *handle, >> - efi_guid_t *protocol, void **protocol_interface, >> - void *agent_handle, void *controller_handle, >> - uint32_t attributes); >> + void *protocol_interface; >> }; >> /* >> @@ -91,14 +86,6 @@ void efi_smbios_register(void); >> /* Called by networking code to memorize the dhcp ack package */ >> void efi_net_set_dhcp_ack(void *pkt, int len); >> -/* >> - * Stub implementation for a protocol opener that just returns the >> handle as >> - * interface >> - */ >> -efi_status_t EFIAPI efi_return_handle(void *handle, >> - efi_guid_t *protocol, void **protocol_interface, >> - void *agent_handle, void *controller_handle, >> - uint32_t attributes); >> /* Called from places to check whether a timer expired */ >> void efi_timer_check(void); >> /* PE loader implementation */ >> diff --git a/lib/efi_loader/efi_boottime.c >> b/lib/efi_loader/efi_boottime.c >> index 2ecec60281..0f67dc2037 100644 >> --- a/lib/efi_loader/efi_boottime.c >> +++ b/lib/efi_loader/efi_boottime.c >> @@ -443,7 +443,6 @@ static efi_status_t EFIAPI efi_load_image(bool >> boot_policy, >> .protocols = { >> { >> .guid = &efi_guid_loaded_image, >> - .open = &efi_return_handle, >> }, >> }, >> }; >> @@ -453,6 +452,7 @@ static efi_status_t EFIAPI efi_load_image(bool >> boot_policy, >> EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image, >> file_path, source_buffer, source_size, image_handle); >> info = malloc(sizeof(*info)); >> + loaded_image_info_obj.protocols[0].protocol_interface = info; >> obj = malloc(sizeof(loaded_image_info_obj)); >> memset(info, 0, sizeof(*info)); >> memcpy(obj, &loaded_image_info_obj, sizeof(loaded_image_info_obj)); >> @@ -724,6 +724,13 @@ static efi_status_t EFIAPI efi_open_protocol( >> EFI_ENTRY("%p, %p, %p, %p, %p, 0x%x", handle, protocol, >> protocol_interface, agent_handle, controller_handle, >> attributes); >> + >> + if (!protocol_interface && attributes != >> + EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { >> + r = EFI_INVALID_PARAMETER; >> + goto out; >> + } >> + >> list_for_each(lhandle, &efi_obj_list) { >> struct efi_object *efiobj; >> efiobj = list_entry(lhandle, struct efi_object, link); >> @@ -737,9 +744,12 @@ static efi_status_t EFIAPI efi_open_protocol( >> if (!hprotocol) >> break; >> if (!guidcmp(hprotocol, protocol)) { >> - r = handler->open(handle, protocol, >> - protocol_interface, agent_handle, >> - controller_handle, attributes); >> + if (attributes != >> + EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { >> + *protocol_interface = >> + handler->protocol_interface; >> + } >> + r = EFI_SUCCESS; >> goto out; >> } >> } >> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c >> index 4e8e7d0ad6..7f8970496f 100644 >> --- a/lib/efi_loader/efi_disk.c >> +++ b/lib/efi_loader/efi_disk.c >> @@ -35,29 +35,6 @@ struct efi_disk_obj { >> const struct blk_desc *desc; >> }; >> -static efi_status_t EFIAPI efi_disk_open_block(void *handle, >> - efi_guid_t *protocol, void **protocol_interface, >> - void *agent_handle, void *controller_handle, >> - uint32_t attributes) >> -{ >> - struct efi_disk_obj *diskobj = handle; >> - >> - *protocol_interface = &diskobj->ops; >> - >> - return EFI_SUCCESS; >> -} >> - >> -static efi_status_t EFIAPI efi_disk_open_dp(void *handle, efi_guid_t >> *protocol, >> - void **protocol_interface, void *agent_handle, >> - void *controller_handle, uint32_t attributes) >> -{ >> - struct efi_disk_obj *diskobj = handle; >> - >> - *protocol_interface = diskobj->dp; >> - >> - return EFI_SUCCESS; >> -} >> - >> static efi_status_t EFIAPI efi_disk_reset(struct efi_block_io *this, >> char extended_verification) >> { >> @@ -210,10 +187,11 @@ static void efi_disk_add_dev(const char *name, >> diskobj = calloc(1, objlen); >> /* Fill in object data */ >> + dp = (void *)&diskobj[1]; >> diskobj->parent.protocols[0].guid = &efi_block_io_guid; >> - diskobj->parent.protocols[0].open = efi_disk_open_block; >> + diskobj->parent.protocols[0].protocol_interface = &diskobj->ops; >> diskobj->parent.protocols[1].guid = &efi_guid_device_path; >> - diskobj->parent.protocols[1].open = efi_disk_open_dp; >> + diskobj->parent.protocols[1].protocol_interface = dp; >> diskobj->parent.handle = diskobj; >> diskobj->ops = block_io_disk_template; >> diskobj->ifname = if_typename; >> @@ -230,7 +208,6 @@ static void efi_disk_add_dev(const char *name, >> diskobj->ops.media = &diskobj->media; >> /* Fill in device path */ >> - dp = (void*)&diskobj[1]; >> diskobj->dp = dp; >> dp[0].dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE; >> dp[0].dp.sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH; >> diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c >> index 286ad83097..c491ca0815 100644 >> --- a/lib/efi_loader/efi_gop.c >> +++ b/lib/efi_loader/efi_gop.c >> @@ -172,7 +172,7 @@ int efi_gop_register(void) >> /* Fill in object data */ >> gopobj->parent.protocols[0].guid = &efi_gop_guid; >> - gopobj->parent.protocols[0].open = efi_return_handle; >> + gopobj->parent.protocols[0].open = &gopobj->ops; > > This doesn't compile. I assume you meant .protocol_interface = > &gopobj->ops? If so, I can fix it up in my tree... > > > Alex > > Yes your analysis was correct. I should have compiled on a system with CONFIG_LCD for testing. Best regards Heinrich Schuchardt --- -- 2.13.2 diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index c491ca0815..db1fd18a34 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -172,7 +172,7 @@ int efi_gop_register(void) /* Fill in object data */ gopobj->parent.protocols[0].guid = &efi_gop_guid; - gopobj->parent.protocols[0].open = &gopobj->ops; + gopobj->parent.protocols[0].protocol_interface = &gopobj->ops; gopobj->parent.handle = &gopobj->ops; gopobj->ops.query_mode = gop_query_mode; gopobj->ops.set_mode = gop_set_mode;