From patchwork Sun Dec 17 15:43:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849635 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 3z07ll6c4Cz9sR8 for ; Mon, 18 Dec 2017 02:45:06 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 25943C21FDA; Sun, 17 Dec 2017 15:44:58 +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.0 required=5.0 tests=FREEMAIL_FROM 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 EA5C0C21EF1; Sun, 17 Dec 2017 15:44:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B0509C21EF1; Sun, 17 Dec 2017 15:44:54 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 4F8E5C21D56 for ; Sun, 17 Dec 2017 15:44:54 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MCtLD-1eHYpT1CKZ-009fLA; Sun, 17 Dec 2017 16:44:52 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:27 +0100 Message-Id: <20171217154342.15469-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:1k/z/RkZ5SXiPbenpcJzt2/VbQYJPGeVtGVVLbk6Djp39uFQwa6 BYtPZJT+o9Nya/40j+cvceaSLiy/WZ14pyMsj3H4sOubD0AkfOLlLv2H2oG8VD2VTT6NVVn t8o8Xz9as+7SPk6i8DsHJr34cDGnWXlrpsrPdSm0Vfszp9KP6CaN6Tj3Mnk9hl9ks/afar5 CP9WlzK3FbWzCh574qr9Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:wHK5CRc6jQg=:9fz+ydksFHSUQPK6cva8SO 8D6B4jRo5E29GFPly6BtEU3dTFfS3kLYn7QgZwAKrLTEj+VM8o5/DDfMbPJpYp9XBzrXtDfg0 KHP2oWL0p8o+ZHqzD4md83IYF0NtxyYr3OrcyO4vU8PRaG5EYg3eO0w/xOl+SJXP3M1V3tnK4 OFzWkMldhCzqhX0YcTtLzsYVz45KZX5xaZPnE5a/NW8O9ijO6FJkTV4xXpp5CWhl897ZQN3oh rfjtmiFEAdZt7v2Qqm+yNHne58NLudJxYpsLAdqp98s35/2fGhml6aq/ctgVyusMMPxM3QDJM Fl++sbD7x8z9lWr50IF88yl214w2lxzisv1XURAlNNr/mjicTg1Xt5YFdPmo5myGZl/URAFG3 JX6D9SkeUhYo3EJRqAQBLsLQeKqwFxI5XT46mHbS5xyPz29hJOr0/BloYC+asndfWTKs+Oxu3 opGCVPHhBXgxj8J44VMOFLnhg7qtMOn8s04W9emlU4PYvTAVsoWsfTCIIoDfZR8kqYCbj2veL 7MNC2eot7c3t2aS08Ci/Az2F8KRGtH1b7HsS1BhHWmBJOcnHIe+DDh6PDllWz5ehC2TZPc99v eSgk7Mf+fU10IwvDMzUTQupohH1V+24l99nIY2NivzRmN2Y0wlLbeOAlVwPLb38A1JnZHN5yk iZv9OLyMz4V69o6ckn7tHiryvlPKzm8P2EDZJ5VJgQnCSGzbixPc3ZPaacaqLc7NotNHmMk4R n1+hj1AgVZNfCrwJT0+jg3W5iRJuXHqsq+laitODIRJ+/Eo/OLr9YUFgpo1ZTjDK4QUQF+X4W 6CkMvGyYwKHaunWg5bL8zpBSYUVCw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 01/16] efi_selftest: colored test output 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add color coding to output: test section blue success green errors red todo yellow summary white others light gray Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- include/efi_selftest.h | 27 +++++++++++++++++---------- lib/efi_selftest/efi_selftest.c | 25 ++++++++++++++----------- lib/efi_selftest/efi_selftest_console.c | 13 +++++++++---- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/include/efi_selftest.h b/include/efi_selftest.h index be5ba4bfa9..344f28ed36 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -18,14 +18,20 @@ #define EFI_ST_SUCCESS 0 #define EFI_ST_FAILURE 1 +/* + * Prints a message. + */ +#define efi_st_printf(...) \ + (efi_st_printc(-1, __VA_ARGS__)) + /* * Prints an error message. * * @... format string followed by fields to print */ #define efi_st_error(...) \ - (efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__), \ - efi_st_printf(__VA_ARGS__)) \ + (efi_st_printc(EFI_LIGHTRED, "%s(%u):\nERROR: ", __FILE__, __LINE__), \ + efi_st_printc(EFI_LIGHTRED, __VA_ARGS__)) /* * Prints a TODO message. @@ -33,8 +39,8 @@ * @... format string followed by fields to print */ #define efi_st_todo(...) \ - (efi_st_printf("%s(%u):\nTODO: ", __FILE__, __LINE__), \ - efi_st_printf(__VA_ARGS__)) \ + (efi_st_printc(EFI_YELLOW, "%s(%u):\nTODO: ", __FILE__, __LINE__), \ + efi_st_printc(EFI_YELLOW, __VA_ARGS__)) \ /* * A test may be setup and executed at boottime, @@ -61,14 +67,15 @@ extern struct efi_simple_input_interface *con_in; void efi_st_exit_boot_services(void); /* - * Print a pointer to an u16 string + * Print a colored message * - * @pointer: pointer - * @buf: pointer to buffer address - * on return position of terminating zero word + * @color color + * @fmt printf format + * @... arguments to be printed + * on return position of terminating zero word */ -void efi_st_printf(const char *fmt, ...) - __attribute__ ((format (__printf__, 1, 2))); +void efi_st_printc(int color, const char *fmt, ...) + __attribute__ ((format (__printf__, 2, 3))); /* * Compare memory. diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c index 4e5a12c47c..fc5ef254a1 100644 --- a/lib/efi_selftest/efi_selftest.c +++ b/lib/efi_selftest/efi_selftest.c @@ -65,7 +65,7 @@ void efi_st_exit_boot_services(void) efi_st_error("ExitBootServices did not return EFI_SUCCESS\n"); return; } - efi_st_printf("\nBoot services terminated\n"); + efi_st_printc(EFI_WHITE, "\nBoot services terminated\n"); } /* @@ -81,13 +81,14 @@ static int setup(struct efi_unit_test *test, unsigned int *failures) if (!test->setup) return EFI_ST_SUCCESS; - efi_st_printf("\nSetting up '%s'\n", test->name); + efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name); ret = test->setup(handle, systable); if (ret != EFI_ST_SUCCESS) { efi_st_error("Setting up '%s' failed\n", test->name); ++*failures; } else { - efi_st_printf("Setting up '%s' succeeded\n", test->name); + efi_st_printc(EFI_LIGHTGREEN, + "Setting up '%s' succeeded\n", test->name); } return ret; } @@ -105,13 +106,14 @@ static int execute(struct efi_unit_test *test, unsigned int *failures) if (!test->execute) return EFI_ST_SUCCESS; - efi_st_printf("\nExecuting '%s'\n", test->name); + efi_st_printc(EFI_LIGHTBLUE, "\nExecuting '%s'\n", test->name); ret = test->execute(); if (ret != EFI_ST_SUCCESS) { efi_st_error("Executing '%s' failed\n", test->name); ++*failures; } else { - efi_st_printf("Executing '%s' succeeded\n", test->name); + efi_st_printc(EFI_LIGHTGREEN, + "Executing '%s' succeeded\n", test->name); } return ret; } @@ -129,13 +131,14 @@ static int teardown(struct efi_unit_test *test, unsigned int *failures) if (!test->teardown) return EFI_ST_SUCCESS; - efi_st_printf("\nTearing down '%s'\n", test->name); + efi_st_printc(EFI_LIGHTBLUE, "\nTearing down '%s'\n", test->name); ret = test->teardown(); if (ret != EFI_ST_SUCCESS) { efi_st_error("Tearing down '%s' failed\n", test->name); ++*failures; } else { - efi_st_printf("Tearing down '%s' succeeded\n", test->name); + efi_st_printc(EFI_LIGHTGREEN, + "Tearing down '%s' succeeded\n", test->name); } return ret; } @@ -262,12 +265,12 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, } } - efi_st_printf("\nTesting EFI API implementation\n"); + efi_st_printc(EFI_WHITE, "\nTesting EFI API implementation\n"); if (testname) - efi_st_printf("\nSelected test: '%ps'\n", testname); + efi_st_printc(EFI_WHITE, "\nSelected test: '%ps'\n", testname); else - efi_st_printf("\nNumber of tests to execute: %u\n", + efi_st_printc(EFI_WHITE, "\nNumber of tests to execute: %u\n", ll_entry_count(struct efi_unit_test, efi_unit_test)); @@ -291,7 +294,7 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, &failures); /* Give feedback */ - efi_st_printf("\nSummary: %u failures\n\n", failures); + efi_st_printc(EFI_WHITE, "\nSummary: %u failures\n\n", failures); /* Reset system */ efi_st_printf("Preparing for reset. Press any key.\n"); diff --git a/lib/efi_selftest/efi_selftest_console.c b/lib/efi_selftest/efi_selftest_console.c index 6a7fd20da5..7920c961ba 100644 --- a/lib/efi_selftest/efi_selftest_console.c +++ b/lib/efi_selftest/efi_selftest_console.c @@ -130,12 +130,13 @@ static void int2dec(s32 value, u16 **buf) } /* - * Print a formatted string to the EFI console + * Print a colored formatted string to the EFI console * - * @fmt: format string - * @...: optional arguments + * @color color + * @fmt format string + * @... optional arguments */ -void efi_st_printf(const char *fmt, ...) +void efi_st_printc(int color, const char *fmt, ...) { va_list args; u16 buf[160]; @@ -215,7 +216,11 @@ void efi_st_printf(const char *fmt, ...) } va_end(args); *pos = 0; + if (color >= 0) + con_out->set_attribute(con_out, (unsigned long)color); con_out->output_string(con_out, buf); + if (color >= 0) + con_out->set_attribute(con_out, EFI_LIGHTGRAY); } /* From patchwork Sun Dec 17 15:43:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849645 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 3z07tD5lH9z9sR8 for ; Mon, 18 Dec 2017 02:50:44 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 662D1C21FA9; Sun, 17 Dec 2017 15:45:54 +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.0 required=5.0 tests=FREEMAIL_FROM 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 AE774C21FC3; Sun, 17 Dec 2017 15:45:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CE9CFC21D56; Sun, 17 Dec 2017 15:45:08 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 66A8AC21FD5 for ; Sun, 17 Dec 2017 15:45:04 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LzbXq-1f3awO2I30-014oGL; Sun, 17 Dec 2017 16:45:02 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:28 +0100 Message-Id: <20171217154342.15469-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:tsM5jrqbTHrrxx5KsLIe0bmc7YpESP2y/wnNTIpfbpETCWQNF/Y uu3van1D/6s2t4OUwirFSefO7f7YSkXUj2Jgu47Yf4KTEsy1zuFVvjSVk0hEjgULIo7+mCT y2E/VkzY5sidWf/K6joAWt9x3VemToEaE9qfw4mfOEpXDhWj8ILAESwvuIjaNuAYNwKjtlM WLsS2A9RLxKhmnPXXF/qg== X-UI-Out-Filterresults: notjunk:1; V01:K0:knfCaq653/c=:+3LVzp2Gtj4dW28zPZeyOb swsZtR0PvzjpfMt04ugSHLKqTVA5VO/iJAJ2lEx2Xp6onvQMZzaf9Nb/oNIgAioJ0kBtDY8nr M+F6xN2Z6t3KQw6IwFBJcDPdGLOPI8rV6Ns6Srp7Trg+/Gy49WxBCWial/qTalrvFyBFYpl+E qczG47PnlH/toK23znRE4jc/Mj5/DS14yDjKHinHxjXQpKKuINTX2ULbEPP4w0CgVJDOzXrac O61d7vdcu6caGQeIYm2GLGjg0/1YJeC5ttJi/YSQo3MhRBzTS/hjpTgU4eQdTyZEwuhBv1hUp aJIYKKPyu2LpJ+MtqCum6W+h3rwQXOM8yGHORoMB14l6MFHm0dyycPF7Pas6NwLy9UZY+ujZ6 D22bsQZtCyjWMDVZZDv5vG9Vp/h6yyQN0MAuLPHc6jQX9cN/7ktUD3MQOTmj92UgObDa99zxA hxqJHyVL5iRLgi3HKYrBPKyyHEKxHrNHJe8YdxlbHG5klpoopwg9cmyW8Za0KhuhNK7IrzkVG qDbiAa3zptVY798nDFnIJtfUKRMtQgOJu/UZRlfcy24BzHpVCDYcYuloWK6uI/jM9cfQgNQkV tITNdx1eih6ZL4HAF39zQLQ3funUlKgQUDq9kZkNbbW1J9j6HkBzklcfAvTZvjnUaoYiGl4bM 1QgLygt6cz5fo0dGP4IXcIIaDkTGCVyXWKAjqgLxXQDvP4GrIdr9fsoCRfitdlgH57tVZLF/p qxfyHOLRtdBXLYTyftpbWCxSHNm6R8CSzUgtZJ15Wjh7t4Epa1OW4/7kKmTmIQI+Lk9ZyXNiw UdkQE5G+yWY3aB9x3AsO988ozznNA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 02/16] efi_loader: simplify efi_remove_all_protocols 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Replace list_for_each_safe() and list_entry() by list_for_each_entry_safe(). Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 02bc9fdcf0..99eb36c306 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -425,18 +425,15 @@ efi_status_t efi_remove_protocol(const void *handle, const efi_guid_t *protocol, efi_status_t efi_remove_all_protocols(const void *handle) { struct efi_object *efiobj; - struct list_head *lhandle; - struct list_head *pos; + struct efi_handler *protocol; + struct efi_handler *pos; efiobj = efi_search_obj(handle); if (!efiobj) return EFI_INVALID_PARAMETER; - list_for_each_safe(lhandle, pos, &efiobj->protocols) { - struct efi_handler *protocol; + list_for_each_entry_safe(protocol, pos, &efiobj->protocols, link) { efi_status_t ret; - protocol = list_entry(lhandle, struct efi_handler, link); - ret = efi_remove_protocol(handle, protocol->guid, protocol->protocol_interface); if (ret != EFI_SUCCESS) From patchwork Sun Dec 17 15:43:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849636 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 3z07mm67pYz9sR8 for ; Mon, 18 Dec 2017 02:46:00 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 61420C21FC9; Sun, 17 Dec 2017 15:45:38 +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.0 required=5.0 tests=FREEMAIL_FROM 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 D06CEC21FC6; Sun, 17 Dec 2017 15:45:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 47D68C21F88; Sun, 17 Dec 2017 15:45:15 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 35375C21F94 for ; Sun, 17 Dec 2017 15:45:11 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M3zG2-1fGmL13CVe-00rYiL; Sun, 17 Dec 2017 16:45:09 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:29 +0100 Message-Id: <20171217154342.15469-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:rYb6yPbWeoWUAnGxV4QVXvA9nfm/A/XJC8yWyAQqtks0n8sDnnT LrpRUCqOHMsumFQY7mzHLUNUBpKMpJLg8HtTOzAkgFPDryjK/AGM4axlWpidlW/77jsrksm Kq12Fo8K/a4Fpd1GzsgiDgdFiawAFptAZU4n6DplqYvDt70ZvEhMYFDPMnjgakUE8GolMHD jy1k1UnZiDqvPtFtumCHw== X-UI-Out-Filterresults: notjunk:1; V01:K0:fuO/RT9E1Vw=:Er0DrhMUIfZwT1EYbq24zh 2WnSO1qj5Dy+v4RRF2esSAKm0Dx7/woPqehEe6quAyYz4uUe0/Iwqf+YjWUTKJkRoumQ/TNOv FOX9zizHGNUbIDJ7n9DmAAxh87V6FnApS327UET0A6uOht88OuAPqjfSh4IK0OMqQ0AJvvoHc hxU0mLjb/xBz2b9f3OG4z5ZIM4wTIYa3WUUGWXS3PJSXYmx8aCuF9UlfQqTUOXbEEP2AovIzR JDb5+J0DpCZkHt334Ha5e4v0bd88tXw2FFF/2VzKp/SDx3R01ndfKhmf6Hd2uJTuhyV3VsYOo rQ5iGxq7sv80AIIViJNv/PUUyCcws1KYZ9Bm+CX37B02vkzK+zXlhEqGIOSit21gpX9UKROzA Ld2BACC6alr5rNtGJbdSK69fsvk/JGASVIu7mfkzPs2T4+SieiokGV3mU+m+xaros6Z8FMke8 IA3pAn9NoWyEbXf9A04KY9dO5okKpti1WFJplqSmt4HUvgmW7U2V9AgBhkAFLy+1tikJSmPGM 42cg1OrXA5P0Dh75EAZ9at6ziuGW7joFYm9IzBOyjJcbC8kQttJSn/umOn2PK8fPpftf0teqp ulmwKlKshRNAZE016yDHTNBFVWeQUJJIZdchRSvaASHvZEv6qOMD08oHVI9JlOB7nuK9SkES1 tv1O/HC1+EQ6R3jy7TqAz63ui7ruFZuMlKDu80wAYKh8FqhfJXL84bFEUJntBzEXmRMPqILge U7nK9rMqpF8maDK7c4oHxQIeNOM1IvlyDCXJ5G7amOzRwJJjXYemegH2c72//xgTJAviDtHw8 16XhF9YqMi3E9VeT8CYxndJAIE04vYFx1+HmTadSEQW0cPy+mI= Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 03/16] efi_selftest: do not try to close device path 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" CloseProtocol cannot be called without agent handle. There is no need to close the device path protocol if it has been opened without agent handle. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_selftest/efi_selftest_devicepath.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_devicepath.c b/lib/efi_selftest/efi_selftest_devicepath.c index 1ab54ebb37..d9a6697892 100644 --- a/lib/efi_selftest/efi_selftest_devicepath.c +++ b/lib/efi_selftest/efi_selftest_devicepath.c @@ -299,10 +299,10 @@ static int execute(void) efi_st_error("FreePool failed\n"); return EFI_ST_FAILURE; } - ret = boottime->close_protocol(handles[i], &guid_device_path, - NULL, NULL); - if (ret != EFI_SUCCESS) - efi_st_todo("Cannot close device path protocol.\n"); + /* + * CloseProtocol cannot be called without agent handle. + * There is no need to close the device path protocol. + */ } ret = boottime->free_pool(handles); if (ret != EFI_SUCCESS) { From patchwork Sun Dec 17 15:43:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849638 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 3z07pt43ydz9sR8 for ; Mon, 18 Dec 2017 02:47:50 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 12649C21FEC; Sun, 17 Dec 2017 15:46:12 +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.0 required=5.0 tests=FREEMAIL_FROM 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 7CEB1C21FC5; Sun, 17 Dec 2017 15:45:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 802A4C21F29; Sun, 17 Dec 2017 15:45:15 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 50FEAC21FBF for ; Sun, 17 Dec 2017 15:45:11 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MLelb-1eQK8r09it-000pdU; Sun, 17 Dec 2017 16:45:10 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:30 +0100 Message-Id: <20171217154342.15469-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:bR+bh7xwjMgvXYhEjU9VLv7/EpB2IDrv2bNFftI+n+g44FEtI8U 3loAu7dojlgfIxaE4FsxXy0lMGhOyjClfI66q1IFaUttTPRqC1LD6REOqnDH9G66XDS0p7p hhzD3SZqqiaR6gKJp7xZZMPO9oHhsw/lT7ZRwz7bAQtd5OFOJKKhDegmrzUVcnJR4Xsk0j7 GxsINOEycOvn7l9KifVvA== X-UI-Out-Filterresults: notjunk:1; V01:K0:N5MQRtQOT0M=:4LRGezSbvBph/w82Bln+8+ /6dvPicGq1D+K8RWvYG6GwU9eutEnnTmnOICQHoX95qFQauwXnXMbYkDJZKVcA5VQEnj0WFYT N1DRC7rAJg03omtp/DonvS3GaAPfTzOrsr2BBCjMzS0ywQz4gW+79crvPOrVpzGsdvVIKr/wr 6X6Taq/37gpP7rdRLmf0jM/DYJ8au2gGt5Yz+EtHqQNYogYmJWajAh1FfWOGXHFNK3iWC/j9n OgxnCIheX2iu2+kl3gE1AJhCpTVnt7V27P6XRggjh02vRiXKpE4mRfkZWvrpyo/KKs8eckoBf njs0oBAwxu+xb3xMVb6zoAN/W820woIFusamrXiISA09k17vkphxq7h3+b7nv3u2Am/FHCKat eXEOVyLDS2iVHZ21SQmVX6Er2cONlVImBLZUSrtjg0O43MPZ1stP4Rq4Q/N683RAXem1ftOjK S1JY9bzKh4Z2LVzAG1IpukOJltERCM0kraNK7qpmf/RGp0gjlhDhAImedFf6OAM+l/ace7uEl pXXljWdzqrV2NY9nIk7Jjz8vq/ckV2gpguZQwwlx3xRIOiSXm+DE/q1sszuFOYxqFHvNeedfe U5AoWL7o/K0SgMAWRYcHkZaCuGzQQWT879C5tmpjcylYErzDMZ6kP1KZI08K9OrWChbf50rmx m8i+OUMjlqNY8AReU3UaOjvd4UySV3znNR0QcUxohscbdM9Q/Kr4P3szli3f18JxpSbvEzIR5 D2+WC4eq+JHJ7ybzyt6lYvUsV884hb60vbzeI5JOvgBTyyhejeIHnpusymxxlc/+HMO89m99S enmZyUVu4dXITPncl4s3X+Xw5p5tg== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 04/16] efi_loader: list of open protocol infos 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a list of open protocol infos to each protocol of a handle. Provide helper functions to access the list items. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- include/efi_loader.h | 15 ++++++++++++++- lib/efi_loader/efi_boottime.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 6185055e78..637e6e166d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -96,15 +96,28 @@ extern const efi_guid_t efi_file_info_guid; extern unsigned int __efi_runtime_start, __efi_runtime_stop; extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; +/* + * When a protocol is opened a open protocol info entry is created. + * These are maintained in a list. + */ +struct efi_open_protocol_info_item { + /* Link to the list of open protocol info entries of a protocol */ + struct list_head link; + struct efi_open_protocol_info_entry info; +}; + /* * 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 interface */ + * protocol GUID to the respective protocol interface + */ struct efi_handler { /* Link to the list of protocols of a handle */ struct list_head link; const efi_guid_t *guid; void *protocol_interface; + /* Link to the list of open protocol info items */ + struct list_head open_infos; }; /* diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 99eb36c306..f5ec2a8866 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -814,6 +814,40 @@ struct efi_object *efi_search_obj(const void *handle) return NULL; } +/* + * Create open protocol info entry and add it to a protocol. + * + * @handler handler of a protocol + * @return open protocol info entry + */ +static struct efi_open_protocol_info_entry *efi_create_open_info( + struct efi_handler *handler) +{ + struct efi_open_protocol_info_item *item; + + item = calloc(1, sizeof(struct efi_open_protocol_info_item)); + if (!item) + return NULL; + /* Append the item to the open protocol info list. */ + list_add_tail(&item->link, &handler->open_infos); + + return &item->info; +} + +/* + * Remove an open protocol info entry from a protocol. + * + * @handler handler of a protocol + * @return status code + */ +static efi_status_t efi_delete_open_info( + struct efi_open_protocol_info_item *item) +{ + list_del(&item->link); + free(item); + return EFI_SUCCESS; +} + /* * Install new protocol on a handle. * @@ -840,6 +874,7 @@ efi_status_t efi_add_protocol(const void *handle, const efi_guid_t *protocol, return EFI_OUT_OF_RESOURCES; handler->guid = protocol; handler->protocol_interface = protocol_interface; + INIT_LIST_HEAD(&handler->open_infos); list_add_tail(&handler->link, &efiobj->protocols); return EFI_SUCCESS; } From patchwork Sun Dec 17 15:43:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849647 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 3z07vl4khBz9sR8 for ; Mon, 18 Dec 2017 02:52:03 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4A5F7C21F21; Sun, 17 Dec 2017 15:46:47 +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.0 required=5.0 tests=FREEMAIL_FROM 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 3BFF6C21FEB; Sun, 17 Dec 2017 15:45:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3B50DC21FC4; Sun, 17 Dec 2017 15:45:15 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 9CCE4C21FD4 for ; Sun, 17 Dec 2017 15:45:11 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MEFqW-1eFcmU1KjA-00FSlD; Sun, 17 Dec 2017 16:45:10 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:31 +0100 Message-Id: <20171217154342.15469-6-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:BSNIX0bk5MD7fuRe+HzjWldpPPJ14cZJoecT/6K42Q3746+M+4D xOc0AE0Pk4yJ3XXIa9Y2W1cW7AK5RfjEhriUKqM/f0Jg2ReKGJqPcSGSBlKcFCN1+Z+apbH wAOkk/LhQBfKhIJrX/CZMep3cXaIE+RJBOymktggRQoGWNwd3+NROYhc1ef90SkbwCIzdcR w+JMLB2AdZ36SUshi1Y0Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:qTEmM55GWzs=:L0XULHYb1j8dQnEPGZo5Xq /wlcNLBkJmBCSN0UySUFNJVcGQK1mn/3Vw6qwnqlY9oEkP1t95RZ8ModASNsHai7Fson+SNp/ QGDuRtcLPjPpA+81HwgSDprCC/k063rffceB6f6x1kD1rtAh+r2q5mGSNFDoAzX0VvDtnCbTC xKFJhCKTc85QLQgLyPIEkgVdtfF7sGxFhUGE3Sjeysjbs5GgxMNlCBrKNi92ZPVduoXcHTQuQ SpNfDmM8oLoWj7CGCzNLTMHrgpGZSX9hYYNxyHu1n4v1l1qX1yVQijOxE8f3A7qcp6P24iTHi 7LaakZwcQpeGAO9DCSlOMZ6PNvMlNFA4eWoRTS0z1HEczmHY2iaG1+QfhmBgaxi8fy2bFWlYz FAPD9rMcIlElvOt6hjS/Xcu9w/aoLv01UtD3noimoKzdjjd7wkFJ8HogvYr6LmQjr1R0GtCYH 5SWCJAqVv3NwLSVp08gpxG78OlHkZVyYY5nAID7Bs/Ktsz5zzM6jyX4BKtuI0DpyUZssnSYeN uPImvW8ZX7sG3yN/tTmaLMYqxju8ynyNi2ngo/PqBaQTEWhB6HrfSpd9xxrIyEMFTGI15RkZT 14mccvFR9VHGuw9pJB2maco5oJrFhPJt8H9WSy06rQjl8sRI5w54sWkgDdXKV0KTEy+xNhRSN WJ1ubTRpA6ylIOj3+N+vxppzmxtXd3GMleCTSE1QDO8bxc4Nd0G1bmwmu/ZziwY/z68N4l/ww /B9dYfu9Jj+gZET70RbR9iVhtUcg3U+0RxvmMqZa4ZEs6yQhbuQ8p6p6Vta2/7PF6z9OluOBs JotUoVg2PIAmQBC33AX+op9ZzD5bQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 05/16] efi_loader: open_info in OpenProtocol 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" efi_open_protocol has to keep track of opened protocols. OpenProtocol enters the agent and controller handle information into this list. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 107 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index f5ec2a8866..bb80c6066a 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2100,6 +2100,101 @@ static void EFIAPI efi_set_mem(void *buffer, size_t size, uint8_t value) EFI_EXIT(EFI_SUCCESS); } +/* + * Open protocol interface on a handle. + * + * @handler handler of a protocol + * @protocol_interface interface implementing the protocol + * @agent_handle handle of the driver + * @controller_handle handle of the controller + * @attributes attributes indicating how to open the protocol + * @return status code + */ +static efi_status_t efi_protocol_open( + struct efi_handler *handler, + void **protocol_interface, void *agent_handle, + void *controller_handle, uint32_t attributes) +{ + struct efi_open_protocol_info_item *item; + struct efi_open_protocol_info_entry *match = NULL; + bool opened_by_driver = false; + bool opened_exclusive = false; + + /* If there is no agent, only return the interface */ + if (!agent_handle) + goto out; + + /* For TEST_PROTOCOL ignore interface attribute */ + if (attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) + *protocol_interface = NULL; + + /* + * Check if the protocol is already opened by a driver with the same + * attributes or opened exclusively + */ + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.agent_handle == agent_handle) { + if ((attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) && + (item->info.attributes == attributes)) + return EFI_ALREADY_STARTED; + } + if (item->info.attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) + opened_exclusive = true; + } + + /* Only one controller can open the protocol exclusively */ + if (opened_exclusive && attributes & + (EFI_OPEN_PROTOCOL_EXCLUSIVE | EFI_OPEN_PROTOCOL_BY_DRIVER)) + return EFI_ACCESS_DENIED; + + /* Prepare exclusive opening */ + if (attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) { + /* Try to disconnect controllers */ + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.attributes == + EFI_OPEN_PROTOCOL_BY_DRIVER) + EFI_CALL(efi_disconnect_controller( + item->info.controller_handle, + item->info.agent_handle, + NULL)); + } + opened_by_driver = false; + /* Check if all controllers are disconnected */ + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) + opened_by_driver = true; + } + /* Only one controller can be conncected */ + if (opened_by_driver) + return EFI_ACCESS_DENIED; + } + + /* Find existing entry */ + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.agent_handle == agent_handle && + item->info.controller_handle == controller_handle) + match = &item->info; + } + /* None found, create one */ + if (!match) { + match = efi_create_open_info(handler); + if (!match) + return EFI_OUT_OF_RESOURCES; + } + + match->agent_handle = agent_handle; + match->controller_handle = controller_handle; + match->attributes = attributes; + match->open_count++; + +out: + /* For TEST_PROTOCOL ignore interface attribute. */ + if (attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) + *protocol_interface = handler->protocol_interface; + + return EFI_SUCCESS; +} + /* * Open protocol interface on a handle. * @@ -2141,12 +2236,16 @@ static efi_status_t EFIAPI efi_open_protocol( case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER: if (controller_handle == handle) goto out; + /* fall-through */ case EFI_OPEN_PROTOCOL_BY_DRIVER: case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE: - if (controller_handle == NULL) + /* Check that the controller handle is valid */ + if (!efi_search_obj(controller_handle)) goto out; + /* fall-through */ case EFI_OPEN_PROTOCOL_EXCLUSIVE: - if (agent_handle == NULL) + /* Check that the agent handle is valid */ + if (!efi_search_obj(agent_handle)) goto out; break; default: @@ -2157,8 +2256,8 @@ static efi_status_t EFIAPI efi_open_protocol( if (r != EFI_SUCCESS) goto out; - if (attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) - *protocol_interface = handler->protocol_interface; + r = efi_protocol_open(handler, protocol_interface, agent_handle, + controller_handle, attributes); out: return EFI_EXIT(r); } From patchwork Sun Dec 17 15:43:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849641 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 3z07s83RQMz9sR8 for ; Mon, 18 Dec 2017 02:49:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1BC87C21F3E; Sun, 17 Dec 2017 15:46:28 +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.0 required=5.0 tests=FREEMAIL_FROM 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 4DC9EC21F99; Sun, 17 Dec 2017 15:45:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C387FC21F9B; Sun, 17 Dec 2017 15:45:16 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id CF794C21FE6 for ; Sun, 17 Dec 2017 15:45:11 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MYfJW-1eUXIa2Xre-00VTRd; Sun, 17 Dec 2017 16:45:10 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:32 +0100 Message-Id: <20171217154342.15469-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:DNEC8RYeVbuYVj9yHgyiJ2n1w05gc9IrO1vGlP0s0BVZJHnv+2l KwbYRe0s6OcK4GTtmlq+A92Ahsv6md4brxgZHrQ2LrLKhzAojWG9/lwp5zS2hVYwLb1DwJ3 q/wDoYrQcAAboYRg4IroMP2zTGK1bzveGgQjCsMfwR7RRo6hRjYYKYG17l0uLgs3GQU5hfZ TmhZKddeLXJFn/IhTluzA== X-UI-Out-Filterresults: notjunk:1; V01:K0:qNmx0l0OUpo=:mE+3rRR16/z0sB6T5mrzaB cf4fY3607Nb6KP0y5ZJ75UpS+81fnn3lnlM+GtR6B4WKP8gsAGGKFwaebszrUM+1KGgcnpUHl /lL06aC8CEWZSwlVLGP88rCnyRnFwZKYnz/2ISJQnIGZoRlh8Pm/wCJCwz3SpcO0T82lKsk4E RTMHQ/Z9THcggU5YoMR3CA/EQYqBB5xY11csK1AOGKMLUBqttwAihJ+w9erXfSpJFacAaRXIs 4dVX45NXG5yoz+BZRPWISHuwujmtnkYInNOLmhBaKIKq0ALzr3O0mmG6ky0w6Kdq9latLKHFG t4e0qTYCHZb8wkqo6rECmilNk8yHKYwF8LPW6C4cPno8j0mMqpAbfxwpffwA6/DzdkGvI823W 1UDkiXRQylD+W+ScVhOfKgYTLVcSqjb80/jPSIIXyhcBwHbem/7M9AmlPSfgYkKJLrp8UW2vX E+Yiarx3zkhFDc6z+qZ8ivaxZZFP8Xy60SILPcE/8BFs3Dirjqz6XBb0QSRhLt8U3MhanhLr5 w+VrDwRvzZu66BTZiMOLkzp3vyDFc7/pFMmlMfiFNGvgbZzLbAkOqPvuirXxoZMuElyt+q2U0 ACU9H9Kp/k7pkSImobCw2UgGmbCgpiHM+GOpHgP0VXdDLq80rCpQrjRtym5egY+f6J5YnlDMb 80SQ//kW8P/7zBjFgcMTqCxcKTN3/sll4cvkvN4eGAnLMGAVojh3Rx0pPqNZFY8Kmr3klBKFt gZ8D5hRzjKmPicq8CFoml2KQDbk66WZqIU4P2d9z13SHKeoWznL7GD6pcf9d/1cWD6dIArB9X JfsWU/WVcn7Axz+WCcbyWUmEDeOJA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 06/16] efi_loader: open_info in CloseProtocol 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" efi_open_protocol and efi_close_protocol have to keep track of opened protocols. Check if the protocol was opened for the same agent and controller. Remove all open protocol information for this pair. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index bb80c6066a..a527e33141 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1675,9 +1675,33 @@ static efi_status_t EFIAPI efi_close_protocol(void *handle, void *agent_handle, void *controller_handle) { + struct efi_handler *handler; + struct efi_open_protocol_info_item *item; + struct efi_open_protocol_info_item *pos; + efi_status_t r; + EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, agent_handle, controller_handle); - return EFI_EXIT(EFI_NOT_FOUND); + + if (!agent_handle) { + r = EFI_INVALID_PARAMETER; + goto out; + } + r = efi_search_protocol(handle, protocol, &handler); + if (r != EFI_SUCCESS) + goto out; + + r = EFI_NOT_FOUND; + list_for_each_entry_safe(item, pos, &handler->open_infos, link) { + if (item->info.agent_handle == agent_handle && + item->info.controller_handle == controller_handle) { + efi_delete_open_info(item); + r = EFI_SUCCESS; + break; + } + } +out: + return EFI_EXIT(r); } /* From patchwork Sun Dec 17 15:43:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849644 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 3z07tB4By1z9sR8 for ; Mon, 18 Dec 2017 02:50:42 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 25777C21F6F; Sun, 17 Dec 2017 15:48:44 +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.0 required=5.0 tests=FREEMAIL_FROM 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 546BFC22002; Sun, 17 Dec 2017 15:46:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E6F15C21F78; Sun, 17 Dec 2017 15:45:16 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 26D0DC21FCE for ; Sun, 17 Dec 2017 15:45:12 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LjquD-1f28nn3jKL-00bp94; Sun, 17 Dec 2017 16:45:11 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:33 +0100 Message-Id: <20171217154342.15469-8-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:7YthxgcVF3eBn/O4iDkvUYxaX5NCBum2G30CU+U+SN+lEvaDiJo 0UvLYtgtwFz03WnWq7d4v7DoTozBUIQY9C0RqunHepvej+pLiVoIQAbkjosv4AuRFvRdGH3 HmEQpOn8n0dlUPvu89yMRZb9IxnNaqJM9GZXfKaJdtmKn/rlOJ1Lb8ipl08NZq6J7GKwREx 0whHtTFTUU76Vtxd+cwXw== X-UI-Out-Filterresults: notjunk:1; V01:K0:ViJrm/lk8ss=:QUjLpoHa6qzTEy/oS3aiSS zIZsoxCYP7YCoRFnGYBVUT3eTyEEwpWlTWe7Lcaq5ioMCiK29RngfOkf9m0hMXvTfnDTelbGj dUswXhKf1KOzhktTnXWTtGMu2VEp/V2AQDTaBhUfNpIAd+NBKNw8pnZp6J33oeW8NNlF0oQLX s9Hxs3mvSABRY35V9ufc51jMEcMOs+l5KrkWtbAccjSHtbSD8IfqzegnI2bAldCwZrcm9BwXf /UvmmMYkeGSqmTpCMN60ykzk2DFvFYjAR2UwsSI2ZemWxTFzF7MGliP7RCu9JG51zzzBh3avi WdIg51ePs+dBHAOGC+QHYtuW5GHKu156vnIh5+TCS7wRd4rkKJEkmddfY21Hiqmg2U0cmjXGR r01k/ZaH5WLEwjYredaS3etAC6d8svoe7tzip0BNAfA8kPv1vzg/hsTufrenCnej2Up6aQHRr g/mc45+oNzNUEF0wsNvcymdjFLjiyK3AY0y1F3jvIP8Ip4taPwr6ITCKDuJWEF28bbhj9bu/Z WM4LLjxswjhK/2miSzL9QAKCnkTFYSvNWdBU/+ze/vHdCa/yuZkaof+57W/gwbZKVp95hG8iY vXnOdnNB4Ieq8GoMo9gxXce1tCplwt8h6fGAk7jbEhIWRdbR2FY9KJR9uUc9PLFGSRRUPvY6Y HwE3u6ydzc7Y+47xe01asWsRhmKXG+2eGgscR7PJ0JKTZMXOJNFoVnhjwI7+DhEGhk4u2Z9g1 ouSTOul0voJaA9Tu6+ZDf9Eaa9iDOXOo/C9oTXNRaebZD2+OJjnwdAPybOG9stECigNR1krGt +DLZExHQdnBGpkxm3ZGVz/RhQVAbA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 07/16] efi_loader: implement OpenProtocolInformation 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" efi_open_protocol_information provides the agent and controller handles as well as the attributes and open count of an protocol on a handle. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index a527e33141..44c9da0a7c 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1722,9 +1722,48 @@ static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle, struct efi_open_protocol_info_entry **entry_buffer, efi_uintn_t *entry_count) { + unsigned long buffer_size; + unsigned long count; + struct efi_handler *handler; + struct efi_open_protocol_info_item *item; + efi_status_t r; + EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, entry_buffer, entry_count); - return EFI_EXIT(EFI_NOT_FOUND); + + /* Check parameters */ + if (!entry_buffer) { + r = EFI_INVALID_PARAMETER; + goto out; + } + r = efi_search_protocol(handle, protocol, &handler); + if (r != EFI_SUCCESS) + goto out; + + /* Count entries */ + count = 0; + list_for_each_entry(item, &handler->open_infos, link) { + ++count; + } + *entry_count = count; + *entry_buffer = NULL; + if (!count) { + r = EFI_SUCCESS; + goto out; + } + + /* Copy entries */ + buffer_size = count * sizeof(struct efi_open_protocol_info_entry); + r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size, + (void **)entry_buffer); + if (r != EFI_SUCCESS) + goto out; + list_for_each_entry_reverse(item, &handler->open_infos, link) { + if (item->info.open_count) + (*entry_buffer)[--count] = item->info; + } +out: + return EFI_EXIT(r); } /* From patchwork Sun Dec 17 15:43:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849648 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 3z07vz5lQ6z9sR8 for ; Mon, 18 Dec 2017 02:52:15 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7E939C21FC5; Sun, 17 Dec 2017 15:50:20 +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.0 required=5.0 tests=FREEMAIL_FROM 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 41A54C2201B; Sun, 17 Dec 2017 15:46:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9B75C21FF6; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 8FE2FC21FEC for ; Sun, 17 Dec 2017 15:45:12 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MBnPX-1eGSmm0flX-00AlGi; Sun, 17 Dec 2017 16:45:11 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:34 +0100 Message-Id: <20171217154342.15469-9-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:Rne0VyOMuxEjJwY0qpPr2HIF18f1rfOZnyg/HVUpHotaWs+w+SN mvl0WX8efpSYdGlKNZx5SsOcly5xSF2zlqYwwRFcJoWqggO95n7C4nwIgJdYzeRCIDUNpwd P6qxmiqoSCYmnn1py2mP8qM5BBbGDBQrXrDlbOSRFmUWIA3CLc/fmVcDJe6cAQCX2DHOS5o fHX6oKF8LII409E8PGkpA== X-UI-Out-Filterresults: notjunk:1; V01:K0:zzm8i4pB0mc=:867Ydh9uIohYouqYrAZb1e zctCaB5yLgQoStqUx9Jbtb6strtMgDOq5SaUuqp5EUvNQ4/15br6w2qqY2LF30JXUe7nrNfv/ olwG4rwq2XlYu48ly5KVF2xEddUOmh4yqC2DEDJ5zitIzHaFOOOa3B3Qk0Dfae6sxhrB2Ksru mKQIBFb7X5WcrhilJouM7jCkCUgunuwObg1JCc6WapROSsvzYSigTqT3XyAoZmWg34xqoOXq0 GC/Tf2Ewg8GlCIlkgV+1Zk4F8/rOEvEjFjCvYfDmSHxqgN9Lpv1O3Uumt94s+cwmFqctVDx5K vyo93wC/gLPGZJu4VPwJhceqSfqTRyk26X2Ke3pvUQ+kXauD1qpEtu5IkeiKhMJCQtKmbfik/ kVcTWiw7t3/hB7tv+O9L/42/T4DgwyPCQ3LsLxRvRMDSda0l7exz9bysXbr2HebNW6wcaJnN1 HX1+1Qea+I7EilyHyGgI2Nk12TnUzEtzVvqGrtzYYj34ZdnPUVAvDOxnhmqKldpkQVxY2W429 cS3Sd9ZZSP8BfaSgFyt04/4BiKRW3YtM/ZstgDnhg+jq70Ufh3arlz9THhuu9qN1QnWxdZUOw XpSzLJO+R9tbd5Vf/zwvdJSWguv509gYn0HKutj1N2dQCvZZaA8rAGV5p5GNG8tT9QOsAyVF/ uU7R0/asp6eFDRlwt4+xq7hGZsFZtbdwnLZtXJCVym3FVnSsF4nXmDZRCJIGpvj3HvTE977UM sn7YXLxBJttOi/FPSHkIafiGIbew+v2nUeSNFiEz+Q79e5N2pUN5wlGs754PQwg5LS7Fpg1P1 Xu07w2QyNyrv9YmdWesGklkU5O6VQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 08/16] efi_loader: debug output installed device path 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When a device path protocol is installed write the device path to the console in debug mode. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 44c9da0a7c..b5d6808bf7 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -876,6 +876,13 @@ efi_status_t efi_add_protocol(const void *handle, const efi_guid_t *protocol, handler->protocol_interface = protocol_interface; INIT_LIST_HEAD(&handler->open_infos); list_add_tail(&handler->link, &efiobj->protocols); +#if _DEBUG == 1 + if (!guidcmp(&efi_guid_device_path, protocol)) { + debug("%sEFI installed device path: %ls\n", __efi_nesting(), + efi_dp_str((struct efi_device_path *) + protocol_interface)); + } +#endif return EFI_SUCCESS; } From patchwork Sun Dec 17 15:43:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849643 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 3z07t31gFwz9sR8 for ; Mon, 18 Dec 2017 02:50:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id AC5BCC21F38; Sun, 17 Dec 2017 15:49:58 +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.0 required=5.0 tests=FREEMAIL_FROM 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 7894CC22013; Sun, 17 Dec 2017 15:46:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C2C85C2200B; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id C8DC8C21FED for ; Sun, 17 Dec 2017 15:45:12 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M5MIN-1fDkTI1oPH-00zYWW; Sun, 17 Dec 2017 16:45:11 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:35 +0100 Message-Id: <20171217154342.15469-10-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:1Apon/vi5n7+xrsv2gENSLsDBaeCOlUOtdCLyGyy1zLtDdqa1qf lT5Pc2/PBjx0QfezgvzhNj7w+9gZhidhIEb2LYW+YliGI4nuRaOHsdFIPdXD7amQ4mJD5R/ e8FaXebkD7NaDN0zcgzZZE+T6oBJnU/nNP9Rpe8Kda0BLXJCswd2Ia04mjZvQkITNMU+A9D HsnQ6oRMVnjiqwRiA+Aew== X-UI-Out-Filterresults: notjunk:1; V01:K0:2c3aAyAbiKU=:yS6qwKFLRf6hHWMsM4qDAi 5JSJ1buXH+olIruC3htz39re+n7Z+0Hl5w5tsMwALiI1/qubnSKa+II0nYjWGyRm7Ljb+8K45 TJ7fev5It4yFFYYrRC+tp5LuGr9WWOp4kShpf8FMTyvIyzlLxC9Qc1mBSxWjQF0xvSl4cibLF kMwl7XZlgeyF0O/lIVPOXhBGXJUw9npQMq4Czfou/GM/qiwKxmpnrrNVlS5oQBc2yrTKBQ8xc Vi0ZfDlvBNPsF5rDnyHtidvnj98oFFt3niesBToIkt1F7xIAoJUJPxU3xKlafp4MRTLCTSHLY TTA5AdkDQr+whRIs09ei7eR/8q5DbrnxdMft4ehO4N7xuf28kZdMuzNcoAjdttauvS63XVbza 0VE5qViO1A0vfJZTvIFiplUi4eOQNyvUP0SMxEnUUatTjgWPjAJS3J/R9RfsaBrktyE613SCR IoSmHDTcrMm+URCrHguvOah6LQvjqszzcJJpx48FNIqvc79hpFUtXncmWe6De8+y19AO+nzg6 1wDvl6A8D0SBok3GlAL6l16p+BVeKck23liWD31MAhyu1cL4meRE5LW7jd93pp+WB9vKity1n QLhIKaoGB3U9FmNkl8M6tkFKDmR44dw1jVXeBWgQhjv670ANCZQOGijVWjj8aniNBgK0GhEUC +wwKhsxUY1YUlHF8fts64lEjiKJ53Umc//CPUaF/5pyXtIWL7WAmmCXRPE4dugo/dJejmpMdT LLGAfw+afQoqi/KvQ/v9EagTY6OBuCcy1JF9UQJzkWkINHTtVivcemBc8ok2w8u8m5CEGOOrS XNk+uh3awA22m9CR2VL6UDYttplKg== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 09/16] efi_loader: implement ConnectController 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Implement the ConnectController boot service. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- include/efi_api.h | 22 ++++++ include/efi_loader.h | 2 + lib/efi_loader/efi_boottime.c | 178 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 178 insertions(+), 24 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 46963f2891..81e580dbbc 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -805,4 +805,26 @@ struct efi_file_info { s16 file_name[0]; }; +#define EFI_DRIVER_BINDING_PROTOCOL_GUID \ + EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\ + 0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71) +struct efi_driver_binding_protocol { + efi_status_t (EFIAPI * supported)( + struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + struct efi_device_path *remaining_device_path); + efi_status_t (EFIAPI * start)( + struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + struct efi_device_path *remaining_device_path); + efi_status_t (EFIAPI * stop)( + struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + efi_uintn_t number_of_children, + efi_handle_t *child_handle_buffer); + u32 version; + efi_handle_t image_handle; + efi_handle_t driver_binding_handle; +}; + #endif diff --git a/include/efi_loader.h b/include/efi_loader.h index 637e6e166d..9e1ae8866b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -88,6 +88,8 @@ uint16_t *efi_dp_str(struct efi_device_path *dp); extern const efi_guid_t efi_global_variable_guid; extern const efi_guid_t efi_guid_console_control; extern const efi_guid_t efi_guid_device_path; +/* GUID of the EFI_DRIVER_BINDING_PROTOCOL */ +extern const efi_guid_t efi_guid_driver_binding_protocol; extern const efi_guid_t efi_guid_loaded_image; extern const efi_guid_t efi_guid_device_path_to_text_protocol; extern const efi_guid_t efi_simple_file_system_protocol_guid; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index b5d6808bf7..6cc0659eb9 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -56,6 +56,9 @@ static volatile void *efi_gd, *app_gd; static int entry_count; static int nesting_level; +/* GUID of the EFI_DRIVER_BINDING_PROTOCOL */ +const efi_guid_t efi_guid_driver_binding_protocol = + EFI_DRIVER_BINDING_PROTOCOL_GUID; /* Called on every callback entry */ int __efi_entry_check(void) @@ -1619,30 +1622,6 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, return EFI_EXIT(efi_set_watchdog(timeout)); } -/* - * Connect a controller to a driver. - * - * This function implements the ConnectController service. - * See the Unified Extensible Firmware Interface (UEFI) specification - * for details. - * - * @controller_handle handle of the controller - * @driver_image_handle handle of the driver - * @remain_device_path device path of a child controller - * @recursive true to connect all child controllers - * @return status code - */ -static efi_status_t EFIAPI efi_connect_controller( - efi_handle_t controller_handle, - efi_handle_t *driver_image_handle, - struct efi_device_path *remain_device_path, - bool recursive) -{ - EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle, - remain_device_path, recursive); - return EFI_EXIT(EFI_NOT_FOUND); -} - /* * Disconnect a controller from a driver. * @@ -2352,6 +2331,157 @@ static efi_status_t EFIAPI efi_handle_protocol(void *handle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); } +static efi_status_t efi_bind_controller( + efi_handle_t controller_handle, + efi_handle_t driver_image_handle, + struct efi_device_path *remain_device_path) +{ + struct efi_driver_binding_protocol *binding_protocol; + efi_status_t r; + + r = EFI_CALL(efi_open_protocol(driver_image_handle, + &efi_guid_driver_binding_protocol, + (void **)&binding_protocol, + driver_image_handle, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL)); + if (r != EFI_SUCCESS) + return r; + r = EFI_CALL(binding_protocol->supported(binding_protocol, + controller_handle, + remain_device_path)); + if (r == EFI_SUCCESS) + r = EFI_CALL(binding_protocol->start(binding_protocol, + controller_handle, + remain_device_path)); + EFI_CALL(efi_close_protocol(driver_image_handle, + &efi_guid_driver_binding_protocol, + driver_image_handle, NULL)); + return r; +} + +static efi_status_t efi_connect_single_controller( + efi_handle_t controller_handle, + efi_handle_t *driver_image_handle, + struct efi_device_path *remain_device_path) +{ + efi_handle_t *buffer; + size_t count; + size_t i; + efi_status_t r; + size_t connected = 0; + + /* Get buffer with all handles with driver binding protocol */ + r = EFI_CALL(efi_locate_handle_buffer(BY_PROTOCOL, + &efi_guid_driver_binding_protocol, + NULL, &count, &buffer)); + if (r != EFI_SUCCESS) + return r; + + /* Context Override */ + if (driver_image_handle) { + for (; *driver_image_handle; ++driver_image_handle) { + for (i = 0; i < count; ++i) { + if (buffer[i] == *driver_image_handle) { + buffer[i] = NULL; + r = efi_bind_controller( + controller_handle, + *driver_image_handle, + remain_device_path); + if (r == EFI_SUCCESS) + ++connected; + } + } + } + } + + /* + * TODO: Some overrides are not yet implemented: + * - Platform Driver Override + * - Driver Family Override Search + * - Bus Specific Driver Override + */ + + /* Driver Binding Search */ + for (i = 0; i < count; ++i) { + if (buffer[i]) { + r = efi_bind_controller(controller_handle, + buffer[i], + remain_device_path); + if (r == EFI_SUCCESS) + ++connected; + } + } + + efi_free_pool(buffer); + if (!connected) + return EFI_NOT_FOUND; + return EFI_SUCCESS; +} + +/* + * Connect a controller to a driver. + * + * This function implements the ConnectController service. + * See the Unified Extensible Firmware Interface (UEFI) specification + * for details. + * + * @controller_handle handle of the controller + * @driver_image_handle handle of the driver + * @remain_device_path device path of a child controller + * @recursive true to connect all child controllers + * @return status code + */ +static efi_status_t EFIAPI efi_connect_controller( + efi_handle_t controller_handle, + efi_handle_t *driver_image_handle, + struct efi_device_path *remain_device_path, + bool recursive) +{ + efi_status_t r; + efi_status_t ret = EFI_NOT_FOUND; + struct efi_object *efiobj; + + EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle, + remain_device_path, recursive); + + efiobj = efi_search_obj(controller_handle); + if (!efiobj) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + r = efi_connect_single_controller(controller_handle, + driver_image_handle, + remain_device_path); + if (r == EFI_SUCCESS) + ret = EFI_SUCCESS; + if (recursive) { + struct efi_handler *handler; + struct efi_open_protocol_info_item *item; + + list_for_each_entry(handler, &efiobj->protocols, link) { + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.attributes & + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) { + r = EFI_CALL(efi_connect_controller( + item->info.controller_handle, + driver_image_handle, + remain_device_path, + recursive)); + if (r == EFI_SUCCESS) + ret = EFI_SUCCESS; + } + } + } + } + /* Check for child controller specified by end node */ + if (ret != EFI_SUCCESS && remain_device_path && + remain_device_path->type == DEVICE_PATH_TYPE_END) + ret = EFI_SUCCESS; +out: + return EFI_EXIT(ret); +} + static const struct efi_boot_services efi_boot_services = { .hdr = { .headersize = sizeof(struct efi_table_hdr), From patchwork Sun Dec 17 15:43:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849639 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 3z07r55n4vz9sR8 for ; Mon, 18 Dec 2017 02:48:53 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6CC8EC21FCE; Sun, 17 Dec 2017 15:47:53 +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.0 required=5.0 tests=FREEMAIL_FROM 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 2F528C21FED; Sun, 17 Dec 2017 15:46:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8448BC21F3E; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id 07C34C21FE0 for ; Sun, 17 Dec 2017 15:45:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LufbI-1f8YsR2xvs-00zqBj; Sun, 17 Dec 2017 16:45:11 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:36 +0100 Message-Id: <20171217154342.15469-11-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:R5VBTWWr9s+hi/fWj/lrmAfx2UdyI+BXEvk0zecl2QDp+TxmNhX dlV5mQKW9jWVbBacqPjRrCE1SJWWK8J0qhLNJuVWnoM+8F25ZxNHbArOm1FZeGIeFCBDDxE ETmXKeU9l6ZYyX0e+QFF9SZF4aDb/NP2fbfk7GDBtonFtGsq627072c1sijC8KReNQY5w0j 2iiD4LwxvmPaWpBENRz4g== X-UI-Out-Filterresults: notjunk:1; V01:K0:hiznlx5fYlU=:vvTbRfUCxY58BYmtKS+++h P72TopEVOHelPX+9Tkzp0nlfGPb3jRZmhEtvNVhAhm1dFH3ISq7tvbI2FhL6qhVzTMSd1IhGw bY+BJIeXlaKtO6IYrj5WXaVADoYwMp3METzmhCpyKF8BM+9YU1EPxlmnfz3CyF5DRTfgHo2uS FVsHJ8WAeW/JFEdreQj/h1zlflWkzEmOb4mwbIBvzjDZc1+jFZdi6x1An+hiCtbGnGd5znldP hq+UvTcT4E239UNGcJejWVauGzL8aWbRAwYJSB6gztPbCq1PncAeUccwm2FkJU+7MhyqncJmn nV1IePxa1onkcc5B2/U6zldoGMpDl+zsAqCZ5dgpa5vLjxiHGq50gzNzIAxEUvJrmrHYEq8ve W7P1DWiT6L/n8GFrEHdFc33ZUAeO2h6lSJI3ki8B326FezXr/zkQHzdsc9puPPiWikdD2UnPS g2PRj3q25ioYfIZSxeKM8cPdsdkhU0vDreMxssRswHNvt6wOaRVPSqcQjbY51eRjQJlxNsRKP QzHzSR58pkO1lwr6HD66cac2qAh2w9QKSCBrPTdL1R8/fFnR+T6uaDaY3pbzr2QL0ZNYpcuVE y4XiGeYv92MNqwrGdMIRMJWCSFCzxdvuoMrYtV9GkGWLbQMmWRvBNhQstVaeqjiz0j14H//D8 NuCq9jalNYQ2fvpMNWSrgeWk8+pWCh/vjxjK08Xg2IqryU5d5GrtWmzMiOeyXKb6mEec6uHIp uSeUzmKbNtWda+1tMyixZCxt9dTQeRdtbp599JcrQ51ilHRovTZ9+42HzOzRxtYb9tXtfiLvJ bOQekfaFcj0K9dONZHHShJ+CjTaEQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 10/16] efi_loader: fix signature of efi_disconnect_controller 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Handles should be passed as efi_handle_t and not as void *. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- include/efi_api.h | 6 ++++-- lib/efi_loader/efi_boottime.c | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 81e580dbbc..7164492f83 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -125,8 +125,10 @@ struct efi_boot_services { efi_handle_t *driver_image_handle, struct efi_device_path *remaining_device_path, bool recursive); - efi_status_t (EFIAPI *disconnect_controller)(void *controller_handle, - void *driver_image_handle, void *child_handle); + efi_status_t (EFIAPI *disconnect_controller)( + efi_handle_t controller_handle, + efi_handle_t driver_image_handle, + efi_handle_t child_handle); #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 6cc0659eb9..3094b26e5d 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1634,9 +1634,10 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, * @child_handle handle of the child to destroy * @return status code */ -static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle, - void *driver_image_handle, - void *child_handle) +static efi_status_t EFIAPI efi_disconnect_controller( + efi_handle_t controller_handle, + efi_handle_t driver_image_handle, + efi_handle_t child_handle) { EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle, child_handle); From patchwork Sun Dec 17 15:43:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849649 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 3z07w56r0Gz9sR8 for ; Mon, 18 Dec 2017 02:52:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A81DEC21FE2; Sun, 17 Dec 2017 15:49:33 +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.0 required=5.0 tests=FREEMAIL_FROM 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 38526C2200C; Sun, 17 Dec 2017 15:46:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AC791C21EF1; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 7D961C21FD1 for ; Sun, 17 Dec 2017 15:45:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MfEsY-1efVeP46Yc-00Oqf7; Sun, 17 Dec 2017 16:45:12 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:37 +0100 Message-Id: <20171217154342.15469-12-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:9Wn9CZagjZi/nt+guN2JgfFmceli1SSTay95AYKnzdmf0RcnFIi 9dDxuFJMLZ/YYcZvNFFov+bq4mUXhu5mLEF10l2CEGi6/br/qqeXGL0ndMTdFSSQa5TztJq WTkj8i+lVKUjtnRBenCXkFhZpZ5neebMBr0iSc6xG2OwQXy8p79a0C58MaPxm1YJ86hapbT KRpaNW6yGR0XAkHvKkIdw== X-UI-Out-Filterresults: notjunk:1; V01:K0:6O92wgk//dA=:Fi7g/hubo2AWf8gCsQaPVh 4hvb+moBHotxXOrUmBVmtRMhkBv5IN3IiX5y2me5f8QlUNAL4h2Kv+k3icW8DwB7y5qc06ZAt gy5czjmDD+ZQrGKenrF/YH8CVhBiqDjXwrd+BjQkDL6yHzY2jEKz50oz+2FHxXsveu4NyZAQB BRK1++iC8sJL/ik/YF5GuYZQJOQhpljqhXJLyFc+U6YQiBSyGj2u1R0DLaKWiaNimf/GT6lam c6HBVufkSLtnA16nP37DvC4KvyQu6+PnoppNv9XsDBMYaoJUr6YP4IpH16uGKou1ApSPLpyvb KJOVK9ibmomF1pKO1EOYAxGVSf4Kye9zgQkIg9uN6dtMeJrVdk59ciw0sUcO9jz6BZd4J51Ru Vkr9Vn2gI0QILu7LcJw+GbVhQdJF5bh1AkTN4xW3b/+0CknbNU4+jp9ck7pUjdYBxPqDUgRhS FRlqNDuj5qdxra0VZ62IuLclHpGG2CZrZUaodNqIPLW5TzaZVC/N2L/HgqxTuKCzWhTwTfUzw PDe/iww2NVunNJ84eDus5sFy7aU2ok2gX7GGXZrsA5F/n71GOkFuYNZPuYS4yLTDSv6OqoEaa kCIiSmwS1R7hLNzXZdbC9pnW6VE7XOIhCuchDYeW+hubb8ihw8t5Dj1w1UvrlUlEgTrUQfUr8 yykhIqzv6AOIbZIkg6so1zp5VnNWCc4hU/Evn1Ku8UgeBTJq3iccg8u84XDO0+528OeWi3s7I H7umSGIfVw4oGxD/PhupD1gqAQN2TEwqiOTH6pm1DBvkzFaAUhDGIf1kqdlV80nf/Qk32FGus FeLTKF7VuVKQpoUzymvzRIFLxnITw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 11/16] efi_loader: implement DisconnectController 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Unfortunately we need a forward declaration because both OpenProtocol and CloseProtocol have to call DisconnectController. And DisconnectController calls both OpenProtcol and CloseProtocol. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 283 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 261 insertions(+), 22 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 3094b26e5d..bf60b79e93 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -60,6 +60,10 @@ static int nesting_level; const efi_guid_t efi_guid_driver_binding_protocol = EFI_DRIVER_BINDING_PROTOCOL_GUID; +static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle, + void *driver_image_handle, + void *child_handle); + /* Called on every callback entry */ int __efi_entry_check(void) { @@ -958,6 +962,108 @@ static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle, return EFI_EXIT(EFI_ACCESS_DENIED); } +/* + * Get all drivers associated to a controller. + * The allocated buffer has to be freed with free(). + * + * @efiobj handle of the controller + * @protocol protocol guid (optional) + * @number_of_drivers number of child controllers + * @driver_handle_buffer handles of the the drivers + * @return status code + */ +static efi_status_t efi_get_drivers(struct efi_object *efiobj, + const efi_guid_t *protocol, + efi_uintn_t *number_of_drivers, + efi_handle_t **driver_handle_buffer) +{ + struct efi_handler *handler; + struct efi_open_protocol_info_item *item; + efi_uintn_t count = 0, i; + bool duplicate; + + /* Count all driver associations */ + list_for_each_entry(handler, &efiobj->protocols, link) { + if (protocol && guidcmp(handler->guid, protocol)) + continue; + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.attributes & + EFI_OPEN_PROTOCOL_BY_DRIVER) + ++count; + } + } + /* + * Create buffer. In case of duplicate driver assignments the buffer + * will be too large. But that does not harm. + */ + *number_of_drivers = 0; + *driver_handle_buffer = calloc(count, sizeof(efi_handle_t)); + if (!*driver_handle_buffer) + return EFI_OUT_OF_RESOURCES; + /* Collect unique driver handles */ + list_for_each_entry(handler, &efiobj->protocols, link) { + if (protocol && guidcmp(handler->guid, protocol)) + continue; + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.attributes & + EFI_OPEN_PROTOCOL_BY_DRIVER) { + /* Check this is a new driver */ + duplicate = false; + for (i = 0; i < *number_of_drivers; ++i) { + if ((*driver_handle_buffer)[i] == + item->info.agent_handle) + duplicate = true; + } + /* Copy handle to buffer */ + if (!duplicate) { + i = (*number_of_drivers)++; + (*driver_handle_buffer)[i] = + item->info.agent_handle; + } + } + } + } + return EFI_SUCCESS; +} + +/* + * Disconnect all drivers from a controller. + * + * This function implements the DisconnectController service. + * See the Unified Extensible Firmware Interface (UEFI) specification + * for details. + * + * @efiobj handle of the controller + * @protocol protocol guid (optional) + * @child_handle handle of the child to destroy + * @return status code + */ +static efi_status_t efi_disconnect_all_drivers( + struct efi_object *efiobj, + const efi_guid_t *protocol, + efi_handle_t child_handle) +{ + efi_uintn_t number_of_drivers; + efi_handle_t *driver_handle_buffer; + efi_status_t r, ret = EFI_NOT_FOUND; + + ret = efi_get_drivers(efiobj, protocol, &number_of_drivers, + &driver_handle_buffer); + if (ret != EFI_SUCCESS) + return ret; + + while (number_of_drivers) { + r = EFI_CALL(efi_disconnect_controller( + efiobj->handle, + driver_handle_buffer[--number_of_drivers], + child_handle)); + if (r == EFI_SUCCESS) + ret = r; + } + free(driver_handle_buffer); + return ret; +} + /* * Uninstall protocol interface. * @@ -1622,28 +1728,6 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, return EFI_EXIT(efi_set_watchdog(timeout)); } -/* - * Disconnect a controller from a driver. - * - * This function implements the DisconnectController service. - * See the Unified Extensible Firmware Interface (UEFI) specification - * for details. - * - * @controller_handle handle of the controller - * @driver_image_handle handle of the driver - * @child_handle handle of the child to destroy - * @return status code - */ -static efi_status_t EFIAPI efi_disconnect_controller( - efi_handle_t controller_handle, - efi_handle_t driver_image_handle, - efi_handle_t child_handle) -{ - EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle, - child_handle); - return EFI_EXIT(EFI_INVALID_PARAMETER); -} - /* * Close a protocol. * @@ -2483,6 +2567,161 @@ out: return EFI_EXIT(ret); } +/* + * Get all child controllers associated to a driver. + * The allocated buffer has to be freed with free(). + * + * @efiobj handle of the controller + * @driver_handle handle of the driver + * @number_of_children number of child controllers + * @child_handle_buffer handles of the the child controllers + */ +static efi_status_t efi_get_child_controllers( + struct efi_object *efiobj, + efi_handle_t driver_handle, + efi_uintn_t *number_of_children, + efi_handle_t **child_handle_buffer) +{ + struct efi_handler *handler; + struct efi_open_protocol_info_item *item; + efi_uintn_t count = 0, i; + bool duplicate; + + /* Count all child controller associations */ + list_for_each_entry(handler, &efiobj->protocols, link) { + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.agent_handle == driver_handle && + item->info.attributes & + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) + ++count; + } + } + /* + * Create buffer. In case of duplicate child controller assignments + * the buffer will be too large. But that does not harm. + */ + *number_of_children = 0; + *child_handle_buffer = calloc(count, sizeof(efi_handle_t)); + if (!*child_handle_buffer) + return EFI_OUT_OF_RESOURCES; + /* Copy unique child handles */ + list_for_each_entry(handler, &efiobj->protocols, link) { + list_for_each_entry(item, &handler->open_infos, link) { + if (item->info.agent_handle == driver_handle && + item->info.attributes & + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) { + /* Check this is a new child controller */ + duplicate = false; + for (i = 0; i < *number_of_children; ++i) { + if ((*child_handle_buffer)[i] == + item->info.controller_handle) + duplicate = true; + } + /* Copy handle to buffer */ + if (!duplicate) { + i = (*number_of_children)++; + (*child_handle_buffer)[i] = + item->info.controller_handle; + } + } + } + } + return EFI_SUCCESS; +} + +/* + * Disconnect a controller from a driver. + * + * This function implements the DisconnectController service. + * See the Unified Extensible Firmware Interface (UEFI) specification + * for details. + * + * @controller_handle handle of the controller + * @driver_image_handle handle of the driver + * @child_handle handle of the child to destroy + * @return status code + */ +static efi_status_t EFIAPI efi_disconnect_controller( + efi_handle_t controller_handle, + efi_handle_t driver_image_handle, + efi_handle_t child_handle) +{ + struct efi_driver_binding_protocol *binding_protocol; + efi_handle_t *child_handle_buffer = NULL; + size_t number_of_children = 0; + efi_status_t r; + size_t stop_count = 0; + struct efi_object *efiobj; + + EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle, + child_handle); + + efiobj = efi_search_obj(controller_handle); + if (!efiobj) { + r = EFI_INVALID_PARAMETER; + goto out; + } + + if (child_handle && !efi_search_obj(child_handle)) { + r = EFI_INVALID_PARAMETER; + goto out; + } + + /* If no driver handle is supplied, disconnect all drivers */ + if (!driver_image_handle) { + r = efi_disconnect_all_drivers(efiobj, NULL, child_handle); + goto out; + } + + /* Create list of child handles */ + if (child_handle) { + number_of_children = 1; + child_handle_buffer = &child_handle; + } else { + efi_get_child_controllers(efiobj, + driver_image_handle, + &number_of_children, + &child_handle_buffer); + } + + /* Get the driver binding protocol */ + r = EFI_CALL(efi_open_protocol(driver_image_handle, + &efi_guid_driver_binding_protocol, + (void **)&binding_protocol, + driver_image_handle, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL)); + if (r != EFI_SUCCESS) + goto out; + /* Remove the children */ + if (number_of_children) { + r = EFI_CALL(binding_protocol->stop(binding_protocol, + controller_handle, + number_of_children, + child_handle_buffer)); + if (r == EFI_SUCCESS) + ++stop_count; + } + /* Remove the driver */ + if (!child_handle) + r = EFI_CALL(binding_protocol->stop(binding_protocol, + controller_handle, + 0, NULL)); + if (r == EFI_SUCCESS) + ++stop_count; + EFI_CALL(efi_close_protocol(driver_image_handle, + &efi_guid_driver_binding_protocol, + driver_image_handle, NULL)); + + if (stop_count) + r = EFI_SUCCESS; + else + r = EFI_NOT_FOUND; +out: + if (!child_handle) + free(child_handle_buffer); + return EFI_EXIT(r); +} + static const struct efi_boot_services efi_boot_services = { .hdr = { .headersize = sizeof(struct efi_table_hdr), From patchwork Sun Dec 17 15:43:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849651 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 3z07xy5hpMz9t34 for ; Mon, 18 Dec 2017 02:53:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 74A2BC21F88; Sun, 17 Dec 2017 15:47:06 +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.0 required=5.0 tests=FREEMAIL_FROM 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 3C0A9C21F2D; Sun, 17 Dec 2017 15:45:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 34CA2C21F3E; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 8B7DEC21FF1 for ; Sun, 17 Dec 2017 15:45:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M3i8r-1fHbHl10BV-00rHbC; Sun, 17 Dec 2017 16:45:12 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:38 +0100 Message-Id: <20171217154342.15469-13-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:2nMVwIthL09owpVr5cW5hFuxjiJ6EmnwZzaFhYfXvUsK0C/u5xt MNSaix2j10gddJMdJCxNlxMIgKUMVIRDxMiC24UuJCnrNOUVxJ2ztvHWqJw0AAo+TEJuOSK ZqIaMEEbqs7jsE9JLMXZ+VBSB3JurmmZ+eFRmdBcqzLyVePEWPG6236w5KOp9Bp1gtAtwav w/qfsSH/hRYp+wONftzdw== X-UI-Out-Filterresults: notjunk:1; V01:K0:z8SLwPJghn4=:6fVzKXvHZRQChxkZAoo4ho yThsXfMTGlSXz6kcvDeR8Y6Kw8zLZwDknmH+8V0CAKT/54JMsCbDrva5kuSAPmy7zaRnvkWWU RJtwPnkN9+oiVCRcDacfjY6N++sXkTScWMaaN/BYNs8zDTTczqZ5X4xtHs/dtmgCyJwJaopv/ qntdRf/I30cCT+EchM4vHRDcCWoPSO9folLVACLQmcfb6QrqpolMK5pdlwsMULzs55weZdzE6 O5mYbi8Nhb5L3RjO+SMSGDqo9pSBtftgQdxYlI+qLdeouDSzYlpJLYAaLDpXLTQ0Wd3YuTRjX PbxYrrwQcU/mKKQR7F637RvFbXjyaj/q6oUxCg7ZzKPvPIHSbnmmjPWgy2hrcS4v/hFdGXXm0 6QNxlhItKmIzP0MBp4hBNGJF7Y0WPCka7vPNbqgnijhXpsbAhJ9Xc7oh0L2YQByjw26P7kq5d bOy6Aq039l9Reg8ZxkRm18HK16bNt51JtayGkhrw8ifxOv6nGamsezt1nHfAtv2b3OUGJTPNQ V68+0PdJ0xep9iDXthqOnRCvi0QxZFM9doDfmBkjvINjtknkA1zUT6U9mDcYWEjtW/yVhcEP8 brsCRnIeE5t7yMb8yCuuKU6rilnh5t//6Ci9dJjmBUt5t7UqEbKf3aB8/Hw+qcay0aSE4sx0m HYd9OgdTxYwTXOPl64mM129WBVuhZoV+ratE75u9YxJocm/IFat1yoMIJ3pDGy1YX1g2wmJAq cT6uV/fCqRFrSUQ0kxkzxbs+R2ubB6Fiqeu2AXWhFUkSOQZwSaTYd/EzRNl7tdwfvPCHVEqEE Zvdg7LmQOoGdFeQy4wTcIiF07tGCA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 12/16] efi_loader: disconnect controllers in UninstallProtocol 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The UninstallProtocol boot service should first try to disconnect controllers that have been connected with EFI_OPEN_PROTOCOL_BY_DRIVER. If the protocol is still opened by an agent, it should be closed. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index bf60b79e93..18022ca734 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1080,26 +1080,43 @@ static efi_status_t EFIAPI efi_uninstall_protocol_interface( void *handle, const efi_guid_t *protocol, void *protocol_interface) { + struct efi_object *efiobj; struct efi_handler *handler; + struct efi_open_protocol_info_item *item; + struct efi_open_protocol_info_item *pos; efi_status_t r; EFI_ENTRY("%p, %pUl, %p", handle, protocol, protocol_interface); - if (!handle || !protocol) { + /* Check handle */ + efiobj = efi_search_obj(handle); + if (!efiobj) { r = EFI_INVALID_PARAMETER; goto out; } - /* Find the protocol on the handle */ r = efi_search_protocol(handle, protocol, &handler); if (r != EFI_SUCCESS) goto out; - if (handler->protocol_interface) { - /* TODO disconnect controllers */ + /* Disconnect controllers */ + efi_disconnect_all_drivers(efiobj, protocol, NULL); + if (!list_empty(&handler->open_infos)) { r = EFI_ACCESS_DENIED; - } else { - r = efi_remove_protocol(handle, protocol, protocol_interface); + goto out; + } + /* Close protocol */ + list_for_each_entry_safe(item, pos, &handler->open_infos, link) { + if (item->info.attributes == + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL || + item->info.attributes == EFI_OPEN_PROTOCOL_GET_PROTOCOL || + item->info.attributes == EFI_OPEN_PROTOCOL_TEST_PROTOCOL) + list_del(&item->link); + } + if (!list_empty(&handler->open_infos)) { + r = EFI_ACCESS_DENIED; + goto out; } + r = efi_remove_protocol(handle, protocol, protocol_interface); out: return EFI_EXIT(r); } From patchwork Sun Dec 17 15:43:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849646 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 3z07vZ5nTRz9sR8 for ; Mon, 18 Dec 2017 02:51:54 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 71EE3C21EF1; Sun, 17 Dec 2017 15:48:26 +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.0 required=5.0 tests=FREEMAIL_FROM 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 472B6C21F59; Sun, 17 Dec 2017 15:46:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6AEB9C21FC9; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lists.denx.de (Postfix) with ESMTPS id CA0CAC21FC3 for ; Sun, 17 Dec 2017 15:45:13 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Lskr7-1fB2mX2DNp-012KE2; Sun, 17 Dec 2017 16:45:12 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:39 +0100 Message-Id: <20171217154342.15469-14-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:z97HismsuUsvsXrByhbT9BORbsfwN8xBf9lUeOYqktm9of1pOxn dvnMq4F+PxHsxI4V84Jdnwc+MNgSQcG/YiVc3kzOd5HfL+c2sq47vkarWHwM/NMMqIpNtUV KocsPOcGv5zYh0ux/lj5h8sQN0SgbgDIA8CorR9GZbumSQ6L/AIcTVhgmzalcIfiB7zoClt WIebPyfW2R7jWJ7w/vdyw== X-UI-Out-Filterresults: notjunk:1; V01:K0:S/vQVG1JXbo=:TB8BY6WMvNSPpaW7FLacIe Ed7wfUP0SMXOIUJ3F+NIvzSk1aWx9Uw7bxtVUhDZylBb7WYIMcRPTFnFrWDLDxVEsl5I2KysY hwsZg0UvLE44LBPt254H7scri21q7MmM7ArRBmy1TU9y5trj9RW5GBQUmKuyOX9fDnu4WS7nJ UMTnTSmOd7vfx3VURhoSUPMvYAEjCuCL7ZWx1D555A1aoyQmCk2LNIrYyQBHungwXtF95oin5 cV7TOFXMe/5lRvjbhbHuH3eyHSWoDMQPfmS4xQ2MuUrEATyxfoWTCfbHOhjCzpIjDfuLideSQ aeFOGAsq4olOwFiqsFmJ2l736N1KB/q1zjKpW7YhtO2uBgIFzt+x8Sp4rVAGSFlEX9vz/vOdd sdFz1gJpQpiIChFwTQIYuRHF2CQXsaGy/0q7KErSntVINfYoAAFM1kN4VogT1muyPzqlVtzR/ JbKjU6oFT9tDgX+l0RqxPH9VuUbJAhp6gXUiS89YNkuvMzD091t2YeQBjBS6SfdSDA+KstIs0 ojGfbaaO1fzM2MkpUkAuV4xG0qFRHBV6IoxQmb4sadCnYvaedI9FdY0/sBlWfdOX3HMMxN8ZZ VvcTZjsV7Fan3aFyKFye1TA/S/6vkieXaIO4uc/XjN4mQAC62EtcsZvTWoi23dbPzvpNrlDoS UKbyOq1Axs2zmSTqRiYsWKiA5KXDFlQyDk5vHuByUGyFhIBh+CWEDGTM+Uh73YfcsPG4DJJMK sHfA0aYS484J1e4JhubGaNw2oSeD2rDCcC41VHxbwJOokgRZKX/8S9xkIyqIlTGzov5bkvkfZ SwIArVmEVnDg5PtdVNsXhz0kRCOoA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 13/16] efi_selftest: remove todo in manage protocols 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The installation of UninstallProtocols is functional now. So we do not expect errors when calling it. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_selftest/efi_selftest_manageprotocols.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c index f20f1528d4..874f86102d 100644 --- a/lib/efi_selftest/efi_selftest_manageprotocols.c +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c @@ -194,7 +194,7 @@ static int execute(void) &guid3, &interface3, NULL); if (ret == EFI_SUCCESS) { - efi_st_todo("UninstallMultipleProtocolInterfaces did not catch error\n"); + efi_st_error("UninstallMultipleProtocolInterfaces did not catch error\n"); return EFI_ST_FAILURE; } @@ -273,8 +273,8 @@ static int execute(void) &guid2, &interface2, NULL); if (ret != EFI_SUCCESS) { - efi_st_todo("UninstallMultipleProtocolInterfaces failed\n"); - /* This test is known to fail due to missing implementation */ + efi_st_error("UninstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; } /* * Check that the protocols are really uninstalled. @@ -287,8 +287,8 @@ static int execute(void) return EFI_ST_FAILURE; } if (count != 1) { - efi_st_todo("UninstallMultipleProtocolInterfaces failed to uninstall protocols\n"); - /* This test is known to fail due to missing implementation */ + efi_st_error("UninstallMultipleProtocolInterfaces failed to uninstall protocols\n"); + return EFI_ST_FAILURE; } ret = find_in_buffer(handle1, count, buffer); if (ret != EFI_SUCCESS) { @@ -327,19 +327,19 @@ static int execute(void) ret = boottime->uninstall_protocol_interface(handle1, &guid1, &interface1); if (ret != EFI_SUCCESS) { - efi_st_todo("UninstallProtocolInterface failed\n"); - /* This test is known to fail due to missing implementation */ + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; } ret = boottime->handle_protocol(handle1, &guid1, (void **)&interface); if (ret == EFI_SUCCESS) { - efi_st_todo("UninstallProtocolInterface failed\n"); - /* This test is known to fail due to missing implementation */ + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; } ret = boottime->uninstall_protocol_interface(handle1, &guid3, &interface1); if (ret != EFI_SUCCESS) { - efi_st_todo("UninstallProtocolInterface failed\n"); - /* This test is known to fail due to missing implementation */ + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; } return EFI_ST_SUCCESS; From patchwork Sun Dec 17 15:43:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849640 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 3z07rT6vcrz9sR8 for ; Mon, 18 Dec 2017 02:49:13 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8D3ADC21F41; Sun, 17 Dec 2017 15:48:09 +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.0 required=5.0 tests=FREEMAIL_FROM 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 41E9EC21FD1; Sun, 17 Dec 2017 15:46:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 89BC4C21FE2; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lists.denx.de (Postfix) with ESMTPS id 0750DC21FF3 for ; Sun, 17 Dec 2017 15:45:14 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0Mh9cj-1ee7fl3IXZ-00MMco; Sun, 17 Dec 2017 16:45:12 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:40 +0100 Message-Id: <20171217154342.15469-15-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:CdO01W4CynsnHHAQqo6PQtlbpb3JWMeEEVu9ZaFpWCqd9Z10srs uno+erIYqaaJtFIE3yqc7S1a2ayKhXNz2M0SV4rmKMAHLFCbCj/0tCr2yN7pY6UnrabEMEO WEVGf0/2DI/Oax5antYdVmH56bH1Qh9+/O2MO8h56qArhn24Ndx9pfcQOpJ6Ovg/UyAzSdF W5tp75zAEWRh607ckfF+g== X-UI-Out-Filterresults: notjunk:1; V01:K0:qnVN6bvNJcc=:wFK4tuIzxdRx5M+wFY7XP6 1yQYGlReiCnFTAl2RcTkgB+cfiDcCb3+0CI3LJxXur/PIcxlXvBSh2EMe1E4sBg9NhA48FsEb e8lOT4TWaHcD/RqXuVcQ97sjzgwX6IvSYRwDPiS6+beAtCsn6mFBYI0rRl8ZRLsnz1HRnIFLZ PXqpw6EMQ44o0KX+Aoj5tjZOwWMBB3A4FE6z53lHWB7GDt1b/s9LkecjiWvowN1aqT9+fcMmi ofcG8pm1QeY2Gqx98Lx7qoWdUw2gwFcWCjMpJMKZD1uLYJvV1b80HB5L5fg6LVploIT8epB7p xc5pF7H1gusLI96wee74XrhZsZbjL3xYVkjZNJlBxN31iVNQYrTV1ydpKneIPYaiomNVccmxZ +ofWGhiXy0yx7Ak35bZ+UX+bUdyfYecAyFQT2MRgV1Dd08y8pdtYD0V4fSPiLhUjQhxF/bLCG qzodcq/7XyCbsKpj3lugWrDE2GNwQ8f53YG4EQXejItgRgZZzEXybTzQhx6REXDJipK7TDN+R raXv/rXXIZi9Lxk8CYggt1YlkLkEv6uLsAjky2iemdUvBKObjirmpiAA3+8iDQ2tWcYjyl2QS hxcVXa2ptwCLjLrHL0Lbj8R1Xqqk1DOofAgttEgcxIj86DRkx4vLR7AX1qgzYAmcCz7b4V8pv /j5lBQGoppwvAs0SVguikoGKKshh9mm6JCrGrs8Q35/1vf29bQlE+I5lJNzGmAgFX8LZPINJF pyeOi+seVBv4w1DqsU3DyuJ+4qKYUfIHNIz+fzVpItxWIPIbr/8kSRX8XfuYlM/Nx+H6Ocibv G0uxU6g164p/z4UyPik3FhyV6KHVw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 14/16] efi_selftest: remove todo in device path test 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The installation of UninstallProtocol is functional now. So we do not expect errors when calling it. Call UninstallProtocol with correct level of indirection for parameter handle. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_selftest/efi_selftest_devicepath.c | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_devicepath.c b/lib/efi_selftest/efi_selftest_devicepath.c index d9a6697892..2f8f3c7f15 100644 --- a/lib/efi_selftest/efi_selftest_devicepath.c +++ b/lib/efi_selftest/efi_selftest_devicepath.c @@ -192,31 +192,41 @@ static int teardown(void) { efi_status_t ret; - ret = boottime->uninstall_protocol_interface(&handle1, + ret = boottime->uninstall_protocol_interface(handle1, &guid_device_path, dp1); - if (ret != EFI_SUCCESS) - efi_st_todo("UninstallProtocolInterface failed\n"); - ret = boottime->uninstall_protocol_interface(&handle1, + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->uninstall_protocol_interface(handle1, &guid_protocol, &interface); - if (ret != EFI_SUCCESS) - efi_st_todo("UninstallProtocolInterface failed\n"); - ret = boottime->uninstall_protocol_interface(&handle2, + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->uninstall_protocol_interface(handle2, &guid_device_path, dp2); - if (ret != EFI_SUCCESS) - efi_st_todo("UninstallProtocolInterface failed\n"); - ret = boottime->uninstall_protocol_interface(&handle2, + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->uninstall_protocol_interface(handle2, &guid_protocol, &interface); - if (ret != EFI_SUCCESS) - efi_st_todo("UninstallProtocolInterface failed\n"); - ret = boottime->uninstall_protocol_interface(&handle3, + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->uninstall_protocol_interface(handle3, &guid_device_path, dp3); - if (ret != EFI_SUCCESS) - efi_st_todo("UninstallProtocolInterface failed\n"); + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } if (dp1) { ret = boottime->free_pool(dp1); if (ret != EFI_SUCCESS) { From patchwork Sun Dec 17 15:43:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849642 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 3z07sg53v8z9sR8 for ; Mon, 18 Dec 2017 02:50:15 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 444F4C21F94; Sun, 17 Dec 2017 15:49:02 +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.0 required=5.0 tests=FREEMAIL_FROM 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 23929C21FFE; Sun, 17 Dec 2017 15:46:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E7ED3C21EF1; Sun, 17 Dec 2017 15:45:19 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 4F59EC21FD5 for ; Sun, 17 Dec 2017 15:45:14 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MYOCL-1eVMFM0EXx-00VCKU; Sun, 17 Dec 2017 16:45:13 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:41 +0100 Message-Id: <20171217154342.15469-16-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:o69bwhHxk0n7VcNhXSJr3235jP4kGJUnz+vhXrwCAWFGufZGv97 9ybpShhKkujAIoFZW9JFXVV77nHXAWHlGLI6VZaIqHdNxM981Wys47Q6BdU6MtTSNFufzlH bq+Y3Zh0/br4eEbN5NpYvYFwYbp3YnMW1MAxKCeFM4Nl+BF1tRnJoYBJdITdH8iifyNnNVz lkiyf/sBZh668hSyIYW7A== X-UI-Out-Filterresults: notjunk:1; V01:K0:TwdcSQHrEa4=:SgDDoiA/phMphvlDeB2svU EyRM0B2BQz8q76x5E6C5K9U0Vk677G9bjh9e5k6oKxTxpUT+SzDfYMPPhS6m3ELXhyFH+MSL8 Be79K+JSuW0Uh9y2hE/22mrihCw1lBpwxuz23Yctc2PE4Q+npttXtHlCQndBdA7eWWPjD9DEw GtvOKaZmra08/AJRlUE+9pubHmGthplI6mCEhSAokjp1kGWkhdpRpNESE1ncWGYn6m37ufx1z CqGxJc5UPiVbB+SjW/4uIdy15vx+KSsHKJlPNUmst35VybCHM8qk7rFdPJBCq7bku7w/63zYc VZ/BmJHNJR2/+WO4CSXabbgIQJjYj28wFnE8YPngUnYesOnet6AMD2ypT08XxIzz10CItWvF+ CGpWj3y8wpOTtIwXMo/wpV95KaxuoD2DMqV2vDDXqmJYoVq3fghYd+SJad6TK40U3XSynNJD0 JaUGcebpHbV0Yv4ZoeLJyosX2taT7JDcvm+F691a7kQvU75ckNcbF0gD0BdCQstW1dDhfGDaA R8v8efNns/+dyTboOkpX410MGwCSP6DMC6eaxTwUWZ9iYrXvC2Cn5S5XVZH+coWAyh8UwooJa Wr0L6/WPjKAZtXu1frCuxdrHun0lOOZzLK+2Wo+3LhzhqlENRn+pcO0MhLX3QXLONIok+QKuu pp13nxw+Bo1wN/sj5o9nyWkLrhH1AvGi6xq49iLtu9JX0N9WyUR2ioSMzxiNaScCx17bv79zf 8kVSxVkxLys/zb/EP3mPxoBcOes3f2NxCm0aGonow9fHY+D+Ii3psKRxy4w5n7igMerG2+ZqS sEDQi3ngr0Z4n6Tnp+slB1v2tWaVw== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 15/16] efi_selftest: test for (Dis)ConnectController 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This unit test checks the following protocol services: ConnectController, DisconnectController, InstallProtocol, UninstallProtocol, OpenProtocol, CloseProtcol, OpenProtocolInformation Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/efi_selftest/Makefile | 1 + lib/efi_selftest/efi_selftest_controllers.c | 385 ++++++++++++++++++++++++++++ 2 files changed, 386 insertions(+) create mode 100644 lib/efi_selftest/efi_selftest_controllers.c diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 837e86228e..e549553c82 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += \ efi_selftest.o \ +efi_selftest_controllers.o \ efi_selftest_console.o \ efi_selftest_devicepath.o \ efi_selftest_events.o \ diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c new file mode 100644 index 0000000000..9908c85c44 --- /dev/null +++ b/lib/efi_selftest/efi_selftest_controllers.c @@ -0,0 +1,385 @@ +/* + * efi_selftest_controllers + * + * Copyright (c) 2017 Heinrich Schuchardt + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This unit test checks the following protocol services: + * ConnectController, DisconnectController, + * InstallProtocol, UninstallProtocol, + * OpenProtocol, CloseProtcol, OpenProtocolInformation + */ + +#include + +#define NUMBER_OF_CHILD_CONTROLLERS 4 + +static struct efi_boot_services *boottime; +const efi_guid_t guid_driver_binding_protocol = + EFI_DRIVER_BINDING_PROTOCOL_GUID; +static efi_guid_t guid_controller = + EFI_GUID(0xe6ab1d96, 0x6bff, 0xdb42, + 0xaa, 0x05, 0xc8, 0x1f, 0x7f, 0x45, 0x26, 0x34); +static efi_guid_t guid_child_controller = + EFI_GUID(0x1d41f6f5, 0x2c41, 0xddfb, + 0xe2, 0x9b, 0xb8, 0x0e, 0x2e, 0xe8, 0x3a, 0x85); +static efi_handle_t handle_controller; +static efi_handle_t handle_child_controller[NUMBER_OF_CHILD_CONTROLLERS]; +static efi_handle_t handle_driver; + +/* + * Count child controllers + * + * @handle handle on which child controllers are installed + * @protocol protocol for which the child controlles where installed + * @count number of child controllers + * @return status code + */ +static efi_status_t count_child_controllers(efi_handle_t handle, + efi_guid_t *protocol, + efi_uintn_t *count) +{ + efi_status_t ret; + efi_uintn_t entry_count; + struct efi_open_protocol_info_entry *entry_buffer; + + *count = 0; + ret = boottime->open_protocol_information(handle, protocol, + &entry_buffer, &entry_count); + if (ret != EFI_SUCCESS) + return ret; + if (!entry_count) + return EFI_SUCCESS; + while (entry_count) { + if (entry_buffer[--entry_count].attributes & + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) + ++*count; + } + ret = boottime->free_pool(entry_buffer); + if (ret != EFI_SUCCESS) + efi_st_error("Cannot free buffer\n"); + return ret; +} + +/* + * Check if the driver supports the controller. + * + * @this driver binding protocol + * @controller_handle handle of the controller + * @remaining_device_path path specifying the child controller + * @return status code + */ +static efi_status_t EFIAPI supported( + struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + struct efi_device_path *remaining_device_path) +{ + efi_status_t ret; + void *interface; + + ret = boottime->open_protocol( + controller_handle, &guid_controller, + &interface, handle_driver, + controller_handle, EFI_OPEN_PROTOCOL_BY_DRIVER); + switch (ret) { + case EFI_ACCESS_DENIED: + case EFI_ALREADY_STARTED: + return ret; + case EFI_SUCCESS: + break; + default: + return EFI_UNSUPPORTED; + } + ret = boottime->close_protocol( + controller_handle, &guid_controller, + handle_driver, controller_handle); + if (ret != EFI_SUCCESS) + ret = EFI_UNSUPPORTED; + return ret; +} + +/* + * Create child controllers and attach driver. + * + * @this driver binding protocol + * @controller_handle handle of the controller + * @remaining_device_path path specifying the child controller + * @return status code + */ +static efi_status_t EFIAPI start( + struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + struct efi_device_path *remaining_device_path) +{ + size_t i; + efi_status_t ret; + void *interface; + + /* Attach driver to controller */ + ret = boottime->open_protocol( + controller_handle, &guid_controller, + &interface, handle_driver, + controller_handle, EFI_OPEN_PROTOCOL_BY_DRIVER); + switch (ret) { + case EFI_ACCESS_DENIED: + case EFI_ALREADY_STARTED: + return ret; + case EFI_SUCCESS: + break; + default: + return EFI_UNSUPPORTED; + } + + /* Create child controllers */ + for (i = 0; i < NUMBER_OF_CHILD_CONTROLLERS; ++i) { + ret = boottime->install_protocol_interface( + &handle_child_controller[i], &guid_child_controller, + EFI_NATIVE_INTERFACE, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("InstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->open_protocol( + controller_handle, &guid_controller, + &interface, handle_child_controller[i], + handle_child_controller[i], + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); + if (ret != EFI_SUCCESS) { + efi_st_error("OpenProtocol failed\n"); + return EFI_ST_FAILURE; + } + } + return ret; +} + +/* + * Remove a single child controller from the parent controller. + * + * @controller_handle parent controller + * @child_handle child controller + * @return status code + */ +static efi_status_t disconnect_child(efi_handle_t controller_handle, + efi_handle_t child_handle) +{ + efi_status_t ret; + + ret = boottime->close_protocol( + controller_handle, &guid_controller, + child_handle, child_handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Cannot close protocol\n"); + return ret; + } + ret = boottime->uninstall_protocol_interface( + child_handle, &guid_child_controller, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("Cannot uninstall protocol interface\n"); + return ret; + } + return ret; +} + +/* + * Remove child controllers and disconnect the controller. + * + * @this driver binding protocol + * @controller_handle handle of the controller + * @number_of_children number of child controllers to remove + * @child_handle_buffer handles of the child controllers to remove + * @return status code + */ +static efi_status_t EFIAPI stop( + struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + size_t number_of_children, + efi_handle_t *child_handle_buffer) +{ + efi_status_t ret; + efi_uintn_t count; + struct efi_open_protocol_info_entry *entry_buffer; + + /* Destroy provided child controllers */ + if (number_of_children) { + efi_uintn_t i; + + for (i = 0; i < number_of_children; ++i) { + ret = disconnect_child(controller_handle, + child_handle_buffer[i]); + if (ret != EFI_SUCCESS) + return ret; + } + return EFI_SUCCESS; + } + + /* Destroy all children */ + ret = boottime->open_protocol_information( + controller_handle, &guid_controller, + &entry_buffer, &count); + if (ret != EFI_SUCCESS) { + efi_st_error("OpenProtocolInformation failed\n"); + return ret; + } + while (count) { + if (entry_buffer[--count].attributes & + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) { + ret = disconnect_child( + controller_handle, + entry_buffer[count].agent_handle); + if (ret != EFI_SUCCESS) + return ret; + } + } + ret = boottime->free_pool(entry_buffer); + if (ret != EFI_SUCCESS) + efi_st_error("Cannot free buffer\n"); + + /* Detach driver from controller */ + ret = boottime->close_protocol( + controller_handle, &guid_controller, + handle_driver, controller_handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Cannot close protocol\n"); + return ret; + } + return EFI_SUCCESS; +} + +/* Driver binding protocol interface */ +struct efi_driver_binding_protocol binding_interface = { + supported, + start, + stop, + 0xffffffff, + NULL, + NULL, + }; + +/* + * Setup unit test. + * + * @handle handle of the loaded image + * @systable system table + */ +static int setup(const efi_handle_t img_handle, + const struct efi_system_table *systable) +{ + efi_status_t ret; + + boottime = systable->boottime; + + /* Create controller handle */ + ret = boottime->install_protocol_interface( + &handle_controller, &guid_controller, + EFI_NATIVE_INTERFACE, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("InstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + /* Create driver handle */ + ret = boottime->install_protocol_interface( + &handle_driver, &guid_driver_binding_protocol, + EFI_NATIVE_INTERFACE, &binding_interface); + if (ret != EFI_SUCCESS) { + efi_st_error("InstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; +} + +/* + * Execute unit test. + * + * The number of child controllers is checked after each of the following + * actions: + * + * Connect a controller to a driver. + * Disconnect and destroy a child controller. + * Disconnect and destroy the remaining child controllers. + * + * Connect a controller to a driver. + * Uninstall the driver protocol from the controller. + */ +static int execute(void) +{ + efi_status_t ret; + efi_uintn_t count; + + /* Connect controller to driver */ + ret = boottime->connect_controller(handle_controller, NULL, NULL, 1); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to connect controller\n"); + return EFI_ST_FAILURE; + } + /* Check number of child controllers */ + ret = count_child_controllers(handle_controller, &guid_controller, + &count); + if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS) { + efi_st_error("Number of children %u != %u\n", + (unsigned int)count, NUMBER_OF_CHILD_CONTROLLERS); + } + /* Destroy second child controller */ + ret = boottime->disconnect_controller(handle_controller, + handle_driver, + handle_child_controller[1]); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to disconnect child controller\n"); + return EFI_ST_FAILURE; + } + /* Check number of child controllers */ + ret = count_child_controllers(handle_controller, &guid_controller, + &count); + if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS - 1) { + efi_st_error("Destroying single child controller failed\n"); + return EFI_ST_FAILURE; + } + /* Destroy remaining child controllers and disconnect controller */ + ret = boottime->disconnect_controller(handle_controller, NULL, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to disconnect controller\n"); + return EFI_ST_FAILURE; + } + /* Check number of child controllers */ + ret = count_child_controllers(handle_controller, &guid_controller, + &count); + if (ret != EFI_SUCCESS || count) { + efi_st_error("Destroying child controllers failed\n"); + return EFI_ST_FAILURE; + } + + /* Connect controller to driver */ + ret = boottime->connect_controller(handle_controller, NULL, NULL, 1); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to connect controller\n"); + return EFI_ST_FAILURE; + } + /* Check number of child controllers */ + ret = count_child_controllers(handle_controller, &guid_controller, + &count); + if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS) { + efi_st_error("Number of children %u != %u\n", + (unsigned int)count, NUMBER_OF_CHILD_CONTROLLERS); + } + /* Uninstall controller protocol */ + ret = boottime->uninstall_protocol_interface(handle_controller, + &guid_controller, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to uninstall protocols\n"); + return EFI_ST_FAILURE; + } + /* Check number of child controllers */ + ret = count_child_controllers(handle_controller, &guid_controller, + &count); + if (ret == EFI_SUCCESS) + efi_st_error("Uninstall failed\n"); + return EFI_ST_SUCCESS; +} + +EFI_UNIT_TEST(controllers) = { + .name = "controllers", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup, + .execute = execute, +}; From patchwork Sun Dec 17 15:43:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 849650 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 3z07xy4Dy1z9sR8 for ; Mon, 18 Dec 2017 02:53:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4AED5C21F3E; Sun, 17 Dec 2017 15:47:24 +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.0 required=5.0 tests=FREEMAIL_FROM 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 54692C21FEC; Sun, 17 Dec 2017 15:46:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DBADAC21F3E; Sun, 17 Dec 2017 15:45:20 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lists.denx.de (Postfix) with ESMTPS id 9D58FC21FDA for ; Sun, 17 Dec 2017 15:45:14 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M9s8K-1eK2cb1Nmq-00B2ut; Sun, 17 Dec 2017 16:45:13 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 17 Dec 2017 16:43:42 +0100 Message-Id: <20171217154342.15469-17-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171217154342.15469-1-xypron.glpk@gmx.de> References: <20171217154342.15469-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:Qa6tzhJvfatsDEA7wjV4r1WqWWUAd0kur+QwECTA99qBbw5UdXr G7mp9OLSVdr5HCNaI9U6+YqDvdzdzEa7YMGwYvxA1sj+ctZdKBpUh7+dTMGI3Gv9tAJFaHu afTVVUqNw5B9OdWfiI2MWWivhufNObI/AQc/mGAcutSIfmx+szZva6hDz0IUysiFvnpSjiK svU+3NK5aaWF6+78ezCIg== X-UI-Out-Filterresults: notjunk:1; V01:K0:n8QeScFok/o=:tanc6B/licBN1oz+3JyvNR o9JLOU+tc1sW+BMA1jVlDNUwq3bG2Dt2BLkj8d1pRYmJjrxFdG8gLYk4gFFNiv92ubpEzdhrk dC6nfYX2KbteFi1MgApVeZcUIAFFjDWGy7Zl52B9z+hMyHZVX4Oi0sZY18FlphpsMOpIRbR3j IMBSjcfqbWcCOLn7AqayAXkejJbVZsQKOKUFWqxMMqaMo1r9sF8d9fkZWjam5J542YccpLigm u2XH2bAjrntpmTACxydaWXZcgwmTZjECAyAch++KjA6TKwcLmo0mmx54S0K7kFq4qNVTX13++ cmaRC2t2IIyRhGLRzWGkIOl+AwoNidjBDxOe/hu5U7Q9VS/XTe+3R313fLjzST2FjScI6x8zT 2JY/yPlRunzxwpPqcgnwcVlvRMfT7HO5nkSj5Y9Z+cGGfHzmZrJXEK/RkP/nH9CQ6dyYF+Z08 bRH1uREvx1SOpZsZxK/hrsJb1DPLKcX6JFPLXDx0PTYIkmzmya76fVP2qVh7N+xVB5SJV4ZbI HqjPm4h+HF9At7OM0d5EgMutBVy0k7c5Uy4uW/QYLsk4LXOFT2JAfNAhr6oSP4a3/E2H8LVGe /wZFtuGPca1r2YyrAOqlMUqEud7Qpxke2PCdxNoFK5tQ88lepgN2YmqngkTl8TgfGUwK/V7oR ORKMP03S3CAHmI5PJEAbWoLfkc9HLvi/4R3uIrYn7h5z5V51aGYVkgunrt8TepelmP7Ce5AVA Rv9PEWceSSxka4BEii4Us9hSQwpVAq+rOKHna59NNVObBxmmig/dxCwCZeACLU0x/PbAnLk1J NLGtS23GiznCRHChykLf2aeKnzKUA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 16/16] efi_loader: consistently use efi_handle_t for handles 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We should consistently use the efi_handle_t typedef when referring to handles. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- cmd/bootefi.c | 10 ++++----- include/efi_api.h | 20 ++++++++++-------- include/efi_loader.h | 14 +++++++------ lib/efi_loader/efi_boottime.c | 49 +++++++++++++++++++++++-------------------- lib/efi_loader/efi_console.c | 6 +++--- 5 files changed, 53 insertions(+), 46 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 78ff109835..97a4f269ae 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -122,8 +122,8 @@ static void *copy_fdt(void *fdt) } static efi_status_t efi_do_enter( - void *image_handle, struct efi_system_table *st, - asmlinkage ulong (*entry)(void *image_handle, + efi_handle_t image_handle, struct efi_system_table *st, + asmlinkage ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st)) { efi_status_t ret = EFI_LOAD_ERROR; @@ -136,8 +136,8 @@ static efi_status_t efi_do_enter( #ifdef CONFIG_ARM64 static efi_status_t efi_run_in_el2(asmlinkage ulong (*entry)( - void *image_handle, struct efi_system_table *st), - void *image_handle, struct efi_system_table *st) + efi_handle_t image_handle, struct efi_system_table *st), + efi_handle_t image_handle, struct efi_system_table *st) { /* Enable caches again */ dcache_enable(); @@ -159,7 +159,7 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt, struct efi_device_path *memdp = NULL; ulong ret; - ulong (*entry)(void *image_handle, struct efi_system_table *st) + ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st) asmlinkage; ulong fdt_pages, fdt_size, fdt_start, fdt_end; const efi_guid_t fdt_guid = EFI_FDT_GUID; diff --git a/include/efi_api.h b/include/efi_api.h index 7164492f83..502fffed20 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -84,11 +84,12 @@ struct efi_boot_services { efi_status_t (EFIAPI *reinstall_protocol_interface)( void *handle, const efi_guid_t *protocol, void *old_interface, void *new_interface); - efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle, - const efi_guid_t *protocol, void *protocol_interface); - efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, - const efi_guid_t *protocol, - void **protocol_interface); + efi_status_t (EFIAPI *uninstall_protocol_interface)( + efi_handle_t handle, const efi_guid_t *protocol, + void *protocol_interface); + efi_status_t (EFIAPI *handle_protocol)( + efi_handle_t handle, const efi_guid_t *protocol, + void **protocol_interface); void *reserved; efi_status_t (EFIAPI *register_protocol_notify)( const efi_guid_t *protocol, struct efi_event *event, @@ -113,7 +114,7 @@ struct efi_boot_services { efi_status_t (EFIAPI *exit)(efi_handle_t handle, efi_status_t exit_status, unsigned long exitdata_size, s16 *exitdata); - efi_status_t (EFIAPI *unload_image)(void *image_handle); + efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle); efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long); efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count); @@ -139,9 +140,10 @@ struct efi_boot_services { const efi_guid_t *protocol, void **interface, efi_handle_t agent_handle, efi_handle_t controller_handle, u32 attributes); - efi_status_t (EFIAPI *close_protocol)(void *handle, - const efi_guid_t *protocol, void *agent_handle, - void *controller_handle); + efi_status_t (EFIAPI *close_protocol)( + efi_handle_t handle, const efi_guid_t *protocol, + efi_handle_t agent_handle, + efi_handle_t controller_handle); efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle, const efi_guid_t *protocol, struct efi_open_protocol_info_entry **entry_buffer, diff --git a/include/efi_loader.h b/include/efi_loader.h index 9e1ae8866b..1411782879 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -204,23 +204,25 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path); /* Add a new object to the object list. */ void efi_add_handle(struct efi_object *obj); /* Create handle */ -efi_status_t efi_create_handle(void **handle); +efi_status_t efi_create_handle(efi_handle_t *handle); /* Delete handle */ void efi_delete_handle(struct efi_object *obj); /* Call this to validate a handle and find the EFI object for it */ -struct efi_object *efi_search_obj(const void *handle); +struct efi_object *efi_search_obj(const efi_handle_t handle); /* Find a protocol on a handle */ -efi_status_t efi_search_protocol(const void *handle, +efi_status_t efi_search_protocol(const efi_handle_t handle, const efi_guid_t *protocol_guid, struct efi_handler **handler); /* Install new protocol on a handle */ -efi_status_t efi_add_protocol(const void *handle, const efi_guid_t *protocol, +efi_status_t efi_add_protocol(const efi_handle_t handle, + const efi_guid_t *protocol, void *protocol_interface); /* Delete protocol from a handle */ -efi_status_t efi_remove_protocol(const void *handle, const efi_guid_t *protocol, +efi_status_t efi_remove_protocol(const efi_handle_t handle, + const efi_guid_t *protocol, void *protocol_interface); /* Delete all protocols from a handle */ -efi_status_t efi_remove_all_protocols(const void *handle); +efi_status_t efi_remove_all_protocols(const efi_handle_t handle); /* Call this to create an event */ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 18022ca734..bb637e20bd 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -60,9 +60,10 @@ static int nesting_level; const efi_guid_t efi_guid_driver_binding_protocol = EFI_DRIVER_BINDING_PROTOCOL_GUID; -static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle, - void *driver_image_handle, - void *child_handle); +static efi_status_t EFIAPI efi_disconnect_controller( + efi_handle_t controller_handle, + efi_handle_t driver_image_handle, + efi_handle_t child_handle); /* Called on every callback entry */ int __efi_entry_check(void) @@ -351,7 +352,7 @@ void efi_add_handle(struct efi_object *obj) * @handle new handle * @return status code */ -efi_status_t efi_create_handle(void **handle) +efi_status_t efi_create_handle(efi_handle_t *handle) { struct efi_object *obj; efi_status_t r; @@ -374,7 +375,7 @@ efi_status_t efi_create_handle(void **handle) * @handler reference to the protocol * @return status code */ -efi_status_t efi_search_protocol(const void *handle, +efi_status_t efi_search_protocol(const efi_handle_t handle, const efi_guid_t *protocol_guid, struct efi_handler **handler) { @@ -407,7 +408,8 @@ efi_status_t efi_search_protocol(const void *handle, * @protocol_interface interface of the protocol implementation * @return status code */ -efi_status_t efi_remove_protocol(const void *handle, const efi_guid_t *protocol, +efi_status_t efi_remove_protocol(const efi_handle_t handle, + const efi_guid_t *protocol, void *protocol_interface) { struct efi_handler *handler; @@ -429,7 +431,7 @@ efi_status_t efi_remove_protocol(const void *handle, const efi_guid_t *protocol, * @handle handle from which the protocols shall be deleted * @return status code */ -efi_status_t efi_remove_all_protocols(const void *handle) +efi_status_t efi_remove_all_protocols(const efi_handle_t handle) { struct efi_object *efiobj; struct efi_handler *protocol; @@ -809,7 +811,7 @@ static efi_status_t EFIAPI efi_check_event(struct efi_event *event) * @handle handle to find * @return EFI object */ -struct efi_object *efi_search_obj(const void *handle) +struct efi_object *efi_search_obj(const efi_handle_t handle) { struct efi_object *efiobj; @@ -863,7 +865,8 @@ static efi_status_t efi_delete_open_info( * @protocol_interface interface of the protocol implementation * @return status code */ -efi_status_t efi_add_protocol(const void *handle, const efi_guid_t *protocol, +efi_status_t efi_add_protocol(const efi_handle_t handle, + const efi_guid_t *protocol, void *protocol_interface) { struct efi_object *efiobj; @@ -953,9 +956,9 @@ out: * @new_interface interface to be installed * @return status code */ -static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle, - const efi_guid_t *protocol, void *old_interface, - void *new_interface) +static efi_status_t EFIAPI efi_reinstall_protocol_interface( + efi_handle_t handle, const efi_guid_t *protocol, + void *old_interface, void *new_interface) { EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, old_interface, new_interface); @@ -1077,7 +1080,7 @@ static efi_status_t efi_disconnect_all_drivers( * @return status code */ static efi_status_t EFIAPI efi_uninstall_protocol_interface( - void *handle, const efi_guid_t *protocol, + efi_handle_t handle, const efi_guid_t *protocol, void *protocol_interface) { struct efi_object *efiobj; @@ -1534,7 +1537,7 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, unsigned long *exit_data_size, s16 **exit_data) { - ulong (*entry)(void *image_handle, struct efi_system_table *st); + ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st); struct efi_loaded_image *info = image_handle; EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data); @@ -1616,7 +1619,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle, * @image_handle handle of the image to be unloaded * @return status code */ -static efi_status_t EFIAPI efi_unload_image(void *image_handle) +static efi_status_t EFIAPI efi_unload_image(efi_handle_t image_handle) { struct efi_object *efiobj; @@ -1654,7 +1657,7 @@ static void efi_exit_caches(void) * @map_key key of the memory map * @return status code */ -static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle, +static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, unsigned long map_key) { int i; @@ -1758,10 +1761,10 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, * @controller_handle handle of the controller * @return status code */ -static efi_status_t EFIAPI efi_close_protocol(void *handle, +static efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle, const efi_guid_t *protocol, - void *agent_handle, - void *controller_handle) + efi_handle_t agent_handle, + efi_handle_t controller_handle) { struct efi_handler *handler; struct efi_open_protocol_info_item *item; @@ -1866,8 +1869,8 @@ out: * @protocol_buffer_count number of entries in the buffer * @return status code */ -static efi_status_t EFIAPI efi_protocols_per_handle(void *handle, - efi_guid_t ***protocol_buffer, +static efi_status_t EFIAPI efi_protocols_per_handle( + efi_handle_t handle, efi_guid_t ***protocol_buffer, efi_uintn_t *protocol_buffer_count) { unsigned long buffer_size; @@ -1957,7 +1960,7 @@ static efi_status_t EFIAPI efi_locate_handle_buffer( r = efi_locate_handle(search_type, protocol, search_key, &buffer_size, *buffer); if (r == EFI_SUCCESS) - *no_handles = buffer_size / sizeof(void *); + *no_handles = buffer_size / sizeof(efi_handle_t); out: return EFI_EXIT(r); } @@ -2425,7 +2428,7 @@ out: * @protocol_interface interface implementing the protocol * @return status code */ -static efi_status_t EFIAPI efi_handle_protocol(void *handle, +static efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle, const efi_guid_t *protocol, void **protocol_interface) { diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 98497db612..56b079cee8 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -503,21 +503,21 @@ int efi_console_register(void) struct efi_object *efi_console_input_obj; /* Create handles */ - r = efi_create_handle((void **)&efi_console_control_obj); + r = efi_create_handle((efi_handle_t *)&efi_console_control_obj); if (r != EFI_SUCCESS) goto out_of_memory; r = efi_add_protocol(efi_console_control_obj->handle, &efi_guid_console_control, &efi_console_control); if (r != EFI_SUCCESS) goto out_of_memory; - r = efi_create_handle((void **)&efi_console_output_obj); + r = efi_create_handle((efi_handle_t *)&efi_console_output_obj); if (r != EFI_SUCCESS) goto out_of_memory; r = efi_add_protocol(efi_console_output_obj->handle, &efi_guid_text_output_protocol, &efi_con_out); if (r != EFI_SUCCESS) goto out_of_memory; - r = efi_create_handle((void **)&efi_console_input_obj); + r = efi_create_handle((efi_handle_t *)&efi_console_input_obj); if (r != EFI_SUCCESS) goto out_of_memory; r = efi_add_protocol(efi_console_input_obj->handle,