Jonathan Zhang | 6d27778 | 2020-06-09 17:56:53 -0700 | [diff] [blame] | 1 | /** @file |
| 2 | OSTA Universal Disk Format (UDF) definitions. |
| 3 | |
| 4 | Copyright (C) 2014-2017 Paulo Alcantara <pcacjr@zytor.com> |
| 5 | |
| 6 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 7 | **/ |
| 8 | |
| 9 | #ifndef __UDF_H__ |
| 10 | #define __UDF_H__ |
| 11 | |
| 12 | #define UDF_BEA_IDENTIFIER "BEA01" |
| 13 | #define UDF_NSR2_IDENTIFIER "NSR02" |
| 14 | #define UDF_NSR3_IDENTIFIER "NSR03" |
| 15 | #define UDF_TEA_IDENTIFIER "TEA01" |
| 16 | |
| 17 | #define UDF_LOGICAL_SECTOR_SHIFT 11 |
| 18 | #define UDF_LOGICAL_SECTOR_SIZE ((UINT64)(1ULL << UDF_LOGICAL_SECTOR_SHIFT)) |
| 19 | #define UDF_VRS_START_OFFSET ((UINT64)(16ULL << UDF_LOGICAL_SECTOR_SHIFT)) |
| 20 | |
| 21 | typedef enum { |
| 22 | UdfPrimaryVolumeDescriptor = 1, |
| 23 | UdfAnchorVolumeDescriptorPointer = 2, |
| 24 | UdfVolumeDescriptorPointer = 3, |
| 25 | UdfImplemenationUseVolumeDescriptor = 4, |
| 26 | UdfPartitionDescriptor = 5, |
| 27 | UdfLogicalVolumeDescriptor = 6, |
| 28 | UdfUnallocatedSpaceDescriptor = 7, |
| 29 | UdfTerminatingDescriptor = 8, |
| 30 | UdfLogicalVolumeIntegrityDescriptor = 9, |
| 31 | UdfFileSetDescriptor = 256, |
| 32 | UdfFileIdentifierDescriptor = 257, |
| 33 | UdfAllocationExtentDescriptor = 258, |
| 34 | UdfFileEntry = 261, |
| 35 | UdfExtendedFileEntry = 266, |
| 36 | } UDF_VOLUME_DESCRIPTOR_ID; |
| 37 | |
| 38 | #pragma pack(1) |
| 39 | |
| 40 | typedef struct { |
| 41 | UINT16 TagIdentifier; |
| 42 | UINT16 DescriptorVersion; |
| 43 | UINT8 TagChecksum; |
| 44 | UINT8 Reserved; |
| 45 | UINT16 TagSerialNumber; |
| 46 | UINT16 DescriptorCRC; |
| 47 | UINT16 DescriptorCRCLength; |
| 48 | UINT32 TagLocation; |
| 49 | } UDF_DESCRIPTOR_TAG; |
| 50 | |
| 51 | typedef struct { |
| 52 | UINT32 ExtentLength; |
| 53 | UINT32 ExtentLocation; |
| 54 | } UDF_EXTENT_AD; |
| 55 | |
| 56 | typedef struct { |
| 57 | UINT8 CharacterSetType; |
| 58 | UINT8 CharacterSetInfo[63]; |
| 59 | } UDF_CHAR_SPEC; |
| 60 | |
| 61 | typedef struct { |
| 62 | UINT8 Flags; |
| 63 | UINT8 Identifier[23]; |
| 64 | union { |
| 65 | // |
| 66 | // Domain Entity Identifier |
| 67 | // |
| 68 | struct { |
| 69 | UINT16 UdfRevision; |
| 70 | UINT8 DomainFlags; |
| 71 | UINT8 Reserved[5]; |
| 72 | } Domain; |
| 73 | // |
| 74 | // UDF Entity Identifier |
| 75 | // |
| 76 | struct { |
| 77 | UINT16 UdfRevision; |
| 78 | UINT8 OSClass; |
| 79 | UINT8 OSIdentifier; |
| 80 | UINT8 Reserved[4]; |
| 81 | } Entity; |
| 82 | // |
| 83 | // Implementation Entity Identifier |
| 84 | // |
| 85 | struct { |
| 86 | UINT8 OSClass; |
| 87 | UINT8 OSIdentifier; |
| 88 | UINT8 ImplementationUseArea[6]; |
| 89 | } ImplementationEntity; |
| 90 | // |
| 91 | // Application Entity Identifier |
| 92 | // |
| 93 | struct { |
| 94 | UINT8 ApplicationUseArea[8]; |
| 95 | } ApplicationEntity; |
| 96 | // |
| 97 | // Raw Identifier Suffix |
| 98 | // |
| 99 | struct { |
| 100 | UINT8 Data[8]; |
| 101 | } Raw; |
| 102 | } Suffix; |
| 103 | } UDF_ENTITY_ID; |
| 104 | |
| 105 | typedef struct { |
| 106 | UINT32 LogicalBlockNumber; |
| 107 | UINT16 PartitionReferenceNumber; |
| 108 | } UDF_LB_ADDR; |
| 109 | |
| 110 | typedef struct { |
| 111 | UINT32 ExtentLength; |
| 112 | UDF_LB_ADDR ExtentLocation; |
| 113 | UINT8 ImplementationUse[6]; |
| 114 | } UDF_LONG_ALLOCATION_DESCRIPTOR; |
| 115 | |
| 116 | typedef struct { |
| 117 | UDF_DESCRIPTOR_TAG DescriptorTag; |
| 118 | UDF_EXTENT_AD MainVolumeDescriptorSequenceExtent; |
| 119 | UDF_EXTENT_AD ReserveVolumeDescriptorSequenceExtent; |
| 120 | UINT8 Reserved[480]; |
| 121 | } UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER; |
| 122 | |
| 123 | typedef struct { |
| 124 | UDF_DESCRIPTOR_TAG DescriptorTag; |
| 125 | UINT32 VolumeDescriptorSequenceNumber; |
| 126 | UDF_CHAR_SPEC DescriptorCharacterSet; |
| 127 | UINT8 LogicalVolumeIdentifier[128]; |
| 128 | UINT32 LogicalBlockSize; |
| 129 | UDF_ENTITY_ID DomainIdentifier; |
| 130 | UDF_LONG_ALLOCATION_DESCRIPTOR LogicalVolumeContentsUse; |
| 131 | UINT32 MapTableLength; |
| 132 | UINT32 NumberOfPartitionMaps; |
| 133 | UDF_ENTITY_ID ImplementationIdentifier; |
| 134 | UINT8 ImplementationUse[128]; |
| 135 | UDF_EXTENT_AD IntegritySequenceExtent; |
| 136 | UINT8 PartitionMaps[6]; |
| 137 | } UDF_LOGICAL_VOLUME_DESCRIPTOR; |
| 138 | |
| 139 | #pragma pack() |
| 140 | |
| 141 | #endif |