diff options
author | Warner Losh <imp@FreeBSD.org> | 2022-09-16 15:08:47 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2022-09-16 15:18:56 +0000 |
commit | 5d1531d9d4e7d1b1b706ab23ac3f864416e87522 (patch) | |
tree | 59bc6fab0c4fce18c315ba9e1f0f91ef3d6d6e98 /stand/common | |
parent | bca9c87b6104219af35ae5ea4a6af098a1631bca (diff) | |
download | src-5d1531d9d4e7d1b1b706ab23ac3f864416e87522.tar.gz src-5d1531d9d4e7d1b1b706ab23ac3f864416e87522.zip |
Diffstat (limited to 'stand/common')
-rw-r--r-- | stand/common/metadata.c | 43 | ||||
-rw-r--r-- | stand/common/modinfo.c | 86 | ||||
-rw-r--r-- | stand/common/modinfo.h | 2 |
3 files changed, 88 insertions, 43 deletions
diff --git a/stand/common/metadata.c b/stand/common/metadata.c index 99b67cfd1060..37171ec3be99 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -93,49 +93,6 @@ md_copyenv(vm_offset_t addr) return(addr); } -static int align; -#define MOD_ALIGN(l) roundup(l, align) - -static vm_offset_t -md_copymodules(vm_offset_t addr, int kern64) -{ - struct preloaded_file *fp; - struct file_metadata *md; - uint64_t scratch64; - uint32_t scratch32; - int c; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - if (kern64) { - scratch64 = fp->f_addr; - MOD_ADDR(addr, scratch64, c); - scratch64 = fp->f_size; - MOD_SIZE(addr, scratch64, c); - } else { - scratch32 = fp->f_addr; -#ifdef __arm__ - scratch32 -= __elfN(relocation_offset); -#endif - MOD_ADDR(addr, scratch32, c); - MOD_SIZE(addr, fp->f_size, c); - } - for (md = fp->f_metadata; md != NULL; md = md->md_next) { - if (!(md->md_type & MODINFOMD_NOCOPY)) { - MOD_METADATA(addr, md, c); - } - } - } - MOD_END(addr, c); - return(addr); -} - /* * Load the information expected by a kernel. * diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c new file mode 100644 index 000000000000..a274890ace64 --- /dev/null +++ b/stand/common/modinfo.c @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> + * 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 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. + * + * from: FreeBSD: src/sys/boot/sparc64/loader/metadata.c,v 1.6 + */ +#include <stand.h> +#include <sys/param.h> +#include <sys/linker.h> +#include <sys/boot.h> +#include <sys/reboot.h> +#if defined(LOADER_FDT_SUPPORT) +#include <fdt_platform.h> +#endif + +#ifdef __arm__ +#include <machine/elf.h> +#endif +#include <machine/metadata.h> + +#include "bootstrap.h" +#include "modinfo.h" + +static int align; +#define MOD_ALIGN(l) roundup(l, align) + +vm_offset_t +md_copymodules(vm_offset_t addr, bool kern64) +{ + struct preloaded_file *fp; + struct file_metadata *md; + uint64_t scratch64; + uint32_t scratch32; + int c; + + c = addr != 0; + /* start with the first module on the list, should be the kernel */ + for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { + + MOD_NAME(addr, fp->f_name, c); /* this field must come first */ + MOD_TYPE(addr, fp->f_type, c); + if (fp->f_args) + MOD_ARGS(addr, fp->f_args, c); + if (kern64) { + scratch64 = fp->f_addr; + MOD_ADDR(addr, scratch64, c); + scratch64 = fp->f_size; + MOD_SIZE(addr, scratch64, c); + } else { + scratch32 = fp->f_addr; +#ifdef __arm__ + scratch32 -= __elfN(relocation_offset); +#endif + MOD_ADDR(addr, scratch32, c); + MOD_SIZE(addr, fp->f_size, c); + } + for (md = fp->f_metadata; md != NULL; md = md->md_next) { + if (!(md->md_type & MODINFOMD_NOCOPY)) { + MOD_METADATA(addr, md, c); + } + } + } + MOD_END(addr, c); + return(addr); +} diff --git a/stand/common/modinfo.h b/stand/common/modinfo.h index 245784ccb2ed..3d7f26a3c963 100644 --- a/stand/common/modinfo.h +++ b/stand/common/modinfo.h @@ -69,4 +69,6 @@ COPY32(0, a, c); \ } +vm_offset_t md_copymodules(vm_offset_t addr, bool kern64); + #endif /* COMMON_MODINFO_H */ |