From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp26.services.sfr.fr (smtp26.services.sfr.fr [93.17.128.192]) by mx.groups.io with SMTP id smtpd.web10.70.1673028067029544708 for ; Fri, 06 Jan 2023 10:01:07 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="no key for verify" header.i=@polynum.com header.s=202006 header.b=YuWjKcAI; spf=pass (domain: sfr.fr, ip: 93.17.128.192, mailfrom: thierry.laronde@sfr.fr) X-mail-filterd: {"version":"1.6.0","queueID":"4NpWNd1CMFz1LQKdZ","contextId": "9e8a81c8-1d68-42a0-856b-c8734a5d5874"} Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) by msfrf2606.sfr.fr (SMTP Server) with ESMTP id 4NpWNd1CMFz1LQKdZ; Fri, 6 Jan 2023 19:01:05 +0100 (CET) X-mail-filterd: {"version":"1.6.0","queueID":"4NpWNc46Swz1LQKdN","contextId": "18c141cb-3aac-4318-a07a-d42780b2de69"} X-sfr-mailing: LEGIT X-sfr-spamrating: 36 X-sfr-spam: not-spam DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=polynum.com; s=202006; t=1673028065; h=Date:From:To:Cc:Subject:References:In-Reply-To; bh=BMWfli8Mzj 6OU/ftwqFkWxduSxkA74LrVZhMKjtfY14=; b=YuWjKcAIjLfSIcz1e6wPwm6e1hY+QsbfeEtwWM nMawbeV+WihCbz+Utvwvgt7kwPwjJMHq05DQr//mGdqRw3WZQewzXo8/GHJPCFoBDFvBliH5kevY tsLGhuq+BRbsXpI2wnTRD/R60b+n9Mg2v5HF5vL2Lrhw4ZRl3CIdDaeKxC6bN0yeQ3hEgD2OVvQ8 XWO6wodrHiKrV8HfDVf3Vv8c2b5rQOip1jyziIbCnNe8EeU2Frsk4c6VCJjTrP9mgF3LzJbR4xXe 8z9HMzS8Cd6oaxi84OFAk1cLu2EsFvVuUtt25DUsJ1vp8l03Vb+crtxyaQxpxTtqtuqhbKm/b4FA == 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 msfrf2606.sfr.fr (SMTP Server) with ESMTPSA id 4NpWNc46Swz1LQKdN; Fri, 6 Jan 2023 19:01:04 +0100 (CET) Authentication-Results: sfr.fr; auth=pass (LOGIN) smtp.auth=thierry.laronde@sfr.fr Received: from cauchy.polynum.local (localhost [127.0.0.1]) by cauchy.polynum.local (8.15.2/8.15.2) with ESMTP id 306I12R0000431; Fri, 6 Jan 2023 19:01:02 +0100 (CET) Received: (from tlaronde@localhost) by cauchy.polynum.local (8.15.2/8.14.9/Submit) id 306I12en000590; Fri, 6 Jan 2023 19:01:02 +0100 (CET) X-Authentication-Warning: cauchy.polynum.local: tlaronde set sender to thierry.laronde@sfr.fr using -f Date: Fri, 6 Jan 2023 19:01:02 +0100 From: tlaronde@polynum.com To: Pedro Falcato Cc: devel@edk2.groups.io, Andrew Fish , Ray Ni Subject: Re: PING [PATCH 1/1 v2] EmulatorPkg: fixes for NetBSD Message-ID: References: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Le Thu, Jan 05, 2023 at 11:40:43PM +0000, Pedro Falcato a =E9crit : > On Thu, Jan 5, 2023 at 11:50 AM wrote: >=20 > > 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 =3D 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40= C > > > > > > > > ---------- 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) =3D=3D 0= ) { > > + Private->Media->BlockSize =3D BlockSize; > > + } > > + > > + if (ioctl (Private->fd, DIOCGMEDIASIZE, &DiskSize) =3D=3D 0) { > > + Private->NumberOfBlocks =3D DivU64x32 (DiskSize, > > (UINT32)BlockSize); > > + Private->Media->LastBlock =3D Private->NumberOfBlocks - 1; > > + } > > + } > > #else > > { > > size_t BlockSize; > > @@ -154,7 +168,7 @@ EmuBlockIoOpenDevice ( > > Private->Media->LastBlock =3D Private->NumberOfBlocks - 1; > > > > if (fstatfs (Private->fd, &buf) =3D=3D 0) { > > - #if __APPLE__ > > + #if __APPLE__ || _NETBSD_SOURCE > > > Isn't this the wrong test? Shouldn't you test for __NetBSD__ instead? A= IUI > _NETBSD_SOURCE is just a feature test macro like _GNU_SOURCE, right? You're right: I was focusing on "not POSIXly defined" and grapping to a featuretest macro at the same level. __NetBSD__ will do. >=20 > > Private->Media->OptimalTransferLengthGranularity =3D > > buf.f_iosize/buf.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/Hos= t.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 >=20 OK. I will suppress the macro and go to a comment. > > + > > // > > // Globals > > // > > @@ -187,7 +189,7 @@ main ( > > // > > InitialStackMemorySize =3D STACK_SIZE; > > InitialStackMemory =3D (UINTN)MapMemory ( > > - 0, > > + MAP_ANON_FD_, > > (UINT32)InitialStackMemorySize, > > PROT_READ | PROT_WRITE | PROT_EX= EC, > > MAP_ANONYMOUS | MAP_PRIVATE > > @@ -348,6 +350,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; > > } > > > > @@ -640,7 +643,7 @@ SecUnixPeiAutoScan ( > > > > *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/Hos= t.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. >=20 > > + #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 > > >=20 > I can give you my Ack or RB after this, but FWIW I'm not a maintainer f= or > EmulatorPkg so you'll still need appropriate reviews from the package > mainainers. OK. Thanks! I will prepare a v3 and let the maintainers decide. Best, --=20 Thierry Laronde http://www.kergis.com/ http://kertex.kergis.com/ Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C