Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. layout.hxx
  5. Abstract:
  6. This contains definitions and constants for the efiformat utility.
  7. Revision History:
  8. --*/
  9. #ifndef __LAYOUT__
  10. #define __LAYOUT__
  11. #include "efiwintypes.hxx"
  12. //
  13. // types and defines for format
  14. //
  15. #define FAT_TYPE_ILLEGAL 0
  16. #define FAT_TYPE_F12 1
  17. #define FAT_TYPE_F16 2
  18. #define FAT_TYPE_F32 3
  19. typedef struct _PART_DESCRIPTOR {
  20. ULONGLONG SectorCount; // number of sectors in the partition
  21. UINT32 SectorSize; // bytes per sector, one of 512, 1024, 2048, 4096
  22. UINT32 HeaderCount; // sectors before 1st fat (total), NOT counting FATs
  23. UINT32 FatEntrySize; // 4 or 2, this code isn't for FAT12
  24. UINT32 MinClusterCount; // Minimum allowed clusters - count, NOT index
  25. UINT32 MaxClusterCount; // Maximum allowed clusters - count, NOT index
  26. // MinClusterCount <= ClusterCount <= MaxClusterCount
  27. UINT32 SectorsPerCluster; // 1 to 128
  28. UINT32 FatSectorCount; // Size of ONE Fat table IN SECTORS
  29. UINT32 FatType; // one of
  30. } PART_DESCRIPTOR, *PPART_DESCRIPTOR;
  31. //
  32. // All FAT constants
  33. //
  34. #define MAX_CLUSTER_BYTES (32*1024)
  35. //
  36. // FAT32 Constants
  37. //
  38. #define MIN_CLUSTER_F32 65525
  39. #define SAFE_MIN_CLUSTER_F32 (MIN_CLUSTER_F32 + 16)
  40. #define SMALLEST_FAT32_BYTES SAFE_MIN_CLUSTER_F32 * 4
  41. #define HEADER_F32 33 // 1 boot, 32 free reserved
  42. #define MAX_CLUSTER_F32 (0xfffffff-1) // max 28 bit number, -2 (first used index),
  43. // +1 it's an inclusive count.
  44. // max of 0xffffffe named 2 to 0xfffffff
  45. #define FATS_F32 2 // number of FATS
  46. //
  47. // FAT16 Constants
  48. //
  49. #define MIN_CLUSTER_F16 4085
  50. #define SAFE_MIN_CLUSTER_F16 (MIN_CLUSTER_F16 + 16)
  51. #define SMALLEST_FAT16_BYTES SAFE_MIN_CLUSTER_F16 * 2
  52. #define HEADER_F16 1 // boot sector only
  53. #define MAX_CLUSTER_F16 65524
  54. #define FATS_F16 2 // number of FATS
  55. // prototypes
  56. // layout choice functions
  57. // found in layout.c
  58. BOOLEAN // TRUE if success, FALSE if failure
  59. ChooseLayout(
  60. PPART_DESCRIPTOR PartDes // Pointer to characteristic description of partition
  61. );
  62. UINT32 // Min. # of sectors for Fat32 part. for given sector size
  63. MinSectorsFat32(
  64. UINT32 SectorSize // The Sector size in question
  65. );
  66. UINT32 // Min. # of sectors for Fat16 part. for given sector size
  67. MinSectorsFat16(
  68. UINT32 SectorSize // Sector size to compute for
  69. );
  70. BOOLEAN // TRUE for success, FALSE for failure
  71. PickClusterSize(
  72. PPART_DESCRIPTOR PartDes, // characteristics of part. at hand
  73. PUINT32 ReturnedSectorsPerCluster, // RETURNED = number of sectors per cluster
  74. PUINT32 ReturnedFatSize // RETURNED = number of sectors for FAT
  75. );
  76. BOOLEAN // FALSE if ERROR, TRUE if SUCCESS
  77. ComputeFatSize(
  78. PPART_DESCRIPTOR PartDes, // partition characteristics to compute for
  79. UINT32 SectorsPerCluster, // number of sectors per cluster
  80. PUINT32 ReturnedFatSectorCount // RETURN Number of FAT sectors in each fat
  81. );
  82. #endif //__LAYOUT__