Date   

Re: TianoCore Community Meeting 20220407 EMEA/NAMO

Kevin@Insyde
 

Miki,

I’m not able to subscribe to https://edk2.groups.io/g/devel/calendar

Do you know if that’s a groups.io problem or a me problem?

Kevin D Davis
Security Strategist
Insyde Software
Phone: 503-310-2222

On Apr 7, 2022, at 9:42 AM, Demeter, Miki via groups.io <miki.demeter@...> wrote:



TianoCore Community Meeting

 

 

**Highlights:**

- GSOC Need Additional Primary Mentors???

- Bugzilla Status update – Devs still need to update status (ongoing issue)

- UEFI Summit switched to Virtual only

- Question to the community Concerns about additional dependencies?

 

# Meeting Minutes:

 

1) **Event Updates (_5 minutes]**

- **UEFI Summit switched to Virtual only**

 

2) [**Stable Tag Updates (_5 minutes_)**

- Soft Freeze - 2022-

- Hard freeze - 2022-

- 2022- Release 

 -** Stable Tag 20220225 released **

 

3) **Stewards Download (_20 minutes_)**

-**Coverity Status**

-- No Updates

- Raised topic number of dependencies on external services (git sub-modules, tools VS, iasm, nasm, Python, pip module)

-- CI tools (spell check has a dependency on node package manager)

-- Stewards responsible to validate whether new dependencies are appropriate.

-- Developer helper tools (don’t affect CI builds)

-- Question to the community Concerns about additional dependencies

 

 

-** Bugzilla Status **

- Still Need developers to update issues Bug Scrubs working through issues

 

 

4) **Opens (_30 minutes_)**

- Brian Johnson concerned about the way build system has become too complex need to simplify, possibly a docker image to help

-- git submodules are complex and not well liked

- Rebecka helping Andrew to get the GDB scripts rebased and checked in waiting on a few more reviews.

- Rajnish – A way to run CI/CD Locally - https://github.com/tianocore/edk2/tree/master/.pytool#running-ci-locally

 

**AR: Miki reach out to Nate(GSOC) and Felix (Coverity)**

**AR: Forward info on UEFI Summit-  brian.johnson@..., Rajnish.s.chauhan@... **

 

Next meeting will be back on the on the first Thursday of the month.

 

 

-- 

Miki Demeter (she/her)

Security Researcher

IPAS GO

Intel Corporation

 

Portland Women in Tech Best Speaker 2019

miki.demeter@...

 


Re: [PATCH v2] OvmfPkg/BhyveBhfPkg: add support for QemuFwCfg

Peter Grehan
 

On 4/7/22 3:24 PM, Corvin Köhne wrote:
Hi Peter and Rebecca,
thanks for your feedback. This patch is backward compatible. It checks
if QemuFwCfg is available and if QemuFwCfg is missing it falls
back to BhyveFwCtl.
So, should I add Reviewed-by (or Acked-by?) Peter and Rebecca to the
commit message?
Acked-by: Peter Grehan <grehan@...>


Re: Intel NUC platform firmware -- no serial I/O support?

Nate DeSimone
 

Hi Laszlo,

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Laszlo
Ersek
Sent: Thursday, April 7, 2022 12:46 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: r, ramesh <rameshr@...>; Sivaraman Nainar
<sivaramann@...>; KARPAGAVINAYAGAM, MANICKAVASAKAM
<manickavasakamk@...>
Subject: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?

Hi List,

my toolbox has been extended with an Intel NUC, the base kit model being
NUC8i3PNH. The NUC has a serial port connector on the back, and indeed
Serial I/O works fine once an OS starts.

However, the UEFI platform firmware seems to have no support for Serial
I/O. I've built a fresh UEFI Shell binary from edk2 master and poked around in
the protocol database, with "drivers" and "dh". The necessary drivers seem
to be included, however they do not appear to bind the hardware that's
inside the chassis. ("connect -r" makes no difference in this regard, so it's not
just BDS policy.)
Yeah you are right the Super I/O stuff is barrels of fun. However it is actually a spec defined protocol, it is just in the PI spec not the UEFI spec. The PI spec also counts for addition to MdePkg. On the MinPlatform side we built a small/simple Super I/O bus driver for UARTs and PS/2 keyboard/mouse: https://github.com/tianocore/edk2-platforms/tree/master/Platform/Intel/BoardModulePkg/LegacySioDxe

Volume 5, Chapter 14 of the PI spec waxes rather poetic about how to build a full ISA plug-and-play capable DXE driver stack for a system that incorporates both a Super I/O and physical ISA slots.

I can say is that the NUC team has opted to build their systems with AMI Aptio instead of starting with the Intel reference UEFI firmware. I'm not privy to the conversation there. Accordingly, there might be some Aptio specific drivers as you note in your listing of the driver handle database. I'm afraid I have as much knowledge about how that driver stack works as you do.

Thanks,
Nate

Interestingly, the related drivers are all called "AMI ...", which I find
somewhat strange on an Intel-branded NUC. I don't know whom I should be
addressing with my question in the first place. Just to be sure, I'm CC'ing a
bunch of randomly picked @ami.com email addresses from my edk2-devel
list archive.

I can provide more details if needed, but first I'd like to ask if *any* firmware
update exists for this kit -- NUC8i3PNH -- where the platform firmware can
drive the serial port. My goal is (of course) completely headless operation of
the NUC; ideally, that would cover the UEFI console too.

Right now, I need to connect an HDMI monitor and a USB keyboard+mouse
to the NUC just to get into the Setup UI / UEFI Shell.

Thanks!
Laszlo





[PATCH 1/1] MdePkg/BaseLib: Add CRC16-ANSI and CRC32c implementations

Pedro Falcato
 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3871

Add the CRC16-ANSI and CRC32C implementations previously found at
Features/Ext4Pkg/Ext4Dxe/Crc{16,32c}.c to BaseLib.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>

Signed-off-by: Pedro Falcato <pedro.falcato@...>
---
MdePkg/Include/Library/BaseLib.h | 35 +++++++-
MdePkg/Library/BaseLib/CheckSum.c | 144 ++++++++++++++++++++++++++++++
2 files changed, 178 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index 6aa0d972186e..f365de9f74a0 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -4503,6 +4503,40 @@ CalculateCrc32 (
IN UINTN Length
);

+/**
+ Calculates the CRC16-ANSI checksum of the given buffer.
+
+ @param[in] Buffer Pointer to the buffer.
+ @param[in] Length Length of the buffer, in bytes.
+ @param[in] InitialValue Initial value of the CRC.
+
+ @return The CRC16-ANSI checksum.
+**/
+UINT16
+EFIAPI
+CalculateCrc16Ansi (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 InitialValue
+ );
+
+/**
+ Calculates the CRC32c checksum of the given buffer.
+
+ @param[in] Buffer Pointer to the buffer.
+ @param[in] Length Length of the buffer, in bytes.
+ @param[in] InitialValue Initial value of the CRC.
+
+ @return The CRC32c checksum.
+**/
+UINT32
+EFIAPI
+CalculateCrc32c (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 InitialValue
+ );
+
//
// Base Library CPU Functions
//
@@ -4512,7 +4546,6 @@ CalculateCrc32 (

@param Context1 Context1 parameter passed into SwitchStack().
@param Context2 Context2 parameter passed into SwitchStack().
-
**/
typedef
VOID
diff --git a/MdePkg/Library/BaseLib/CheckSum.c b/MdePkg/Library/BaseLib/CheckSum.c
index 28dee5ac6a15..b6a076573191 100644
--- a/MdePkg/Library/BaseLib/CheckSum.c
+++ b/MdePkg/Library/BaseLib/CheckSum.c
@@ -3,6 +3,7 @@
algorithm.

Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2022, Pedro Falcato. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -618,3 +619,146 @@ CalculateCrc32 (

return Crc ^ 0xffffffff;
}
+
+GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT16 mCrc16LookupTable[256] =
+{
+ 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
+ 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
+ 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
+ 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
+ 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
+ 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
+ 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
+ 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
+ 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
+ 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
+ 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
+ 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
+ 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
+ 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
+ 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
+ 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
+ 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
+ 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
+ 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
+ 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
+ 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
+ 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
+ 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
+ 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
+ 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
+ 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
+ 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
+ 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
+ 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
+ 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
+ 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
+ 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
+};
+
+/**
+ Calculates the CRC16-ANSI checksum of the given buffer.
+
+ @param[in] Buffer Pointer to the buffer.
+ @param[in] Length Length of the buffer, in bytes.
+ @param[in] InitialValue Initial value of the CRC.
+
+ @return The CRC16-ANSI checksum.
+**/
+UINT16
+EFIAPI
+CalculateCrc16Ansi (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 InitialValue
+ )
+{
+ CONST UINT8 *Buf;
+ UINT16 Crc;
+
+ Buf = Buffer;
+
+ Crc = ~InitialValue;
+
+ while (Length-- != 0) {
+ Crc = mCrc16LookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8);
+ }
+
+ return ~Crc;
+}
+
+GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT32 mCrc32cLookupTable[256] = {
+ 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c,
+ 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
+ 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c,
+ 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
+ 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc,
+ 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
+ 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512,
+ 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
+ 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad,
+ 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
+ 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf,
+ 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
+ 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f,
+ 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
+ 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f,
+ 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
+ 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e,
+ 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
+ 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e,
+ 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
+ 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de,
+ 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
+ 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4,
+ 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
+ 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b,
+ 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
+ 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5,
+ 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
+ 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975,
+ 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
+ 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905,
+ 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
+ 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8,
+ 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
+ 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8,
+ 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
+ 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78,
+ 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
+ 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6,
+ 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
+ 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69,
+ 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
+ 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351
+};
+
+/**
+ Calculates the CRC32c checksum of the given buffer.
+
+ @param[in] Buffer Pointer to the buffer.
+ @param[in] Length Length of the buffer, in bytes.
+ @param[in] InitialValue Initial value of the CRC.
+
+ @return The CRC32c checksum.
+**/
+UINT32
+EFIAPI
+CalculateCrc32c (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 InitialValue
+ )
+{
+ CONST UINT8 *Buf;
+ UINT32 Crc;
+
+ Buf = Buffer;
+ Crc = ~InitialValue;
+
+ while (Length-- != 0) {
+ Crc = mCrc32cLookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8);
+ }
+
+ return ~Crc;
+}
--
2.35.1


[PATCH edk2-platforms 2/3] Ext4Pkg: Format using uncrustify

Pedro Falcato
 

Previously, Ext4Pkg was formatted using uncrustify with an older config file.
Re-format it using the upstream edk2 uncrustify config file.

