Page MenuHomeFreeBSD

D36572.id110644.diff
No OneTemporary

D36572.id110644.diff

diff --git a/stand/common/metadata.c b/stand/common/metadata.c
--- a/stand/common/metadata.c
+++ b/stand/common/metadata.c
@@ -93,49 +93,6 @@
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.h b/stand/common/modinfo.h
--- 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 */
diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c
new file mode 100644
--- /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/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c
--- a/stand/efi/loader/bootinfo.c
+++ b/stand/efi/loader/bootinfo.c
@@ -61,11 +61,6 @@
#include "geliboot.h"
#endif
-/*
- * Align to a pointer / long
- */
-#define MOD_ALIGN(l) roundup(l, sizeof(u_long))
-
int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp,
bool exit_bs);
@@ -170,36 +165,6 @@
return(last);
}
-static vm_offset_t
-bi_copymodules(vm_offset_t addr)
-{
- struct preloaded_file *fp;
- struct file_metadata *md;
- int c;
- uint64_t v;
-
- 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 must come first. */
- MOD_TYPE(addr, fp->f_type, c);
- if (fp->f_args)
- MOD_ARGS(addr, fp->f_args, c);
- v = fp->f_addr;
-#if defined(__arm__)
- v -= __elfN(relocation_offset);
-#endif
- MOD_ADDR(addr, v, c);
- v = fp->f_size;
- MOD_SIZE(addr, v, 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);
-}
-
static EFI_STATUS
efi_do_vmap(EFI_MEMORY_DESCRIPTOR *mm, UINTN sz, UINTN mmsz, UINT32 mmver)
{
@@ -487,7 +452,7 @@
#endif
bi_load_efi_data(kfp, exit_bs);
- size = bi_copymodules(0);
+ size = md_copymodules(0, true);
kernend = roundup(addr + size, PAGE_SIZE);
*kernendp = kernend;
@@ -512,7 +477,7 @@
#endif
/* Copy module list and metadata. */
- (void)bi_copymodules(addr);
+ (void)md_copymodules(addr, true);
return (0);
}
diff --git a/stand/i386/libi386/bootinfo32.c b/stand/i386/libi386/bootinfo32.c
--- a/stand/i386/libi386/bootinfo32.c
+++ b/stand/i386/libi386/bootinfo32.c
@@ -44,37 +44,6 @@
static struct bootinfo bi;
-/*
- * We have 4 byte alignment for 32-bit targets. This code is compiled as 32-bit
- * code...
- */
-#define MOD_ALIGN(l) roundup(l, sizeof(u_long))
-
-static vm_offset_t
-bi_copymodules32(vm_offset_t addr)
-{
- struct preloaded_file *fp;
- struct file_metadata *md;
- 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);
- MOD_ADDR(addr, fp->f_addr, 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 an i386 kernel.
*
@@ -179,7 +148,7 @@
/* Figure out the size and location of the metadata */
*modulep = addr;
- size = bi_copymodules32(0);
+ size = md_copymodules(0, false);
kernend = roundup(addr + size, PAGE_SIZE);
*kernendp = kernend;
@@ -188,7 +157,7 @@
bcopy(&kernend, md->md_data, sizeof kernend);
/* copy module list and metadata */
- (void)bi_copymodules32(addr);
+ (void)md_copymodules(addr, false);
ssym = esym = 0;
md = file_findmetadata(kfp, MODINFOMD_SSYM);
diff --git a/stand/i386/libi386/bootinfo64.c b/stand/i386/libi386/bootinfo64.c
--- a/stand/i386/libi386/bootinfo64.c
+++ b/stand/i386/libi386/bootinfo64.c
@@ -45,40 +45,6 @@
#include "geliboot.h"
#endif
-/*
- * We have 8 byte alignment for 64-bit targets. This code is compiled as 64-bit
- * code...
- */
-#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
-
-static vm_offset_t
-bi_copymodules64(vm_offset_t addr)
-{
- struct preloaded_file *fp;
- struct file_metadata *md;
- int c;
- uint64_t v;
-
- 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);
- v = fp->f_addr;
- MOD_ADDR(addr, v, c);
- v = fp->f_size;
- MOD_SIZE(addr, v, 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);
-}
-
/*
* Check to see if this CPU supports long mode.
*/
@@ -197,7 +163,7 @@
#endif
bi_load_vbe_data(kfp);
- size = bi_copymodules64(0);
+ size = md_copymodules(0, true);
/* copy our environment */
envp = roundup(addr + size, PAGE_SIZE);
@@ -216,7 +182,7 @@
bcopy(&envp, md->md_data, sizeof envp);
/* copy module list and metadata */
- (void)bi_copymodules64(*modulep);
+ (void)md_copymodules(*modulep, true);
return(0);
}
diff --git a/stand/loader.mk b/stand/loader.mk
--- a/stand/loader.mk
+++ b/stand/loader.mk
@@ -6,6 +6,7 @@
SRCS+= boot.c commands.c console.c devopen.c interp.c
SRCS+= interp_backslash.c interp_parse.c ls.c misc.c
+SRCS+= modinfo.c
SRCS+= module.c nvstore.c pnglite.c tslog.c
CFLAGS.module.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite
diff --git a/stand/userboot/userboot/bootinfo32.c b/stand/userboot/userboot/bootinfo32.c
--- a/stand/userboot/userboot/bootinfo32.c
+++ b/stand/userboot/userboot/bootinfo32.c
@@ -43,36 +43,6 @@
static struct bootinfo bi;
-/*
- * We have 4 byte alignment for 32-bit targets.
- */
-#define MOD_ALIGN(l) roundup(l, sizeof(uint32_t))
-
-static vm_offset_t
-bi_copymodules32(vm_offset_t addr)
-{
- struct preloaded_file *fp;
- struct file_metadata *md;
- 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);
- MOD_ADDR(addr, fp->f_addr, 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 an i386 kernel.
*
@@ -157,7 +127,7 @@
/* Figure out the size and location of the metadata */
*modulep = addr;
- size = bi_copymodules32(0);
+ size = md_copymodules(0, false);
kernend = roundup(addr + size, PAGE_SIZE);
*kernendp = kernend;
@@ -166,7 +136,7 @@
bcopy(&kernend, md->md_data, sizeof kernend);
/* copy module list and metadata */
- (void)bi_copymodules32(addr);
+ (void)md_copymodules(addr, false);
ssym = esym = 0;
md = file_findmetadata(kfp, MODINFOMD_SSYM);
diff --git a/stand/userboot/userboot/bootinfo64.c b/stand/userboot/userboot/bootinfo64.c
--- a/stand/userboot/userboot/bootinfo64.c
+++ b/stand/userboot/userboot/bootinfo64.c
@@ -40,40 +40,6 @@
#include "modinfo.h"
#include "libuserboot.h"
-/*
- * We have 8 byte alignment for 64-bit targets. This code is compiled as 32-bit
- * code...
- */
-#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
-
-static vm_offset_t
-bi_copymodules64(vm_offset_t addr)
-{
- struct preloaded_file *fp;
- struct file_metadata *md;
- int c;
- uint64_t v;
-
- 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);
- v = fp->f_addr;
- MOD_ADDR(addr, v, c);
- v = fp->f_size;
- MOD_SIZE(addr, v, 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);
-}
-
/*
* Check to see if this CPU supports long mode.
*/
@@ -190,7 +156,7 @@
/* Figure out the size and location of the metadata */
*modulep = addr;
- size = bi_copymodules64(0);
+ size = md_copymodules(0, true);
kernend = roundup(addr + size, PAGE_SIZE);
*kernendp = kernend;
@@ -199,7 +165,7 @@
bcopy(&kernend, md->md_data, sizeof kernend);
/* copy module list and metadata */
- (void)bi_copymodules64(addr);
+ (void)md_copymodules(addr, true);
return(0);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 7:29 PM (21 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14947957
Default Alt Text
D36572.id110644.diff (12 KB)

Event Timeline