Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst/arch/evbarm Instead of a (bogus) attempt to...



details:   https://anonhg.NetBSD.org/src/rev/89b871dc6abc
branches:  trunk
changeset: 467018:89b871dc6abc
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Jan 09 17:06:46 2020 +0000

description:
Instead of a (bogus) attempt to query the model via ofctl, use the (now
fixed) sysctl hw.model instead.

diffstat:

 usr.sbin/sysinst/arch/evbarm/md.c |  30 ++++++++++++++++++++++--------
 usr.sbin/sysinst/arch/evbarm/md.h |   7 ++++---
 2 files changed, 26 insertions(+), 11 deletions(-)

diffs (77 lines):

diff -r 0e7c6ad17f78 -r 89b871dc6abc usr.sbin/sysinst/arch/evbarm/md.c
--- a/usr.sbin/sysinst/arch/evbarm/md.c Thu Jan 09 16:35:03 2020 +0000
+++ b/usr.sbin/sysinst/arch/evbarm/md.c Thu Jan 09 17:06:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.11 2020/01/09 13:22:31 martin Exp $ */
+/*     $NetBSD: md.c,v 1.12 2020/01/09 17:06:46 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -42,6 +42,7 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/param.h>
+#include <sys/sysctl.h>
 
 #include "defs.h"
 #include "md.h"
@@ -50,18 +51,31 @@
 
 int boardtype = BOARD_TYPE_NORMAL;
 
+#define        SBSA_MODEL_STR  "netbsd,generic-acpi"
+#define        RPI_MODEL_STR   "raspberrypi,"
+
 void
 md_init(void)
 {
-       int rv;
+       static const int mib[2] = {CTL_HW, HW_MODEL};
+       size_t len;
+       char *cpu_model;
+
+       sysctl(mib, 2, NULL, &len, NULL, 0);
+       cpu_model = malloc(len);
+       sysctl(mib, 2, cpu_model, &len, NULL, 0);
 
-       rv =run_program(RUN_SILENT|RUN_ERROR_OK, "sh -c 'ofctl -p / model | "
-           "fgrep \"Raspberry Pi\"'");
-       if (rv != 0)
-               return;
+       if (strstr(cpu_model, RPI_MODEL_STR) != NULL)
+               /* this is some kind of Raspberry Pi */
+               boardtype = BOARD_TYPE_RPI;
+       else if (strstr(cpu_model, SBSA_MODEL_STR) != NULL)
+               /* some SBSA compatible machine */
+               boardtype = BOARD_TYPE_ACPI;
+       else
+               /* unknown, assume u-boot + dtb */
+               boardtype = BOARD_TYPE_NORMAL;
 
-       /* this is some kind of Raspberry Pi */
-       boardtype = BOARD_TYPE_RPI;
+       free(cpu_model);
 }
 
 void
diff -r 0e7c6ad17f78 -r 89b871dc6abc usr.sbin/sysinst/arch/evbarm/md.h
--- a/usr.sbin/sysinst/arch/evbarm/md.h Thu Jan 09 16:35:03 2020 +0000
+++ b/usr.sbin/sysinst/arch/evbarm/md.h Thu Jan 09 17:06:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.h,v 1.3 2019/10/02 11:16:02 maya Exp $      */
+/*     $NetBSD: md.h,v 1.4 2020/01/09 17:06:46 martin Exp $    */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -76,8 +76,9 @@
 #define DISKLABEL_CMD "disklabel -w -r"
 
 /* Special board type routines need a switch */
-#define BOARD_TYPE_NORMAL      0
-#define BOARD_TYPE_RPI         1
+#define BOARD_TYPE_NORMAL      0       /* assume u-boot */
+#define BOARD_TYPE_RPI         1       /* RPi firmware booted us */
+#define        BOARD_TYPE_ACPI         2       /* generic SBSA machine */
 int boardtype;
 
 /*



Home | Main Index | Thread Index | Old Index