Cc: Leif Lindholm <leif@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Signed-off-by: Pedro Falcato <pedro.falcato@...>
---
Features/Ext4Pkg/Ext4Dxe/Collation.c | 4 +-
Features/Ext4Pkg/Ext4Dxe/Directory.c | 13 +-
Features/Ext4Pkg/Ext4Dxe/DiskUtil.c | 6 +-
Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 28 +-
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c | 95 +++----
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 365 ++++++++++++++------------
Features/Ext4Pkg/Ext4Dxe/Extents.c | 10 +-
Features/Ext4Pkg/Ext4Dxe/File.c | 19 +-
Features/Ext4Pkg/Ext4Dxe/Inode.c | 24 +-
Features/Ext4Pkg/Ext4Dxe/Partition.c | 12 +-
Features/Ext4Pkg/Ext4Dxe/Superblock.c | 13 +-
11 files changed, 316 insertions(+), 273 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Collation.c b/Features/Ext4Pkg/Ext4Dxe/Collation.c
index 510ab24ebdf3..91d172b1cb89 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Collation.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Collation.c
@@ -58,7 +58,7 @@ Ext4InitialiseUnicodeCollationInternal (
CHAR8 *BestLanguage;

Iso639Language = (BOOLEAN)(ProtocolGuid == &gEfiUnicodeCollationProtocolGuid);
- RetStatus = EFI_UNSUPPORTED;
+ RetStatus = EFI_UNSUPPORTED;
GetEfiGlobalVariable2 (VariableName, (VOID **)&Language, NULL);

Status = gBS->LocateHandleBuffer (
@@ -96,7 +96,7 @@ Ext4InitialiseUnicodeCollationInternal (
if (BestLanguage != NULL) {
FreePool (BestLanguage);
gUnicodeCollationInterface = Uci;
- RetStatus = EFI_SUCCESS;
+ RetStatus = EFI_SUCCESS;
break;
}
}
diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dxe/Directory.c
index 9e003ea43719..682f66ad5525 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Directory.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c
@@ -121,7 +121,7 @@ Ext4RetrieveDirent (

Off = 0;

- Inode = Directory->Inode;
+ Inode = Directory->Inode;
DirInoSize = EXT4_INODE_SIZE (Inode);

DivU64x32Remainder (DirInoSize, Partition->BlockSize, &BlockRemainder);
@@ -141,7 +141,7 @@ Ext4RetrieveDirent (
}

for (BlockOffset = 0; BlockOffset < Partition->BlockSize; ) {
- Entry = (EXT4_DIR_ENTRY *)(Buf + BlockOffset);
+ Entry = (EXT4_DIR_ENTRY *)(Buf + BlockOffset);
RemainingBlock = Partition->BlockSize - BlockOffset;
// Check if the minimum directory entry fits inside [BlockOffset, EndOfBlock]
if (RemainingBlock < EXT4_MIN_DIR_ENTRY_LEN) {
@@ -154,7 +154,7 @@ Ext4RetrieveDirent (
return EFI_VOLUME_CORRUPTED;
}

- if (Entry->name_len > RemainingBlock || Entry->rec_len > RemainingBlock) {
+ if ((Entry->name_len > RemainingBlock) || (Entry->rec_len > RemainingBlock)) {
// Corrupted filesystem
FreePool (Buf);
return EFI_VOLUME_CORRUPTED;
@@ -191,8 +191,9 @@ Ext4RetrieveDirent (
continue;
}

- if (Entry->name_len == StrLen (Name) &&
- !Ext4StrCmpInsensitive (DirentUcs2Name, (CHAR16 *)Name)) {
+ if ((Entry->name_len == StrLen (Name)) &&
+ !Ext4StrCmpInsensitive (DirentUcs2Name, (CHAR16 *)Name))
+ {
ToCopy = MIN (Entry->rec_len, sizeof (EXT4_DIR_ENTRY));

CopyMem (Result, Entry, ToCopy);
@@ -595,7 +596,7 @@ Ext4AddDentry (
**/
EXT4_DENTRY *
Ext4CreateDentry (
- IN CONST CHAR16 *Name,
+ IN CONST CHAR16 *Name,
IN OUT EXT4_DENTRY *Parent OPTIONAL
)
{
diff --git a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c b/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c
index da8120374772..32da35f7d9f5 100644
--- a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c
+++ b/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c
@@ -60,11 +60,11 @@ Ext4ReadBlocks (
// Check for overflow on the block -> byte conversions.
// Partition->BlockSize is never 0, so we don't need to check for that.

- if (Offset > DivU64x32 ((UINT64)- 1, Partition->BlockSize)) {
+ if (Offset > DivU64x32 ((UINT64)-1, Partition->BlockSize)) {
return EFI_INVALID_PARAMETER;
}

- if (Length > (UINTN)- 1/Partition->BlockSize) {
+ if (Length > (UINTN)-1/Partition->BlockSize) {
return EFI_INVALID_PARAMETER;
}

@@ -94,7 +94,7 @@ Ext4AllocAndReadBlocks (

Length = NumberBlocks * Partition->BlockSize;

- if (Length > (UINTN)- 1/Partition->BlockSize) {
+ if (Length > (UINTN)-1/Partition->BlockSize) {
return NULL;
}

diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
index 756b1bbe1087..5f812215fbb8 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
@@ -130,16 +130,16 @@

#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
-#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 // Unused
+#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004// Unused
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
-#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080 // Not implemented in ext4
+#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080// Not implemented in ext4
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
-#define EXT4_FEATURE_RO_COMPAT_REPLICA 0x0800 // Not used
+#define EXT4_FEATURE_RO_COMPAT_REPLICA 0x0800// Not used

// We explicitly don't recognise this, so we get read only.
#define EXT4_FEATURE_RO_COMPAT_READONLY 0x1000
@@ -149,7 +149,7 @@
* Absolutely needed features:
* 1) Every incompat, because we might want to mount root filesystems
* 2) Relevant RO_COMPATs(I'm not sure of what to do wrt quota, project)
-**/
+ **/

#define EXT4_INO_TYPE_FIFO 0x1000
#define EXT4_INO_TYPE_CHARDEV 0x2000
@@ -259,7 +259,7 @@ typedef struct {
UINT64 s_mmp_block;
UINT32 s_raid_stride_width;
UINT8 s_log_groups_per_flex;
- UINT8 s_checksum_type; // Only valid value is 1 - CRC32C
+ UINT8 s_checksum_type; // Only valid value is 1 - CRC32C
UINT16 s_reserved_pad;
UINT64 s_kbytes_written;

@@ -283,7 +283,7 @@ typedef struct {
UINT32 s_usr_quota_inum;
UINT32 s_grp_quota_inum;
UINT32 s_overhead_blocks;
- UINT32 s_backup_bgs[2]; // sparse_super2
+ UINT32 s_backup_bgs[2]; // sparse_super2
UINT8 s_encrypt_algos[4];
UINT8 s_encrypt_pw_salt[16];
UINT32 s_lpf_ino;
@@ -293,7 +293,10 @@ typedef struct {
UINT32 s_checksum;
} EXT4_SUPERBLOCK;

-STATIC_ASSERT (sizeof (EXT4_SUPERBLOCK) == 1024, "ext4 superblock struct has incorrect size");
+STATIC_ASSERT (
+ sizeof (EXT4_SUPERBLOCK) == 1024,
+ "ext4 superblock struct has incorrect size"
+ );

typedef struct {
UINT32 bg_block_bitmap_lo;
@@ -355,7 +358,8 @@ typedef struct _Ext4_I_OSD2_Hurd {
} EXT4_OSD2_HURD;

typedef union {
- // Note: Toolchain-specific defines (such as "linux") stops us from using simpler names down here.
+ // Note: Toolchain-specific defines (such as "linux") stops us from using
+ // simpler names down here.
EXT4_OSD2_LINUX data_linux;
EXT4_OSD2_HURD data_hurd;
} EXT4_OSD2;
@@ -418,7 +422,8 @@ typedef struct {
typedef struct {
// This index covers logical blocks from 'ei_block'
UINT32 ei_block;
- // Block of the next level of the extent tree, similarly split in a high and low portion.
+ // Block of the next level of the extent tree, similarly split in a high and
+ // low portion.
UINT32 ei_leaf_lo;
UINT16 ei_leaf_hi;

@@ -451,8 +456,9 @@ typedef struct {
/**
* EXT4 has this feature called uninitialized extents:
* An extent has a maximum of 32768 blocks (2^15 or 1 << 15).
- * When we find an extent with > 32768 blocks, this extent is called uninitialized.
- * Long story short, it's an extent that behaves as a file hole but has blocks already allocated.
+ * When we find an extent with > 32768 blocks, this extent is called
+ * uninitialized. Long story short, it's an extent that behaves as a file hole
+ * but has blocks already allocated.
*/
#define EXT4_EXTENT_MAX_INITIALIZED (1 << 15)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
index d9fbe9ea78e1..43b9340d3956 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
@@ -104,11 +104,11 @@ Ext4ComponentNameGetDriverName (
EFI_STATUS
EFIAPI
Ext4ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);

extern EFI_COMPONENT_NAME_PROTOCOL gExt4ComponentName;
@@ -175,9 +175,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gExt4ComponentName2
EFI_STATUS
EFIAPI
Ext4IsBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
);

/**
@@ -218,9 +218,9 @@ Ext4IsBindingSupported (
EFI_STATUS
EFIAPI
Ext4Bind (
- IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
);

/**
@@ -252,10 +252,10 @@ Ext4Bind (
EFI_STATUS
EFIAPI
Ext4Stop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
);

EFI_DRIVER_BINDING_PROTOCOL gExt4BindingProtocol =
@@ -309,11 +309,11 @@ EFI_DRIVER_BINDING_PROTOCOL gExt4BindingProtocol =
EFI_STATUS
EFIAPI
Ext4ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
@@ -410,10 +410,10 @@ Ext4ComponentNameGetDriverName (
EFI_STATUS
EFIAPI
Ext4Stop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
EFI_STATUS Status;
@@ -637,16 +637,16 @@ Ext4Unload (
EFI_STATUS
EFIAPI
Ext4IsBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_DISK_IO_PROTOCOL *DiskIo;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_STATUS Status;
+ EFI_DISK_IO_PROTOCOL *DiskIo;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;

- DiskIo = NULL;
+ DiskIo = NULL;
BlockIo = NULL;

//
@@ -655,7 +655,7 @@ Ext4IsBindingSupported (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
+ (VOID **)&DiskIo,
BindingProtocol->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -664,13 +664,14 @@ Ext4IsBindingSupported (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
BindingProtocol->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -687,20 +688,22 @@ Ext4IsBindingSupported (
//
if (DiskIo != NULL) {
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- BindingProtocol->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ BindingProtocol->DriverBindingHandle,
+ ControllerHandle
+ );
}
+
if (BlockIo != NULL) {
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- BindingProtocol->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ BindingProtocol->DriverBindingHandle,
+ ControllerHandle
+ );
}
+
return Status;
}

@@ -742,9 +745,9 @@ Ext4IsBindingSupported (
EFI_STATUS
EFIAPI
Ext4Bind (
- IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
+ IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL
)
{
EFI_DISK_IO_PROTOCOL *DiskIo;
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
index fbdffd21f918..03e0586cbb05 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
@@ -18,16 +18,16 @@
#include <Protocol/DiskIo2.h>
#include <Protocol/SimpleFileSystem.h>

-#include <Library/PcdLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiDriverEntryPoint.h>
+#include <Library/OrderedCollectionLib.h>
+#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/OrderedCollectionLib.h>

#include "Ext4Disk.h"

@@ -40,7 +40,8 @@

@param[in] DeviceHandle Handle to the block device.
@param[in] DiskIo Pointer to an EFI_DISK_IO_PROTOCOL.
- @param[in opt] DiskIo2 Pointer to an EFI_DISK_IO2_PROTOCOL, if supported.
+ @param[in opt] DiskIo2 Pointer to an EFI_DISK_IO2_PROTOCOL,
+if supported.
@param[in] BlockIo Pointer to an EFI_BLOCK_IO_PROTOCOL.

@retval EFI_SUCCESS The opening was successful.
@@ -54,8 +55,8 @@ Ext4OpenPartition (
IN EFI_BLOCK_IO_PROTOCOL *BlockIo
);

-typedef struct _Ext4File EXT4_FILE;
-typedef struct _Ext4_Dentry EXT4_DENTRY;
+typedef struct _Ext4File EXT4_FILE;
+typedef struct _Ext4_Dentry EXT4_DENTRY;

typedef struct _Ext4_PARTITION {
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL Interface;
@@ -88,12 +89,12 @@ typedef struct _Ext4_PARTITION {

/**
This structure represents a directory entry inside our directory entry tree.
- For now, it will be used as a way to track file names inside our opening code,
- but it may very well be used as a directory cache in the future.
+ For now, it will be used as a way to track file names inside our opening
+ code, but it may very well be used as a directory cache in the future.
Because it's not being used as a directory cache right now,
an EXT4_DENTRY structure is not necessarily unique name-wise in the list of
- children. Therefore, the dentry tree does not accurately reflect the filesystem
- structure.
+ children. Therefore, the dentry tree does not accurately reflect the
+ filesystem structure.
*/
struct _Ext4_Dentry {
UINTN RefCount;
@@ -104,7 +105,7 @@ struct _Ext4_Dentry {
LIST_ENTRY ListNode;
};

-#define EXT4_DENTRY_FROM_DENTRY_LIST(Node) BASE_CR (Node, EXT4_DENTRY, ListNode)
+#define EXT4_DENTRY_FROM_DENTRY_LIST(Node) BASE_CR(Node, EXT4_DENTRY, ListNode)

/**
Creates a new dentry object.
@@ -118,7 +119,7 @@ struct _Ext4_Dentry {
EXT4_DENTRY *
Ext4CreateDentry (
IN CONST CHAR16 *Name,
- IN OUT EXT4_DENTRY *Parent OPTIONAL
+ IN OUT EXT4_DENTRY *Parent OPTIONAL
);

/**
@@ -147,7 +148,8 @@ Ext4UnrefDentry (
/**
Opens and parses the superblock.

- @param[out] Partition Partition structure to fill with filesystem details.
+ @param[out] Partition Partition structure to fill with filesystem
+details.
@retval EFI_SUCCESS Parsing was succesful and the partition is a
valid ext4 partition.
**/
@@ -219,15 +221,15 @@ Ext4ReadDiskIo (
**/
EFI_STATUS
Ext4ReadBlocks (
- IN EXT4_PARTITION *Partition,
- OUT VOID *Buffer,
- IN UINTN NumberBlocks,
- IN EXT4_BLOCK_NR BlockNumber
+ IN EXT4_PARTITION *Partition,
+ OUT VOID *Buffer,
+ IN UINTN NumberBlocks,
+ IN EXT4_BLOCK_NR BlockNumber
);

/**
- Allocates a buffer and reads blocks from the partition's disk using the DISK_IO protocol.
- This function is deprecated and will be removed in the future.
+ Allocates a buffer and reads blocks from the partition's disk using the
+DISK_IO protocol. This function is deprecated and will be removed in the future.

@param[in] Partition Pointer to the opened ext4 partition.
@param[in] NumberBlocks Length of the read, in filesystem blocks.
@@ -244,13 +246,15 @@ Ext4AllocAndReadBlocks (
);

/**
- Checks if the opened partition has the 64-bit feature (see EXT4_FEATURE_INCOMPAT_64BIT).
+ Checks if the opened partition has the 64-bit feature (see
+EXT4_FEATURE_INCOMPAT_64BIT).

@param[in] Partition Pointer to the opened ext4 partition.

@return TRUE if EXT4_FEATURE_INCOMPAT_64BIT is enabled, else FALSE.
**/
-#define EXT4_IS_64_BIT(Partition) ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_64BIT) != 0)
+#define EXT4_IS_64_BIT(Partition) \
+ ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_64BIT) != 0)

/**
Composes an EXT4_BLOCK_NR safely, from two halfs.
@@ -261,8 +265,8 @@ Ext4AllocAndReadBlocks (

@return The block number formed by Low, and if 64 bit is enabled, High.
**/
-#define EXT4_BLOCK_NR_FROM_HALFS(Partition, Low, High) \
- EXT4_IS_64_BIT (Partition) ? (Low | LShiftU64 (High, 32)) : Low
+#define EXT4_BLOCK_NR_FROM_HALFS(Partition, Low, High) \
+ EXT4_IS_64_BIT(Partition) ? (Low | LShiftU64(High, 32)) : Low

/**
Retrieves a block group descriptor of the ext4 filesystem.
@@ -283,15 +287,16 @@ Ext4GetBlockGroupDesc (

@param[in] Partition Pointer to the opened partition.
@param[in] InodeNum Number of the desired Inode
- @param[out] OutIno Pointer to where it will be stored a pointer to the read inode.
+ @param[out] OutIno Pointer to where it will be stored a pointer to the
+read inode.

@return Status of the inode read.
**/
EFI_STATUS
Ext4ReadInode (
- IN EXT4_PARTITION *Partition,
- IN EXT4_INO_NR InodeNum,
- OUT EXT4_INODE **OutIno
+ IN EXT4_PARTITION *Partition,
+ IN EXT4_INO_NR InodeNum,
+ OUT EXT4_INODE **OutIno
);

/**
@@ -302,7 +307,8 @@ Ext4ReadInode (

@return The number of bytes.
**/
-#define EXT4_BLOCK_TO_BYTES(Partition, Block) MultU64x32 (Block, Partition->BlockSize)
+#define EXT4_BLOCK_TO_BYTES(Partition, Block) \
+ MultU64x32(Block, Partition->BlockSize)

/**
Reads from an EXT4 inode.
@@ -311,17 +317,18 @@ Ext4ReadInode (
@param[out] Buffer Pointer to the buffer.
@param[in] Offset Offset of the read.
@param[in out] Length Pointer to the length of the buffer, in bytes.
- After a succesful read, it's updated to the number of read bytes.
+ After a succesful read, it's updated to the
+number of read bytes.

@return Status of the read operation.
**/
EFI_STATUS
Ext4Read (
- IN EXT4_PARTITION *Partition,
- IN EXT4_FILE *File,
- OUT VOID *Buffer,
- IN UINT64 Offset,
- IN OUT UINTN *Length
+ IN EXT4_PARTITION *Partition,
+ IN EXT4_FILE *File,
+ OUT VOID *Buffer,
+ IN UINT64 Offset,
+ IN OUT UINTN *Length
);

/**
@@ -331,24 +338,27 @@ Ext4Read (

@return The size of the inode, in bytes.
**/
-#define EXT4_INODE_SIZE(Inode) (LShiftU64 (Inode->i_size_hi, 32) | Inode->i_size_lo)
+#define EXT4_INODE_SIZE(Inode) \
+ (LShiftU64(Inode->i_size_hi, 32) | Inode->i_size_lo)

/**
Retrieves an extent from an EXT4 inode.
@param[in] Partition Pointer to the opened EXT4 partition.
@param[in] File Pointer to the opened file.
- @param[in] LogicalBlock Block number which the returned extent must cover.
- @param[out] Extent Pointer to the output buffer, where the extent will be copied to.
+ @param[in] LogicalBlock Block number which the returned extent must
+cover.
+ @param[out] Extent Pointer to the output buffer, where the extent
+will be copied to.

@retval EFI_SUCCESS Retrieval was succesful.
@retval EFI_NO_MAPPING Block has no mapping.
**/
EFI_STATUS
Ext4GetExtent (
- IN EXT4_PARTITION *Partition,
- IN EXT4_FILE *File,
- IN EXT4_BLOCK_NR LogicalBlock,
- OUT EXT4_EXTENT *Extent
+ IN EXT4_PARTITION *Partition,
+ IN EXT4_FILE *File,
+ IN EXT4_BLOCK_NR LogicalBlock,
+ OUT EXT4_EXTENT *Extent
);

struct _Ext4File {
@@ -369,7 +379,8 @@ struct _Ext4File {
EXT4_DENTRY *Dentry;
};

-#define EXT4_FILE_FROM_OPEN_FILES_NODE(Node) BASE_CR (Node, EXT4_FILE, OpenFilesListNode)
+#define EXT4_FILE_FROM_OPEN_FILES_NODE(Node) \
+ BASE_CR(Node, EXT4_FILE, OpenFilesListNode)

/**
Retrieves a directory entry.
@@ -383,9 +394,9 @@ struct _Ext4File {
**/
EFI_STATUS
Ext4RetrieveDirent (
- IN EXT4_FILE *Directory,
- IN CONST CHAR16 *NameUnicode,
- IN EXT4_PARTITION *Partition,
+ IN EXT4_FILE *Directory,
+ IN CONST CHAR16 *NameUnicode,
+ IN EXT4_PARTITION *Partition,
OUT EXT4_DIR_ENTRY *Result
);

@@ -402,11 +413,11 @@ Ext4RetrieveDirent (
**/
EFI_STATUS
Ext4OpenFile (
- IN EXT4_FILE *Directory,
- IN CONST CHAR16 *Name,
- IN EXT4_PARTITION *Partition,
- IN UINT64 OpenMode,
- OUT EXT4_FILE **OutFile
+ IN EXT4_FILE *Directory,
+ IN CONST CHAR16 *Name,
+ IN EXT4_PARTITION *Partition,
+ IN UINT64 OpenMode,
+ OUT EXT4_FILE **OutFile
);

/**
@@ -422,11 +433,11 @@ Ext4OpenFile (
**/
EFI_STATUS
Ext4OpenDirent (
- IN EXT4_PARTITION *Partition,
- IN UINT64 OpenMode,
- OUT EXT4_FILE **OutFile,
- IN EXT4_DIR_ENTRY *Entry,
- IN EXT4_FILE *Directory
+ IN EXT4_PARTITION *Partition,
+ IN UINT64 OpenMode,
+ OUT EXT4_FILE **OutFile,
+ IN EXT4_DIR_ENTRY *Entry,
+ IN EXT4_FILE *Directory
);

/**
@@ -447,20 +458,22 @@ Ext4AllocateInode (
Open the root directory on a volume.

@param[in] This A pointer to the volume to open the root directory.
- @param[out] Root A pointer to the location to return the opened file handle for the
- root directory.
+ @param[out] Root A pointer to the location to return the opened file handle
+for the root directory.

@retval EFI_SUCCESS The device was opened.
- @retval EFI_UNSUPPORTED This volume does not support the requested file system type.
+ @retval EFI_UNSUPPORTED This volume does not support the requested file
+system type.
@retval EFI_NO_MEDIA The device has no medium.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
@retval EFI_ACCESS_DENIED The service denied access to the file.
- @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
- @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
- longer supported. Any existing file handles for this volume are
- no longer valid. To access the files on the new medium, the
- volume must be reopened with OpenVolume().
+ @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of
+resources.
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
+medium is no longer supported. Any existing file handles for this volume are no
+longer valid. To access the files on the new medium, the volume must be reopened
+with OpenVolume().

**/
EFI_STATUS
@@ -501,30 +514,32 @@ Ext4CloseInternal (
/**
Opens a new file relative to the source file's location.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
- handle to the source location. This would typically be an open
- handle to a directory.
- @param[out] NewHandle A pointer to the location to return the opened handle for the new
- file.
- @param[in] FileName The Null-terminated string of the name of the file to be opened.
- The file name may contain the following path modifiers: "\", ".",
- and "..".
- @param[in] OpenMode The mode to open the file. The only valid combinations that the
- file may be opened with are: Read, Read/Write, or Create/Read/Write.
- @param[in] Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the
- attribute bits for the newly created file.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the
+file handle to the source location. This would typically be an open handle to a
+directory.
+ @param[out] NewHandle A pointer to the location to return the opened handle
+for the new file.
+ @param[in] FileName The Null-terminated string of the name of the file to
+be opened. The file name may contain the following path modifiers: "\", ".", and
+"..".
+ @param[in] OpenMode The mode to open the file. The only valid combinations
+that the file may be opened with are: Read, Read/Write, or Create/Read/Write.
+ @param[in] Attributes Only valid for EFI_FILE_MODE_CREATE, in which case
+these are the attribute bits for the newly created file.

@retval EFI_SUCCESS The file was opened.
- @retval EFI_NOT_FOUND The specified file could not be found on the device.
+ @retval EFI_NOT_FOUND The specified file could not be found on the
+device.
@retval EFI_NO_MEDIA The device has no medium.
- @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
- longer supported.
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
+medium is no longer supported.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
- when the media is write-protected.
+ @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a
+file for write when the media is write-protected.
@retval EFI_ACCESS_DENIED The service denied access to the file.
- @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
+ @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
+file.
@retval EFI_VOLUME_FULL The volume is full.

**/
@@ -541,8 +556,8 @@ Ext4Open (
/**
Closes a specified file handle.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
- handle to close.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is
+the file handle to close.

@retval EFI_SUCCESS The file was closed.

@@ -556,11 +571,13 @@ Ext4Close (
/**
Close and delete the file handle.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the
- handle to the file to delete.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL
+instance that is the handle to the file to delete.

- @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
- @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not deleted.
+ @retval EFI_SUCCESS The file was closed and deleted, and the
+handle was closed.
+ @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not
+deleted.

**/
EFI_STATUS
@@ -572,21 +589,23 @@ Ext4Delete (
/**
Reads data from a file.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
- handle to read data from.
- @param[in out] BufferSize On input, the size of the Buffer. On output, the amount of data
- returned in Buffer. In both cases, the size is measured in bytes.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance
+that is the file handle to read data from.
+ @param[in out] BufferSize On input, the size of the Buffer. On output,
+the amount of data returned in Buffer. In both cases, the size is measured in
+bytes.
@param[out] Buffer The buffer into which the data is read.

@retval EFI_SUCCESS Data was read.
@retval EFI_NO_MEDIA The device has no medium.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file.
- @retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file.
+ @retval EFI_DEVICE_ERROR On entry, the current file position is beyond the
+end of the file.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory
- entry. BufferSize has been updated with the size
- needed to complete the request.
+ @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current
+directory entry. BufferSize has been updated with the size needed to complete
+the request.

**/
EFI_STATUS
@@ -600,10 +619,10 @@ Ext4ReadFile (
/**
Writes data to a file.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
- handle to write data to.
- @param[in out] BufferSize On input, the size of the Buffer. On output, the amount of data
- actually written. In both cases, the size is measured in bytes.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that
+is the file handle to write data to.
+ @param[in out] BufferSize On input, the size of the Buffer. On output, the
+amount of data actually written. In both cases, the size is measured in bytes.
@param[in] Buffer The buffer of data to write.

@retval EFI_SUCCESS Data was written.
@@ -628,13 +647,15 @@ Ext4WriteFile (
/**
Returns a file's current position.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
- handle to get the current position on.
- @param[out] Position The address to return the file's current position value.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that
+is the file handle to get the current position on.
+ @param[out] Position The address to return the file's current position
+value.

@retval EFI_SUCCESS The position was returned.
@retval EFI_UNSUPPORTED The request is not valid on open directories.
- @retval EFI_DEVICE_ERROR An attempt was made to get the position from a deleted file.
+ @retval EFI_DEVICE_ERROR An attempt was made to get the position from a
+deleted file.

**/
EFI_STATUS
@@ -647,14 +668,16 @@ Ext4GetPosition (
/**
Sets a file's current position.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the
- file handle to set the requested position on.
- @param[in] Position The byte position from the start of the file to set.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that
+is the file handle to set the requested position on.
+ @param[in] Position The byte position from the start of the file to
+set.

@retval EFI_SUCCESS The position was set.
@retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open
directories.
- @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted file.
+ @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted
+file.

**/
EFI_STATUS
@@ -667,21 +690,22 @@ Ext4SetPosition (
/**
Returns information about a file.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
- handle the requested information is for.
- @param[in] InformationType The type identifier for the information being requested.
- @param[in out] BufferSize On input, the size of Buffer. On output, the amount of data
- returned in Buffer. In both cases, the size is measured in bytes.
- @param[out] Buffer A pointer to the data buffer to return. The buffer's type is
- indicated by InformationType.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance
+that is the file handle the requested information is for.
+ @param[in] InformationType The type identifier for the information being
+requested.
+ @param[in out] BufferSize On input, the size of Buffer. On output, the
+amount of data returned in Buffer. In both cases, the size is measured in bytes.
+ @param[out] Buffer A pointer to the data buffer to return. The
+buffer's type is indicated by InformationType.

@retval EFI_SUCCESS The information was returned.
@retval EFI_UNSUPPORTED The InformationType is not known.
@retval EFI_NO_MEDIA The device has no medium.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.
- BufferSize has been updated with the size needed to complete
+ @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current
+directory entry. BufferSize has been updated with the size needed to complete
the request.
**/
EFI_STATUS
@@ -696,35 +720,36 @@ Ext4GetInfo (
/**
Sets information about a file.

- @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
- handle the information is for.
+ @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that
+is the file handle the information is for.
@param[in] InformationType The type identifier for the information being set.
@param[in] BufferSize The size, in bytes, of Buffer.
- @param[in] Buffer A pointer to the data buffer to write. The buffer's type is
- indicated by InformationType.
+ @param[in] Buffer A pointer to the data buffer to write. The
+buffer's type is indicated by InformationType.

@retval EFI_SUCCESS The information was set.
@retval EFI_UNSUPPORTED The InformationType is not known.
@retval EFI_NO_MEDIA The device has no medium.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the media is
- read-only.
- @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_PROTOCOL_SYSTEM_INFO_ID
- and the media is read only.
- @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_SYSTEM_VOLUME_LABEL_ID
- and the media is read-only.
- @retval EFI_ACCESS_DENIED An attempt is made to change the name of a file to a
- file that is already present.
- @retval EFI_ACCESS_DENIED An attempt is being made to change the EFI_FILE_DIRECTORY
- Attribute.
- @retval EFI_ACCESS_DENIED An attempt is being made to change the size of a directory.
- @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the file was opened
- read-only and an attempt is being made to modify a field
- other than Attribute.
+ @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the media
+is read-only.
+ @retval EFI_WRITE_PROTECTED InformationType is
+EFI_FILE_PROTOCOL_SYSTEM_INFO_ID and the media is read only.
+ @retval EFI_WRITE_PROTECTED InformationType is
+EFI_FILE_SYSTEM_VOLUME_LABEL_ID and the media is read-only.
+ @retval EFI_ACCESS_DENIED An attempt is made to change the name of a file
+to a file that is already present.
+ @retval EFI_ACCESS_DENIED An attempt is being made to change the
+EFI_FILE_DIRECTORY Attribute.
+ @retval EFI_ACCESS_DENIED An attempt is being made to change the size of a
+directory.
+ @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the file
+was opened read-only and an attempt is being made to modify a field other than
+Attribute.
@retval EFI_VOLUME_FULL The volume is full.
- @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the type indicated
- by InformationType.
+ @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the type
+indicated by InformationType.

**/
EFI_STATUS
@@ -760,8 +785,8 @@ Ext4FileIsReg (
IN CONST EXT4_FILE *File
);

-// In EFI we can't open FIFO pipes, UNIX sockets, character/block devices since these concepts are
-// at the kernel level and are OS dependent.
+// In EFI we can't open FIFO pipes, UNIX sockets, character/block devices since
+// these concepts are at the kernel level and are OS dependent.

/**
Checks if a file is openable.
@@ -772,11 +797,11 @@ Ext4FileIsReg (
it's a regular file or a directory, since most other file types
don't make sense under UEFI.
**/
-#define Ext4FileIsOpenable(File) (Ext4FileIsReg (File) || Ext4FileIsDir (File))
+#define Ext4FileIsOpenable(File) (Ext4FileIsReg(File) || Ext4FileIsDir(File))

-#define EXT4_INODE_HAS_FIELD(Inode, \
- Field) (Inode->i_extra_isize + EXT4_GOOD_OLD_INODE_SIZE >= OFFSET_OF (EXT4_INODE, Field) + \
- sizeof (((EXT4_INODE *)NULL)->Field))
+#define EXT4_INODE_HAS_FIELD(Inode, Field) \
+ (Inode->i_extra_isize + EXT4_GOOD_OLD_INODE_SIZE >= \
+ OFFSET_OF(EXT4_INODE, Field) + sizeof(((EXT4_INODE *)NULL)->Field))

/**
Calculates the physical space used by a file.
@@ -815,8 +840,8 @@ Ext4FileMTime (
Gets the file's creation time, if possible.
@param[in] File Pointer to the opened file.
@param[out] Time Pointer to an EFI_TIME structure.
- In the case where the the creation time isn't recorded,
- Time is zeroed.
+ In the case where the the creation time isn't
+recorded, Time is zeroed.
**/
VOID
Ext4FileCreateTime (
@@ -825,8 +850,9 @@ Ext4FileCreateTime (
);

/**
- Initialises Unicode collation, which is needed for case-insensitive string comparisons
- within the driver (a good example of an application of this is filename comparison).
+ Initialises Unicode collation, which is needed for case-insensitive string
+comparisons within the driver (a good example of an application of this is
+filename comparison).

@param[in] DriverHandle Handle to the driver image.

@@ -839,8 +865,8 @@ Ext4InitialiseUnicodeCollation (
);

/**
- Does a case-insensitive string comparison. Refer to EFI_UNICODE_COLLATION_PROTOCOL's StriColl
- for more details.
+ Does a case-insensitive string comparison. Refer to
+EFI_UNICODE_COLLATION_PROTOCOL's StriColl for more details.

@param[in] Str1 Pointer to a null terminated string.
@param[in] Str2 Pointer to a null terminated string.
@@ -859,7 +885,8 @@ Ext4StrCmpInsensitive (
Retrieves the filename of the directory entry and converts it to UTF-16/UCS-2

@param[in] Entry Pointer to a EXT4_DIR_ENTRY.
- @param[out] Ucs2FileName Pointer to an array of CHAR16's, of size EXT4_NAME_MAX + 1.
+ @param[out] Ucs2FileName Pointer to an array of CHAR16's, of size
+EXT4_NAME_MAX + 1.

@retval EFI_SUCCESS Unicode collation was successfully initialised.
@retval !EFI_SUCCESS Failure.
@@ -871,7 +898,8 @@ Ext4GetUcs2DirentName (
);

/**
- Retrieves information about the file and stores it in the EFI_FILE_INFO format.
+ Retrieves information about the file and stores it in the EFI_FILE_INFO
+format.

@param[in] File Pointer to an opened file.
@param[out] Info Pointer to a EFI_FILE_INFO.
@@ -881,9 +909,9 @@ Ext4GetUcs2DirentName (
**/
EFI_STATUS
Ext4GetFileInfo (
- IN EXT4_FILE *File,
- OUT EFI_FILE_INFO *Info,
- IN OUT UINTN *BufferSize
+ IN EXT4_FILE *File,
+ OUT EFI_FILE_INFO *Info,
+ IN OUT UINTN *BufferSize
);

/**
@@ -893,8 +921,8 @@ Ext4GetFileInfo (
@param[in] File Pointer to the open directory.
@param[out] Buffer Pointer to the output buffer.
@param[in] Offset Initial directory position.
- @param[in out] OutLength Pointer to a UINTN that contains the length of the buffer,
- and the length of the actual EFI_FILE_INFO after the call.
+ @param[in out] OutLength Pointer to a UINTN that contains the length of
+the buffer, and the length of the actual EFI_FILE_INFO after the call.

@return Result of the operation.
**/
@@ -1025,7 +1053,7 @@ Ext4CalculateBlockGroupDescChecksum (

@return TRUE if all features are supported, else FALSE.
**/
-#define EXT4_HAS_RO_COMPAT(Partition, RoCompatFeatureSet) \
+#define EXT4_HAS_RO_COMPAT(Partition, RoCompatFeatureSet) \
((Partition->FeaturesRoCompat & RoCompatFeatureSet) == RoCompatFeatureSet)

/**
@@ -1035,7 +1063,7 @@ Ext4CalculateBlockGroupDescChecksum (

@return TRUE if all features are supported, else FALSE.
**/
-#define EXT4_HAS_COMPAT(Partition, CompatFeatureSet) \
+#define EXT4_HAS_COMPAT(Partition, CompatFeatureSet) \
((Partition->FeaturesCompat & CompatFeatureSet) == CompatFeatureSet)

/**
@@ -1045,10 +1073,11 @@ Ext4CalculateBlockGroupDescChecksum (

@return TRUE if all features are supported, else FALSE.
**/
-#define EXT4_HAS_INCOMPAT(Partition, IncompatFeatureSet) \
+#define EXT4_HAS_INCOMPAT(Partition, IncompatFeatureSet) \
((Partition->FeaturesIncompat & IncompatFeatureSet) == IncompatFeatureSet)

-// Note: Might be a good idea to provide generic Ext4Has$feature() through macros.
+// Note: Might be a good idea to provide generic Ext4Has$feature() through
+// macros.

/**
Checks if metadata_csum is enabled on the partition.
@@ -1056,8 +1085,8 @@ Ext4CalculateBlockGroupDescChecksum (

@return TRUE if the metadata_csum is supported, else FALSE.
**/
-#define EXT4_HAS_METADATA_CSUM(Partition) \
- EXT4_HAS_RO_COMPAT (Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
+#define EXT4_HAS_METADATA_CSUM(Partition) \
+ EXT4_HAS_RO_COMPAT(Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)

/**
Checks if gdt_csum is enabled on the partition.
@@ -1065,8 +1094,8 @@ Ext4CalculateBlockGroupDescChecksum (

@return TRUE if the gdt_csum is supported, else FALSE.
**/
-#define EXT4_HAS_GDT_CSUM(Partition) \
- EXT4_HAS_RO_COMPAT (Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
+#define EXT4_HAS_GDT_CSUM(Partition) \
+ EXT4_HAS_RO_COMPAT(Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)

/**
Retrieves the volume name.
@@ -1106,10 +1135,12 @@ Ext4SuperblockCheckMagic (

@returns True if uninitialized, else false.
**/
-#define EXT4_EXTENT_IS_UNINITIALIZED(Extent) ((Extent)->ee_len > EXT4_EXTENT_MAX_INITIALIZED)
+#define EXT4_EXTENT_IS_UNINITIALIZED(Extent) \
+ ((Extent)->ee_len > EXT4_EXTENT_MAX_INITIALIZED)

/**
- Retrieves the extent's length, dealing with uninitialized extents in the process.
+ Retrieves the extent's length, dealing with uninitialized extents in the
+process.

@param[in] Extent Pointer to the EXT4_EXTENT

diff --git a/Features/Ext4Pkg/Ext4Dxe/Extents.c b/Features/Ext4Pkg/Ext4Dxe/Extents.c
index 1ae175f417c9..e920eed090fd 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Extents.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Extents.c
@@ -249,7 +249,7 @@ Ext4GetExtent (
}

// ext4 does not have support for logical block numbers bigger than UINT32_MAX
- if (LogicalBlock > (UINT32)- 1) {
+ if (LogicalBlock > (UINT32)-1) {
return EFI_NO_MAPPING;
}

@@ -332,7 +332,7 @@ Ext4GetExtent (
return EFI_NO_MAPPING;
}

- if (!(LogicalBlock >= Ext->ee_block && Ext->ee_block + Ext4GetExtentLength (Ext) > LogicalBlock)) {
+ if (!((LogicalBlock >= Ext->ee_block) && (Ext->ee_block + Ext4GetExtentLength (Ext) > LogicalBlock))) {
// This extent does not cover the block
if (Buffer != NULL) {
FreePool (Buffer);
@@ -378,7 +378,7 @@ Ext4ExtentsMapStructCompare (
Extent1 = UserStruct1;
Extent2 = UserStruct2;

- return Extent1->ee_block < Extent2->ee_block ? - 1 :
+ return Extent1->ee_block < Extent2->ee_block ? -1 :
Extent1->ee_block > Extent2->ee_block ? 1 : 0;
}

@@ -413,11 +413,11 @@ Ext4ExtentsMapKeyCompare (
Extent = UserStruct;
Block = (UINT32)(UINTN)StandaloneKey;

- if (Block >= Extent->ee_block && Block < Extent->ee_block + Ext4GetExtentLength (Extent)) {
+ if ((Block >= Extent->ee_block) && (Block < Extent->ee_block + Ext4GetExtentLength (Extent))) {
return 0;
}

- return Block < Extent->ee_block ? - 1 :
+ return Block < Extent->ee_block ? -1 :
Block > Extent->ee_block ? 1 : 0;
}

diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/File.c
index 4ad7cad8dcf5..ff1746d5640a 100644
--- a/Features/Ext4Pkg/Ext4Dxe/File.c
+++ b/Features/Ext4Pkg/Ext4Dxe/File.c
@@ -91,7 +91,8 @@ Ext4IsLastPathSegment (
STATIC
BOOLEAN
Ext4ApplyPermissions (
- IN OUT EXT4_FILE *File, IN UINT64 OpenMode
+ IN OUT EXT4_FILE *File,
+ IN UINT64 OpenMode
)
{
UINT16 NeededPerms;
@@ -228,7 +229,7 @@ Ext4Open (

Status = Ext4OpenFile (Current, PathSegment, Partition, EFI_FILE_MODE_READ, &File);

- if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
return Status;
} else if (Status == EFI_NOT_FOUND) {
// We explicitly ignore the EFI_FILE_MODE_CREATE flag, since we don't have write support
@@ -308,7 +309,7 @@ Ext4CloseInternal (
IN EXT4_FILE *File
)
{
- if (File == File->Partition->Root && !File->Partition->Unmounting) {
+ if ((File == File->Partition->Root) && !File->Partition->Unmounting) {
return EFI_SUCCESS;
}

@@ -374,7 +375,7 @@ Ext4ReadFile (
EXT4_PARTITION *Partition;
EFI_STATUS Status;

- File = (EXT4_FILE *)This;
+ File = (EXT4_FILE *)This;
Partition = File->Partition;

ASSERT (Ext4FileIsOpenable (File));
@@ -491,12 +492,12 @@ Ext4SetPosition (
File = (EXT4_FILE *)This;

// Only seeks to 0 (so it resets the ReadDir operation) are allowed
- if (Ext4FileIsDir (File) && Position != 0) {
+ if (Ext4FileIsDir (File) && (Position != 0)) {
return EFI_UNSUPPORTED;
}

// -1 (0xffffff.......) seeks to the end of the file
- if (Position == (UINT64)- 1) {
+ if (Position == (UINT64)-1) {
Position = EXT4_INODE_SIZE (File->Inode);
}

@@ -549,7 +550,7 @@ Ext4GetFileInfo (
Ext4FileMTime (File, &Info->ModificationTime);
Ext4FileCreateTime (File, &Info->LastAccessTime);
Info->Attribute = 0;
- Info->Size = NeededLength;
+ Info->Size = NeededLength;

if (Ext4FileIsDir (File)) {
Info->Attribute |= EFI_FILE_DIRECTORY;
@@ -659,7 +660,7 @@ Ext4GetFilesystemInfo (
Part->SuperBlock.s_free_blocks_count_hi
);

- Info->BlockSize = Part->BlockSize;
+ Info->BlockSize = Part->BlockSize;
Info->Size = NeededLength;
Info->ReadOnly = Part->ReadOnly;
Info->VolumeSize = MultU64x32 (TotalBlocks, Part->BlockSize);
@@ -790,7 +791,7 @@ Ext4DuplicateFile (
EFI_STATUS Status;

Partition = Original->Partition;
- File = AllocateZeroPool (sizeof (EXT4_FILE));
+ File = AllocateZeroPool (sizeof (EXT4_FILE));

if (File == NULL) {
return NULL;
diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/Inode.c
index 48bfe026a3c2..f692909edf78 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Inode.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c
@@ -50,7 +50,7 @@ Ext4CalculateInodeChecksum (

Crc = Ext4CalculateChecksum (Partition, &Dummy, sizeof (Dummy), Crc);

- RestOfInode = &Inode->i_osd2.data_linux.l_i_reserved;
+ RestOfInode = &Inode->i_osd2.data_linux.l_i_reserved;
RestOfInodeLength = Partition->InodeSize - OFFSET_OF (EXT4_INODE, i_osd2.data_linux.l_i_reserved);

if (HasSecondChecksumField) {
@@ -61,7 +61,7 @@ Ext4CalculateInodeChecksum (

// 4 is the size of the i_extra_size field + the size of i_checksum_hi
RestOfInodeLength = Partition->InodeSize - EXT4_GOOD_OLD_INODE_SIZE - 4;
- RestOfInode = &Inode->i_ctime_extra;
+ RestOfInode = &Inode->i_ctime_extra;
}

Crc = Ext4CalculateChecksum (Partition, RestOfInode, RestOfInodeLength, Crc);
@@ -138,14 +138,13 @@ Ext4Read (
&Extent
);

- if (Status != EFI_SUCCESS && Status != EFI_NO_MAPPING) {
+ if ((Status != EFI_SUCCESS) && (Status != EFI_NO_MAPPING)) {
return Status;
}

HasBackingExtent = Status != EFI_NO_MAPPING;

if (!HasBackingExtent || EXT4_EXTENT_IS_UNINITIALIZED (&Extent)) {
-
HoleOff = BlockOff;

if (!HasBackingExtent) {
@@ -167,8 +166,8 @@ Ext4Read (
);
ExtentLengthBytes = Extent.ee_len * Partition->BlockSize;
ExtentLogicalBytes = (UINT64)Extent.ee_block * Partition->BlockSize;
- ExtentOffset = CurrentSeek - ExtentLogicalBytes;
- ExtentMayRead = (UINTN)(ExtentLengthBytes - ExtentOffset);
+ ExtentOffset = CurrentSeek - ExtentLogicalBytes;
+ ExtentMayRead = (UINTN)(ExtentLengthBytes - ExtentOffset);

WasRead = ExtentMayRead > RemainingRead ? RemainingRead : ExtentMayRead;

@@ -187,9 +186,9 @@ Ext4Read (
}

RemainingRead -= WasRead;
- Buffer = (VOID *)((CHAR8 *)Buffer + WasRead);
- BeenRead += WasRead;
- CurrentSeek += WasRead;
+ Buffer = (VOID *)((CHAR8 *)Buffer + WasRead);
+ BeenRead += WasRead;
+ CurrentSeek += WasRead;
}

*Length = BeenRead;
@@ -214,7 +213,7 @@ Ext4AllocateInode (
EXT4_INODE *Inode;

NeedsToZeroRest = FALSE;
- InodeSize = Partition->InodeSize;
+ InodeSize = Partition->InodeSize;

// We allocate a structure of at least sizeof(EXT4_INODE), but in the future, when
// write support is added and we need to flush inodes to disk, we could have a bit better
@@ -224,7 +223,7 @@ Ext4AllocateInode (
// is 160 bytes).

if (InodeSize < sizeof (EXT4_INODE)) {
- InodeSize = sizeof (EXT4_INODE);
+ InodeSize = sizeof (EXT4_INODE);
NeedsToZeroRest = TRUE;
}

@@ -409,7 +408,8 @@ EXT4_FILE_GET_TIME_GENERIC (MTime, i_mtime);
**/
STATIC
EXT4_FILE_GET_TIME_GENERIC (
- CrTime, i_crtime
+ CrTime,
+ i_crtime
);

/**
diff --git a/Features/Ext4Pkg/Ext4Dxe/Partition.c b/Features/Ext4Pkg/Ext4Dxe/Partition.c
index afa0392024ec..316807497dd4 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Partition.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Partition.c
@@ -50,12 +50,12 @@ Ext4OpenPartition (

Part->Interface.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
Part->Interface.OpenVolume = Ext4OpenVolume;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &DeviceHandle,
- &gEfiSimpleFileSystemProtocolGuid,
- &Part->Interface,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DeviceHandle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ &Part->Interface,
+ NULL
+ );

if (EFI_ERROR (Status)) {
FreePool (Part);
diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index 9c3f7a9e7bfb..a7dbe9bf0fec 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -85,7 +85,7 @@ Ext4SuperblockValidate (
return FALSE;
}

- if (Sb->s_rev_level != EXT4_DYNAMIC_REV && Sb->s_rev_level != EXT4_GOOD_OLD_REV) {
+ if ((Sb->s_rev_level != EXT4_DYNAMIC_REV) && (Sb->s_rev_level != EXT4_GOOD_OLD_REV)) {
return FALSE;
}

@@ -188,11 +188,11 @@ Ext4OpenSuperblock (
Partition->FeaturesCompat = Sb->s_feature_compat;
Partition->FeaturesIncompat = Sb->s_feature_incompat;
Partition->FeaturesRoCompat = Sb->s_feature_ro_compat;
- Partition->InodeSize = Sb->s_inode_size;
+ Partition->InodeSize = Sb->s_inode_size;
} else {
// GOOD_OLD_REV
Partition->FeaturesCompat = Partition->FeaturesIncompat = Partition->FeaturesRoCompat = 0;
- Partition->InodeSize = EXT4_GOOD_OLD_INODE_SIZE;
+ Partition->InodeSize = EXT4_GOOD_OLD_INODE_SIZE;
}

// Now, check for the feature set of the filesystem
@@ -220,7 +220,8 @@ Ext4OpenSuperblock (

// At the time of writing, it's the only supported checksum.
if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM &&
- Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C) {
+ (Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C))
+ {
return EFI_UNSUPPORTED;
}

@@ -250,7 +251,7 @@ Ext4OpenSuperblock (
return EFI_UNSUPPORTED;
}

- Partition->NumberBlocks = EXT4_BLOCK_NR_FROM_HALFS (Partition, Sb->s_blocks_count, Sb->s_blocks_count_hi);
+ Partition->NumberBlocks = EXT4_BLOCK_NR_FROM_HALFS (Partition, Sb->s_blocks_count, Sb->s_blocks_count_hi);
Partition->NumberBlockGroups = DivU64x32 (Partition->NumberBlocks, Sb->s_blocks_per_group);

DEBUG ((
@@ -266,7 +267,7 @@ Ext4OpenSuperblock (
Partition->DescSize = EXT4_OLD_BLOCK_DESC_SIZE;
}

- if (Partition->DescSize < EXT4_64BIT_BLOCK_DESC_SIZE && EXT4_IS_64_BIT (Partition)) {
+ if ((Partition->DescSize < EXT4_64BIT_BLOCK_DESC_SIZE) && EXT4_IS_64_BIT (Partition)) {
// 64 bit filesystems need DescSize to be 64 bytes
return EFI_VOLUME_CORRUPTED;
}
--
2.35.1


[PATCH edk2-platforms 3/3] Ext4Pkg: Add ext2/3 support

Pedro Falcato
 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3745

Adds ext2/3 support by supporting (legacy) block maps.
Also fixes a bug regarding uninitialised extents.

Cc: Leif Lindholm <leif@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Signed-off-by: Pedro Falcato <pedro.falcato@...>
---
Features/Ext4Pkg/Ext4Dxe/BlockMap.c | 279 ++++++++++++++++++++++++++
Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 2 +
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 18 ++
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf | 1 +
Features/Ext4Pkg/Ext4Dxe/Extents.c | 17 +-
Features/Ext4Pkg/Ext4Dxe/Inode.c | 9 +-
Features/Ext4Pkg/Ext4Dxe/Superblock.c | 7 +-
7 files changed, 318 insertions(+), 15 deletions(-)
create mode 100644 Features/Ext4Pkg/Ext4Dxe/BlockMap.c

diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockMap.c b/Features/Ext4Pkg/Ext4Dxe/BlockMap.c
new file mode 100644
index 000000000000..6e8ccaa82437
--- /dev/null
+++ b/Features/Ext4Pkg/Ext4Dxe/BlockMap.c
@@ -0,0 +1,279 @@
+/** @file
+ Implementation of routines that deal with ext2/3 block maps.
+
+ Copyright (c) 2022 Pedro Falcato All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Ext4Dxe.h>
+
+// Note: The largest path we can take uses up 4 indices
+#define EXT4_MAX_BLOCK_PATH 4
+
+typedef enum ext4_logical_block_type {
+ EXT4_TYPE_DIRECT_BLOCK = 0,
+ EXT4_TYPE_SINGLY_BLOCK,
+ EXT4_TYPE_DOUBLY_BLOCK,
+ EXT4_TYPE_TREBLY_BLOCK,
+ EXT4_TYPE_BAD_BLOCK
+} EXT4_LOGICAL_BLOCK_TYPE;
+
+/**
+ @brief Detect the type of path the logical block will follow
+
+ @param[in] LogicalBlock The logical block
+ @param[in] Partition Pointer to an EXT4_PARTITION
+ @return The type of path the logical block will need to follow
+ */
+STATIC
+EXT4_LOGICAL_BLOCK_TYPE
+Ext4DetectBlockType (
+ IN UINT32 LogicalBlock,
+ IN CONST EXT4_PARTITION *Partition
+ )
+{
+ UINT32 Entries;
+ UINT32 MinSinglyBlock;
+ UINT32 MinDoublyBlock;
+ UINT32 MinTreblyBlock;
+ UINT32 MinQuadBlock;
+
+ Entries = (Partition->BlockSize / sizeof (UINT32));
+ MinSinglyBlock = EXT4_DBLOCKS;
+ MinDoublyBlock = Entries + MinSinglyBlock;
+ MinTreblyBlock = Entries * Entries + MinDoublyBlock;
+ MinQuadBlock = Entries * Entries * Entries + MinTreblyBlock; // Doesn't actually exist
+
+ if (LogicalBlock < MinSinglyBlock) {
+ return EXT4_TYPE_DIRECT_BLOCK;
+ } else if ((LogicalBlock >= MinSinglyBlock) && (LogicalBlock < MinDoublyBlock)) {
+ return EXT4_TYPE_SINGLY_BLOCK;
+ } else if ((LogicalBlock >= MinDoublyBlock) && (LogicalBlock < MinTreblyBlock)) {
+ return EXT4_TYPE_DOUBLY_BLOCK;
+ } else if (((LogicalBlock >= MinTreblyBlock) && (LogicalBlock < MinQuadBlock))) {
+ return EXT4_TYPE_TREBLY_BLOCK;
+ } else {
+ return EXT4_TYPE_BAD_BLOCK;
+ }
+}
+
+/**
+ @brief Get a block's path in indices
+
+ @param[in] Partition Pointer to an EXT4_PARTITION
+ @param[in] LogicalBlock Logical block
+ @param[out] BlockPath Pointer to an array of EXT4_MAX_BLOCK_PATH elements, where the
+ indices we'll need to read are inserted.
+ @return The number of path elements that are required (and were inserted in BlockPath)
+ */
+UINTN
+Ext4GetBlockPath (
+ IN CONST EXT4_PARTITION *Partition,
+ IN UINT32 LogicalBlock,
+ OUT EXT4_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH]
+ )
+{
+ // The logic behind the block map is very much like a page table
+ // Let's think of blocks with 512 entries (exactly like a page table on x64).
+ // On doubly indirect block paths, we subtract the min doubly blocks from the logical block.
+ // The top 9 bits of the result are the index inside the dind block, the bottom 9 bits are the
+ // index inside the ind block. Since Entries is always a power of 2, entries - 1 will give us
+ // a mask of the BlockMapBits.
+ // Note that all this math could be done with ands and shifts (similar implementations exist
+ // in a bunch of other places), but I'm doing it a simplified way with divs and modulus,
+ // since it's not going to be a bottleneck anyway.
+
+ UINT32 Entries;
+ UINT32 EntriesEntries;
+ UINT32 MinSinglyBlock;
+ UINT32 MinDoublyBlock;
+ UINT32 MinTreblyBlock;
+
+ EXT4_LOGICAL_BLOCK_TYPE Type;
+
+ Entries = (Partition->BlockSize / sizeof (UINT32));
+ EntriesEntries = Entries * Entries;
+
+ MinSinglyBlock = EXT4_DBLOCKS;
+ MinDoublyBlock = Entries + MinSinglyBlock;
+ MinTreblyBlock = EntriesEntries + MinDoublyBlock;
+
+ Type = Ext4DetectBlockType (LogicalBlock, Partition);
+
+ switch (Type) {
+ case EXT4_TYPE_DIRECT_BLOCK:
+ BlockPath[0] = LogicalBlock;
+ break;
+ case EXT4_TYPE_SINGLY_BLOCK:
+ BlockPath[0] = EXT4_IND_BLOCK;
+ BlockPath[1] = LogicalBlock - EXT4_DBLOCKS;
+ break;
+ case EXT4_TYPE_DOUBLY_BLOCK:
+ BlockPath[0] = EXT4_DIND_BLOCK;
+ LogicalBlock -= MinDoublyBlock;
+ BlockPath[1] = LogicalBlock / Entries;
+ BlockPath[2] = LogicalBlock % Entries;
+ break;
+ case EXT4_TYPE_TREBLY_BLOCK:
+ BlockPath[0] = EXT4_DIND_BLOCK;
+ LogicalBlock -= MinTreblyBlock;
+ BlockPath[1] = LogicalBlock / EntriesEntries;
+ BlockPath[2] = (LogicalBlock % EntriesEntries) / Entries;
+ BlockPath[3] = (LogicalBlock % EntriesEntries) % Entries;
+ break;
+ default:
+ // EXT4_TYPE_BAD_BLOCK
+ return -1;
+ }
+
+ return Type + 1;
+}
+
+/**
+ @brief Get an extent from a block map
+ Note: Also parses file holes and creates uninitialised extents from them.
+
+ @param[in] Buffer Buffer of block pointers
+ @param[in] IndEntries Number of entries in this block pointer table
+ @param[in] StartIndex The start index from which we want to find a contiguous extent
+ @param[out] Extent Pointer to the resulting EXT4_EXTENT
+ */
+VOID
+Ext4GetExtentInBlockMap (
+ IN CONST UINT32 *Buffer,
+ IN CONST UINT32 IndEntries,
+ IN UINT32 StartIndex,
+ OUT EXT4_EXTENT *Extent
+ )
+{
+ UINT32 Index;
+ UINT32 FirstBlock;
+ UINT32 LastBlock;
+ UINT16 Count;
+
+ Count = 1;
+ LastBlock = Buffer[StartIndex];
+ FirstBlock = LastBlock;
+
+ if (FirstBlock == EXT4_BLOCK_FILE_HOLE) {
+ // File hole, let's see how many blocks this hole spans
+ Extent->ee_start_hi = 0;
+ Extent->ee_start_lo = 0;
+
+ for (Index = StartIndex + 1; Index < IndEntries; Index++) {
+ if (Count == EXT4_EXTENT_MAX_INITIALIZED - 1) {
+ // We've reached the max size of an uninit extent, break
+ break;
+ }
+
+ if (Buffer[Index] == EXT4_BLOCK_FILE_HOLE) {
+ Count++;
+ } else {
+ break;
+ }
+ }
+
+ // We mark the extent as uninitialised, although there's a difference between uninit
+ // extents and file holes.
+ Extent->ee_len = EXT4_EXTENT_MAX_INITIALIZED + Count;
+ return;
+ }
+
+ for (Index = StartIndex + 1; Index < IndEntries; Index++) {
+ if (Count == EXT4_EXTENT_MAX_INITIALIZED) {
+ // We've reached the max size of an extent, break
+ break;
+ }
+
+ if ((Buffer[Index] == LastBlock + 1) && (Buffer[Index] != EXT4_BLOCK_FILE_HOLE)) {
+ Count++;
+ } else {
+ break;
+ }
+
+ LastBlock = Buffer[Index];
+ }
+
+ Extent->ee_start_lo = FirstBlock;
+ Extent->ee_start_hi = 0;
+ Extent->ee_len = Count;
+}
+
+/**
+ Retrieves an extent from an EXT2/3 inode (with a blockmap).
+ @param[in] Partition Pointer to the opened EXT4 partition.
+ @param[in] File Pointer to the opened file.
+ @param[in] LogicalBlock Block number which the returned extent must cover.
+ @param[out] Extent Pointer to the output buffer, where the extent will be copied to.
+
+ @retval EFI_SUCCESS Retrieval was succesful.
+ @retval EFI_NO_MAPPING Block has no mapping.
+**/
+EFI_STATUS
+Ext4GetBlocks (
+ IN EXT4_PARTITION *Partition,
+ IN EXT4_FILE *File,
+ IN EXT4_BLOCK_NR LogicalBlock,
+ OUT EXT4_EXTENT *Extent
+ )
+{
+ EXT4_INODE *Inode;
+ EXT4_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH];
+ UINTN BlockPathLength;
+ UINTN Index;
+ UINT32 *Buffer;
+ EFI_STATUS Status;
+ UINT32 Block;
+ UINT32 BlockIndex;
+
+ Inode = File->Inode;
+
+ BlockPathLength = Ext4GetBlockPath (Partition, LogicalBlock, BlockPath);
+
+ if (BlockPathLength == (UINTN)-1) {
+ // Bad logical block (out of range)
+ return EFI_NO_MAPPING;
+ }
+
+ Extent->ee_block = LogicalBlock;
+
+ if (BlockPathLength == 1) {
+ // Fast path for blocks 0 - 12 that skips allocations
+ Ext4GetExtentInBlockMap (Inode->i_data, EXT4_DBLOCKS, BlockPath[0], Extent);
+
+ return EFI_SUCCESS;
+ }
+
+ Buffer = AllocatePool (Partition->BlockSize);
+ if (Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ // Note the BlockPathLength - 1 so we don't end up reading the final block
+ for (Index = 0; Index < BlockPathLength - 1; Index++) {
+ BlockIndex = BlockPath[Index];
+
+ if (Index == 0) {
+ Block = Inode->i_data[BlockIndex];
+ } else {
+ Block = Buffer[BlockIndex];
+ }
+
+ if (Block == EXT4_BLOCK_FILE_HOLE) {
+ FreePool (Buffer);
+ return EFI_NO_MAPPING;
+ }
+
+ Status = Ext4ReadBlocks (Partition, Buffer, 1, Block);
+
+ if (EFI_ERROR (Status)) {
+ FreePool (Buffer);
+ return Status;
+ }
+ }
+
+ Ext4GetExtentInBlockMap (Buffer, Partition->BlockSize / sizeof (UINT32), BlockPath[BlockPathLength - 1], Extent);
+ FreePool (Buffer);
+
+ return EFI_SUCCESS;
+}
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
index 5f812215fbb8..a55cd2fa68ad 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
@@ -468,4 +468,6 @@ typedef UINT32 EXT4_INO_NR;
// 2 is always the root inode number in ext4
#define EXT4_ROOT_INODE_NR 2

+#define EXT4_BLOCK_FILE_HOLE 0
+
#endif
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
index 03e0586cbb05..b1508482b0a7 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
@@ -1151,4 +1151,22 @@ Ext4GetExtentLength (
IN CONST EXT4_EXTENT *Extent
);

+/**
+ Retrieves an extent from an EXT2/3 inode (with a blockmap).
+ @param[in] Partition Pointer to the opened EXT4 partition.
+ @param[in] File Pointer to the opened file.
+ @param[in] LogicalBlock Block number which the returned extent must cover.
+ @param[out] Extent Pointer to the output buffer, where the extent will be copied to.
+
+ @retval EFI_SUCCESS Retrieval was succesful.
+ @retval EFI_NO_MAPPING Block has no mapping.
+**/
+EFI_STATUS
+Ext4GetBlocks (
+ IN EXT4_PARTITION *Partition,
+ IN EXT4_FILE *File,
+ IN EXT4_BLOCK_NR LogicalBlock,
+ OUT EXT4_EXTENT *Extent
+ );
+
#endif
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf
index 12e89bf1fdfc..deaf89fb3743 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf
@@ -111,6 +111,7 @@
Collation.c
Ext4Disk.h
Ext4Dxe.h
+ BlockMap.c

[Packages]
MdePkg/MdePkg.dec
diff --git a/Features/Ext4Pkg/Ext4Dxe/Extents.c b/Features/Ext4Pkg/Ext4Dxe/Extents.c
index e920eed090fd..c3874df71751 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Extents.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Extents.c
@@ -1,7 +1,7 @@
/** @file
Extent related routines

- Copyright (c) 2021 Pedro Falcato All rights reserved.
+ Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -244,10 +244,6 @@ Ext4GetExtent (

DEBUG ((DEBUG_FS, "[ext4] Looking up extent for block %lu\n", LogicalBlock));

- if (!(Inode->i_flags & EXT4_EXTENTS_FL)) {
- return EFI_UNSUPPORTED;
- }
-
// ext4 does not have support for logical block numbers bigger than UINT32_MAX
if (LogicalBlock > (UINT32)-1) {
return EFI_NO_MAPPING;
@@ -261,6 +257,17 @@ Ext4GetExtent (
return EFI_SUCCESS;
}

+ if (!(Inode->i_flags & EXT4_EXTENTS_FL)) {
+ // If this is an older ext2/ext3 filesystem, emulate Ext4GetExtent using the block map
+ Status = Ext4GetBlocks (Partition, File, LogicalBlock, Extent);
+
+ if (!EFI_ERROR (Status)) {
+ Ext4CacheExtents (File, Extent, 1);
+ }
+
+ return Status;
+ }
+
// Slow path, we'll need to read from disk and (try to) cache those extents.

ExtHeader = Ext4GetInoExtentHeader (Inode);
diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/Inode.c
index f692909edf78..831f5946e870 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Inode.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c
@@ -1,7 +1,7 @@
/** @file
Inode related routines

- Copyright (c) 2021 Pedro Falcato All rights reserved.
+ Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

EpochToEfiTime copied from EmbeddedPkg/Library/TimeBaseLib.c
@@ -150,8 +150,9 @@ Ext4Read (
if (!HasBackingExtent) {
HoleLen = Partition->BlockSize - HoleOff;
} else {
- // Uninitialized extents behave exactly the same as file holes.
- HoleLen = Ext4GetExtentLength (&Extent) - HoleOff;
+ // Uninitialized extents behave exactly the same as file holes, except they have
+ // blocks already allocated to them.
+ HoleLen = (Ext4GetExtentLength (&Extent) * Partition->BlockSize) - HoleOff;
}

WasRead = HoleLen > RemainingRead ? RemainingRead : HoleLen;
@@ -176,7 +177,7 @@ Ext4Read (
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
- "[ext4] Error %x reading [%lu, %lu]\n",
+ "[ext4] Error %r reading [%lu, %lu]\n",
Status,
ExtentStartBytes + ExtentOffset,
ExtentStartBytes + ExtentOffset + WasRead - 1
diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index a7dbe9bf0fec..47fc3a65507a 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -1,7 +1,7 @@
/** @file
Superblock managing routines

- Copyright (c) 2021 Pedro Falcato All rights reserved.
+ Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -208,11 +208,6 @@ Ext4OpenSuperblock (
return EFI_UNSUPPORTED;
}

- // This should be removed once we add ext2/3 support in the future.
- if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_EXTENTS) == 0) {
- return EFI_UNSUPPORTED;
- }
-
if (EXT4_HAS_INCOMPAT (Partition, EXT4_FEATURE_INCOMPAT_RECOVER)) {
DEBUG ((DEBUG_WARN, "[ext4] Needs journal recovery, mounting read-only\n"));
Partition->ReadOnly = TRUE;
--
2.35.1


[PATCH edk2-platforms 1/3] Ext4Pkg: Replace the CRC implementations with BaseLib

Pedro Falcato
 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3871

Since the existing CRC16/CRC32c implementations have been/will be
a part of BaseLib, use BaseLib and remove the Crc16.c/Crc32c.c.

Cc: Leif Lindholm <leif@...>
Cc: Michael D Kinney <michael.d.kinney@...>

Signed-off-by: Pedro Falcato <pedro.falcato@...>
---
Features/Ext4Pkg/Ext4Dxe/BlockGroup.c | 10 ++--
Features/Ext4Pkg/Ext4Dxe/Crc16.c | 75 ------------------------
Features/Ext4Pkg/Ext4Dxe/Crc32c.c | 84 ---------------------------
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 34 +----------
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf | 2 -
5 files changed, 6 insertions(+), 199 deletions(-)
delete mode 100644 Features/Ext4Pkg/Ext4Dxe/Crc16.c
delete mode 100644 Features/Ext4Pkg/Ext4Dxe/Crc32c.c

diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
index abfeff52b139..9a1a41901f36 100644
--- a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
+++ b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
@@ -168,12 +168,12 @@ Ext4CalculateBlockGroupDescChecksumGdtCsum (

Dummy = 0;

- Csum = CalculateCrc16 (Partition->SuperBlock.s_uuid, 16, 0);
- Csum = CalculateCrc16 (&BlockGroupNum, sizeof (BlockGroupNum), Csum);
- Csum = CalculateCrc16 (BlockGroupDesc, OFFSET_OF (EXT4_BLOCK_GROUP_DESC, bg_checksum), Csum);
- Csum = CalculateCrc16 (&Dummy, sizeof (Dummy), Csum);
+ Csum = CalculateCrc16Ansi (Partition->SuperBlock.s_uuid, 16, 0);
+ Csum = CalculateCrc16Ansi (&BlockGroupNum, sizeof (BlockGroupNum), Csum);
+ Csum = CalculateCrc16Ansi (BlockGroupDesc, OFFSET_OF (EXT4_BLOCK_GROUP_DESC, bg_checksum), Csum);
+ Csum = CalculateCrc16Ansi (&Dummy, sizeof (Dummy), Csum);
Csum =
- CalculateCrc16 (
+ CalculateCrc16Ansi (
&BlockGroupDesc->bg_block_bitmap_hi,
Partition->DescSize - OFFSET_OF (EXT4_BLOCK_GROUP_DESC, bg_block_bitmap_hi),
Csum
diff --git a/Features/Ext4Pkg/Ext4Dxe/Crc16.c b/Features/Ext4Pkg/Ext4Dxe/Crc16.c
deleted file mode 100644
index 58d0220e4d30..000000000000
--- a/Features/Ext4Pkg/Ext4Dxe/Crc16.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/** @file
- CRC16 calculation routines.
-
- Copyright (c) 2021 Pedro Falcato All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include <Uefi.h>
-
-STATIC CONST UINT16 gCrc16LookupTable[256] =
-{
- 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
- 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
- 0x0919, 0x1890, 0x2a0b, 0x3b82, 0x4f3d, 0x5eb4, 0x6c2f, 0x7da6,
- 0x8551, 0x94d8, 0xa643, 0xb7ca, 0xc375, 0xd2fc, 0xe067, 0xf1ee,
- 0x1232, 0x03bb, 0x3120, 0x20a9, 0x5416, 0x459f, 0x7704, 0x668d,
- 0x9e7a, 0x8ff3, 0xbd68, 0xace1, 0xd85e, 0xc9d7, 0xfb4c, 0xeac5,
- 0x1b2b, 0x0aa2, 0x3839, 0x29b0, 0x5d0f, 0x4c86, 0x7e1d, 0x6f94,
- 0x9763, 0x86ea, 0xb471, 0xa5f8, 0xd147, 0xc0ce, 0xf255, 0xe3dc,
- 0x2464, 0x35ed, 0x0776, 0x16ff, 0x6240, 0x73c9, 0x4152, 0x50db,
- 0xa82c, 0xb9a5, 0x8b3e, 0x9ab7, 0xee08, 0xff81, 0xcd1a, 0xdc93,
- 0x2d7d, 0x3cf4, 0x0e6f, 0x1fe6, 0x6b59, 0x7ad0, 0x484b, 0x59c2,
- 0xa135, 0xb0bc, 0x8227, 0x93ae, 0xe711, 0xf698, 0xc403, 0xd58a,
- 0x3656, 0x27df, 0x1544, 0x04cd, 0x7072, 0x61fb, 0x5360, 0x42e9,
- 0xba1e, 0xab97, 0x990c, 0x8885, 0xfc3a, 0xedb3, 0xdf28, 0xcea1,
- 0x3f4f, 0x2ec6, 0x1c5d, 0x0dd4, 0x796b, 0x68e2, 0x5a79, 0x4bf0,
- 0xb307, 0xa28e, 0x9015, 0x819c, 0xf523, 0xe4aa, 0xd631, 0xc7b8,
- 0x48c8, 0x5941, 0x6bda, 0x7a53, 0x0eec, 0x1f65, 0x2dfe, 0x3c77,
- 0xc480, 0xd509, 0xe792, 0xf61b, 0x82a4, 0x932d, 0xa1b6, 0xb03f,
- 0x41d1, 0x5058, 0x62c3, 0x734a, 0x07f5, 0x167c, 0x24e7, 0x356e,
- 0xcd99, 0xdc10, 0xee8b, 0xff02, 0x8bbd, 0x9a34, 0xa8af, 0xb926,
- 0x5afa, 0x4b73, 0x79e8, 0x6861, 0x1cde, 0x0d57, 0x3fcc, 0x2e45,
- 0xd6b2, 0xc73b, 0xf5a0, 0xe429, 0x9096, 0x811f, 0xb384, 0xa20d,
- 0x53e3, 0x426a, 0x70f1, 0x6178, 0x15c7, 0x044e, 0x36d5, 0x275c,
- 0xdfab, 0xce22, 0xfcb9, 0xed30, 0x998f, 0x8806, 0xba9d, 0xab14,
- 0x6cac, 0x7d25, 0x4fbe, 0x5e37, 0x2a88, 0x3b01, 0x099a, 0x1813,
- 0xe0e4, 0xf16d, 0xc3f6, 0xd27f, 0xa6c0, 0xb749, 0x85d2, 0x945b,
- 0x65b5, 0x743c, 0x46a7, 0x572e, 0x2391, 0x3218, 0x0083, 0x110a,
- 0xe9fd, 0xf874, 0xcaef, 0xdb66, 0xafd9, 0xbe50, 0x8ccb, 0x9d42,
- 0x7e9e, 0x6f17, 0x5d8c, 0x4c05, 0x38ba, 0x2933, 0x1ba8, 0x0a21,
- 0xf2d6, 0xe35f, 0xd1c4, 0xc04d, 0xb4f2, 0xa57b, 0x97e0, 0x8669,
- 0x7787, 0x660e, 0x5495, 0x451c, 0x31a3, 0x202a, 0x12b1, 0x0338,
- 0xfbcf, 0xea46, 0xd8dd, 0xc954, 0xbdeb, 0xac62, 0x9ef9, 0x8f70
-};
-
-/**
- Calculates the CRC16 checksum of the given buffer.
-
- @param[in] Buffer Pointer to the buffer.
- @param[in] Length Length of the buffer, in bytes.
- @param[in] InitialValue Initial value of the CRC.
-
- @return The CRC16 checksum.
-**/
-UINT16
-CalculateCrc16 (
- IN CONST VOID *Buffer,
- IN UINTN Length,
- IN UINT16 InitialValue
- )
-{
- CONST UINT8 *Buf;
- UINT16 Crc;
-
- Buf = Buffer;
-
- Crc = ~InitialValue;
-
- while (Length-- != 0) {
- Crc = gCrc16LookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8);
- }
-
- return ~Crc;
-}
diff --git a/Features/Ext4Pkg/Ext4Dxe/Crc32c.c b/Features/Ext4Pkg/Ext4Dxe/Crc32c.c
deleted file mode 100644
index 9601316240d7..000000000000
--- a/Features/Ext4Pkg/Ext4Dxe/Crc32c.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/** @file
- CRC32c calculation routines.
-
- Copyright (c) 2021 Pedro Falcato All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include <Uefi.h>
-
-STATIC CONST UINT32 gCrc32cLookupTable[256] = {
- 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c,
- 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
- 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c,
- 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
- 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc,
- 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
- 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512,
- 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
- 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad,
- 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
- 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf,
- 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
- 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f,
- 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
- 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f,
- 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
- 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e,
- 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
- 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e,
- 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
- 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de,
- 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
- 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4,
- 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
- 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b,
- 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
- 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5,
- 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
- 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975,
- 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
- 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905,
- 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
- 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8,
- 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
- 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8,
- 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
- 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78,
- 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
- 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6,
- 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
- 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69,
- 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
- 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351
-};
-
-/**
- Calculates the CRC32c checksum of the given buffer.
-
- @param[in] Buffer Pointer to the buffer.
- @param[in] Length Length of the buffer, in bytes.
- @param[in] InitialValue Initial value of the CRC.
-
- @return The CRC32c checksum.
-**/
-UINT32
-CalculateCrc32c (
- IN CONST VOID *Buffer,
- IN UINTN Length,
- IN UINT32 InitialValue
- )
-{
- CONST UINT8 *Buf;
- UINT32 Crc;
-
- Buf = Buffer;
- Crc = ~InitialValue;
-
- while (Length-- != 0) {
- Crc = gCrc32cLookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8);
- }
-
- return ~Crc;
-}
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
index 1d9a4ac6bad3..fbdffd21f918 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
@@ -1,7 +1,7 @@
/** @file
Common header for the driver

- Copyright (c) 2021 Pedro Falcato All rights reserved.
+ Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -929,38 +929,6 @@ Ext4FreeExtentsMap (
IN EXT4_FILE *File
);

-/**
- Calculates the CRC32c checksum of the given buffer.
-
- @param[in] Buffer Pointer to the buffer.
- @param[in] Length Length of the buffer, in bytes.
- @param[in] InitialValue Initial value of the CRC.
-
- @return The CRC32c checksum.
-**/
-UINT32
-CalculateCrc32c (
- IN CONST VOID *Buffer,
- IN UINTN Length,
- IN UINT32 InitialValue
- );
-
-/**
- Calculates the CRC16 checksum of the given buffer.
-
- @param[in] Buffer Pointer to the buffer.
- @param[in] Length Length of the buffer, in bytes.
- @param[in] InitialValue Initial value of the CRC.
-
- @return The CRC16 checksum.
-**/
-UINT16
-CalculateCrc16 (
- IN CONST VOID *Buffer,
- IN UINTN Length,
- IN UINT16 InitialValue
- );
-
/**
Calculates the checksum of the given buffer.
@param[in] Partition Pointer to the opened EXT4 partition.
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf
index 6533de6247dc..12e89bf1fdfc 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf
@@ -109,8 +109,6 @@
Extents.c
File.c
Collation.c
- Crc32c.c
- Crc16.c
Ext4Disk.h
Ext4Dxe.h

--
2.35.1


[PATCH edk2-platforms 0/3] Ext4Pkg: Add ext2/3 support and move crc16/32c to BaseLib

Pedro Falcato
 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3745
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3871

Hi all,

This patch-set attempts to address two open feature requests for Ext4Pkg
by adding ext2/3 support (id 3745) and moving crc16-ansi/crc32c to BaseLib (id 3871).

The previous patch-set regarding 3871 attempted to merge the different crc16 implementations
but failed because, contrary to what I thought, there are many, many different CRC16s which
are all slightly different. This one (plus the separate edk2 patch) attempts to just merge
CRC16-ANSI (confusingly, also known as CRC16) into BaseLib.

Since this patch set grew to be considerably different from the original, I didn't mark it
as v2 but rather a separate, new patch-set.

CC'ing the edk2-platforms stewards (as I cannot review my own code) and the CC's of the MdePkg
patch.

Cc: Leif Lindholm <leif@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>

Pedro Falcato (3):
Ext4Pkg: Replace the CRC implementations with BaseLib
Ext4Pkg: Format using uncrustify
Ext4Pkg: Add ext2/3 support

Features/Ext4Pkg/Ext4Dxe/BlockGroup.c | 10 +-
Features/Ext4Pkg/Ext4Dxe/BlockMap.c | 279 +++++++++++++++++
Features/Ext4Pkg/Ext4Dxe/Collation.c | 4 +-
Features/Ext4Pkg/Ext4Dxe/Crc16.c | 75 -----
Features/Ext4Pkg/Ext4Dxe/Crc32c.c | 84 ------
Features/Ext4Pkg/Ext4Dxe/Directory.c | 13 +-
Features/Ext4Pkg/Ext4Dxe/DiskUtil.c | 6 +-
Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 30 +-
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c | 95 +++---
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 417 ++++++++++++++------------
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf | 3 +-
Features/Ext4Pkg/Ext4Dxe/Extents.c | 27 +-
Features/Ext4Pkg/Ext4Dxe/File.c | 19 +-
Features/Ext4Pkg/Ext4Dxe/Inode.c | 33 +-
Features/Ext4Pkg/Ext4Dxe/Partition.c | 12 +-
Features/Ext4Pkg/Ext4Dxe/Superblock.c | 20 +-
16 files changed, 640 insertions(+), 487 deletions(-)
create mode 100644 Features/Ext4Pkg/Ext4Dxe/BlockMap.c
delete mode 100644 Features/Ext4Pkg/Ext4Dxe/Crc16.c
delete mode 100644 Features/Ext4Pkg/Ext4Dxe/Crc32c.c

--
2.35.1


Re: GSoC 2022: Add S3 resume support to MinPlatform

Nate DeSimone
 

Hi Benjamin,

 

Welcome back! That sounds like a great project! Speaking from experience on the HDMI closed chassis work and how much work there is left to do there, I think that the two combined would qualify as a large project and they fit together rather naturally since the HDMI closed chassis debugging will undoubtedly help you get S3 resume working. It sounds like you have done some research already which is great! I’ll dig up the code that I have thus far and point you at it as well. What I have is mostly working but there does seem to be some bugs in it, especially around handling I/O errors on the DDC bus.

 

From what I remember most of the needed interaction was indeed with registered in the GMBUS, but I seem to recall also having to program some GPIOs as the PHY for the low speed DDC connection was implemented on the PCH side. Again… let me find the code and we can work from there.

 

Anyway, sounds like an awesome proposal and a fun summer project, feel free to write up a proposal 😊.

 

With Best Regards,

Nate

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Benjamin Doron
Sent: Tuesday, April 5, 2022 11:14 AM
To: devel@edk2.groups.io
Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>; Kubacki, Michael <michael.kubacki@...>
Subject: Re: [edk2-devel] GSoC 2022: Add S3 resume support to MinPlatform

 

Hi,

I'm looking for feedback on a proposal for a large project. I intend to implement S3 resume for MinPlatform (medium project) and develop closed chassis debug over an HDMI cable as an additional project to assist the bringup work. Commonly, serial ports in laptops are either difficult to access or missing entirely. As Nate has previously addressed (https://github.com/nate-desimone/Bus_Pirate#closed-chassis-debug-over-hdmi), HDMI's DDC pins offer a connection to an I2C controller available early in the boot process, making it a good candidate as early, accessible debug port.

 

On Intel chipsets, the GMBUS implements the I2C controller. It has registers inside the iGFX MMIO and is documented in Intel's iGFX PRMs. I plan to use the register definitions and the documentation of EDID access, along with the I2C specification, to develop this project.

 

Would this make for a good project proposal? I'd appreciate any feedback. Thanks.

 

Best regards,

Benjamin

 

 

On Tue, 22 Mar 2022 at 17:14, Benjamin Doron <benjamin.doron00@...> wrote:

Hi all,

I'm Benjamin Doron. Last year, I worked on a board port to MinPlatform. This year, I hope to pick up where I left off and help improve MinPlatform by adding support for S3 resume (time permitting and if my skills are sufficient, etc). Previously, I worked a little on coreboot (mainly a board port), and a fork with some improvements for UefiPayloadPkg.

 

I'm a little apprehensive reading the task proposal, but I really don't think that I would have to design the S3 architecture; the easiest part is adding the module stack. It's some of the deviations from the regular boot-flow in related areas like memory and CPU init (complicated by preparing the data structures and the adjacent FSP) that I have to worry about, as I understand (which I began looking at last year and discussed with Nate and Michael).

 

Before, code analysis gave me some hints and I found issues to address, but I want to consider actual possibilities for debugging. I've looked at the S3 boot-flow and from early PEI to the S3Resume2 PPI, the boot script and SMM, there are a lot of things to verify. Analysing code at each step to resolve issues might take a while. Some ideas I had:

  • Realistically, the SPI flash console or an accessible serial port.
  • Simics, or other simulator/emulator: Would be helpful, if the architecture of SimicsOpenBoardPkg weren't so different from MinPlatform.
  • System debug with DCI: Would be great, but my laptop has disconnected CPU<->PCH JTAG pins. Fixing this would presumably be very risky. (I now also have a Tigerlake system, where DCI might work, but I haven't tried and I don't have a port yet.)

I should mention that I'll almost certainly be taking at least one course, but no more than two.

 

Looking forward to working with you all!

 

Best regards,

Benjamin


Re: [GSoC 2022] Introducing myself & seeking for project ideas

Nate DeSimone
 

Hi Theo,

 

Great to meet you and welcome to the TianoCore project! Great to hear you are interested! Apologize for the tardiness in my response. Pedro is correct that the audio support task unfortunately did not make it past the finish line last year. My understanding is that the communication protocol for USB audio devices turned out to be much more complex than the student anticipated! It involved implementing several audio codecs as each device was allowed per spec to have a different set of supported codecs, and the transfer protocol was also highly non-trivial. I’m not sure where exactly things left off last year, Leif (cc’d) would have a better understanding there. Overall, I wouldn’t necessarily recommend that project because it seems like there was a lot of pitfalls and unpleasant surprises that were encountered along the way, but if are really interested in tackling a challenging project you are welcome to try taking it on.

 

The Qemu Minplatform port is something that I can speak with high levels of authority on. I’ve kinda been hoping that someone would pick that project 😊. I provided some background information on the MinPlatform Architecture in the following message on the mailing list: https://edk2.groups.io/g/devel/message/73152 Also, I would recommend that over the next couple months you read “Beyond BIOS” to learn more about the overall UEFI architecture.

 

The general goal of this project is to create a method of working on full featured UEFI firmware in an emulated environment. While there is some overlap between this and OVMF, over time OVMF has evolved to be used to initialize KVM and Xen virtual machines. The goals of being a developer sandbox vs. bootstrapping VM guest OSes don’t always align, which is where QemuOpenBoardPkg comes in.

 

For example, OVMF only implements UEFI variable services for DXE, and does not provide UEFI variable services in PEI or SMM. This is largely due to the virtualization focus that OVMF has gained over time. Given the focus on bootstrapping OSes, only implementing UEFI variables in DXE is fine. But for developers who want to test new SMM features without immediately integrating them into a real platform, having SMM variable services would immensely help. The same is true for PEI.

 

In parallel, MinPlatform Architecture is moving the methodologies for platform firmware development forward, by reducing the amount of platform specific code that needs to be written. But OVMF has not kept up with these new developments. So naturally, it make sense to combine these two together, which results in the QemuOpenBoardPkg project.

 

If any of this piques your interest I would be happy to answer any questions you have about it!

 

Hope this helps and welcome to the project!

 

With Best Regards,

Nate

 

From: Pedro Falcato <pedro.falcato@...>
Sent: Monday, April 4, 2022 2:13 PM
To: edk2-devel-groups-io <devel@edk2.groups.io>; theojehl76@...
Cc: Desimone, Nathaniel L <nathaniel.l.desimone@...>
Subject: Re: [edk2-devel] [GSoC 2022] Introducing myself & seeking for project ideas

 

Theo,

 

Sorry for leaving you on read!

 

CC'ing Nate as he knows a lot more about MinPlatform than I do!

 

Meanwhile, you can also take a look at the MinPlatform spec: https://edk2-docs.gitbook.io/edk-ii-minimum-platform-specification/

Since you're new to UEFI, you may also want to take a brief look (don't read it front-to-back, that's almost useless) at the UEFI spec: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf

 

Thanks,

Pedro

 

On Sat, Apr 2, 2022 at 1:01 PM Théo Jehl <theojehl76@...> wrote:

Hi Pedro,
Thanks a lot for your answer!

My bad then :') After taking a look at the tasks proposal lists I'm interested in the MinPlatform port to QEMU [1], of course, I'm open to other projects ideas that are not on the list. 

To talk about myself a little more, I have a bachelor's in computer science and it's my first year as a Master's student, and I took the embedded systems programming branch to learn more about operating systems, booting, and how systems work in general :) I'm only starting in the field but I have a lot of fun making the software interact with the hardware, and understanding how computers work under the hood.

And you are right, larger projects are way better to learn :) 

Best regards,
Théo

[1] https://github.com/tianocore/tianocore.github.io/wiki/Tasks-MinPlatform-QemuOpenBoardPkg



--

Pedro Falcato


Re: GSoC2022-Add Rust Support to EDK II.

Nate DeSimone
 

Hi Wenyu,

 

Great to meet you and welcome to the TianoCore project! Great to hear you are interested! Apologize for the tardiness in my response. Implementing Rust support sounds like a wonderful project and one that would really help advance the state of the art for UEFI firmware development! I am looking for someone with Rust experience that can help mentor this project. My usage of Rust at time of writing has not advanced very far beyond "Hello World." While I can give a great deal of knowledge and background on UEFI and EDK II, my ability to recommend how that be applied to a Rust binding is limited. However, I do know enough to suspect the vast majority of the work will be figuring out how to integrate the vast array of libraries that EDK II provides into a coherent and clean Rust binding. The one aspect of this project that I think will be interesting is figuring out is what to do about std:: in Rust. From what I have seen of the functionality there more or less assumes the existence of a libc implementation for the platform, which is not necessarily true for DXE and is absolutely not true for PEI. I would be interested in hearing your thought on how to handle that elegantly.

 

Hope this helps and welcome to the project!

 

With Best Regards,

Nate

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of huangwenyuu via groups.io
Sent: Sunday, April 3, 2022 6:46 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] GSoC2022-Add Rust Support to EDK II.

 

Hi!

I'm Wenyu Huang, pursueing the MPhil degree in the Chinese University of Hong Kong, Shenzhen. My research is focusing on the operating system and virtualization and I am familiar with using Rust. So I am so interested in Add Rust Support to EDK II. Could you guide me how to go through researching about the project? Thank you.

Best regards,

Wenyu Huang


Re: Applying for GSoC 2022: Add Rust Support to EDK II

Nate DeSimone
 

Hi Ayush,

Great to meet you and welcome to the TianoCore project! Great to hear you are interested! Apologize for the tardiness in my response. Implementing Rust support sounds like a wonderful project and one that would really help advance the state of the art for UEFI firmware development! I am looking for someone with Rust experience that can help mentor this project. My usage of Rust at time of writing has not advanced very far beyond "Hello World." While I can give a great deal of knowledge and background on UEFI and EDK II, my ability to recommend how that be applied to a Rust binding is limited. However, I do know enough to suspect the vast majority of the work will be figuring out how to integrate the vast array of libraries that EDK II provides into a coherent and clean Rust binding. The one aspect of this project that I think will be interesting is figuring out is what to do about std:: in Rust. From what I have seen of the functionality there more or less assumes the existence of a libc implementation for the platform, which is not necessarily true for DXE and is absolutely not true for PEI. I would be interested in hearing your thought on how to handle that elegantly.

I'm sorry that your patches haven't gotten much attention thus far. Once I find mentor(s) for the Rust project I'll make sure they pick those up and take a look at the work you have done thus far.

Hope this helps and welcome to the project!

With Best Regards,
Nate

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ayush Singh
Sent: Monday, April 4, 2022 10:18 AM
To: devel@edk2.groups.io
Cc: Bret.Barkelew@...; Desimone, Nathaniel L <nathaniel.l.desimone@...>; mhaeuser@...
Subject: [edk2-devel] Applying for GSoC 2022: Add Rust Support to EDK II

Hello everyone, I am a 2nd-year University Student from India. I am interested in applying for adding Rust support to EDK2. I have already introduced myself to the mailing list earlier
(https://edk2.groups.io/g/devel/message/87637) and have even submitted some patches for the edkii-rust branch in edk2-staging (which were not merged since that branch seems to be abandoned now).
- https://edk2.groups.io/g/devel/message/87753
- https://edk2.groups.io/g/devel/message/87754
- https://edk2.groups.io/g/devel/message/87755
- https://edk2.groups.io/g/devel/message/87756

Anyway, since no mentor has been listed for this project, I was wondering who should I discuss the proposal with? Normally, I think one is supposed to discuss the proposal details with a mentor in form of a google doc or something before submitting an application. So should I directly start by submitting a proposal through the GSoC application portal? Or is there someone I should contact first?

Ayush Singh


Re: Intel NUC platform firmware -- no serial I/O support?

manickavasakam karpagavinayagam
 

Laszlo/Gred :

Can you please let us know the GITHUB project location from where you have downloaded the source ?

Thank you

-Manic

-----Original Message-----
From: Laszlo Ersek <lersek@...>
Sent: Thursday, April 7, 2022 10:12 AM
To: Gerd Hoffmann <kraxel@...>
Cc: devel@edk2.groups.io; Ramesh R. <rameshr@...>; Sivaraman Nainar <sivaramann@...>; Manickavasakam Karpagavinayagam <manickavasakamk@...>
Subject: [EXTERNAL] Re: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

On 04/07/22 14:50, Gerd Hoffmann wrote:

Well, it at least looks like 16550 / ide hardware. Not sure how this
is actually implemented, I suspect it is virtual, maybe port access
traps into SMM and it's emulated there. Or the management engine can
intercept those port accesses somehow.
If today's hardware still works the same way I'd expect you have a
little driver taking the role of SioBusDxe, but binding to
PCI_CLASS_COMMUNICATION_SERIAL devices instead of a LPC bridge with
isa serial ports behind it. Possibly the AMI drivers you've seen are
just that.

Does the NUC accept unsigned firmware updates? If so we can maybe
just add a SioBusDxe driver variant customized for the NUC hardware
You are spot on, but reality is even simpler than this. :)

Here's what I've done:

(1) I cross-referenced three lists of PCI IDs:

(1.1) The supported IDs in the windows UART driver INF file, downloaded from Intel, for this NUC.

(1.2) The "lspci" output on the NUC.

(1.3) The "drivers/mfd/intel-lpss-pci.c" file in the Linux tree.

Result: there is no separate PCI device on this NUC that stands for a serial controller. Furthermore, "intel-lpss-pci.c" suggests all the "LPSS" serial ports (UARTs) are 16550 compatible -- see the reference chain

<all UART IDs> -> spt_uart_info -> uart_node -> uart_properties -> "snps,uart-16550-compatible".

(2) While navigating the (graphical) Setup UI, I noticed that HII debug messages *were* sent to the serial port, by this nice, graphical, Setup Browser.

(3) The particular (non-Linux) kernel that I booted on this NUC could flawlessly drive the serial port for input and output just by my specification of the bog standard params baud-rate=115200, 8 data bits, no parity, 1 stop bit.

That gave me the following idea:

commit 0e794fe273b77830532ffb003b0d5539d7ae9823 (HEAD ->
nuc_serial_pkg)
Author: Laszlo Ersek <lersek@...>
Date: Thu Apr 7 14:37:13 2022 +0200

add NucSerialPkg: build SerialDxe and TerminalDxe for the
NUC8i3PNH

Signed-off-by: Laszlo Ersek <lersek@...>

diff --git a/NucSerialPkg/NucSerialPkg.dec
b/NucSerialPkg/NucSerialPkg.dec new file mode 100644 index
000000000000..b077cde229c0
--- /dev/null
+++ b/NucSerialPkg/NucSerialPkg.dec
@@ -0,0 +1,13 @@
+## @file
+# UART 16650 serial port driver build for the NUC8i3PNH.
+#
+# Copyright (c) 2022, Red Hat, Inc.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent ##
+
+[Defines]
+ DEC_SPECIFICATION = 1.29
+ PACKAGE_NAME = NucSerialPkg
+ PACKAGE_GUID = afdaaf17-4a06-4d97-a456-1ede0db46bc0
+ PACKAGE_VERSION = 0.1
diff --git a/NucSerialPkg/NucSerialPkg.dsc
b/NucSerialPkg/NucSerialPkg.dsc new file mode 100644 index
000000000000..971fb2f96a43
--- /dev/null
+++ b/NucSerialPkg/NucSerialPkg.dsc
@@ -0,0 +1,46 @@
+## @file
+# UART 16650 serial port driver build for the NUC8i3PNH.
+#
+# Copyright (c) 2022, Red Hat, Inc.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent ##
+
+[Defines]
+ PLATFORM_NAME = NucSerial
+ PLATFORM_GUID = 30c397cf-a446-4f41-858f-9ae677547094
+ PLATFORM_VERSION = 0.1
+ DSC_SPECIFICATION = 1.30
+ OUTPUT_DIRECTORY = Build/NucSerial
+ SUPPORTED_ARCHITECTURES = X64
+ BUILD_TARGETS = NOOPT|DEBUG|RELEASE
+ SKUID_IDENTIFIER = DEFAULT
+
+[BuildOptions]
+ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
+ RELEASE_*_*_GENFW_FLAGS = --zero
+ GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+
+[LibraryClasses]
+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+ BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+
+DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+ IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+
+MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemory
+AllocationLib.inf
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+
+RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilter
+LibNull.inf
+
+ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRe
+portStatusCodeLibNull.inf
+ SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
+
+UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/Uefi
+BootServicesTableLib.inf
+
+UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEn
+tryPoint.inf
+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+
+UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLi
+b/UefiRuntimeServicesTableLib.inf
+
+[PcdsFeatureFlag]
+ gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE
+
+[Components]
+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+ MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
The key line is the following lib class resolution:

SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf

It's the simplest possible (= most compatible) approach on X64.

And It Just Works (TM), with the following two commands in the UEFI shell (after I copied the binaries to the USB stick, alongside the UEFI Shell binary I built earlier):

Shell> fs0:
FS0:\> cd efi\boot
FS0:\efi\boot\> load SerialDxe.efi
Image 'FS0:\EFI\BOOT\SerialDxe.efi' loaded at 2C801000 - Success
FS0:\efi\boot\> load TerminalDxe.efi Image
'FS0:\EFI\BOOT\TerminalDxe.efi' loaded at 2C7FB000 - Success
FS0:\efi\boot\>
At this point, the UEFI console is properly multiplexed to both serial and HDMI+USB.

(Side comment: SerialDxe is not even a UEFI_DRIVER just a DXE_DRIVER, so it produces SerialIo immediately.)

With the serial console up, I can provide a "drivers" output too:

FS0:\efi\boot\> drivers
T D
D Y C I
R P F A
V VERSION E G G #D #C DRIVER NAME IMAGE NAME
== ======== = = = == == =================================== ==========
49 00000017 D - - 1 - AMI USB Driver Uhcd
4B 00000017 B - - 1 3 AMI USB Bus Driver Uhcd
4C 00000002 D - - 2 - AMI USB Hid Driver Uhcd
4D 00000001 D - - 1 - AMI USB Mass Storage Driver Uhcd
78 00010000 ? - - - - AMI NTFS Driver NTFS
7A 00000001 D - - 2 - <null string> MouseDriver
7D 00000001 D - - 1 - AMI AHCI BUS Driver Ahci
7F 00000010 ? - - - - AMI Serial I/O Driver SerialIo
83 00000001 B - - 1 1 AMI NVMe BUS Driver Nvme
124 00000010 D - - 1 - Serial ATA Controller Initializatio
SataController
132 00000010 B - - 2 2 AMI Console Splitter Text Out Drive
ConSplitter
133 00000010 B - - 2 2 AMI Console Splitter Text In Driver
ConSplitter
134 00000010 B - - 1 1 AMI Console Splitter Pointer Driver ConSplitter
137 00000010 D - - 1 - AMI Graphic Console Driver GraphicsConsole
138 0000000A D - - 8 - Generic Disk I/O Driver DiskIoDxe
139 0000000B B - - 2 6 Partition Driver(MBR/GPT/El Torito) PartitionDxe
13D 00000000 ? - - - - Integrated Touch Driver IntegratedTouch
13E 0000000A ? - - - - Bluetooth Bus Driver BluetoothBusDxe
13F 0000000A ? - - - - <null string> BluetoothBusDxe
140 0000000A ? - - - - Bluetooth Connection Manager BluetoothConfigDxe
141 0000000A ? - - - - Bluetooth HID Driver BluetoothHidDxe
142 0000000A ? - - - - Hid Keyboard Driver HidKbDxe
143 0000000A ? - - - - Hid Mouse Driver HidMouseDxe
147 00000010 D - - 1 - AMI Generic LPC Super I/O Driver GenericSio
149 00A50111 B - - 1 17 AMI PCI Bus Driver PciBus
14B 00000010 ? - - - - AMI PS/2 Driver Ps2Main
14D 00000010 ? - - - - AMI Terminal Driver TerminalSrc
14E 0000000A ? - - - - IpSec Driver IpSecDxe
150 0000000A ? - - - - IpSec Driver IpSecDxe
151 0000000A ? - - - - VLAN Configuration Driver VlanConfigDxe
152 0000000A ? - - - - HttpDxe HttpDxe
153 0000000A ? - - - - HttpDxe HttpDxe
154 00000000 ? - - - - DNS Network Service Driver DnsDxe
155 00000000 ? - - - - DNS Network Service Driver DnsDxe
158 0000000A D - - 4 - FAT File System Driver Fat
159 0000000A ? - - - - iSCSI Driver IScsiDxe
15A 0000000A ? - - - - iSCSI Driver IScsiDxe
15C 0000000A ? - - - - SCSI Bus Driver ScsiBus
15D 0000000A ? - - - - Scsi Disk Driver ScsiDisk
16A 0900044A B - - 1 1 Intel(R) GOP Driver [9.0.1098] MemoryMapped(0x3,0x29A33018,0x29A44A98)
19B 0000000A B - - 1 1 Serial Terminal Driver \EFI\BOOT\TerminalDxe.efi
SerialDxe is not in the list, as it is not a UEFI driver (it does not install an instance of the Driver Binding protocol).

The curious parts are:

- what the "TerminalSrc" driver ("AMI Terminal Driver") stands for (it
does not bind the SerialIo instance installed by SerialDxe, not even
after "connect -r" -- that's why I need TerminalDxe from edk2),

- why the platform firmware packager thought it would be a good idea to
*exclude* the SerialDxe and TerminalDxe drivers -- these binaries
weigh in at 23 KB together, in a DEBUG build! And the hardware is
there...

Thanks,
Laszlo

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


[PATCH] BaseTools/Conf: Fix Dynamic-Library-File template

Jake Garver
 

In the Dynamic-Library-File template, add missing output file
declarations. These files are generated by the template and other rules
explicitly depend on them.

This change resolves missing dependency issues we encountered while
running a recursive make with job control.

Signed-off-by: Jake Garver <jake@...>
---
BaseTools/Conf/build_rule.template | 2 ++
1 file changed, 2 insertions(+)

diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template
index f401182344..4356623512 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -366,6 +366,8 @@

<OutputFile>
$(OUTPUT_DIR)(+)$(MODULE_NAME).efi
+ $(DEBUG_DIR)(+)$(MODULE_NAME).efi
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).map

<Command.MSFT, Command.INTEL, Command.RVCT, Command.CLANGPDB>
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
--
2.17.1


[PATCH] BaseTools: Fix dependency issue in PcdValueInit

Jake Garver
 

The generated Makefile was missing a dependency. This resulted in a
build-time race condition if the recursive make is multi-threaded and
shares job control.

Signed-off-by: Jake Garver <jake@...>
---
BaseTools/Source/Python/Workspace/DscBuildData.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index fc1e773417..d55ea1bbe2 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -97,7 +97,8 @@ PcdMakefileEnd = '''

AppTarget = '''
all: $(APPFILE)
-$(APPFILE): $(OBJECTS)
+$(APPLICATION): $(OBJECTS)
+$(APPFILE): $(APPLICATION)
%s
'''

--
2.17.1


Re: [PATCH v2] OvmfPkg/BhyveBhfPkg: add support for QemuFwCfg

Rebecca Cran
 

I've just looked at the patch and it looks good, though I haven't tested it.

So yes, please add:


Acked-by: Rebecca Cran <rebecca@...>

On 4/6/22 23:24, Corvin Köhne wrote:
Hi Peter and Rebecca,

thanks for your feedback. This patch is backward compatible. It checks
if QemuFwCfg is available and if QemuFwCfg is missing it falls
back to BhyveFwCtl.

So, should I add Reviewed-by (or Acked-by?) Peter and Rebecca to the
commit message?


Thanks
Corvin

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075



TianoCore Community Meeting 20220407 EMEA/NAMO

Demeter, Miki
 

TianoCore Community Meeting

 

 

**Highlights:**

- GSOC Need Additional Primary Mentors???

- Bugzilla Status update – Devs still need to update status (ongoing issue)

- UEFI Summit switched to Virtual only

- Question to the community Concerns about additional dependencies?

 

# Meeting Minutes:

 

1) **Event Updates (_5 minutes]**

- **UEFI Summit switched to Virtual only**

 

2) [**Stable Tag Updates (_5 minutes_)**

- Soft Freeze - 2022-

- Hard freeze - 2022-

- 2022- Release 

 -** Stable Tag 20220225 released **

 

3) **Stewards Download (_20 minutes_)**

-**Coverity Status**

-- No Updates

- Raised topic number of dependencies on external services (git sub-modules, tools VS, iasm, nasm, Python, pip module)

-- CI tools (spell check has a dependency on node package manager)

-- Stewards responsible to validate whether new dependencies are appropriate.

-- Developer helper tools (don’t affect CI builds)

-- Question to the community Concerns about additional dependencies

 

 

-** Bugzilla Status **

- Still Need developers to update issues Bug Scrubs working through issues

 

 

4) **Opens (_30 minutes_)**

- Brian Johnson concerned about the way build system has become too complex need to simplify, possibly a docker image to help

-- git submodules are complex and not well liked

- Rebecka helping Andrew to get the GDB scripts rebased and checked in waiting on a few more reviews.

- Rajnish – A way to run CI/CD Locally - https://github.com/tianocore/edk2/tree/master/.pytool#running-ci-locally

 

**AR: Miki reach out to Nate(GSOC) and Felix (Coverity)**

**AR: Forward info on UEFI Summit-  brian.johnson@..., Rajnish.s.chauhan@... **

 

Next meeting will be back on the on the first Thursday of the month.

 

 

-- 

Miki Demeter (she/her)

Security Researcher

IPAS GO

Intel Corporation

 

Portland Women in Tech Best Speaker 2019

miki.demeter@...

 


Event: TianoCore Community Meeting - EMEA / NAMO - 04/07/2022 #cal-reminder

devel@edk2.groups.io Calendar <noreply@...>
 

Reminder: TianoCore Community Meeting - EMEA / NAMO

When:
04/07/2022
9:00am to 10:00am
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_N2UyMTVhZjUtOTk3Ni00MmI0LTg0NmItNzIwYTkyMGJhYzNh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Miki Demeter

View Event

Description:

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 111 422 379 4

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,482062805#   United States, Sacramento

Phone Conference ID: 482 062 805#

Find a local number | Reset PIN

Learn More | Meeting options


Event: TianoCore Community Meeting - EMEA / NAMO - 04/07/2022 #cal-reminder

devel@edk2.groups.io Calendar <noreply@...>
 

Reminder: TianoCore Community Meeting - EMEA / NAMO

When:
04/07/2022
9:00am to 10:00am
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_N2UyMTVhZjUtOTk3Ni00MmI0LTg0NmItNzIwYTkyMGJhYzNh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Miki Demeter

View Event

Description:

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 111 422 379 4

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,482062805#   United States, Sacramento

Phone Conference ID: 482 062 805#

Find a local number | Reset PIN

Learn More | Meeting options


Re: edk2-libc Python Build issue

Michael D Kinney
 

Hi,

 

Yes.  This is a known issue.

 

https://bugzilla.tianocore.org/show_bug.cgi?id=3779

 

If you are interested, we could use the help fixing this issue.

 

Thanks,

 

Mike

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of M.T.
Sent: Wednesday, April 6, 2022 11:46 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] edk2-libc Python Build issue

 

Hello

 

I am trying to build the Python environment for UEFI as per Py368ReadMe.txt.

I am doing this on Ubuntu 20.04.4 LTS with GCC5 for X64, all instructions seem to be meant for windows and MSFT.

I was able to build everything else and verify that it works, so I don't see why this should be an issue, but I am running into several issues.

 

Initial error is missing Python.h.

The path to AppPkg/Applications/Python/Python-3.6.8/Include seems to be missing from the build command, I was able to fix that by modifying Python368.inf and under BuildOptions, adding: 

GCC:*_*_*_CC_FLAGS = -I$(WORKSPACE)/AppPkg/Applications/Python/Python-3.6.8/Include

However this then results in other errors such as unused functions - fixed with -Wno-unused-functions added to the same line above, and then finally redfinitions.

 

Is the build process of Python 3.6.8 documented anywhere that might help me out, or if someone could point me in the right direction, that would be greatly appreciated.

 

Thank you

xp

3841 - 3860 of 92312