From nobody Fri Mar 29 05:03:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96521+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96521+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1669065680; cv=none; d=zohomail.com; s=zohoarc; b=BZ4aC7E6c/iHIdIBXppxTFVgTWSMzdKJlFx8yaVGkZSZKEzq4cnZT1lMLBkxjHGHfmUDkxiAJXsGnt5tgh8Cob0L5hzCnyxvFlBt2mlV87KgpJ75yd2RICLpBA0RM/o38vbbMkfnvEg52ZP3nRkaRmVW1Webqco4j6iMZC8+nic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669065680; h=Content-Type:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=XdKQgaqUP+fxq41pNEn3tVfZmKrAX8MIOSkF4BQyMLQ=; b=LXXaeaNiV1g/lDX+UpIz81DCEw3XPaSrEynB+OmiNMLkgvDnukPaaxBNEkRVM0sD76i2ybc3IoZWtE6kWEcTTvwEvW7WJEs2cXel/+i/4eyjEd70wHBcgApHJKO6YMhX2IjseJUuk4ty8RMQuFFnTB/m3c6rWHKHhkBApf/HMAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96521+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1669065680270331.4403804959991; Mon, 21 Nov 2022 13:21:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id kuQBYY1788612xKVGcyjxPkt; Mon, 21 Nov 2022 13:21:19 -0800 X-Received: from smtp26.services.sfr.fr (smtp26.services.sfr.fr [93.17.128.204]) by mx.groups.io with SMTP id smtpd.web11.37823.1669036105988782079 for ; Mon, 21 Nov 2022 05:08:26 -0800 X-mail-filterd: {"version":"1.5.3","queueID":"4NG7476ZCZz1LQLxk","contextId": "72e1ccc5-c77b-4c2a-a602-f79d84ac5620"} X-Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) by msfrf2624.sfr.fr (SMTP Server) with ESMTP id 4NG7476ZCZz1LQLxk for ; Mon, 21 Nov 2022 14:08:23 +0100 (CET) X-mail-filterd: {"version":"1.5.3","queueID":"4NG73y5LHBz1LQLxt","contextId": "e0f684c2-d724-4a65-85c3-39a3d89f2cfd"} X-sfr-mailing: LEGIT X-sfr-spamrating: 40 X-sfr-spam: not-spam X-Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: thierry.laronde@sfr.fr) by msfrf2624.sfr.fr (SMTP Server) with ESMTPSA id 4NG73y5LHBz1LQLxt for ; Mon, 21 Nov 2022 14:08:14 +0100 (CET) X-Received: from cauchy.polynum.local (localhost [127.0.0.1]) by cauchy.polynum.local (8.15.2/8.15.2) with ESMTP id 2ALD8CFU001514 for ; Mon, 21 Nov 2022 14:08:12 +0100 (CET) X-Received: (from tlaronde@localhost) by cauchy.polynum.local (8.15.2/8.14.9/Submit) id 2ALD8C6p001100 for devel@edk2.groups.io; Mon, 21 Nov 2022 14:08:12 +0100 (CET) X-Authentication-Warning: cauchy.polynum.local: tlaronde set sender to thierry.laronde@sfr.fr using -f Date: Mon, 21 Nov 2022 14:08:12 +0100 From: tlaronde@polynum.com To: devel@edk2.groups.io Subject: [edk2-devel] EmulatorPkg: fixes for NetBSD compilation Message-ID: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tlaronde@polynum.com X-Gm-Message-State: 52nsIzWvs8SOMT56YYhtdRVkx1787277AA= Content-Disposition: inline DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1669065679; bh=NqTijM1ITuXzAZdxJ+3R9h/eivUF5BTZ0JtPRNUfK3U=; h=Content-Type:Date:From:Reply-To:Subject:To; b=NP0U3ExKpJiNiSnQ+0gCsq1pGBrkF2VX+e85liw7AKHcT1L7dwbzr1TOM/mKkl30EWk WXGLSJm80EyL+jpXkoaQocnd/WloGUWuykDW/O7d5S8FJGPQy6XPnTBiX9XVylTLovG0p 34aLJHjmmmrJ7Aj5+b+zOKDq9/ZRstAiFto= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1669065681940100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" diff --git a/EmulatorPkg/Unix/Host/BlockIo.c b/EmulatorPkg/Unix/Host/BlockI= o.c index cf2d6b4cda..c0c694be55 100644 --- a/EmulatorPkg/Unix/Host/BlockIo.c +++ b/EmulatorPkg/Unix/Host/BlockIo.c @@ -133,6 +133,20 @@ EmuBlockIoOpenDevice ( =20 ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE, &Private->Media->Opt= imalTransferLengthGranularity); } + #elif _NETBSD_SOURCE + { + u_int BlockSize; + off_t DiskSize; + + if (ioctl (Private->fd, DIOCGSECTORSIZE, &BlockSize) =3D=3D 0) { + Private->Media->BlockSize =3D BlockSize; + } + + if (ioctl (Private->fd, DIOCGMEDIASIZE, &DiskSize) =3D=3D 0) { + Private->NumberOfBlocks =3D DivU64x32 (DiskSize, (UINT32)BlockSi= ze); + Private->Media->LastBlock =3D Private->NumberOfBlocks - 1; + } + } #else { size_t BlockSize; @@ -154,7 +168,7 @@ EmuBlockIoOpenDevice ( Private->Media->LastBlock =3D Private->NumberOfBlocks - 1; =20 if (fstatfs (Private->fd, &buf) =3D=3D 0) { - #if __APPLE__ + #if __APPLE__ || _NETBSD_SOURCE Private->Media->OptimalTransferLengthGranularity =3D buf.f_iosize/bu= f.f_bsize; #else Private->Media->OptimalTransferLengthGranularity =3D buf.f_bsize/buf= .f_bsize; diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c index 38c01c84af..c505300129 100644 --- a/EmulatorPkg/Unix/Host/Host.c +++ b/EmulatorPkg/Unix/Host/Host.c @@ -12,6 +12,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define MAP_ANONYMOUS MAP_ANON #endif =20 +#ifdef _NETBSD_SOURCE +#define MAP_ANON_FD_ (-1) +#else +#define MAP_ANON_FD_ (0) +#endif + // // Globals // @@ -187,7 +193,7 @@ main ( // InitialStackMemorySize =3D STACK_SIZE; InitialStackMemory =3D (UINTN)MapMemory ( - 0, + MAP_ANON_FD_, (UINT32)InitialStackMemorySize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE @@ -348,6 +354,7 @@ MapMemory ( while ((!isAligned) && (base !=3D 0)) { res =3D mmap ((void *)base, length, prot, flags, fd, 0); if (res =3D=3D MAP_FAILED) { + perror("MapMemory"); return NULL; } =20 @@ -640,7 +647,7 @@ SecUnixPeiAutoScan ( =20 *MemoryBase =3D 0; res =3D MapMemory ( - 0, + MAP_ANON_FD_, gSystemMemory[Index].Size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS diff --git a/EmulatorPkg/Unix/Host/Host.h b/EmulatorPkg/Unix/Host/Host.h index 0c81cdfc01..0de925adaf 100644 --- a/EmulatorPkg/Unix/Host/Host.h +++ b/EmulatorPkg/Unix/Host/Host.h @@ -31,6 +31,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #if __CYGWIN__ #include +#elif _NETBSD_SOURCE + #include #else #include #endif @@ -55,7 +57,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 -#ifdef __APPLE__ +#if defined(__APPLE__) #include #include #include @@ -65,6 +67,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _Bool #define _Bool char // for clang debug #endif +#elif defined(_NETBSD_SOURCE) + #define statfs statvfs + #define fstatfs fstatvfs #else #include #include signed-off-by: Thierry LARONDE --=20 Thierry Laronde http://www.kergis.com/ http://kertex.kergis.com/ Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96521): https://edk2.groups.io/g/devel/message/96521 Mute This Topic: https://groups.io/mt/95182515/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-