Index: sys/conf/files.riscv =================================================================== --- sys/conf/files.riscv +++ sys/conf/files.riscv @@ -59,6 +59,7 @@ riscv/riscv/plic.c standard riscv/riscv/platform.c optional platform riscv/riscv/platform_if.m optional platform +riscv/riscv/platform_default.c optional platform platform_default riscv/riscv/pmap.c standard riscv/riscv/riscv_console.c optional rcons riscv/riscv/sbi.c standard Index: sys/conf/options.riscv =================================================================== --- sys/conf/options.riscv +++ sys/conf/options.riscv @@ -4,4 +4,5 @@ FPE opt_global.h INTRNG opt_global.h PLATFORM opt_global.h +PLATFORM_DEFAULT opt_global.h SIFIVE_FU540 opt_global.h Index: sys/riscv/riscv/platform.c =================================================================== --- sys/riscv/riscv/platform.c +++ sys/riscv/riscv/platform.c @@ -103,6 +103,17 @@ */ TUNABLE_STR_FETCH("hw.platform", plat_name, sizeof(plat_name)); +#ifdef PLATFORM_DEFAULT + /* Assign default platform */ + SET_FOREACH(platpp, platform_set) { + platp = *platpp; + if (strcmp(platp->name, "default") == 0) { + plat_def_impl = platp; + break; + } + } +#endif + /* * Try to locate the best platform kobj */ @@ -135,7 +146,8 @@ } /* Otherwise, see if it is better than our current best */ - if (plat_def_impl == NULL || prio > best_prio) { + if (plat_def_impl == NULL || strcmp(plat_def_impl->name, "default") == 0 || + prio > best_prio) { best_prio = prio; plat_def_impl = platp; } Index: sys/riscv/riscv/platform_default.c =================================================================== --- /dev/null +++ sys/riscv/riscv/platform_default.c @@ -0,0 +1,57 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Axiado Corporation + * All rights reserved. + * + * This software was developed in part by Nick O'Brien for Axiado + * Corporation. + * + * 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 AUTHOR 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 AUTHOR 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 "opt_platform.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include + +#include "platform_if.h" + +#if defined(PLATFORM_DEFAULT) + +static platform_method_t default_methods[] = { + + PLATFORMMETHOD_END, +}; + +FDT_PLATFORM_DEF(default, "default", 0, "default,default"); + +#endif /* PLATFORM_DEFAULT */