Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/stand/efiboot Add support for the boot services watchdog...



details:   https://anonhg.NetBSD.org/src/rev/f6d82c8894b7
branches:  trunk
changeset: 984066:f6d82c8894b7
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jun 20 19:10:47 2021 +0000

description:
Add support for the boot services watchdog and pet it on every block I/O
access. For slow media (like ISO image redirection on Lenovo HR330A BMC)
this is needed because otherwise the default watchdog timeout fires before
we can finish loading the kernel from install media.

diffstat:

 sys/stand/efiboot/Makefile.efiboot |   5 ++-
 sys/stand/efiboot/efiblock.c       |   7 +++++-
 sys/stand/efiboot/efiboot.h        |   5 +++-
 sys/stand/efiboot/efiwatchdog.c    |  40 ++++++++++++++++++++++++++++++++++++++
 sys/stand/efiboot/version          |   3 +-
 5 files changed, 55 insertions(+), 5 deletions(-)

diffs (124 lines):

diff -r b15f73b2943a -r f6d82c8894b7 sys/stand/efiboot/Makefile.efiboot
--- a/sys/stand/efiboot/Makefile.efiboot        Sun Jun 20 19:07:39 2021 +0000
+++ b/sys/stand/efiboot/Makefile.efiboot        Sun Jun 20 19:10:47 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.21 2021/05/27 06:54:45 mrg Exp $
+# $NetBSD: Makefile.efiboot,v 1.22 2021/06/20 19:10:47 jmcneill Exp $
 
 S=             ${.CURDIR}/../../..
 
@@ -24,7 +24,8 @@
 SOURCES+=      boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \
                module.c overlay.c panic.c prompt.c
 SOURCES+=      efiboot.c efichar.c efidev.c efigetsecs.c efifdt.c \
-               efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c smbios.c
+               efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c efiwatchdog.c \
+               smbios.c
 
 .PATH: ${S}/external/bsd/libfdt/dist
 CPPFLAGS+=     -I${S}/external/bsd/libfdt/dist
diff -r b15f73b2943a -r f6d82c8894b7 sys/stand/efiboot/efiblock.c
--- a/sys/stand/efiboot/efiblock.c      Sun Jun 20 19:07:39 2021 +0000
+++ b/sys/stand/efiboot/efiblock.c      Sun Jun 20 19:10:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.11 2021/05/26 09:42:36 mrg Exp $ */
+/* $NetBSD: efiblock.c,v 1.12 2021/06/20 19:10:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -38,6 +38,9 @@
 #include "efiboot.h"
 #include "efiblock.h"
 
+#define        EFI_BLOCK_TIMEOUT       120
+#define        EFI_BLOCK_TIMEOUT_CODE  0x810c0000
+
 /*
  * The raidframe support is basic.  Ideally, it should be expanded to
  * consider raid volumes a first-class citizen like the x86 efiboot does,
@@ -605,6 +608,8 @@
        if (rw != F_READ)
                return EROFS;
 
+       efi_set_watchdog(EFI_BLOCK_TIMEOUT, EFI_BLOCK_TIMEOUT_CODE);
+
        switch (bpart->type) {
        case EFI_BLOCK_PART_DISKLABEL:
                if (bpart->bdev->bio->Media->BlockSize != bpart->disklabel.secsize) {
diff -r b15f73b2943a -r f6d82c8894b7 sys/stand/efiboot/efiboot.h
--- a/sys/stand/efiboot/efiboot.h       Sun Jun 20 19:07:39 2021 +0000
+++ b/sys/stand/efiboot/efiboot.h       Sun Jun 20 19:10:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efiboot.h,v 1.14 2020/10/11 14:03:33 jmcneill Exp $    */
+/*     $NetBSD: efiboot.h,v 1.15 2021/06/20 19:10:47 jmcneill Exp $    */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -104,6 +104,9 @@
 void efi_pxe_probe(void);
 bool efi_pxe_match_booted_interface(const EFI_MAC_ADDRESS *, UINT32);
 
+/* efiwatchdog.c */
+void efi_set_watchdog(uint32_t, uint64_t);
+
 /* exec.c */
 int exec_netbsd(const char *, const char *);
 
diff -r b15f73b2943a -r f6d82c8894b7 sys/stand/efiboot/efiwatchdog.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/stand/efiboot/efiwatchdog.c   Sun Jun 20 19:10:47 2021 +0000
@@ -0,0 +1,40 @@
+/* $NetBSD: efiwatchdog.c,v 1.1 2021/06/20 19:10:47 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 Jared McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+
+#include "efiboot.h"
+
+/*
+ * Set the system watchdog timer.
+ */
+void
+efi_set_watchdog(uint32_t timeout, uint64_t code)
+{
+       uefi_call_wrapper(BS->SetWatchdogTimer, 4, timeout, code, 0, NULL);
+}
diff -r b15f73b2943a -r f6d82c8894b7 sys/stand/efiboot/version
--- a/sys/stand/efiboot/version Sun Jun 20 19:07:39 2021 +0000
+++ b/sys/stand/efiboot/version Sun Jun 20 19:10:47 2021 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.25 2021/05/27 06:54:45 mrg Exp $
+$NetBSD: version,v 1.26 2021/06/20 19:10:47 jmcneill Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -29,3 +29,4 @@
 2.6:   Disable ACPI support when booting big endian kernels.
 2.7:   Add basic support for booting from RAID1 volumes.
 2.8:   Add bi-endian disklabel and FFS support.
+2.9:   Watchdog support.



Home | Main Index | Thread Index | Old Index