All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 03/18] x86: sysreset: Separate out the EFI code
Date: Thu,  2 May 2019 10:52:13 -0600	[thread overview]
Message-ID: <20190502165229.203099-4-sjg@chromium.org> (raw)
In-Reply-To: <20190502165229.203099-1-sjg@chromium.org>

The EFI implementation of reset sits inside the driver and is called
directly from outside the driver, breaking the normal driver-model
conventions. Worse, it passed NULL as the device pointer, hoping that
the called function won't use it, which breaks as soon as code is added
to use it.

Separate out the implementation to improve the situation enough to allow
a future patch to add new sysreset features.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---

Changes in v3: None
Changes in v2:
- Add new patch to separate out the EFI code in sysreset

 drivers/sysreset/sysreset_x86.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c
index 009f3766027..d484ec5de49 100644
--- a/drivers/sysreset/sysreset_x86.c
+++ b/drivers/sysreset/sysreset_x86.c
@@ -12,8 +12,7 @@
 #include <asm/processor.h>
 #include <efi_loader.h>
 
-static __efi_runtime int x86_sysreset_request(struct udevice *dev,
-					      enum sysreset_t type)
+static int x86_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
 	int value;
 
@@ -39,11 +38,18 @@ void __efi_runtime EFIAPI efi_reset_system(
 			efi_status_t reset_status,
 			unsigned long data_size, void *reset_data)
 {
+	int value;
+
+	/*
+	 * inline this code since we are not caused in the context of a
+	 * udevice and passing NULL to x86_sysreset_request() is too horrible.
+	 */
 	if (reset_type == EFI_RESET_COLD ||
 		 reset_type == EFI_RESET_PLATFORM_SPECIFIC)
-		x86_sysreset_request(NULL, SYSRESET_COLD);
-	else if (reset_type == EFI_RESET_WARM)
-		x86_sysreset_request(NULL, SYSRESET_WARM);
+		value = SYS_RST | RST_CPU | FULL_RST;
+	else /* assume EFI_RESET_WARM since we cannot return an error */
+		value = SYS_RST | RST_CPU;
+	outb(value, IO_PORT_RESET);
 
 	/* TODO EFI_RESET_SHUTDOWN */
 
-- 
2.21.0.1020.gf2820cf01a-goog

  parent reply	other threads:[~2019-05-02 16:52 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-02 16:52 [U-Boot] [PATCH v3 00/18] x86: Add support for booting from TPL Simon Glass
2019-05-02 16:52 ` [U-Boot] [PATCH v3 01/18] cros_ec: Use a hyphen in the uclass name Simon Glass
2019-05-07  9:10   ` Bin Meng
2019-05-07  9:21     ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 02/18] x86: Add a simple TPL implementation Simon Glass
2019-05-07  9:21   ` Bin Meng
2019-05-02 16:52 ` Simon Glass [this message]
2019-05-07  9:21   ` [U-Boot] [PATCH v3 03/18] x86: sysreset: Separate out the EFI code Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 04/18] x86: sysreset: Implement power-off if available Simon Glass
2019-05-07  9:21   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 05/18] x86: sysreset: Implement the get_last() method Simon Glass
2019-05-07  9:21   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 06/18] x86: Add documention on the samus flashmap Simon Glass
2019-05-07  9:21   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 07/18] x86: samus: Update device tree for SPL Simon Glass
2019-05-07  9:10   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 08/18] x86: samus: Update device tree for verified boot Simon Glass
2019-05-02 16:52 ` [U-Boot] [PATCH v3 09/18] x86: Update device tree for TPL Simon Glass
2019-05-07  9:10   ` Bin Meng
2019-05-07  9:26     ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 10/18] x86: Update device tree for Chromium OS verified boot Simon Glass
2019-05-07  9:26   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 11/18] x86: Fix device-tree indentation Simon Glass
2019-05-07  9:26   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 12/18] x86: samus: Increase the pre-reloc memory again Simon Glass
2019-05-07  9:26   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 13/18] Revert "pci: Scale MAX_PCI_REGIONS based on CONFIG_NR_DRAM_BANKS" Simon Glass
2019-05-02 16:52 ` [U-Boot] [PATCH v3 14/18] x86: Enable the RTC on all boards Simon Glass
2019-05-07  9:10   ` Bin Meng
2019-05-07  9:31     ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 15/18] x86: Update the memory map a little Simon Glass
2019-05-07  9:31   ` Bin Meng
2019-05-07  9:46     ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 16/18] x86: broadwell: Update PCH to work in TPL Simon Glass
2019-05-07  9:31   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 17/18] x86: Add a way to jump from TPL to SPL Simon Glass
2019-05-07  9:31   ` Bin Meng
2019-05-02 16:52 ` [U-Boot] [PATCH v3 18/18] x86: samus: Add a target to boot through TPL Simon Glass
2019-05-07 10:07 ` [U-Boot] [PATCH v3 00/18] x86: Add support for booting from TPL Bin Meng
2019-05-08  3:33   ` Bin Meng
2019-05-08  3:41     ` Simon Glass
2019-05-08  4:52       ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190502165229.203099-4-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.