aboutsummaryrefslogtreecommitdiff
path: root/stand/i386/libi386/bootinfo64.c
diff options
context:
space:
mode:
Diffstat (limited to 'stand/i386/libi386/bootinfo64.c')
-rw-r--r--stand/i386/libi386/bootinfo64.c99
1 files changed, 5 insertions, 94 deletions
diff --git a/stand/i386/libi386/bootinfo64.c b/stand/i386/libi386/bootinfo64.c
index 1ffa4188d926..a55b86eb5ba7 100644
--- a/stand/i386/libi386/bootinfo64.c
+++ b/stand/i386/libi386/bootinfo64.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stand.h>
#include <sys/param.h>
#include <sys/reboot.h>
@@ -37,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <machine/psl.h>
#include <machine/specialreg.h>
#include "bootstrap.h"
+#include "modinfo.h"
#include "libi386.h"
#include "btxv86.h"
@@ -45,93 +43,6 @@ __FBSDID("$FreeBSD$");
#endif
/*
- * Copy module-related data into the load area, where it can be
- * used as a directory for loaded modules.
- *
- * Module data is presented in a self-describing format. Each datum
- * is preceded by a 32-bit identifier and a 32-bit size field.
- *
- * Currently, the following data are saved:
- *
- * MOD_NAME (variable) module name (string)
- * MOD_TYPE (variable) module type (string)
- * MOD_ARGS (variable) module parameters (string)
- * MOD_ADDR sizeof(vm_offset_t) module load address
- * MOD_SIZE sizeof(size_t) module size
- * MOD_METADATA (variable) type-specific metadata
- */
-#define COPY32(v, a, c) { \
- uint32_t x = (v); \
- if (c) \
- i386_copyin(&x, a, sizeof(x)); \
- a += sizeof(x); \
-}
-
-#define MOD_STR(t, a, s, c) { \
- COPY32(t, a, c); \
- COPY32(strlen(s) + 1, a, c); \
- if (c) \
- i386_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(uint64_t));\
-}
-
-#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
-#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c)
-#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c)
-
-#define MOD_VAR(t, a, s, c) { \
- COPY32(t, a, c); \
- COPY32(sizeof(s), a, c); \
- if (c) \
- i386_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(uint64_t)); \
-}
-
-#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
-#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c)
-
-#define MOD_METADATA(a, mm, c) { \
- COPY32(MODINFO_METADATA | mm->md_type, a, c); \
- COPY32(mm->md_size, a, c); \
- if (c) \
- i386_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(uint64_t));\
-}
-
-#define MOD_END(a, c) { \
- COPY32(MODINFO_END, a, c); \
- COPY32(0, a, c); \
-}
-
-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.
*/
static int
@@ -216,7 +127,7 @@ bi_load64(char *args, vm_offset_t *modulep,
}
/* Try reading the /etc/fstab file to select the root device */
- getrootmount(i386_fmtdev((void *)rootdev));
+ getrootmount(devformat(&rootdev->dd));
addr = 0;
/* find the last module in the chain */
@@ -249,11 +160,11 @@ bi_load64(char *args, vm_offset_t *modulep,
#endif
bi_load_vbe_data(kfp);
- size = bi_copymodules64(0);
+ size = md_copymodules(0, true);
/* copy our environment */
envp = roundup(addr + size, PAGE_SIZE);
- addr = bi_copyenv(envp);
+ addr = md_copyenv(envp);
/* set kernend */
kernend = roundup(addr, PAGE_SIZE);
@@ -268,7 +179,7 @@ bi_load64(char *args, vm_offset_t *modulep,
bcopy(&envp, md->md_data, sizeof envp);
/* copy module list and metadata */
- (void)bi_copymodules64(*modulep);
+ (void)md_copymodules(*modulep, true);
return(0);
}