diff --git a/usr.sbin/sysinst/arch/evbarm/md.c b/usr.sbin/sysinst/arch/evbarm/md.c index 347e4ace065d..5866f6c7c4f8 100644 --- a/usr.sbin/sysinst/arch/evbarm/md.c +++ b/usr.sbin/sysinst/arch/evbarm/md.c @@ -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 #include #include +#include #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; - rv =run_program(RUN_SILENT|RUN_ERROR_OK, "sh -c 'ofctl -p / model | " - "fgrep \"Raspberry Pi\"'"); - if (rv != 0) - return; + sysctl(mib, 2, NULL, &len, NULL, 0); + cpu_model = malloc(len); + sysctl(mib, 2, cpu_model, &len, NULL, 0); - /* this is some kind of Raspberry Pi */ - boardtype = BOARD_TYPE_RPI; + 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; + + free(cpu_model); } void diff --git a/usr.sbin/sysinst/arch/evbarm/md.h b/usr.sbin/sysinst/arch/evbarm/md.h index 227eaa377c3e..475b9738b2ed 100644 --- a/usr.sbin/sysinst/arch/evbarm/md.h +++ b/usr.sbin/sysinst/arch/evbarm/md.h @@ -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; /*