[edk2] [PATCH 1/4] MdeModulePkg/PartitionDxe: Add UDF/ECMA-167 file system support

Paulo Alcantara posted 4 patches 7 years, 4 months ago
There is a newer version of this series
[edk2] [PATCH 1/4] MdeModulePkg/PartitionDxe: Add UDF/ECMA-167 file system support
Posted by Paulo Alcantara 7 years, 4 months ago
UDF revision 2.00 or higher is the only supported.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
---
 MdeModulePkg/MdeModulePkg.dec                      |   6 +
 .../Universal/Disk/PartitionDxe/Partition.c        |   3 +-
 .../Universal/Disk/PartitionDxe/Partition.h        |  41 ++-
 .../Universal/Disk/PartitionDxe/PartitionDxe.inf   |  10 +-
 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c     | 335 +++++++++++++++++++++
 MdePkg/Include/IndustryStandard/Udf.h              |  78 +++++
 6 files changed, 465 insertions(+), 8 deletions(-)
 create mode 100644 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
 create mode 100644 MdePkg/Include/IndustryStandard/Udf.h

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 593bff357a..3bc3b65ebb 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -794,6 +794,12 @@
   # @Prompt Turn on PS2 Mouse Extended Verification
   gEfiMdeModulePkgTokenSpaceGuid.PcdPs2MouseExtendedVerification|TRUE|BOOLEAN|0x00010075
 
+  ## Indicates if UDF/ECMA-167 filesystem will be supported.<BR><BR>
+  #   TRUE  -  UDF/ECMA-167 filesystem will be supported.<BR>
+  #   FALSE - UDF/ECMA-167 filesystem will not be supported.<BR>
+  # @Prompt Enable UDF/ECMA-167 filesystem support.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUdfFileSystemSupport|FALSE|BOOLEAN|0x00010077
+
   ## Indicates whether 64-bit PCI MMIO BARs should degrade to 32-bit in the presence of an option ROM
   #  On X64 platforms, Option ROMs may contain code that executes in the context of a legacy BIOS (CSM),
   #  which requires that all PCI MMIO BARs are located below 4 GB
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
index 5a7d119b43..152bc72738 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
@@ -2,7 +2,7 @@
   Partition driver that produces logical BlockIo devices from a physical
   BlockIo device. The logical BlockIo devices are based on the format
   of the raw block devices media. Currently "El Torito CD-ROM", Legacy
-  MBR, and GPT partition schemes are supported.
+  MBR, GPT partition and UDF/ECMA-167 volume schemes are supported.
 
 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
@@ -45,6 +45,7 @@ PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
   PartitionInstallGptChildHandles,
   PartitionInstallElToritoChildHandles,
   PartitionInstallMbrChildHandles,
