Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Add sysctl machdep.bootmethod



details:   https://anonhg.NetBSD.org/src/rev/01c2513460b7
branches:  trunk
changeset: 827251:01c2513460b7
user:      maya <maya%NetBSD.org@localhost>
date:      Sun Oct 22 01:29:26 2017 +0000

description:
Add sysctl machdep.bootmethod

either "UEFI" or "BIOS" to mimic freebsd

diffstat:

 sys/arch/x86/x86/efi.c         |   5 ++---
 sys/arch/x86/x86/x86_machdep.c |  29 ++++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 6 deletions(-)

diffs (93 lines):

diff -r 3695ca1bcf44 -r 01c2513460b7 sys/arch/x86/x86/efi.c
--- a/sys/arch/x86/x86/efi.c    Sun Oct 22 00:59:28 2017 +0000
+++ b/sys/arch/x86/x86/efi.c    Sun Oct 22 01:29:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efi.c,v 1.13 2017/10/22 00:59:28 maya Exp $    */
+/*     $NetBSD: efi.c,v 1.14 2017/10/22 01:29:26 maya Exp $    */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.13 2017/10/22 00:59:28 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.14 2017/10/22 01:29:26 maya Exp $");
 
 #include <sys/kmem.h>
 #include <sys/param.h>
@@ -54,7 +54,6 @@
 bool           efi_uuideq(const struct uuid *, const struct uuid *);
 
 static bool efi_is32x64 = false;
-bool bootmethod_efi = true;
 static struct efi_systbl *efi_systbl_va = NULL;
 static struct efi_cfgtbl *efi_cfgtblhead_va = NULL;
 static struct efi_e820memmap {
diff -r 3695ca1bcf44 -r 01c2513460b7 sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c    Sun Oct 22 00:59:28 2017 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c    Sun Oct 22 01:29:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_machdep.c,v 1.98 2017/10/09 17:49:28 maya Exp $    */
+/*     $NetBSD: x86_machdep.c,v 1.99 2017/10/22 01:29:26 maya Exp $    */
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.98 2017/10/09 17:49:28 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.99 2017/10/22 01:29:26 maya Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -104,6 +104,8 @@
 
 /* --------------------------------------------------------------------- */
 
+bool bootmethod_efi;
+
 static kauth_listener_t x86_listener;
 
 extern paddr_t lowmem_rsvd, avail_start, avail_end;
@@ -1114,6 +1116,23 @@
 }
 
 static int
+sysctl_machdep_bootmethod(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node;
+       char buf[5];
+
+       node = *rnode;
+       node.sysctl_data = buf;
+       if (bootmethod_efi)
+               memcpy(node.sysctl_data, "UEFI", 5);
+       else
+               memcpy(node.sysctl_data, "BIOS", 5);
+
+       return sysctl_lookup(SYSCTLFN_CALL(&node));
+}
+
+
+static int
 sysctl_machdep_diskinfo(SYSCTLFN_ARGS)
 {
        struct sysctlnode node;
@@ -1198,10 +1217,14 @@
                       CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL);
        sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
+                      CTLTYPE_STRING, "bootmethod", NULL,
+                      sysctl_machdep_bootmethod, 0, NULL, 0,
+                      CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+       sysctl_createv(clog, 0, NULL, NULL,
+                      CTLFLAG_PERMANENT,
                       CTLTYPE_STRUCT, "diskinfo", NULL,
                       sysctl_machdep_diskinfo, 0, NULL, 0,
                       CTL_MACHDEP, CPU_DISKINFO, CTL_EOL);
-
        sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRING, "cpu_brand", NULL,



Home | Main Index | Thread Index | Old Index