Module Name: src Committed By: skrll Date: Sat Apr 22 09:53:45 UTC 2023
Modified Files: src/sys/arch/evbarm/fdt: fdt_machdep.c src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: fdt_boot.c fdt_boot.h Log Message: Move fdt_update_stdout_path from evbarm code to MI code To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/arch/evbarm/fdt/fdt_machdep.c cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_boot.c src/sys/dev/fdt/fdt_boot.h cvs rdiff -u -r1.68 -r1.69 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/evbarm/fdt/fdt_machdep.c diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.102 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.103 --- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.102 Fri Apr 7 08:55:31 2023 +++ src/sys/arch/evbarm/fdt/fdt_machdep.c Sat Apr 22 09:53:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_machdep.c,v 1.102 2023/04/07 08:55:31 skrll Exp $ */ +/* $NetBSD: fdt_machdep.c,v 1.103 2023/04/22 09:53:45 skrll Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.102 2023/04/07 08:55:31 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.103 2023/04/22 09:53:45 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_bootconfig.h" @@ -94,6 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep. #include <arm/fdt/arm_fdtvar.h> #include <dev/fdt/fdtvar.h> +#include <dev/fdt/fdt_boot.h> #include <dev/fdt/fdt_private.h> #include <dev/fdt/fdt_memory.h> @@ -140,7 +141,6 @@ static uint8_t fdt_data[FDT_BUF_SIZE]; extern char KERNEL_BASE_phys[]; #define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys) -static void fdt_update_stdout_path(void); static void fdt_device_register(device_t, void *); static void fdt_device_register_post_config(device_t, void *); static void fdt_cpu_rootconf(void); @@ -547,7 +547,7 @@ initarm(void *arg) * value in /chosen/stdout-path before initializing console. */ VPRINTF("stdout\n"); - fdt_update_stdout_path(); + fdt_update_stdout_path(fdt_data, boot_args); #if BYTE_ORDER == BIG_ENDIAN /* @@ -668,32 +668,6 @@ initarm(void *arg) return sp; } -static void -fdt_update_stdout_path(void) -{ - char *stdout_path, *ep; - int stdout_path_len; - char buf[256]; - - const int chosen_off = fdt_path_offset(fdt_data, "/chosen"); - if (chosen_off == -1) - return; - - if (get_bootconf_option(boot_args, "stdout-path", - BOOTOPT_TYPE_STRING, &stdout_path) == 0) - return; - - ep = strchr(stdout_path, ' '); - stdout_path_len = ep ? (ep - stdout_path) : strlen(stdout_path); - if (stdout_path_len >= sizeof(buf)) - return; - - strncpy(buf, stdout_path, stdout_path_len); - buf[stdout_path_len] = '\0'; - fdt_setprop(fdt_data, chosen_off, "stdout-path", - buf, stdout_path_len + 1); -} - void consinit(void) { Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.68 src/sys/dev/fdt/files.fdt:1.69 --- src/sys/dev/fdt/files.fdt:1.68 Sun Apr 16 16:51:38 2023 +++ src/sys/dev/fdt/files.fdt Sat Apr 22 09:53:45 2023 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.68 2023/04/16 16:51:38 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.69 2023/04/22 09:53:45 skrll Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -66,6 +66,7 @@ device iicmux: i2cbus, i2cmux attach iicmux at fdt with iicmux_fdt file dev/fdt/i2cmux_fdt.c iicmux_fdt +file dev/fdt/fdt_boot.c fdtbase file dev/fdt/fdt_memory.c fdtbase file dev/fdt/fdt_openfirm.c fdtbase file dev/fdt/fdt_platform.c fdtbase Added files: Index: src/sys/dev/fdt/fdt_boot.c diff -u /dev/null src/sys/dev/fdt/fdt_boot.c:1.1 --- /dev/null Sat Apr 22 09:53:45 2023 +++ src/sys/dev/fdt/fdt_boot.c Sat Apr 22 09:53:45 2023 @@ -0,0 +1,92 @@ +/* $NetBSD: fdt_boot.c,v 1.1 2023/04/22 09:53:45 skrll Exp $ */ + +/*- + * Copyright (c) 2015-2017 Jared McNeill <jmcne...@invisible.ca> + * 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 AUTHOR ``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 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. + */ + +/*- + * Copyright (c) 2022 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nick Hudson + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v 1.1 2023/04/22 09:53:45 skrll Exp $"); + +#include <sys/param.h> + +#include <sys/optstr.h> + +#include <libfdt.h> + +#include <dev/fdt/fdtvar.h> +#include <dev/fdt/fdt_boot.h> + +void +fdt_update_stdout_path(void *fdt, const char *boot_args) +{ + const char *stdout_path; + char buf[256]; + + const int chosen_off = fdt_path_offset(fdt, "/chosen"); + if (chosen_off == -1) + return; + + if (optstr_get_string(boot_args, "stdout-path", &stdout_path) == false) + return; + + const char *ep = strchr(stdout_path, ' '); + size_t stdout_path_len = ep ? (ep - stdout_path) : strlen(stdout_path); + if (stdout_path_len >= sizeof(buf)) + return; + + strncpy(buf, stdout_path, stdout_path_len); + buf[stdout_path_len] = '\0'; + fdt_setprop(fdt, chosen_off, "stdout-path", + buf, stdout_path_len + 1); +} Index: src/sys/dev/fdt/fdt_boot.h diff -u /dev/null src/sys/dev/fdt/fdt_boot.h:1.1 --- /dev/null Sat Apr 22 09:53:45 2023 +++ src/sys/dev/fdt/fdt_boot.h Sat Apr 22 09:53:45 2023 @@ -0,0 +1,37 @@ +/* $NetBSD: fdt_boot.h,v 1.1 2023/04/22 09:53:45 skrll Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jared McNeill <jmcne...@invisible.ca>. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#ifndef _DEV_FDT_FDT_BOOT_H_ +#define _DEV_FDT_FDT_BOOT_H_ + +void fdt_update_stdout_path(void *, const char *); + +#endif /* _DEV_FDT_FDT_BOOT_H_ */