+  PartitionInstallUdfChildHandles,
   NULL
 };
 
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
index f2f6185317..a205e3e47b 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
@@ -1,8 +1,8 @@
 /** @file
-  Partition driver that produces logical BlockIo devices from a physical 
+  Partition driver that produces logical BlockIo devices from a physical
   BlockIo device. The logical BlockIo devices are based on the format
-  of the raw block devices media. Currently "El Torito CD-ROM", Legacy 
-  MBR, and GPT partition schemes are supported.
+  of the raw block devices media. Currently "El Torito CD-ROM", Legacy
+  MBR, GPT partition and UDF/ECMA-167 volume schemes are supported.
 
 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
@@ -15,8 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
-#ifndef _PARTITION_H_ 
-#define _PARTITION_H_ 
+#ifndef _PARTITION_H_
+#define _PARTITION_H_
 
 #include <Uefi.h>
 #include <Protocol/BlockIo.h>
@@ -39,6 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 #include <IndustryStandard/Mbr.h>
 #include <IndustryStandard/ElTorito.h>
+#include <IndustryStandard/Udf.h>
 
 
 //
@@ -428,7 +429,7 @@ PartitionInstallElToritoChildHandles (
   @param[in]  BlockIo           Parent BlockIo interface.
   @param[in]  BlockIo2          Parent BlockIo2 interface.
   @param[in]  DevicePath        Parent Device Path.
-   
+
   @retval EFI_SUCCESS       A child handle was added.
   @retval EFI_MEDIA_CHANGED Media change was detected.
   @retval Others            MBR partition was not found.
@@ -445,6 +446,34 @@ PartitionInstallMbrChildHandles (
   IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath
   );
 
+/**
+  Install child handles if the Handle supports UDF/ECMA-167 volume format.
+
+  @param[in]  This        Calling context.
+  @param[in]  Handle      Parent Handle.
+  @param[in]  DiskIo      Parent DiskIo interface.
+  @param[in]  DiskIo2     Parent DiskIo2 interface.
+  @param[in]  BlockIo     Parent BlockIo interface.
+  @param[in]  BlockIo2    Parent BlockIo2 interface.
+  @param[in]  DevicePath  Parent Device Path
+
+
+  @retval EFI_SUCCESS         Child handle(s) was added.
+  @retval EFI_MEDIA_CHANGED   Media changed Detected.
+  @retval other               no child handle was added.
+
+**/
+EFI_STATUS
+PartitionInstallUdfChildHandles (
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN  EFI_HANDLE                   Handle,
+  IN  EFI_DISK_IO_PROTOCOL         *DiskIo,
+  IN  EFI_DISK_IO2_PROTOCOL        *DiskIo2,
+  IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,
+  IN  EFI_BLOCK_IO2_PROTOCOL       *BlockIo2,
+  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath
+  );
+
 typedef
 EFI_STATUS
 (*PARTITION_DETECT_ROUTINE) (
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
index 48212773e8..1dfe5509a0 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
@@ -4,7 +4,7 @@
 #  This module produces the logical Block I/O device that represents
 #  the bytes from Start to End of the Parent Block I/O device.
 #  The partition of physical BlockIo device supported is one of legacy MBR, GPT,
-#  and "El Torito" partitions.
+#  "El Torito" partitions and UDF/ECMA-167 volumes.
 #
 #  Caution: This module requires additional review when modified.
 #  This driver will have external input - disk partition.
@@ -46,12 +46,14 @@
   Mbr.c
   Gpt.c
   ElTorito.c
+  Udf.c
   Partition.c
   Partition.h
 
 
 [Packages]
   MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
 
 
 [LibraryClasses]
@@ -63,6 +65,7 @@
   BaseLib
   UefiDriverEntryPoint
   DebugLib
+  PcdLib
 
 
 [Guids]
@@ -86,5 +89,10 @@
   gEfiDiskIoProtocolGuid                        ## TO_START
   gEfiDiskIo2ProtocolGuid                       ## TO_START
 
+
+[FeaturePcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUdfFileSystemSupport  ## CONSUMES
+
+
 [UserExtensions.TianoCore."ExtraFiles"]
   PartitionDxeExtra.uni
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
new file mode 100644
index 0000000000..333b93d666
--- /dev/null
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
@@ -0,0 +1,335 @@
+/** @file
+  Decode a UDF/ECMA-167 formatted media.
+
+  Copyright (C) 2014-2017 Paulo Alcantara <pcacjr@zytor.com>
+
+  This program and the accompanying materials are licensed and made available
+  under the terms and conditions of the BSD License which accompanies this
+  distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#include "Partition.h"
+
+EFI_GUID gUdfVolumeSignatureGuid = {
+  0xC5BD4D42, 0x1A76, 0x4996,
+  { 0x89, 0x56, 0x73, 0xCD, 0xA3, 0x26, 0xCD, 0x0A }
+};
+
+//
+// The UDF/ECMA-167 file system driver only supports UDF revision 2.00 or
+// higher.
+//
+// Note the "NSR03" identifier.
+//
+UDF_STANDARD_IDENTIFIER gUdfStandardIdentifiers[NR_STANDARD_IDENTIFIERS] = {
+  { { 'B', 'E', 'A', '0', '1' } },
+  { { 'N', 'S', 'R', '0', '3' } },
+  { { 'T', 'E', 'A', '0', '1' } },
+};
+
+typedef struct {
+  VENDOR_DEVICE_PATH        DevicePath;
+  EFI_DEVICE_PATH_PROTOCOL  End;
+} UDF_DEVICE_PATH;
+
+//
+// C5BD4D42-1A76-4996-8956-73CDA326CD0A
+//
+#define EFI_UDF_DEVICE_PATH_GUID \
+  { 0xC5BD4D42, 0x1A76, 0x4996, \
+    { 0x89, 0x56, 0x73, 0xCD, 0xA3, 0x26, 0xCD, 0x0A } \
+  }
+
+UDF_DEVICE_PATH gUdfDevicePath = {
+  { { MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,
+      { sizeof (VENDOR_DEVICE_PATH), 0 } },
+    EFI_UDF_DEVICE_PATH_GUID
+  },
+  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
+    { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+  }
+};
+
+EFI_STATUS
+FindAnchorVolumeDescriptorPointer (
+  IN   EFI_BLOCK_IO_PROTOCOL                 *BlockIo,
+  IN   EFI_DISK_IO_PROTOCOL                  *DiskIo,
+  OUT  UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER  *AnchorPoint
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      BlockSize;
+  EFI_LBA     EndLBA;
+
+  BlockSize  = BlockIo->Media->BlockSize;
+  EndLBA     = BlockIo->Media->LastBlock;
+
+  //
+  // Look for AVDP at LBA 256.
+  //
+  Status = DiskIo->ReadDisk (
+    DiskIo,
+    BlockIo->Media->MediaId,
+    256ULL * BlockSize,
+    sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER),
+    (VOID *)AnchorPoint
+    );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (IS_AVDP (AnchorPoint)) {
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Look for AVDP at last LBA - 256.
+  //
+  Status = DiskIo->ReadDisk (
+    DiskIo,
+    BlockIo->Media->MediaId,
+    MultU64x32 (EndLBA - 256, BlockSize),
+    sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER),
+    (VOID *)AnchorPoint
+    );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (IS_AVDP (AnchorPoint)) {
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Look for AVDP at last LBA.
+  //
+  Status = DiskIo->ReadDisk (
+    DiskIo,
+    BlockIo->Media->MediaId,
+    MultU64x32 (EndLBA, BlockSize),
+    sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER),
+    (VOID *)AnchorPoint
+    );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (IS_AVDP (AnchorPoint)) {
+    return EFI_SUCCESS;
+  }
+
+  //
+  // No AVDP found in this media.
+  //
+  return EFI_VOLUME_CORRUPTED;
+}
+
+EFI_STATUS
+SupportUdfFileSystem (
+  IN EFI_BLOCK_IO_PROTOCOL  *BlockIo,
+  IN EFI_DISK_IO_PROTOCOL   *DiskIo
+  )
+{
+  EFI_STATUS                            Status;
+  UINT64                                Offset;
+  UINT64                                EndDiskOffset;
+  UDF_VOLUME_DESCRIPTOR                 VolDescriptor;
+  UDF_VOLUME_DESCRIPTOR                 TerminatingVolDescriptor;
+  UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER  AnchorPoint;
+
+  ZeroMem ((VOID *)&TerminatingVolDescriptor, sizeof (UDF_VOLUME_DESCRIPTOR));
+
+  //
+  // Start Volume Recognition Sequence.
+  //
+  EndDiskOffset = MultU64x32 (BlockIo->Media->LastBlock, BlockIo->Media->BlockSize);
+
+  for (Offset = UDF_VRS_START_OFFSET; Offset < EndDiskOffset;
+       Offset += UDF_LOGICAL_SECTOR_SIZE) {
+    Status = DiskIo->ReadDisk (
+      DiskIo,
+      BlockIo->Media->MediaId,
+      Offset,
+      sizeof (UDF_VOLUME_DESCRIPTOR),
+      (VOID *)&VolDescriptor
+      );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+
+    if (CompareMem ((VOID *)&VolDescriptor.StandardIdentifier,
+                    (VOID *)&gUdfStandardIdentifiers[BEA_IDENTIFIER],
+                    UDF_STANDARD_IDENTIFIER_LENGTH) == 0) {
+      break;
+    }
+
+    if ((CompareMem ((VOID *)&VolDescriptor.StandardIdentifier,
+                     (VOID *)UDF_CDROM_VOLUME_IDENTIFIER,
+                     UDF_STANDARD_IDENTIFIER_LENGTH) != 0) ||
+        CompareMem ((VOID *)&VolDescriptor,
+                    (VOID *)&TerminatingVolDescriptor,
+                    sizeof (UDF_VOLUME_DESCRIPTOR)) == 0) {
+      return EFI_UNSUPPORTED;
+    }
+  }
+
+  //
+  // Look for "NSR03" identifier in the Extended Area.
+  //
+  Offset += UDF_LOGICAL_SECTOR_SIZE;
+  if (Offset >= EndDiskOffset) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Status = DiskIo->ReadDisk (
+                          DiskIo,
+                          BlockIo->Media->MediaId,
+                          Offset,
+                          sizeof (UDF_VOLUME_DESCRIPTOR),
+                          (VOID *)&VolDescriptor
+                          );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (CompareMem ((VOID *)&VolDescriptor.StandardIdentifier,
+                  (VOID *)&gUdfStandardIdentifiers[VSD_IDENTIFIER],
+                  UDF_STANDARD_IDENTIFIER_LENGTH) != 0) {
+    return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Look for "TEA01" identifier in the Extended Area
+  //
+  Offset += UDF_LOGICAL_SECTOR_SIZE;
+  if (Offset >= EndDiskOffset) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Status = DiskIo->ReadDisk (
+    DiskIo,
+    BlockIo->Media->MediaId,
+    Offset,
+    sizeof (UDF_VOLUME_DESCRIPTOR),
+    (VOID *)&VolDescriptor
+    );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (CompareMem ((VOID *)&VolDescriptor.StandardIdentifier,
+                  (VOID *)&gUdfStandardIdentifiers[TEA_IDENTIFIER],
+                  UDF_STANDARD_IDENTIFIER_LENGTH) != 0) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Status = FindAnchorVolumeDescriptorPointer (BlockIo, DiskIo, &AnchorPoint);
+  if (EFI_ERROR (Status)) {
+    return EFI_UNSUPPORTED;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Install child handles if the Handle supports UDF/ECMA-167 volume format.
+
+  @param[in]  This        Calling context.
+  @param[in]  Handle      Parent Handle.
+  @param[in]  DiskIo      Parent DiskIo interface.
+  @param[in]  DiskIo2     Parent DiskIo2 interface.
+  @param[in]  BlockIo     Parent BlockIo interface.
+  @param[in]  BlockIo2    Parent BlockIo2 interface.
+  @param[in]  DevicePath  Parent Device Path
+
+
+  @retval EFI_SUCCESS         Child handle(s) was added.
+  @retval EFI_MEDIA_CHANGED   Media changed Detected.
+  @retval other               no child handle was added.
+
+**/
+EFI_STATUS
+PartitionInstallUdfChildHandles (
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN  EFI_HANDLE                   Handle,
+  IN  EFI_DISK_IO_PROTOCOL         *DiskIo,
+  IN  EFI_DISK_IO2_PROTOCOL        *DiskIo2,
+  IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,
+  IN  EFI_BLOCK_IO2_PROTOCOL       *BlockIo2,
+  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath
+  )
+{
+  EFI_STATUS                   Status;
+  EFI_BLOCK_IO_MEDIA           *Media;
+  EFI_DEVICE_PATH_PROTOCOL     *LastDevicePathNode;
+  EFI_DEVICE_PATH_PROTOCOL     *DevicePathNode;
+  EFI_GUID                     *VendorDevGuid;
+  EFI_GUID                     UdfDevGuid = EFI_UDF_DEVICE_PATH_GUID;
+  EFI_PARTITION_INFO_PROTOCOL  PartitionInfo;
+
+  Media = BlockIo->Media;
+
+  //
+  // Check if platform supports UDF file system.
+  //
+  if (!FeaturePcdGet (PcdUdfFileSystemSupport)) {
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Check if UDF logical block size is multiple of underlying device block
+  // size.
+  //
+  if ((UDF_LOGICAL_SECTOR_SIZE % Media->BlockSize) != 0 ||
+      (Media->BlockSize > UDF_LOGICAL_SECTOR_SIZE)) {
+    return EFI_NOT_FOUND;
+  }
+
+  Status = SupportUdfFileSystem (BlockIo, DiskIo);
+  if (EFI_ERROR (Status)) {
+    return EFI_NOT_FOUND;
+  }
+
+  LastDevicePathNode = NULL;
+  DevicePathNode = DevicePath;
+  while (!IsDevicePathEnd (DevicePathNode)) {
+    LastDevicePathNode  = DevicePathNode;
+    DevicePathNode      = NextDevicePathNode (DevicePathNode);
+  }
+  if (LastDevicePathNode) {
+    VendorDevGuid = (EFI_GUID *)((UINT8 *)LastDevicePathNode +
+                                 OFFSET_OF (VENDOR_DEVICE_PATH, Guid));
+    if (DevicePathSubType (LastDevicePathNode) == MEDIA_VENDOR_DP &&
+        CompareGuid (VendorDevGuid, &UdfDevGuid)) {
+      return EFI_NOT_FOUND;
+    }
+  }
+
+  ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL));
+  PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION;
+  PartitionInfo.Type = PARTITION_TYPE_OTHER;
+
+  Status = PartitionInstallChildHandle (
+    This,
+    Handle,
+    DiskIo,
+    DiskIo2,
+    BlockIo,
+    BlockIo2,
+    DevicePath,
+    (EFI_DEVICE_PATH_PROTOCOL *)&gUdfDevicePath,
+    &PartitionInfo,
+    0,
+    Media->LastBlock,
+    Media->BlockSize
+    );
+  if (!EFI_ERROR (Status)) {
+    Status = EFI_NOT_FOUND;
+  }
+
+  return Status;
+}
diff --git a/MdePkg/Include/IndustryStandard/Udf.h b/MdePkg/Include/IndustryStandard/Udf.h
new file mode 100644
index 0000000000..d571424315
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Udf.h
@@ -0,0 +1,78 @@
+/** @file
+  UDF/ECMA-167 Volume and File Structure Format Definition.
+
+  Copyright (C) 2014-2017 Paulo Alcantara <pcacjr@zytor.com>
+
+  This program and the accompanying materials are licensed and made available
+  under the terms and conditions of the BSD License which accompanies this
+  distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#ifndef _UDF_H_
+#define _UDF_H_
+
+#define UDF_LOGICAL_SECTOR_SHIFT  11
+#define UDF_LOGICAL_SECTOR_SIZE   ((UINT64)(1ULL << UDF_LOGICAL_SECTOR_SHIFT))
+#define UDF_VRS_START_OFFSET      ((UINT64)(16ULL << UDF_LOGICAL_SECTOR_SHIFT))
+#define UDF_STANDARD_IDENTIFIER_LENGTH  5
+#define UDF_CDROM_VOLUME_IDENTIFIER     "CD001"
+
+#define _GET_TAG_ID(_Pointer) \
+  (((UDF_DESCRIPTOR_TAG *) (_Pointer))->TagIdentifier)
+
+#define IS_PVD(_Pointer) \
+  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 1))
+#define IS_AVDP(_Pointer) \
+  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 2))
+
+typedef struct {
+  UINT8 StandardIdentifier[UDF_STANDARD_IDENTIFIER_LENGTH];
+} UDF_STANDARD_IDENTIFIER;
+
+enum {
+  BEA_IDENTIFIER,
+  VSD_IDENTIFIER,
+  TEA_IDENTIFIER,
+  NR_STANDARD_IDENTIFIERS,
+};
+
+#pragma pack(1)
+
+typedef struct {
+  UINT16  TagIdentifier;
+  UINT16  DescriptorVersion;
+  UINT8   TagChecksum;
+  UINT8   Reserved;
+  UINT16  TagSerialNumber;
+  UINT16  DescriptorCRC;
+  UINT16  DescriptorCRCLength;
+  UINT32  TagLocation;
+} UDF_DESCRIPTOR_TAG;
+
+typedef struct {
+  UINT32  ExtentLength;
+  UINT32  ExtentLocation;
+} UDF_EXTENT_AD;
+
+typedef struct {
+  UINT8  StructureType;
+  UINT8  StandardIdentifier[UDF_STANDARD_IDENTIFIER_LENGTH];
+  UINT8  StructureVersion;
+  UINT8  Reserved;
+  UINT8  StructureData[2040];
+} UDF_VOLUME_DESCRIPTOR;
+
+typedef struct {
+  UDF_DESCRIPTOR_TAG  DescriptorTag;
+  UDF_EXTENT_AD       MainVolumeDescriptorSequenceExtent;
+  UDF_EXTENT_AD       ReserveVolumeDescriptorSequenceExtent;
+  UINT8               Reserved[480];
+} UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER;
+
+#pragma pack()
+
+#endif // _UDF_H_
-- 
2.11.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel