From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mx.groups.io with SMTP id smtpd.web11.860.1672962054993218029 for ; Thu, 05 Jan 2023 15:40:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F/bnBm5L; spf=pass (domain: gmail.com, ip: 209.85.210.169, mailfrom: pedro.falcato@gmail.com) Received: by mail-pf1-f169.google.com with SMTP id w203so9885477pfc.12 for ; Thu, 05 Jan 2023 15:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XL7IfxXvkMIb9BPFy0A32PN+mW83eoShb+27VB7XP4Q=; b=F/bnBm5LXM+4wwk6J8xfV3zUuOVV80cH4wXRu+zmorNb3E2rNwmk+Ya8dzsewYZ6iP Ae62QSBbZrSA6TYdPo0OlnCj+l0U61jbCp/DhBrzGM728RCJS1Brk0/F5U9Bsipuf7Oa ELblASGqREkaW67TpBLl3qVjY0nM349DdWxJ70gTx3vYLbgwh6hVqxphPzRszDUYaUnb /u9eo6yuZ5hqhY5SQ1Dm1nieS7cEfOJZiN5Sjkg03eLZVLnKTZI6rjN3HCjR6kLV5weo Z3/BlJ6eD5tNpA2nWitQ597e/9/vPEgeXmdqZVtqmGtLu0nJkBGWJ5/Tc6rTfxbbq+IT keJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XL7IfxXvkMIb9BPFy0A32PN+mW83eoShb+27VB7XP4Q=; b=T2hZdbfxD7GrcyrcGgGm4pAQipIAHXT2CrniY78TkampXScZYLS+F9vMkgKyfFX24s P+zrgokfVCAPERT/6jnaYzEd/QzAw1J/8zFPW+tgx84l7cysNmLVZ0W67KDeiUZFfHGp UUJKOVVQPRFeP1giNdWrJd3qsnJHDXR9aFk34qD9XuhSF5PvZkdpvXj/C46/s0T91Uly XLLFRosuJvv2xJ98SNAZj75gPjAaBMoceM/1efIlLhHEQck5zKsSIm9dIPhGOScZeHmY C8LJKEjRtXMAAVYjHsY1JFH2bT6IXTgjFrrmiSAh/rIqhIgT/r5r9u++Zc2vFHDLgNhO rbIA== X-Gm-Message-State: AFqh2kp0IlaOHx4GlGQyPEDmdNH4RylKGO9n72imWsjYvksWk0E7a4+q 1XI4xiHArPuOYjMygts+JJNcwkWoxX2LYmYw0bw= X-Google-Smtp-Source: AMrXdXuVGywQXIgKS8eh9S0DAnRR7aLyL6utSBHhpX5ZegjVDACWQIlmFWPLD0PDST7Oc0ioB+++nwMaCAUfv19uMlA= X-Received: by 2002:a63:ee0f:0:b0:4a5:c88:55c2 with SMTP id e15-20020a63ee0f000000b004a50c8855c2mr617113pgi.530.1672962054210; Thu, 05 Jan 2023 15:40:54 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Pedro Falcato" Date: Thu, 5 Jan 2023 23:40:43 +0000 Message-ID: Subject: Re: PING [PATCH 1/1 v2] EmulatorPkg: fixes for NetBSD To: tlaronde@polynum.com Cc: devel@edk2.groups.io, Andrew Fish , Ray Ni Content-Type: multipart/alternative; boundary="000000000000f6cb7405f18cd45d" --000000000000f6cb7405f18cd45d Content-Type: text/plain; charset="UTF-8" On Thu, Jan 5, 2023 at 11:50 AM wrote: > Hello, > > Ping'ing for this patch sent on November 2022. > > The patch is trivial. Can someone review it or eventually merge it if OK? > > TIA, > -- > Thierry Laronde > http://www.kergis.com/ > http://kertex.kergis.com/ > Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C > > > > ---------- Forwarded message ---------- > From: tlaronde@polynum.com > To: devel@edk2.groups.io > Cc: Andrew Fish , Ray Ni , Pedro > Falcato > Bcc: > Date: Thu, 24 Nov 2022 15:46:59 +0100 > Subject: [edk2-devel] [PATCH 1/1 v2] EmulatorPkg: fixes for NetBSD > Signed-off-by: Thierry Laronde > > Fixes for compilation on NetBSD. > > --- > EmulatorPkg/Unix/Host/BlockIo.c | 16 +++++++++++++++- > EmulatorPkg/Unix/Host/Host.c | 7 +++++-- > EmulatorPkg/Unix/Host/Host.h | 7 ++++++- > 3 files changed, 26 insertions(+), 4 deletions(-) > > diff --git a/EmulatorPkg/Unix/Host/BlockIo.c > b/EmulatorPkg/Unix/Host/BlockIo.c > index cf2d6b4cda..57b4c8d3be 100644 > --- a/EmulatorPkg/Unix/Host/BlockIo.c > +++ b/EmulatorPkg/Unix/Host/BlockIo.c > @@ -133,6 +133,20 @@ EmuBlockIoOpenDevice ( > > ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE, > &Private->Media->OptimalTransferLengthGranularity); > } > + #elif _NETBSD_SOURCE > + { > + UINTN BlockSize; > + off_t DiskSize; > + > + if (ioctl (Private->fd, DIOCGSECTORSIZE, &BlockSize) == 0) { > + Private->Media->BlockSize = BlockSize; > + } > + > + if (ioctl (Private->fd, DIOCGMEDIASIZE, &DiskSize) == 0) { > + Private->NumberOfBlocks = DivU64x32 (DiskSize, > (UINT32)BlockSize); > + Private->Media->LastBlock = Private->NumberOfBlocks - 1; > + } > + } > #else > { > size_t BlockSize; > @@ -154,7 +168,7 @@ EmuBlockIoOpenDevice ( > Private->Media->LastBlock = Private->NumberOfBlocks - 1; > > if (fstatfs (Private->fd, &buf) == 0) { > - #if __APPLE__ > + #if __APPLE__ || _NETBSD_SOURCE > Isn't this the wrong test? Shouldn't you test for __NetBSD__ instead? AIUI _NETBSD_SOURCE is just a feature test macro like _GNU_SOURCE, right? > Private->Media->OptimalTransferLengthGranularity = > buf.f_iosize/buf.f_bsize; > #else > Private->Media->OptimalTransferLengthGranularity = > buf.f_bsize/buf.f_bsize; > diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c > index 38c01c84af..1700a4b60f 100644 > --- a/EmulatorPkg/Unix/Host/Host.c > +++ b/EmulatorPkg/Unix/Host/Host.c > @@ -12,6 +12,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #define MAP_ANONYMOUS MAP_ANON > #endif > > +#define MAP_ANON_FD_ (-1) > Again, I don't think you need a define for this. At most you could just stick a -1 down there with a comment like: // We're required to pass -1 for anonymous mappings on BSD-like systems > + > // > // Globals > // > @@ -187,7 +189,7 @@ main ( > // > InitialStackMemorySize = STACK_SIZE; > InitialStackMemory = (UINTN)MapMemory ( > - 0, > + MAP_ANON_FD_, > (UINT32)InitialStackMemorySize, > PROT_READ | PROT_WRITE | PROT_EXEC, > MAP_ANONYMOUS | MAP_PRIVATE > @@ -348,6 +350,7 @@ MapMemory ( > while ((!isAligned) && (base != 0)) { > res = mmap ((void *)base, length, prot, flags, fd, 0); > if (res == MAP_FAILED) { > + perror("MapMemory"); > return NULL; > } > > @@ -640,7 +643,7 @@ SecUnixPeiAutoScan ( > > *MemoryBase = 0; > res = 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 > > #if __CYGWIN__ > #include > +#elif _NETBSD_SOURCE > Same as above. > + #include > #else > #include > #endif > @@ -55,7 +57,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #include > #include > > -#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 > -- > 2.34.1 > > -- > Thierry Laronde > http://www.kergis.com/ > http://kertex.kergis.com/ > Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C > I can give you my Ack or RB after this, but FWIW I'm not a maintainer for EmulatorPkg so you'll still need appropriate reviews from the package mainainers. -- Pedro --000000000000f6cb7405f18cd45d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Jan 5, 2023 at 11:50 AM <tlaronde@polynum.com> wrote:
Hello,

