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.

201 lines
4.2 KiB

  1. //
  2. // diskpart.h
  3. //
  4. //
  5. // Alignmnet macros
  6. //
  7. #if defined (i386)
  8. # define UNALIGNED
  9. #elif defined (_IA64_)
  10. # define UNALIGNED __unaligned
  11. #elif defined (ALPHA)
  12. # define UNALIGNED __unaligned
  13. #endif
  14. //
  15. // C_ASSERT() can be used to perform many compile-time assertions:
  16. // type sizes, field offsets, etc.
  17. //
  18. // An assertion failure results in error C2118: negative subscript.
  19. //
  20. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  21. #include "efi.h"
  22. #include "efilib.h"
  23. #include "msg.h"
  24. #include "scriptmsg.h"
  25. #include "gpt.h"
  26. #include "mbr.h"
  27. //
  28. // Debug Control
  29. //
  30. #define DEBUG_NONE 0
  31. #define DEBUG_ERRPRINT 1
  32. #define DEBUG_ARGPRINT 2
  33. #define DEBUG_OPPROMPT 3
  34. extern UINTN DebugLevel;
  35. //
  36. // Externs
  37. //
  38. extern EFI_GUID BlockIOProtocol;
  39. extern EFI_STATUS status; // always save the last error status
  40. // by using this global
  41. extern INTN AllocCount; // track DoFree/DoAlloc
  42. extern EFI_HANDLE *DiskHandleList;
  43. extern INTN SelectedDisk;
  44. BOOLEAN ScriptList(CHAR16 **Token);
  45. //
  46. // Prototypes for all fo the workers for main parser in DiskPart
  47. // Declared here so that scripts can call them
  48. //
  49. BOOLEAN CmdAbout(CHAR16 **Token);
  50. BOOLEAN CmdList(CHAR16 **Token);
  51. BOOLEAN CmdSelect(CHAR16 **Token);
  52. BOOLEAN CmdInspect(CHAR16 **Token);
  53. BOOLEAN CmdClean(CHAR16 **Token);
  54. BOOLEAN CmdNew(CHAR16 **Token);
  55. BOOLEAN CmdFix(CHAR16 **Token);
  56. BOOLEAN CmdCreate(CHAR16 **Token);
  57. BOOLEAN CmdDelete(CHAR16 **Token);
  58. BOOLEAN CmdHelp(CHAR16 **Token);
  59. BOOLEAN CmdExit(CHAR16 **Token);
  60. BOOLEAN CmdSymbols(CHAR16 **Token);
  61. BOOLEAN CmdRemark(CHAR16 **Token);
  62. BOOLEAN CmdMake(CHAR16 **Token);
  63. BOOLEAN CmdDebug(CHAR16 **Token);
  64. //
  65. // Worker function type
  66. //
  67. typedef
  68. BOOLEAN
  69. (*PSCRIPT_FUNCTION)(
  70. CHAR16 **Token
  71. );
  72. //
  73. // The script table structure
  74. //
  75. typedef struct {
  76. CHAR16 *Name;
  77. PSCRIPT_FUNCTION Function;
  78. CHAR16 *HelpSummary;
  79. } SCRIPT_ENTRY;
  80. extern SCRIPT_ENTRY ScriptTable[];
  81. //
  82. // Routines that will need to be ported
  83. //
  84. EFI_STATUS
  85. FindPartitionableDevices(
  86. EFI_HANDLE **ReturnBuffer,
  87. UINTN *Count
  88. );
  89. //
  90. // Utility/Wrapper routines
  91. //
  92. UINT32 GetBlockSize(EFI_HANDLE Handle);
  93. UINT64 GetDiskSize(EFI_HANDLE Handle);
  94. VOID DoFree(VOID *Buffer);
  95. VOID *DoAllocate(UINTN Size);
  96. UINT32 GetCRC32(VOID *Buffer, UINT32 Length);
  97. EFI_GUID GetGUID();
  98. EFI_STATUS
  99. WriteBlock(
  100. EFI_HANDLE DiskHandle,
  101. VOID *Buffer,
  102. UINT64 BlockAddress,
  103. UINT32 BlockCount
  104. );
  105. EFI_STATUS
  106. ReadBlock(
  107. EFI_HANDLE DiskHandle,
  108. VOID *Buffer,
  109. UINT64 BlockAddress,
  110. UINT32 Size
  111. );
  112. EFI_STATUS
  113. FlushBlock(
  114. EFI_HANDLE DiskHandle
  115. );
  116. VOID
  117. TerribleError(
  118. CHAR16 *String
  119. );
  120. //
  121. // Misc useful stuff
  122. //
  123. VOID PrintHelp(CHAR16 *HelpText[]);
  124. EFI_STATUS GetGuidFromString(CHAR16 *String, EFI_GUID *Guid);
  125. INTN HexChar(CHAR16 Ch);
  126. UINT64 Xtoi64(CHAR16 *String);
  127. UINT64 Atoi64(CHAR16 *String);
  128. VOID PrintGuidString(EFI_GUID *Guid);
  129. BOOLEAN IsIn(CHAR16 What, CHAR16 *InWhat);
  130. VOID Tokenize(CHAR16 *CommandLine, CHAR16 **Token);
  131. #define COMMAND_LINE_MAX 512
  132. #define TOKEN_COUNT_MAX 256 // most possible in 512 chars
  133. #define NUL ((CHAR16)0)
  134. //
  135. // Some EFI functions are just a rename of 'C' lib functions,
  136. // so they can just be macroed back.
  137. // Somebody will need to check this out...
  138. //
  139. #if 0
  140. #define CompareMem(a, b, c) memcmp(a, b, c)
  141. #define ZeroMem(a, b) memset(a, 0, b)
  142. //
  143. // This is a fiction, Print is NOT printf, but it's close
  144. // enough that everything or almost everything will work...
  145. //
  146. #define Print printf
  147. #endif
  148. //
  149. // Functions that allow the Guid Generator to be used
  150. //
  151. VOID InitGuid(VOID);
  152. VOID CreateGuid(EFI_GUID *guid);
  153. //
  154. // Status Symbols
  155. //
  156. #define DISK_ERROR 0
  157. #define DISK_RAW 1
  158. #define DISK_MBR 2
  159. #define DISK_GPT 4
  160. #define DISK_GPT_UPD 6
  161. #define DISK_GPT_BAD 7