Leaked source code of windows server 2003
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.

194 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. fatboot.h
  5. Abstract:
  6. This module defines globally used procedure and data structures used
  7. by fat boot.
  8. Author:
  9. Gary Kimura (garyki) 29-Aug-1989
  10. Revision History:
  11. --*/
  12. #ifndef _FATBOOT_
  13. #define _FATBOOT_
  14. #include "fat.h"
  15. //
  16. // The following structure is used to define the local mcb structure used within
  17. // the fat boot loader to maintain a small cache of the retrieval information
  18. // for a single file/directory
  19. //
  20. #define FAT_MAXIMUM_MCB (41)
  21. typedef struct _FAT_MCB {
  22. //
  23. // The following fields indicate the number of entries in use by
  24. // the boot mcb. and the boot mcb itself. The boot mcb is
  25. // just a collection of [vbo, lbo] pairs. The last InUse entry
  26. // Lbo's value is ignored, because it is only used to give the
  27. // length of the previous run.
  28. //
  29. ULONG InUse;
  30. VBO Vbo[ FAT_MAXIMUM_MCB ];
  31. LBO Lbo[ FAT_MAXIMUM_MCB ];
  32. } FAT_MCB, *PFAT_MCB;
  33. //
  34. // The following structure is used to define the geometry of the fat volume
  35. // There is one for every mounted volume. It describes the size/configuration
  36. // of the volume, contains a small cached mcb for the last file being accessed
  37. // on the volume, and contains a small cache of the fat. Given a FileId we
  38. // can access the structure context through the structure context field in the
  39. // global BlFileTable (e.g., BlFileTable[FileId].StructureContext).
  40. //
  41. //
  42. // The following constant is used to determine how much of the fat we keep
  43. // cached in memory at any one time. It must be a multiple of 6 bytes in order to
  44. // hold complete 12 and 16 bit fat entries in the cache at any one time.
  45. //
  46. #define FAT_CACHE_SIZE (512*3)
  47. typedef struct _FAT_STRUCTURE_CONTEXT {
  48. //
  49. // The following field contains an unpacked copy of the bios parameter block
  50. // for the mounted volume
  51. //
  52. BIOS_PARAMETER_BLOCK Bpb;
  53. //
  54. // The following two fields contain current file id of the file/directory
  55. // whose mcb we are keeping around, and the second field is the mcb itself
  56. //
  57. ULONG FileId;
  58. FAT_MCB Mcb;
  59. //
  60. // The following fields describe/contain the current cached fat. The vbo
  61. // is the smallest vbo of the fat currently in the cache, and cached fat
  62. // is a pointer to the cached data. The extra buffer/indirectiion is needed
  63. // to keep everything aligned properly. The dirty flag is used to indicate
  64. // if the current cached fat has been modified and needs to be flushed to disk.
  65. // Vbo is used because this allows us to do a lot of our computations having
  66. // already biased lbo offset to the first fat table.
  67. //
  68. BOOLEAN CachedFatDirty;
  69. VBO CachedFatVbo;
  70. PUCHAR CachedFat;
  71. UCHAR CachedFatBuffer[ FAT_CACHE_SIZE + 256 ];
  72. } FAT_STRUCTURE_CONTEXT, *PFAT_STRUCTURE_CONTEXT;
  73. //
  74. // The following structure is used to define the location and size of each
  75. // opened file. There is one of these of every opened file. It is part of
  76. // the union of a BL_FILE_TABLE structuure. Given a FileId we can access the
  77. // file context via the BlFileTable (e.g., BlFileTable[FileId].u.FatFileContext)
  78. //
  79. typedef struct _FAT_FILE_CONTEXT {
  80. //
  81. // The following two fields describe where on the disk the dirent for the
  82. // file is located and also contains a copy of the dirent
  83. //
  84. LBO DirentLbo;
  85. DIRENT Dirent;
  86. } FAT_FILE_CONTEXT, *PFAT_FILE_CONTEXT;
  87. //
  88. // Define file I/O prototypes.
  89. //
  90. ARC_STATUS
  91. FatClose (
  92. IN ULONG FileId
  93. );
  94. ARC_STATUS
  95. FatOpen (
  96. IN CHAR * FIRMWARE_PTR OpenPath,
  97. IN OPEN_MODE OpenMode,
  98. OUT ULONG * FIRMWARE_PTR FileId
  99. );
  100. ARC_STATUS
  101. FatRead (
  102. IN ULONG FileId,
  103. OUT VOID * FIRMWARE_PTR Buffer,
  104. IN ULONG Length,
  105. OUT ULONG * FIRMWARE_PTR Count
  106. );
  107. ARC_STATUS
  108. FatSeek (
  109. IN ULONG FileId,
  110. IN LARGE_INTEGER * FIRMWARE_PTR Offset,
  111. IN SEEK_MODE SeekMode
  112. );
  113. ARC_STATUS
  114. FatWrite (
  115. IN ULONG FileId,
  116. IN VOID * FIRMWARE_PTR Buffer,
  117. IN ULONG Length,
  118. OUT ULONG * FIRMWARE_PTR Count
  119. );
  120. ARC_STATUS
  121. FatGetFileInformation (
  122. IN ULONG FileId,
  123. OUT FILE_INFORMATION * FIRMWARE_PTR Buffer
  124. );
  125. ARC_STATUS
  126. FatSetFileInformation (
  127. IN ULONG FileId,
  128. IN ULONG AttributeFlags,
  129. IN ULONG AttributeMask
  130. );
  131. ARC_STATUS
  132. FatRename(
  133. IN ULONG FileId,
  134. IN CHAR * FIRMWARE_PTR NewFileName
  135. );
  136. ARC_STATUS
  137. FatGetDirectoryEntry (
  138. IN ULONG FileId,
  139. IN DIRECTORY_ENTRY * FIRMWARE_PTR DirEntry,
  140. IN ULONG NumberDir,
  141. OUT ULONG * FIRMWARE_PTR CountDir
  142. );
  143. ARC_STATUS
  144. FatInitialize(
  145. VOID
  146. );
  147. #endif // _FATBOOT_