stand: Create common/modinfo.h
Move all the MOD_xxx macros to this header. Each user of this interface is currently required to define MOD_ALIGNMENT(l). modinfo was selected because it sits inbetween modules and metadata and will make it easier to migrate to new, shared intefaces. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36571
This commit is contained in:
parent
8b19d28d68
commit
bca9c87b61
@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/metadata.h>
|
#include <machine/metadata.h>
|
||||||
|
|
||||||
#include "bootstrap.h"
|
#include "bootstrap.h"
|
||||||
|
#include "modinfo.h"
|
||||||
|
|
||||||
#ifdef LOADER_GELI_SUPPORT
|
#ifdef LOADER_GELI_SUPPORT
|
||||||
#include "geliboot.h"
|
#include "geliboot.h"
|
||||||
@ -92,68 +93,8 @@ md_copyenv(vm_offset_t addr)
|
|||||||
return(addr);
|
return(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int align;
|
static int align;
|
||||||
|
|
||||||
#define MOD_ALIGN(l) roundup(l, align)
|
#define MOD_ALIGN(l) roundup(l, align)
|
||||||
#define COPY32(v, a, c) { \
|
|
||||||
uint32_t x = (v); \
|
|
||||||
if (c) \
|
|
||||||
archsw.arch_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) \
|
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1);\
|
|
||||||
a += MOD_ALIGN(strlen(s) + 1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
|
||||||
a += MOD_ALIGN(sizeof(s)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
|
|
||||||
a += MOD_ALIGN(mm->md_size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOD_END(a, c) { \
|
|
||||||
COPY32(MODINFO_END, a, c); \
|
|
||||||
COPY32(0, a, c); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static vm_offset_t
|
static vm_offset_t
|
||||||
md_copymodules(vm_offset_t addr, int kern64)
|
md_copymodules(vm_offset_t addr, int kern64)
|
||||||
|
72
stand/common/modinfo.h
Normal file
72
stand/common/modinfo.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2022, Netflix, Inc.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
#ifndef COMMON_MODINFO_H
|
||||||
|
#define COMMON_MODINFO_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* Clients are required to define a MOD_ALIGN(l) macro which rounds the passed
|
||||||
|
* in length to the required alignment for the kernel being booted.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define COPY32(v, a, c) { \
|
||||||
|
uint32_t x = (v); \
|
||||||
|
if (c) \
|
||||||
|
archsw.arch_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) \
|
||||||
|
archsw.arch_copyin(s, a, strlen(s) + 1);\
|
||||||
|
a += MOD_ALIGN(strlen(s) + 1); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#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) \
|
||||||
|
archsw.arch_copyin(&s, a, sizeof(s)); \
|
||||||
|
a += MOD_ALIGN(sizeof(s)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#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) \
|
||||||
|
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
|
||||||
|
a += MOD_ALIGN(mm->md_size); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MOD_END(a, c) { \
|
||||||
|
COPY32(MODINFO_END, a, c); \
|
||||||
|
COPY32(0, a, c); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* COMMON_MODINFO_H */
|
@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <efilib.h>
|
#include <efilib.h>
|
||||||
|
|
||||||
#include "bootstrap.h"
|
#include "bootstrap.h"
|
||||||
|
#include "modinfo.h"
|
||||||
#include "loader_efi.h"
|
#include "loader_efi.h"
|
||||||
|
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
@ -60,6 +61,11 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "geliboot.h"
|
#include "geliboot.h"
|
||||||
#endif
|
#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,
|
int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp,
|
||||||
bool exit_bs);
|
bool exit_bs);
|
||||||
|
|
||||||
@ -164,66 +170,6 @@ bi_copyenv(vm_offset_t start)
|
|||||||
return(last);
|
return(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 MOD_ALIGN(l) roundup(l, sizeof(u_long))
|
|
||||||
#define COPY32(v, a, c) { \
|
|
||||||
uint32_t x = (v); \
|
|
||||||
if (c) \
|
|
||||||
archsw.arch_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) \
|
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1); \
|
|
||||||
a += MOD_ALIGN(strlen(s) + 1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
|
||||||
a += MOD_ALIGN(sizeof(s)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
|
|
||||||
a += MOD_ALIGN(mm->md_size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOD_END(a, c) { \
|
|
||||||
COPY32(MODINFO_END, a, c); \
|
|
||||||
COPY32(0, a, c); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static vm_offset_t
|
static vm_offset_t
|
||||||
bi_copymodules(vm_offset_t addr)
|
bi_copymodules(vm_offset_t addr)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/bootinfo.h>
|
#include <machine/bootinfo.h>
|
||||||
#include <machine/metadata.h>
|
#include <machine/metadata.h>
|
||||||
#include "bootstrap.h"
|
#include "bootstrap.h"
|
||||||
|
#include "modinfo.h"
|
||||||
#include "libi386.h"
|
#include "libi386.h"
|
||||||
#include "btxv86.h"
|
#include "btxv86.h"
|
||||||
|
|
||||||
@ -44,64 +45,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
static struct bootinfo bi;
|
static struct bootinfo bi;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy module-related data into the load area, where it can be
|
* We have 4 byte alignment for 32-bit targets. This code is compiled as 32-bit
|
||||||
* used as a directory for loaded modules.
|
* code...
|
||||||
*
|
|
||||||
* 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 MOD_ALIGN(l) roundup(l, sizeof(u_long))
|
#define MOD_ALIGN(l) roundup(l, sizeof(u_long))
|
||||||
#define COPY32(v, a, c) { \
|
|
||||||
uint32_t x = (v); \
|
|
||||||
if (c) \
|
|
||||||
archsw.arch_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) \
|
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1); \
|
|
||||||
a += MOD_ALIGN(strlen(s) + 1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
|
||||||
a += MOD_ALIGN(sizeof(s)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
|
|
||||||
a += MOD_ALIGN(mm->md_size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOD_END(a, c) { \
|
|
||||||
COPY32(MODINFO_END, a, c); \
|
|
||||||
COPY32(0, a, c); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static vm_offset_t
|
static vm_offset_t
|
||||||
bi_copymodules32(vm_offset_t addr)
|
bi_copymodules32(vm_offset_t addr)
|
||||||
|
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/psl.h>
|
#include <machine/psl.h>
|
||||||
#include <machine/specialreg.h>
|
#include <machine/specialreg.h>
|
||||||
#include "bootstrap.h"
|
#include "bootstrap.h"
|
||||||
|
#include "modinfo.h"
|
||||||
#include "libi386.h"
|
#include "libi386.h"
|
||||||
#include "btxv86.h"
|
#include "btxv86.h"
|
||||||
|
|
||||||
@ -45,64 +46,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy module-related data into the load area, where it can be
|
* We have 8 byte alignment for 64-bit targets. This code is compiled as 64-bit
|
||||||
* used as a directory for loaded modules.
|
* code...
|
||||||
*
|
|
||||||
* 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 MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
|
#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
|
||||||
#define COPY32(v, a, c) { \
|
|
||||||
uint32_t x = (v); \
|
|
||||||
if (c) \
|
|
||||||
archsw.arch_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) \
|
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1); \
|
|
||||||
a += MOD_ALIGN(strlen(s) + 1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
|
||||||
a += MOD_ALIGN(sizeof(s)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
|
|
||||||
a += MOD_ALIGN(mm->md_size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOD_END(a, c) { \
|
|
||||||
COPY32(MODINFO_END, a, c); \
|
|
||||||
COPY32(0, a, c); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static vm_offset_t
|
static vm_offset_t
|
||||||
bi_copymodules64(vm_offset_t addr)
|
bi_copymodules64(vm_offset_t addr)
|
||||||
|
@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <i386/include/bootinfo.h>
|
#include <i386/include/bootinfo.h>
|
||||||
|
|
||||||
#include "bootstrap.h"
|
#include "bootstrap.h"
|
||||||
|
#include "modinfo.h"
|
||||||
#include "libuserboot.h"
|
#include "libuserboot.h"
|
||||||
|
|
||||||
#ifdef LOADER_GELI_SUPPORT
|
#ifdef LOADER_GELI_SUPPORT
|
||||||
@ -43,64 +44,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
static struct bootinfo bi;
|
static struct bootinfo bi;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy module-related data into the load area, where it can be
|
* We have 4 byte alignment for 32-bit targets.
|
||||||
* 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 MOD_ALIGN(l) roundup(l, sizeof(uint32_t))
|
#define MOD_ALIGN(l) roundup(l, sizeof(uint32_t))
|
||||||
#define COPY32(v, a, c) { \
|
|
||||||
uint32_t x = (v); \
|
|
||||||
if (c) \
|
|
||||||
archsw.arch_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) \
|
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1);\
|
|
||||||
a += MOD_ALIGN(strlen(s) + 1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
|
||||||
a += MOD_ALIGN(sizeof(s)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
|
|
||||||
a += MOD_ALIGN(mm->md_size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOD_END(a, c) { \
|
|
||||||
COPY32(MODINFO_END, a, c); \
|
|
||||||
COPY32(0, a, c); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static vm_offset_t
|
static vm_offset_t
|
||||||
bi_copymodules32(vm_offset_t addr)
|
bi_copymodules32(vm_offset_t addr)
|
||||||
|
@ -37,67 +37,14 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/specialreg.h>
|
#include <machine/specialreg.h>
|
||||||
|
|
||||||
#include "bootstrap.h"
|
#include "bootstrap.h"
|
||||||
|
#include "modinfo.h"
|
||||||
#include "libuserboot.h"
|
#include "libuserboot.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy module-related data into the load area, where it can be
|
* We have 8 byte alignment for 64-bit targets. This code is compiled as 32-bit
|
||||||
* used as a directory for loaded modules.
|
* code...
|
||||||
*
|
|
||||||
* 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 MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
|
#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
|
||||||
#define COPY32(v, a, c) { \
|
|
||||||
uint32_t x = (v); \
|
|
||||||
if (c) \
|
|
||||||
archsw.arch_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) \
|
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1);\
|
|
||||||
a += MOD_ALIGN(strlen(s) + 1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
|
||||||
a += MOD_ALIGN(sizeof(s)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#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) \
|
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
|
|
||||||
a += MOD_ALIGN(mm->md_size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOD_END(a, c) { \
|
|
||||||
COPY32(MODINFO_END, a, c); \
|
|
||||||
COPY32(0, a, c); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static vm_offset_t
|
static vm_offset_t
|
||||||
bi_copymodules64(vm_offset_t addr)
|
bi_copymodules64(vm_offset_t addr)
|
||||||
|
Loading…
Reference in New Issue
Block a user