Ping'ing for this patch sent on November 2022.

The patch is trivial. Can someone review it or eventually merge it if OK?
TIA,
--
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Thierry Laronde <tlaronde +AT+ polynum +dot+= com>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0= http://www.kergis.com/
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http:= //kertex.kergis.com/
Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89=C2=A0 250D 52B1 AE95 6006 F40C=



---------- Forwarded message ----------
From:=C2=A0tlaronde@polynum.com=
To:=C2=A0deve= l@edk2.groups.io
Cc:=C2=A0Andrew Fish <afish@apple.com>, Ray Ni <ray.ni@intel.com>, Pedro F= alcato <ped= ro.falcato@gmail.com>
Bcc:=C2=A0
Date:=C2=A0Thu, 24 Nov 2022 1= 5:46:59 +0100
Subject:=C2=A0[edk2-devel] [PATCH 1/1 v2] EmulatorPkg: fix= es for NetBSD
Signed-off-by: Thierry Laronde <tlaronde@polynum.com>

Fixes for compilation on NetBSD.

---
=C2=A0EmulatorPkg/Unix/Host/BlockIo.c | 16 +++++++++++++++-
=C2=A0EmulatorPkg/Unix/Host/Host.c=C2=A0 =C2=A0 |=C2=A0 7 +++++--
=C2=A0EmulatorPkg/Unix/Host/Host.h=C2=A0 =C2=A0 |=C2=A0 7 ++++++-
=C2=A03 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/EmulatorPkg/Unix/Host/BlockIo.c b/EmulatorPkg/Unix/Host/BlockI= o.c
index cf2d6b4cda..57b4c8d3be 100644
--- a/EmulatorPkg/Unix/Host/BlockIo.c
+++ b/EmulatorPkg/Unix/Host/BlockIo.c
@@ -133,6 +133,20 @@ EmuBlockIoOpenDevice (

=C2=A0 =C2=A0 =C2=A0 =C2=A0ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRIT= E, &Private->Media->OptimalTransferLengthGranularity);
=C2=A0 =C2=A0 =C2=A0}
+ #elif _NETBSD_SOURCE
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 UINTN=C2=A0 BlockSize;
+=C2=A0 =C2=A0 =C2=A0 off_t=C2=A0 DiskSize;
+
+=C2=A0 =C2=A0 =C2=A0 if (ioctl (Private->fd,=C2=A0 DIOCGSECTORSIZE, &am= p;BlockSize) =3D=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Private->Media->BlockSize =3D BlockSize;=
+=C2=A0 =C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 =C2=A0 if (ioctl (Private->fd, DIOCGMEDIASIZE, &DiskS= ize) =3D=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Private->NumberOfBlocks=C2=A0 =C2=A0=3D Div= U64x32 (DiskSize, (UINT32)BlockSize);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Private->Media->LastBlock =3D Private-&g= t;NumberOfBlocks - 1;
+=C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 }
=C2=A0 #else
=C2=A0 =C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0size_t=C2=A0 BlockSize;
@@ -154,7 +168,7 @@ EmuBlockIoOpenDevice (
=C2=A0 =C2=A0 =C2=A0Private->Media->LastBlock =3D Private->NumberO= fBlocks - 1;

=C2=A0 =C2=A0 =C2=A0if (fstatfs (Private->fd, &buf) =3D=3D 0) {
- #if __APPLE__
+ #if __APPLE__ || _NETBSD_SOURCE
Isn't this the w= rong test? Shouldn't you test for __NetBSD__ instead? AIUI _NETBSD_SOUR= CE is just a feature test macro like _GNU_SOURCE, right?
=C2=A0 =C2=A0 =C2=A0 =C2=A0Private->Media->OptimalTransferLengthGranu= larity =3D buf.f_iosize/buf.f_bsize;
=C2=A0 #else
=C2=A0 =C2=A0 =C2=A0 =C2=A0Private->Media->OptimalTransferLengthGranu= larity =3D buf.f_bsize/buf.f_bsize;
diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c index 38c01c84af..1700a4b60f 100644
--- a/EmulatorPkg/Unix/Host/Host.c
+++ b/EmulatorPkg/Unix/Host/Host.c
@@ -12,6 +12,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#define MAP_ANONYMOUS=C2=A0 MAP_ANON
=C2=A0#endif

+#define MAP_ANON_FD_ (-1)
Again, I don't think yo= u need a define for this. At most you could just stick a -1 down there with= a comment like:
// We're required to pass -1 for anonymous m= appings on BSD-like systems
+
=C2=A0//
=C2=A0// Globals
=C2=A0//
@@ -187,7 +189,7 @@ main (
=C2=A0 =C2=A0//
=C2=A0 =C2=A0InitialStackMemorySize =3D STACK_SIZE;
=C2=A0 =C2=A0InitialStackMemory=C2=A0 =C2=A0 =C2=A0=3D (UINTN)MapMemory ( -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MAP_ANON_FD_,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(UINT32)InitialS= tackMemorySize,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0PROT_READ | PROT= _WRITE | PROT_EXEC,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0MAP_ANONYMOUS | = MAP_PRIVATE
@@ -348,6 +350,7 @@ MapMemory (
=C2=A0 =C2=A0while ((!isAligned) && (base !=3D 0)) {
=C2=A0 =C2=A0 =C2=A0res =3D mmap ((void *)base, length, prot, flags, fd, 0)= ;
=C2=A0 =C2=A0 =C2=A0if (res =3D=3D MAP_FAILED) {
+=C2=A0 =C2=A0 =C2=A0 perror("MapMemory");
=C2=A0 =C2=A0 =C2=A0 =C2=A0return NULL;
=C2=A0 =C2=A0 =C2=A0}

@@ -640,7 +643,7 @@ SecUnixPeiAutoScan (

=C2=A0 =C2=A0*MemoryBase =3D 0;
=C2=A0 =C2=A0res=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D MapMemory (
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MAP_ANON_FD= _,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0gSyste= mMemory[Index].Size,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0PROT_R= EAD | PROT_WRITE | PROT_EXEC,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0MAP_PR= IVATE | 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

=C2=A0#if __CYGWIN__
=C2=A0 =C2=A0#include <sys/dirent.h>
+#elif _NETBSD_SOURCE
Same as above.
+=C2=A0 #include <dirent.h>
=C2=A0#else
=C2=A0 =C2=A0#include <sys/dir.h>
=C2=A0#endif
@@ -55,7 +57,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#include <net/if.h>
=C2=A0#include <ifaddrs.h>

-#ifdef __APPLE__
+#if defined(__APPLE__)
=C2=A0 =C2=A0#include <net/if_dl.h>
=C2=A0 =C2=A0#include <net/bpf.h>
=C2=A0 =C2=A0#include <sys/param.h>
@@ -65,6 +67,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0 =C2=A0#ifndef _Bool
=C2=A0#define _Bool=C2=A0 char=C2=A0 // for clang debug
=C2=A0 =C2=A0#endif
+#elif defined(_NETBSD_SOURCE)
+=C2=A0 #define statfs statvfs
+=C2=A0 #define fstatfs fstatvfs
=C2=A0#else
=C2=A0 =C2=A0#include <termio.h>
=C2=A0 =C2=A0#include <sys/vfs.h>
--
2.34.1

--
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Thierry Laronde <tlaronde +AT+ polynum +dot+= com>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0= http://www.kergis.com/
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http:= //kertex.kergis.com/
Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89=C2=A0 250D 52B1 AE95 6006 F40C=

I can give you my Ack or RB after this= , but FWIW I'm not a maintainer for EmulatorPkg so you'll still nee= d appropriate reviews from the package mainainers.

--
Pedro
--000000000000f6cb7405f18cd45d--