From nobody Tue Jan 24 22:12:36 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 4P1h6X4vMQz3bg93; Tue, 24 Jan 2023 22:12:36 +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 4P1h6X2VV0z3DTr; Tue, 24 Jan 2023 22:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598356; 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=+lBHWo1YQMhcKNkRmK0E+YP0BqO+aACLdqJZgKdo/GA=; b=Wy55hVPCvz+RGJ4qKTqm9GRHoWrfX3t6ynyZ6RTzb2fHsgL2sSUB8oMi+Zk6fTqpm7M0DV NxIsiMf1Af0gcLjv9opMGxVReK2KyjfThR/VNJrlzvaHTjYF6SgGmrE4hghN0MgIwUrJ7O 3JQkAAHa4yS7t2nnG7WNWE4H00Xm4+GidRq8R0ay94aJXyEbJphlJxoXQ9gVJq3NLtteM0 FyUOW71yO3j+YO3uzaR7MKLoHPtSgevkwJrZo3nqz6UK4Xrr/OZp1ltELm4yEBHICjZaWW g3FZQwvGffrBOIBCLNBJpm1gd6yuqUX+nvKSEjaw6dAGD7a3xdkDFKIDg4iW9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598356; 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=+lBHWo1YQMhcKNkRmK0E+YP0BqO+aACLdqJZgKdo/GA=; b=Y22n+xxaMJ6so3Ou8/mzh9ALwlo7Q9ysJTvQJ5UXTRhF3yaGxZLsGp2DIrVBpI1vDFbcPX P+KXyINnofpprgDHb63DhKPtka9z8tUjomLIwIt84J5IP+v6FF6knBf1Y2paSP7V7ilXCq BMBETOXB5ZytHAIwB/EeYK2gmsJw83Yb1AKhgxA5L/1AxIkNfYKZekXiHN8004y2l90SnO zkESaYtJsraBmBNc0EZZoFEAEn3q7Qw1YHn4aq0dsvcKo7zrLddzNeGDEuIi5Unk33l0XH t9syJeVxg44bZJpJEgcXqQ5c1od7uov79LvOcS7J39WWd654LbWcALbx08fQAw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598356; a=rsa-sha256; cv=none; b=ScB5TFR6dCNVVLvsCbZBpOt5nhl72uMek64d78WoyfHAxEMCEuW3cj/Dmop1wtJis7UsDI GICxN0pbiFV+QTjAbnv9/+Y0EZclB8vkqguxxFuNjICga32FXnfM+IczymMefo6RTffFAW rJwY/nEW9ijdQBX43eq6xgiw6wmAkTM9p8rUGA4+wQfqic5YIrogG3nnmDnOfAW1bGAq+6 XETptUxjdSJ2pBh0eHV0C4687EervMRJ8xJZ1lP4WK6c314V/uGwnMvwA3Rc8kL8/p7CzT jxbGGEsUiEuZ3MqPVfW1HyZRx22LyKERRcmKBcq/gRAt3qL4f+tDITt6pJy9vA== 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 4P1h6X0hgjzQVQ; Tue, 24 Jan 2023 22:12:36 +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 30OMCaG5087246; Tue, 24 Jan 2023 22:12:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMCaER087245; Tue, 24 Jan 2023 22:12:36 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:12:36 GMT Message-Id: <202301242212.30OMCaER087245@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: 52804bde1baf - stable/13 - stand: Create common/modinfo.h 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: 52804bde1baf251701e345879dff30205abdc6de Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=52804bde1baf251701e345879dff30205abdc6de commit 52804bde1baf251701e345879dff30205abdc6de Author: Warner Losh AuthorDate: 2022-09-16 15:08:42 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:34 +0000 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 (cherry picked from commit bca9c87b6104219af35ae5ea4a6af098a1631bca) --- stand/common/metadata.c | 61 +----------------------------- stand/common/modinfo.h | 72 ++++++++++++++++++++++++++++++++++++ stand/efi/loader/bootinfo.c | 66 +++------------------------------ stand/i386/libi386/bootinfo32.c | 59 ++--------------------------- stand/i386/libi386/bootinfo64.c | 59 ++--------------------------- stand/userboot/userboot/bootinfo32.c | 58 +---------------------------- stand/userboot/userboot/bootinfo64.c | 59 ++--------------------------- 7 files changed, 90 insertions(+), 344 deletions(-) diff --git a/stand/common/metadata.c b/stand/common/metadata.c index cb92537d1ce2..99b67cfd1060 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" +#include "modinfo.h" #ifdef LOADER_GELI_SUPPORT #include "geliboot.h" @@ -92,68 +93,8 @@ md_copyenv(vm_offset_t 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; - #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 md_copymodules(vm_offset_t addr, int kern64) diff --git a/stand/common/modinfo.h b/stand/common/modinfo.h new file mode 100644 index 000000000000..245784ccb2ed --- /dev/null +++ b/stand/common/modinfo.h @@ -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 */ diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index 542f15a471d9..05dfc9f59c1f 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" +#include "modinfo.h" #include "loader_efi.h" #if defined(__amd64__) @@ -60,6 +61,11 @@ __FBSDID("$FreeBSD$"); #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); @@ -166,66 +172,6 @@ bi_copyenv(vm_offset_t start) 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 bi_copymodules(vm_offset_t addr) { diff --git a/stand/i386/libi386/bootinfo32.c b/stand/i386/libi386/bootinfo32.c index 207fe9a3fde8..f00c692a3993 100644 --- a/stand/i386/libi386/bootinfo32.c +++ b/stand/i386/libi386/bootinfo32.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include "bootstrap.h" +#include "modinfo.h" #include "libi386.h" #include "btxv86.h" @@ -44,64 +45,10 @@ __FBSDID("$FreeBSD$"); static struct bootinfo bi; /* - * 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 + * 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)) -#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 bi_copymodules32(vm_offset_t addr) diff --git a/stand/i386/libi386/bootinfo64.c b/stand/i386/libi386/bootinfo64.c index e088c27347be..18ed4af3e27f 100644 --- a/stand/i386/libi386/bootinfo64.c +++ b/stand/i386/libi386/bootinfo64.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include "bootstrap.h" +#include "modinfo.h" #include "libi386.h" #include "btxv86.h" @@ -45,64 +46,10 @@ __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 + * 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)) -#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 bi_copymodules64(vm_offset_t addr) diff --git a/stand/userboot/userboot/bootinfo32.c b/stand/userboot/userboot/bootinfo32.c index bd2729927349..a717f4ad1f5a 100644 --- a/stand/userboot/userboot/bootinfo32.c +++ b/stand/userboot/userboot/bootinfo32.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" +#include "modinfo.h" #include "libuserboot.h" #ifdef LOADER_GELI_SUPPORT @@ -43,64 +44,9 @@ __FBSDID("$FreeBSD$"); static struct bootinfo bi; /* - * 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 + * We have 4 byte alignment for 32-bit targets. */ #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 bi_copymodules32(vm_offset_t addr) diff --git a/stand/userboot/userboot/bootinfo64.c b/stand/userboot/userboot/bootinfo64.c index 5fffb04d8d75..773f59474bf4 100644 --- a/stand/userboot/userboot/bootinfo64.c +++ b/stand/userboot/userboot/bootinfo64.c @@ -37,67 +37,14 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" +#include "modinfo.h" #include "libuserboot.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 + * 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)) -#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 bi_copymodules64(vm_offset_t addr)