From nobody Fri Sep 16 15:53:55 2022 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 4MTdsb2GZmz4cLDR; Fri, 16 Sep 2022 15:53:55 +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 4MTdsb203Bz3hHw; Fri, 16 Sep 2022 15:53:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663343635; 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=pgR2oB1TY8VK3GFiemiKn0iL8YnOG94ZZhdIA1H7Mxc=; b=IHzJtHMoS5y2V5LxGrbGc+55ux3w+Yu2t0aEdpsS3ZSugvsszu7chYpo0qy3eGVrvwIlhE GiANXzUctlrWlrALrJJif72O1rKavA3LGg67VtFOLxQhHyS2rBjEToMBJaO7zUWIoiglj0 GYdvH4rGRuUCEgRQ4AfzQFoSdacjC8faZBnyjGf7bYeDTaAwkdb4coGWwjU8SpMoqEl/Ac 5Yy6rRxLKZ5XZA720NPEGfu4BhzmBt6wgmU0CvEEvjVL+am/QGQy7EEAxbIwnVv87xExNh 7yBfT06Dg6eFh/cW/4KjMG7A3c73ALnr8XDZJZGgVrxgvdR3ovL6wTxnWiodbQ== 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 4MTdsb0tl9zPqX; Fri, 16 Sep 2022 15:53:55 +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 28GFrtvq086406; Fri, 16 Sep 2022 15:53:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28GFrtOn086405; Fri, 16 Sep 2022 15:53:55 GMT (envelope-from git) Date: Fri, 16 Sep 2022 15:53:55 GMT Message-Id: <202209161553.28GFrtOn086405@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: bca9c87b6104 - main - 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/main X-Git-Reftype: branch X-Git-Commit: bca9c87b6104219af35ae5ea4a6af098a1631bca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663343635; 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=pgR2oB1TY8VK3GFiemiKn0iL8YnOG94ZZhdIA1H7Mxc=; b=VATYrnTqmIX18VXq3y0cgSg72u5xIUrX7Ucf8ol7cY3fr5r1EmKFho/cf7d4O65jCn0KZC EiDxNdwbSTQ1f58i3kdZDmGfcV6Y5xnHOaE4mTt/innHHjlWJVs8+fVH5C/5RuoZtKqH69 vH/qKPjC1P3L5Id1RlrbErbfjJpnL/ZueQe7nIEyBzYQrgyqtAizuBeDOE5KG+P8yfxlL7 kNNA7kGLdapb4GxrzAExXQLUaYKZKtufC9f1UwB3sni4A+VXKj4RUagD2PSTsObbud7GyL Q2U6alxSqmLh0EtfD+IzkzJcgLgMAx1Dl7TOkUvdP4T74zxrjdkGTldOdFznPg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663343635; a=rsa-sha256; cv=none; b=GvVXesY+xHs4ki9lg7QWghk/i3n0dcFkusUhCZgEqXFqeqzkFkl1u4sxWdN55cCN4MTYsu lC+3/vH2UGmit0CHdnaUrrnGF5fkIX/sTpe/vpxFqKRiKqbbAOhwqyIeE5c1XcAA5KydGD 6t6l1Syb9vCF5oEXR1R5umzRqcFBE2KcHc76dL0XLj+rvkqOfAPkvFpDSRY7h+VDUZDBR9 vUV+gpxAeiTROo7IcbAeiDqviBzL2FccQgo5xJMsAqNkvLh0wHTGb8h3NFDzjlFpjiLq0N UDMY/DIEbO5AwCESp3q54Aetn0ynBTunz/28vEo4BqVGUE9dI5RLPJA4Cdhp1Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=bca9c87b6104219af35ae5ea4a6af098a1631bca commit bca9c87b6104219af35ae5ea4a6af098a1631bca Author: Warner Losh AuthorDate: 2022-09-16 15:08:42 +0000 Commit: Warner Losh CommitDate: 2022-09-16 15:18:56 +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 --- 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 c3184a1e84d5..08ed518d9cff 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); @@ -164,66 +170,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)