From nobody Fri Dec 9 05:10:26 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NSzcL6Jxmz4jVb3; Fri, 9 Dec 2022 05:10:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NSzcL5r41z4QRM; Fri, 9 Dec 2022 05:10:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670562626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FpWYZqMRrA009ox6Zaa0kBG4sbW4aqlbKq+GeEQ8vAg=; b=nRWni5OlJxD5cpnvtPbdPp+ijj77Kfz6vaOP9zLrH9lyjPNezJ1xPF5P04tOZSM8sBSYv6 DzZsGEG5VqTmOp7oRkqa+ENnYhQdo5TR6bEIMHY6gWKWmFXgKqSteBMPEcp6HweCEGqcTO nvBA5meH1ty+/dARBD0zADO36GFnprRQ79tB4oNhhnJ2Vgm5UWIDNwpKoA0JU5phejn3dc s63rBrPm43rfCuMV5NsVxPlrjjuFW93izZYBVS/5yhQLR4szd+ijKrnJQvk4ROfoNqr2Tp Idjx83wVU8R9hIeiZKL9rNbF9A24eSM0T2air7qyodJYQUeyarTmYWcVn7VUcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670562626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FpWYZqMRrA009ox6Zaa0kBG4sbW4aqlbKq+GeEQ8vAg=; b=ETQHHPX2blgZUKfDwqzrfVhUglF/bwITMCZ8/mozuEMvkEFKVczdoGoWQu2AFf2Nj6tif1 ZNTMKxyIrJzO75X3vWtpMTiieTyW6mZmyl2NjWPt6S6ZXUdPfx0Dnmlvbpfv9DlG8J2gsJ DI8J3X3NZIMDFFtETD4aa/Wz6LWPb1/qux4j/1bFqCA9hU2qqWlycxidby7cr5u841Y0VV /MgoxvVNVJl5F5ZUCn9/17TGFWo0DdeS6F+YUu1h4pziv9AhbAEiwMTnXQc0Z6J/VZ679E YTTBSl7ETe5wWluwvg0gFibw70ewzdBv9dJWNMevDRL1F61bxkMbSXFgyYbFJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670562626; a=rsa-sha256; cv=none; b=badxnhwRW7VRjS3j5tSP9GBTeZrlEn0OZ32cyKXZ6Mbi3Zh6pgf6Mc9m7l6qDfTKsG61Cd cXPwGTlxj057SgOFudmAzbtocUA4Ho7aa76lBIVCl7V9nWTmR80RGZl7hV8IzR31bZc3kp yxqtnixOP80BEMox578Ym/D6ZZWMNnzxa5diIerSIJO7JH2uEcTCZjqq2IdiniCZVOIsTn gKpgrIyJlWCfIQksL8tpvB60bKDtoD58vCLeOzrjhehPkNCw/tZOAy5v7JTzrqGd+yM4CZ Hr/swpVcexaRB/VMm+FRVEvzBnH78uFanrWBIqbzvQZ7qWFe5+wmiUlm4uGvsw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NSzcL4tQPzNXK; Fri, 9 Dec 2022 05:10:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2B95AQuE082882; Fri, 9 Dec 2022 05:10:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B95AQeD082881; Fri, 9 Dec 2022 05:10:26 GMT (envelope-from git) Date: Fri, 9 Dec 2022 05:10:26 GMT Message-Id: <202212090510.2B95AQeD082881@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 111610316e49 - main - kboot: Allow loading fdt from different sources List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 111610316e49dd6dc6b0b74455c1e4c81960faa8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=111610316e49dd6dc6b0b74455c1e4c81960faa8 commit 111610316e49dd6dc6b0b74455c1e4c81960faa8 Author: Warner Losh AuthorDate: 2022-12-09 05:07:52 +0000 Commit: Warner Losh CommitDate: 2022-12-09 05:07:52 +0000 kboot: Allow loading fdt from different sources Linux has /sys/firmware/fdt and /proc/device-tree to publish the dtb for the system. The former has it all in one file, while the latter breaks it out. Prefer the former since it's the more modern interface, but retain both since I don't have a PS3 to test to see if its kernel is new enough for /sys/firmware or not. In addition, do the proper fixup. Sponsored by: Netflix --- stand/kboot/kbootfdt.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/stand/kboot/kbootfdt.c b/stand/kboot/kbootfdt.c index aafa436daf9f..3791b0c92ddd 100644 --- a/stand/kboot/kbootfdt.c +++ b/stand/kboot/kbootfdt.c @@ -94,11 +94,26 @@ fdt_platform_load_dtb(void) { void *buffer; size_t buflen = 409600; + int fd; + /* + * Should load /sys/firmware/fdt if it exists, otherwise we walk the + * tree from /proc/device-tree. The former is much easier than the + * latter and also the newer interface. But as long as we support the + * PS3 boot, we'll need the latter due to that kernel's age. It likely + * would be better to script the decision between the two, but that + * turns out to be tricky... + */ buffer = malloc(buflen); - fdt_create_empty_tree(buffer, buflen); - add_node_to_fdt(buffer, "/proc/device-tree", - fdt_path_offset(buffer, "/")); + fd = host_open("/sys/firmware/fdt", O_RDONLY, 0); + if (fd != -1) { + buflen = host_read(fd, buffer, buflen); + close(fd); + } else { + fdt_create_empty_tree(buffer, buflen); + add_node_to_fdt(buffer, "/proc/device-tree", + fdt_path_offset(buffer, "/")); + } fdt_arch_fixups(buffer); fdt_pack(buffer); @@ -112,12 +127,11 @@ fdt_platform_load_dtb(void) void fdt_platform_load_overlays(void) { - + fdt_load_dtb_overlays(NULL); } void fdt_platform_fixups(void) { - + fdt_apply_overlays(); } -