From nobody Tue Jan 24 22:12:38 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 4P1h6Z3r47z3bg1H; Tue, 24 Jan 2023 22:12:38 +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 4P1h6Z35Byz3Db0; Tue, 24 Jan 2023 22:12:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598358; 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=JWespAvH9InvmcM0aHWL1EivWDafFhLMJyMjqHSdKNQ=; b=CDRxIVX3QnGDOaRblkVLy8rJjzpByeIkuzuHtOXewulVI27k1wFRHTNU6O3dTaM/6YJfXd Cjo0ACl+hsZxpQ+A6F9GakZ+OImOzSqdu8c9s+kv/4hAYvJT7w1IYE1HZebWymsYO7fJLC 4/5eEeZfalH9/3oqTTkOew5EhUnvFo1ZBO9HUGAvQEoFN17DZmE372M7OdEDsas+U6Ec8D oqbZEZKfIt046rDxWS2GJmE3BucnPBqg3aUBPiq8X4fK0Q6bxNcMpZrmRf9f92O2WQ9W8l W/dMQcmhl6KqO3OMOJf51UVRnzjS2WSg+Z1nGquRKPsFvx39EJMgQI9grTZ7ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598358; 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=JWespAvH9InvmcM0aHWL1EivWDafFhLMJyMjqHSdKNQ=; b=J1L6PjAIpkR3L2wArw3qY7tChlr46NMxbIKhxv/e/eOevQ/GfcBsDyeGRoaQPrtlSzafqM 1F/CSUg5CxwS1JQXM7PEHSlT8ry1uix06lU/+04Ly2x/qe6DHr5n5AUwtcq6pk3Hetpud8 Z+o401/5bE/0O+3Ad8lXDwAt+QWP5eY7tG5lQYbTYWEQxXsKslA/cMk0UAjHoLZVsWotr0 fng/uvqZX/Zykd+dzyh1P/HGMI/4rNgKtsBPEGabxyndAq7xRIr8N7Eh6f/tMbKEASQEBm +Xa4gb7EfECcUWNF6ufK7P5xs7DYby4hcWOE8sY3s0zhFOso/CRaySy6gtvV6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598358; a=rsa-sha256; cv=none; b=PNBgj35enEVXgHxG/BZ4C1g87N3851wcYpaqhCqwyVxtRAwGS8P7g+kQDIE3M1zJYfmxez Xmir2eCydi+HCP/SSmvM60N2K/aq6uyUC2bEOMyBHWRwZET1Ht6rqRk3mMZXWKZXcQPFwh R2QePwCs6pBqDFY1aDTO/7lddsFjBlDB7esrpAVw+jlli3Bq8DC/jWoZyJkETPuKbKDR+c kjLFGF9ls5vifcExJbiPf/WJBYHU+cOqLBsX+26ZgO94ctBA2GtGBmb61g33FbAxijHvBG XvM217b1QqwZixm6cAGzOMLzFsjmyqOtGrVLYXHwUfeqg/JdNdOB4KyZfMkj/Q== 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 4P1h6Z2589zQmJ; Tue, 24 Jan 2023 22:12:38 +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 30OMCcYB087302; Tue, 24 Jan 2023 22:12:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMCc4k087301; Tue, 24 Jan 2023 22:12:38 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:12:38 GMT Message-Id: <202301242212.30OMCc4k087301@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: b33c831ade59 - stable/13 - stand: Move MOD_xxx macros from modinfo.h to .c 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: b33c831ade59ced7a01d2374fc2c4e4c05e06d33 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b33c831ade59ced7a01d2374fc2c4e4c05e06d33 commit b33c831ade59ced7a01d2374fc2c4e4c05e06d33 Author: Warner Losh AuthorDate: 2022-09-16 15:08:52 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:34 +0000 stand: Move MOD_xxx macros from modinfo.h to .c Now that MOD_xxx macros are modinfo.c, they don't need to be in modinfo.h. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36573 (cherry picked from commit 2e6ed47a4609ff03a9308a173c64900485172c22) --- stand/common/modinfo.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++- stand/common/modinfo.h | 63 ----------------------------------------------- 2 files changed, 65 insertions(+), 64 deletions(-) diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c index a274890ace64..15116b3b9b78 100644 --- a/stand/common/modinfo.c +++ b/stand/common/modinfo.c @@ -42,7 +42,69 @@ #include "bootstrap.h" #include "modinfo.h" -static int align; +/* + * 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); \ +} + #define MOD_ALIGN(l) roundup(l, align) vm_offset_t @@ -53,7 +115,9 @@ md_copymodules(vm_offset_t addr, bool kern64) uint64_t scratch64; uint32_t scratch32; int c; + int align; + align = kern64 ? sizeof(uint64_t) : sizeof(uint32_t); 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) { diff --git a/stand/common/modinfo.h b/stand/common/modinfo.h index 3d7f26a3c963..fc56173e1c51 100644 --- a/stand/common/modinfo.h +++ b/stand/common/modinfo.h @@ -6,69 +6,6 @@ #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); \ -} - vm_offset_t md_copymodules(vm_offset_t addr, bool kern64); #endif /* COMMON_MODINFO_H */