From nobody Tue Jan 24 22:12:49 2023 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 4P1h6n4wDTz3bg6W; Tue, 24 Jan 2023 22:12:49 +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 4P1h6n3sWcz3Dm3; Tue, 24 Jan 2023 22:12:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598369; 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=IfCo1MawnlpEn8Bdy4qxEM/2lm4mZxfzqfWVVi7KK90=; b=BfroB7JFp/zLt6nNYGx/I8tBXhsQhL5CXOkl4L1h+I+ZCTOP7lP8T0M0ddHEXxfxFHG7mo qkDHNyt0KbqC5tRihrjWrjKnystgkJ/PuTqkwWpx+bLGHieDQWOAEmwas5lvUTi5EAhFAV x7hmdi/pY50doBjdHI2dAmsvU87tEqjjs8RIEZptdmW5fxfo5JXk4tlntcEKpxWu6NFiq2 mAqak12R/RZsSlSg7X1AfwdMFNQzlH6l52qyrctY3WXRGjB9htkkKdS06ZtzAL3CGIkSqf MP9ovmGbZ7sTZdGEXULseNAYokbrRra5E+dCpIj00aEZWrUVevFWr6H8ZhbX8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598369; 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=IfCo1MawnlpEn8Bdy4qxEM/2lm4mZxfzqfWVVi7KK90=; b=h8oU5L8+EwzRdGkO9oD1tw2zE7T0vWrLDDMbOV9bBB1BdVSEqUp+TWaQqhQ720lU/fFSy+ saExNdgmKCHfUVloUXoLOOzzNx5B/A+qKYNLimxRscnhJeHj2Q4Dx6BiAnIpLiKjCFVu8V PoqIWRTcSA2tVyeORIqmn1n0sedugN+JysXaeviDZfNHDuY2g0v04w3RmGMyJfvm/0l1i+ UDq9m2WeMS0zOTWkGOKtxw4PBPnpJ3t8uT3OJ7YuZ+Dfbd5h/p9c/Z5kunUSvp/M5peTHO N5miNZRCorCB09QECV+KYH9Oh5/SZALjjgoS9AO8Ide7lUbhENkaSKICH1R+aw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598369; a=rsa-sha256; cv=none; b=g5BC4HHnfA644CIZX/qVum3AL7vQeDramEyjufopHMjk/c0KH9kY2LhyzZ7eMbSmAOsQYi Rt/ZQtc0WosfI4ZZKj0WRJKh2iAqyJplYSCaz1gCdM71L2fIWWKn92XLouaHO+65XhxTj6 5YihUlJxL4tUNKxR1gzONOoua5amWcmGCI5qjHlgF1V+NPyqqz9u/OMkwRZfuGDJYS7+F3 rX9xl6Ya8EjSYwadkUlzJIAjqI/+npbnxb2qRmst9u7ySNoGpZuPk+Vc2Llg1YinQp3Duc tCezzkScrWB6gnL3aFd73GenU10i6x3CItY1euY0jAwZp4rEKL+PTOrOCXIXMw== 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 4P1h6n2yYmzQVg; Tue, 24 Jan 2023 22:12:49 +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 30OMCnEF087566; Tue, 24 Jan 2023 22:12:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMCnYx087565; Tue, 24 Jan 2023 22:12:49 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:12:49 GMT Message-Id: <202301242212.30OMCnYx087565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 924dc2ef3d58 - stable/13 - kboot: Move load address stuff to MD code 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 924dc2ef3d586f453a1db171362ed647ce23dce8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=924dc2ef3d586f453a1db171362ed647ce23dce8 commit 924dc2ef3d586f453a1db171362ed647ce23dce8 Author: Warner Losh AuthorDate: 2022-10-08 05:40:56 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:36 +0000 kboot: Move load address stuff to MD code The load address computations are highly architecture specific. There are generic ways that are augmented by specific constraints of specific way things work on each architecture. Move the current load segment computations into a MD routine load_addr. As part of the move, I'm marking kboot_get_kernel_machine_bits as unused. This arrived in a prior commit, but never seems to have been connected, suggesting an incomplete merge at the time, or a path not yet taken. Create a stub for amd64 that will be filled in with a later commit. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36603 (cherry picked from commit beba54e4b8349c5482f92d1abf366cfdc12b2416) --- stand/kboot/arch/amd64/Makefile.inc | 2 +- stand/kboot/arch/amd64/load_addr.c | 37 ++++++ stand/kboot/arch/powerpc64/Makefile.inc | 2 +- stand/kboot/arch/powerpc64/load_addr.c | 210 ++++++++++++++++++++++++++++++++ stand/kboot/kboot.h | 2 + stand/kboot/main.c | 160 ------------------------ 6 files changed, 251 insertions(+), 162 deletions(-) diff --git a/stand/kboot/arch/amd64/Makefile.inc b/stand/kboot/arch/amd64/Makefile.inc index 79ddbd67f5b6..e2f5b9038ee6 100644 --- a/stand/kboot/arch/amd64/Makefile.inc +++ b/stand/kboot/arch/amd64/Makefile.inc @@ -1,4 +1,4 @@ -SRCS+= host_syscall.S amd64_tramp.S elf64_freebsd.c +SRCS+= host_syscall.S amd64_tramp.S elf64_freebsd.c load_addr.c CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include diff --git a/stand/kboot/arch/amd64/load_addr.c b/stand/kboot/arch/amd64/load_addr.c new file mode 100644 index 000000000000..cbe066d02d40 --- /dev/null +++ b/stand/kboot/arch/amd64/load_addr.c @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2022 Netflix, Inc + * + * 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 +#include + +#include "stand.h" +#include "host_syscall.h" +#include "kboot.h" + +uint64_t +kboot_get_phys_load_segment(void) +{ + return (~0ULL); +} diff --git a/stand/kboot/arch/powerpc64/Makefile.inc b/stand/kboot/arch/powerpc64/Makefile.inc index b62a12506969..4c863553397c 100644 --- a/stand/kboot/arch/powerpc64/Makefile.inc +++ b/stand/kboot/arch/powerpc64/Makefile.inc @@ -1,6 +1,6 @@ CFLAGS+= -mcpu=powerpc64 -SRCS+= ppc64_elf_freebsd.c host_syscall.S kerneltramp.S +SRCS+= ppc64_elf_freebsd.c host_syscall.S kerneltramp.S load_addr.c SRCS+= ucmpdi2.c LDFLAGS= -nostdlib -static -T ${.CURDIR}/arch/${MACHINE_ARCH}/ldscript.powerpc diff --git a/stand/kboot/arch/powerpc64/load_addr.c b/stand/kboot/arch/powerpc64/load_addr.c new file mode 100644 index 000000000000..81b5d0d50581 --- /dev/null +++ b/stand/kboot/arch/powerpc64/load_addr.c @@ -0,0 +1,210 @@ +/*- + * Copyright (C) 2010-2014 Nathan Whitehorn + * 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 TOOLS GMBH 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 +#include + +#include "stand.h" +#include "host_syscall.h" +#include "kboot.h" + +struct region_desc { + uint64_t start; + uint64_t end; +}; + +/* + * Find a good place to load the kernel, subject to the PowerPC's constraints + * + * This excludes ranges that are marked as reserved. + * And 0..end of kernel + * + * It then tries to find the memory exposed from the DTB, which it assumes is one + * contiguous range. It adds everything not in that list to the excluded list. + * + * Sort, dedup, and it finds the first region and uses that as the load_segment + * and returns that. All addresses are offset by this amount. + */ +uint64_t +kboot_get_phys_load_segment(void) +{ + int fd; + uint64_t entry[2]; + static uint64_t load_segment = ~(0UL); + uint64_t val_64; + uint32_t val_32; + struct region_desc rsvd_reg[32]; + int rsvd_reg_cnt = 0; + int ret, a, b; + uint64_t start, end; + + if (load_segment == ~(0UL)) { + + /* Default load address is 0x00000000 */ + load_segment = 0UL; + + /* Read reserved regions */ + fd = host_open("/proc/device-tree/reserved-ranges", O_RDONLY, 0); + if (fd >= 0) { + while (host_read(fd, &entry[0], sizeof(entry)) == sizeof(entry)) { + rsvd_reg[rsvd_reg_cnt].start = be64toh(entry[0]); + rsvd_reg[rsvd_reg_cnt].end = + be64toh(entry[1]) + rsvd_reg[rsvd_reg_cnt].start - 1; + rsvd_reg_cnt++; + } + host_close(fd); + } + /* Read where the kernel ends */ + fd = host_open("/proc/device-tree/chosen/linux,kernel-end", O_RDONLY, 0); + if (fd >= 0) { + ret = host_read(fd, &val_64, sizeof(val_64)); + + if (ret == sizeof(uint64_t)) { + rsvd_reg[rsvd_reg_cnt].start = 0; + rsvd_reg[rsvd_reg_cnt].end = be64toh(val_64) - 1; + } else { + memcpy(&val_32, &val_64, sizeof(val_32)); + rsvd_reg[rsvd_reg_cnt].start = 0; + rsvd_reg[rsvd_reg_cnt].end = be32toh(val_32) - 1; + } + rsvd_reg_cnt++; + + host_close(fd); + } + /* Read memory size (SOCKET0 only) */ + fd = host_open("/proc/device-tree/memory@0/reg", O_RDONLY, 0); + if (fd < 0) + fd = host_open("/proc/device-tree/memory/reg", O_RDONLY, 0); + if (fd >= 0) { + ret = host_read(fd, &entry, sizeof(entry)); + + /* Memory range in start:length format */ + entry[0] = be64toh(entry[0]); + entry[1] = be64toh(entry[1]); + + /* Reserve everything what is before start */ + if (entry[0] != 0) { + rsvd_reg[rsvd_reg_cnt].start = 0; + rsvd_reg[rsvd_reg_cnt].end = entry[0] - 1; + rsvd_reg_cnt++; + } + /* Reserve everything what is after end */ + if (entry[1] != 0xffffffffffffffffUL) { + rsvd_reg[rsvd_reg_cnt].start = entry[0] + entry[1]; + rsvd_reg[rsvd_reg_cnt].end = 0xffffffffffffffffUL; + rsvd_reg_cnt++; + } + + host_close(fd); + } + + /* Sort entries in ascending order (bubble) */ + for (a = rsvd_reg_cnt - 1; a > 0; a--) { + for (b = 0; b < a; b++) { + if (rsvd_reg[b].start > rsvd_reg[b + 1].start) { + struct region_desc tmp; + tmp = rsvd_reg[b]; + rsvd_reg[b] = rsvd_reg[b + 1]; + rsvd_reg[b + 1] = tmp; + } + } + } + + /* Join overlapping/adjacent regions */ + for (a = 0; a < rsvd_reg_cnt - 1; ) { + + if ((rsvd_reg[a + 1].start >= rsvd_reg[a].start) && + ((rsvd_reg[a + 1].start - 1) <= rsvd_reg[a].end)) { + /* We have overlapping/adjacent regions! */ + rsvd_reg[a].end = + MAX(rsvd_reg[a].end, rsvd_reg[a + a].end); + + for (b = a + 1; b < rsvd_reg_cnt - 1; b++) + rsvd_reg[b] = rsvd_reg[b + 1]; + rsvd_reg_cnt--; + } else + a++; + } + + /* Find the first free region */ + if (rsvd_reg_cnt > 0) { + start = 0; + end = rsvd_reg[0].start; + for (a = 0; a < rsvd_reg_cnt - 1; a++) { + if ((start >= rsvd_reg[a].start) && + (start <= rsvd_reg[a].end)) { + start = rsvd_reg[a].end + 1; + end = rsvd_reg[a + 1].start; + } else + break; + } + + if (start != end) { + uint64_t align = 64UL*1024UL*1024UL; + + /* Align both to 64MB boundary */ + start = (start + align - 1UL) & ~(align - 1UL); + end = ((end + 1UL) & ~(align - 1UL)) - 1UL; + + if (start < end) + load_segment = start; + } + } + } + + return (load_segment); +} + +#if 0 +/* + * XXX this appears to be unused, but may have been for selecting the allowed + * kernels ABIs. It's been unused since the first commit, which suggests an + * error in bringing this into the tree. + */ +uint8_t +kboot_get_kernel_machine_bits(void) +{ + static uint8_t bits = 0; + struct old_utsname utsname; + int ret; + + if (bits == 0) { + /* Default is 32-bit kernel */ + bits = 32; + + /* Try to get system type */ + memset(&utsname, 0, sizeof(utsname)); + ret = host_uname(&utsname); + if (ret == 0) { + if (strcmp(utsname.machine, "ppc64") == 0) + bits = 64; + else if (strcmp(utsname.machine, "ppc64le") == 0) + bits = 64; + } + } + + return (bits); +} +#endif diff --git a/stand/kboot/kboot.h b/stand/kboot/kboot.h index 01de346234f3..13c9f9ad3032 100644 --- a/stand/kboot/kboot.h +++ b/stand/kboot/kboot.h @@ -8,5 +8,7 @@ #define KBOOT_H void do_init(void); +uint64_t kboot_get_phys_load_segment(void); +uint8_t kboot_get_kernel_machine_bits(void); #endif /* KBOOT_H */ diff --git a/stand/kboot/main.c b/stand/kboot/main.c index be08528049e6..10dd6b05194b 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -49,166 +49,6 @@ static void kboot_kseg_get(int *nseg, void **ptr); extern int command_fdt_internal(int argc, char *argv[]); -struct region_desc { - uint64_t start; - uint64_t end; -}; - -static uint64_t -kboot_get_phys_load_segment(void) -{ - int fd; - uint64_t entry[2]; - static uint64_t load_segment = ~(0UL); - uint64_t val_64; - uint32_t val_32; - struct region_desc rsvd_reg[32]; - int rsvd_reg_cnt = 0; - int ret, a, b; - uint64_t start, end; - - if (load_segment == ~(0UL)) { - - /* Default load address is 0x00000000 */ - load_segment = 0UL; - - /* Read reserved regions */ - fd = host_open("/proc/device-tree/reserved-ranges", O_RDONLY, 0); - if (fd >= 0) { - while (host_read(fd, &entry[0], sizeof(entry)) == sizeof(entry)) { - rsvd_reg[rsvd_reg_cnt].start = be64toh(entry[0]); - rsvd_reg[rsvd_reg_cnt].end = - be64toh(entry[1]) + rsvd_reg[rsvd_reg_cnt].start - 1; - rsvd_reg_cnt++; - } - host_close(fd); - } - /* Read where the kernel ends */ - fd = host_open("/proc/device-tree/chosen/linux,kernel-end", O_RDONLY, 0); - if (fd >= 0) { - ret = host_read(fd, &val_64, sizeof(val_64)); - - if (ret == sizeof(uint64_t)) { - rsvd_reg[rsvd_reg_cnt].start = 0; - rsvd_reg[rsvd_reg_cnt].end = be64toh(val_64) - 1; - } else { - memcpy(&val_32, &val_64, sizeof(val_32)); - rsvd_reg[rsvd_reg_cnt].start = 0; - rsvd_reg[rsvd_reg_cnt].end = be32toh(val_32) - 1; - } - rsvd_reg_cnt++; - - host_close(fd); - } - /* Read memory size (SOCKET0 only) */ - fd = host_open("/proc/device-tree/memory@0/reg", O_RDONLY, 0); - if (fd < 0) - fd = host_open("/proc/device-tree/memory/reg", O_RDONLY, 0); - if (fd >= 0) { - ret = host_read(fd, &entry, sizeof(entry)); - - /* Memory range in start:length format */ - entry[0] = be64toh(entry[0]); - entry[1] = be64toh(entry[1]); - - /* Reserve everything what is before start */ - if (entry[0] != 0) { - rsvd_reg[rsvd_reg_cnt].start = 0; - rsvd_reg[rsvd_reg_cnt].end = entry[0] - 1; - rsvd_reg_cnt++; - } - /* Reserve everything what is after end */ - if (entry[1] != 0xffffffffffffffffUL) { - rsvd_reg[rsvd_reg_cnt].start = entry[0] + entry[1]; - rsvd_reg[rsvd_reg_cnt].end = 0xffffffffffffffffUL; - rsvd_reg_cnt++; - } - - host_close(fd); - } - - /* Sort entries in ascending order (bubble) */ - for (a = rsvd_reg_cnt - 1; a > 0; a--) { - for (b = 0; b < a; b++) { - if (rsvd_reg[b].start > rsvd_reg[b + 1].start) { - struct region_desc tmp; - tmp = rsvd_reg[b]; - rsvd_reg[b] = rsvd_reg[b + 1]; - rsvd_reg[b + 1] = tmp; - } - } - } - - /* Join overlapping/adjacent regions */ - for (a = 0; a < rsvd_reg_cnt - 1; ) { - - if ((rsvd_reg[a + 1].start >= rsvd_reg[a].start) && - ((rsvd_reg[a + 1].start - 1) <= rsvd_reg[a].end)) { - /* We have overlapping/adjacent regions! */ - rsvd_reg[a].end = - MAX(rsvd_reg[a].end, rsvd_reg[a + a].end); - - for (b = a + 1; b < rsvd_reg_cnt - 1; b++) - rsvd_reg[b] = rsvd_reg[b + 1]; - rsvd_reg_cnt--; - } else - a++; - } - - /* Find the first free region */ - if (rsvd_reg_cnt > 0) { - start = 0; - end = rsvd_reg[0].start; - for (a = 0; a < rsvd_reg_cnt - 1; a++) { - if ((start >= rsvd_reg[a].start) && - (start <= rsvd_reg[a].end)) { - start = rsvd_reg[a].end + 1; - end = rsvd_reg[a + 1].start; - } else - break; - } - - if (start != end) { - uint64_t align = 64UL*1024UL*1024UL; - - /* Align both to 64MB boundary */ - start = (start + align - 1UL) & ~(align - 1UL); - end = ((end + 1UL) & ~(align - 1UL)) - 1UL; - - if (start < end) - load_segment = start; - } - } - } - - return (load_segment); -} - -uint8_t -kboot_get_kernel_machine_bits(void) -{ - static uint8_t bits = 0; - struct old_utsname utsname; - int ret; - - if (bits == 0) { - /* Default is 32-bit kernel */ - bits = 32; - - /* Try to get system type */ - memset(&utsname, 0, sizeof(utsname)); - ret = host_uname(&utsname); - if (ret == 0) { - if (strcmp(utsname.machine, "ppc64") == 0) - bits = 64; - else if (strcmp(utsname.machine, "ppc64le") == 0) - bits = 64; - } - } - - return (bits); -} - int kboot_getdev(void **vdev, const char *devspec, const char **path) {