From nobody Wed Nov 16 11:47:53 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 4NC1WY6NbGz4hhTc; Wed, 16 Nov 2022 11:47:53 +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 4NC1WY5h3Sz4DxB; Wed, 16 Nov 2022 11:47:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668599273; 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=D/ZU/DZ4EKkZxVnMbkkQZHy7cnvehl9g7kF3lSjJVFQ=; b=Xa/xWJWdV/VFnyzMgJTWSkyLk4MlN5Qp2Y9ojXYVtb2+2XUefB0xKv5IN9yOeccU6Ckxgn +soAB/FYG8aqRg5HAmUz3XVr2TXCSYcnmHTWD5OClPzJFWtPQgbpssN/9CCLXwMZQT7LPl ME1iBYjqMka8p95/FcoTEZ6IAHl22IJoSOowjCfAklvzSj1v9hBJHsrVB91qPX3XL+8aAJ 0ziZuTtO77IG6fyIPWd+P2TqXpf/aAey3r2aRPVmrnoxPs5wLY3u6G7ABFjsX8UATItbyf mrsn40muQo2wMJP+Z13t6Du/U4Tn0Qod227hs+fTHqDLqMCoWV6j4cI2R1LWCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668599273; 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=D/ZU/DZ4EKkZxVnMbkkQZHy7cnvehl9g7kF3lSjJVFQ=; b=poZ9IyhU3z4wj/V2iT6oAdKtlr8YsnyIPh3dRxGd5QRymua2uFBvzZPDG1qSrxe4ARmjO7 V9BBcqeGPM9AO5PwQBDumRTB2NAvy5k/3bjdOjuwSPnFGWlAtIPHGuRaHhgtp7ehEv1PcP 5PMIlZEBF1PntZc2xKpFnp8y4uH9H5cjhPFFkRueW/bo8w0/suV1+xaTnK5TmLN9b2Xiie XYx6Rl0mu2reuW1Qd2nK6oYOr64OBiBEG8VEwv+hUwk78ylGqU3u9bppN7w2e5FGT9eGrg uHNMbNHJ3i+yfuctR/xKMiN9/3crKmepHI6k4WxIx75tQD40d4c8h1qsiakCyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668599273; a=rsa-sha256; cv=none; b=fPLpGJIm40NJhjPjujef6j5rCLs3sZxkFoYfwXBQyls/BK1oXpDpZ2peL7Z9S33l7HhT23 Nql72sO3qjqvaKfChi39zN7+Sf03M/3YfugxWPFN4/LN9JZWgEGrScmT/utixES/QfkZ1L 01Zoio/6ZqCDeKCgaSkUZmGDVu3CjG/Hm1G1XkeWlJSS+uHGQ+KZKv+zsR5kQ+hPh4MTEa Ic/y9kGcdeYBMECVrGKXtY8ugx/jTIwCi/4tgfUpPZxUzGZplv9W+Zm3Ub1cGLfAcAlGGJ ptM+V3+R7xlx+h/J96mHvIT5tqf+Aispcbh4UKBTLcbPdp3isuaJC/Yf6eOGIw== 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 4NC1WY4kTMz11Gr; Wed, 16 Nov 2022 11:47:53 +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 2AGBlrgr066373; Wed, 16 Nov 2022 11:47:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AGBlrbB066372; Wed, 16 Nov 2022 11:47:53 GMT (envelope-from git) Date: Wed, 16 Nov 2022 11:47:53 GMT Message-Id: <202211161147.2AGBlrbB066372@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 2fb0f352b977 - main - bhyve: add basl support for common table header 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: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2fb0f352b977aeb34650081e51454b0b637c5ace Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=2fb0f352b977aeb34650081e51454b0b637c5ace commit 2fb0f352b977aeb34650081e51454b0b637c5ace Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:40 +0000 Commit: Corvin Köhne CommitDate: 2022-11-16 11:42:19 +0000 bhyve: add basl support for common table header Most ACPI tables are using the same header. Make it easy to create this header by creating a function for it. Reviewed by: jhb, markj (older version) Approved by: manu (mentor) MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36992 --- usr.sbin/bhyve/basl.c | 36 ++++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/basl.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c index 1da0a7028f57..e8724b857381 100644 --- a/usr.sbin/bhyve/basl.c +++ b/usr.sbin/bhyve/basl.c @@ -446,6 +446,42 @@ basl_table_append_gas(struct basl_table *const table, const uint8_t space_id, return (basl_table_append_bytes(table, &gas_le, sizeof(gas_le))); } +int +basl_table_append_header(struct basl_table *const table, + const uint8_t signature[ACPI_NAMESEG_SIZE], const uint8_t revision, + const uint32_t oem_revision) +{ + ACPI_TABLE_HEADER header_le; + /* + 1 is required for the null terminator */ + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1]; + + assert(table != NULL); + assert(table->len == 0); + + memcpy(header_le.Signature, signature, ACPI_NAMESEG_SIZE); + header_le.Length = 0; /* patched by basl_finish */ + header_le.Revision = revision; + header_le.Checksum = 0; /* patched by basl_finish */ + memcpy(header_le.OemId, "BHYVE ", ACPI_OEM_ID_SIZE); + snprintf(oem_table_id, ACPI_OEM_TABLE_ID_SIZE, "BV%.4s ", signature); + memcpy(header_le.OemTableId, oem_table_id, + sizeof(header_le.OemTableId)); + header_le.OemRevision = htole32(oem_revision); + memcpy(header_le.AslCompilerId, "BASL", ACPI_NAMESEG_SIZE); + header_le.AslCompilerRevision = htole32(0x20220504); + + BASL_EXEC( + basl_table_append_bytes(table, &header_le, sizeof(header_le))); + + BASL_EXEC(basl_table_add_length(table, + offsetof(ACPI_TABLE_HEADER, Length), sizeof(header_le.Length))); + BASL_EXEC(basl_table_add_checksum(table, + offsetof(ACPI_TABLE_HEADER, Checksum), 0, + BASL_TABLE_CHECKSUM_LEN_FULL_TABLE)); + + return (0); +} + int basl_table_append_int(struct basl_table *const table, const uint64_t val, const uint8_t size) diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h index 978b2722acf9..aab4a16a63f5 100644 --- a/usr.sbin/bhyve/basl.h +++ b/usr.sbin/bhyve/basl.h @@ -46,6 +46,9 @@ int basl_table_append_checksum(struct basl_table *table, uint32_t start, int basl_table_append_gas(struct basl_table *table, uint8_t space_id, uint8_t bit_width, uint8_t bit_offset, uint8_t access_width, uint64_t address); +int basl_table_append_header(struct basl_table *table, + const uint8_t signature[ACPI_NAMESEG_SIZE], uint8_t revision, + uint32_t oem_revision); int basl_table_append_int(struct basl_table *table, uint64_t val, uint8_t size); int basl_table_append_length(struct basl_table *table, uint8_t size); int basl_table_append_pointer(struct basl_table *table,