EFIFileProtocol.Mod 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. MODULE EFIFileProtocol; (** AUTHOR "Matthias Frei"; PURPOSE "EFI File Protocol"; *)
  2. IMPORT
  3. EFI, SYSTEM;
  4. CONST
  5. Revision* = 00010000H;
  6. (* Open Modes. Allowed combinations are Read, Read/Write, Create/Read/Write *)
  7. ModeRead* = 1H;
  8. ModeWrite* = 2H;
  9. ModeCreate* = MIN(HUGEINT);
  10. (* File Attributes *)
  11. ReadOnly* = 1H;
  12. Hidden *= 2H;
  13. System *= 4H;
  14. Reserved *= 8H;
  15. Directory *= 10H;
  16. FileArchive *= 20H;
  17. ValidAttr *= 37H;
  18. VAR
  19. FileInfoGUID- : EFI.GUID;
  20. FileSystemInfoGUID- : EFI.GUID;
  21. FileSystemVolumeInfoGUID- : EFI.GUID;
  22. TYPE Protocol*= POINTER TO ProtocolDescription;
  23. (* Open or create a new file. 'This' is a pointer to a protocol instance that is the file handle to the source location. This would
  24. typically be an open handle to a directory. A handle for the new file is returned to 'NewHandle'. The filename may include
  25. the path modifiers '\', '.' and '..'. If the filename starts with a '\' the relative location is the root directory. *)
  26. TYPE FileOpen* = PROCEDURE{WINAPI}(This : Protocol; VAR NewHandle : Protocol; CONST FileName : ARRAY OF EFI.Char16; OpenMode : EFI.Int64; Attributes : EFI.Int64) : EFI.Status;
  27. (* Close a specified handle. All dirty cached file data is flushed to the device, and the file is closed *)
  28. TYPE FileClose* = PROCEDURE{WINAPI}(This : Protocol) : EFI.Status;
  29. (* Close and delete a file *)
  30. TYPE FileDelete* = PROCEDURE{WINAPI}(This : Protocol) : EFI.Status;
  31. (* Read 'BufferSize' bytes. On success, the number bytes read is written to 'BufferSize' and the file position is updated.
  32. If 'This' is a directory, read the directory entry at the current file position. If this entry does not fit into the buffer BufferTooSmall
  33. is returned and the file position is not updated and 'BufferSize' is set to the size needed to read the entry. *)
  34. TYPE FileRead* = PROCEDURE{WINAPI}(This : Protocol; VAR BufferSize : EFI.Int; Buffer : ADDRESS) : EFI.Status;
  35. (* Write specified number of bytes to the file at the current file position. Current file position is advanced the actual number of
  36. bytes written, which is returned in 'BufferSize'. Direct writes to open directories are not supported *)
  37. TYPE FileWrite* = PROCEDURE{WINAPI}(This : Protocol; VAR BufferSize : EFI.Int; CONST Buffer : ARRAY OF SYSTEM.BYTE) : EFI.Status;
  38. (* Set the current file position. Only absolute position is supported with exception of FFFFFFFFFFFFFFFFH which sets the position
  39. to the end of the file. Seeking past the end of file is allowed (a subsequent write would grow the file. *)
  40. TYPE FileGetPosition* = PROCEDURE{WINAPI}(This : Protocol; VAR Position : EFI.Int64) : EFI.Status;
  41. TYPE FileSetPosition* = PROCEDURE{WINAPI}(This : Protocol; Position : EFI.Int64) : EFI.Status;
  42. TYPE FileGetInfo* = PROCEDURE{WINAPI}(This : Protocol; CONST InformationType : EFI.GUID; VAR BufferSize : EFI.Int; VAR Buffer : ARRAY OF SYSTEM.BYTE) : EFI.Status;
  43. TYPE FileSetInfo* = PROCEDURE{WINAPI}(This : Protocol; CONST InformationType : EFI.GUID; BufferSize : EFI.Int; CONST Buffer : ARRAY OF SYSTEM.BYTE) : EFI.Status;
  44. TYPE FileFlush* = PROCEDURE{WINAPI}(This : Protocol) : EFI.Status;
  45. TYPE ProtocolDescription*= RECORD(EFI.ProtocolDescription)
  46. Revision-: EFI.Int64;
  47. Open- : FileOpen;
  48. Close-: FileClose;
  49. Delete-: FileDelete;
  50. Read-: FileRead;
  51. Write-: FileWrite;
  52. GetPosition-: FileGetPosition;
  53. SetPosition-: FileSetPosition;
  54. GetInfo-: FileGetInfo;
  55. SetInfo-: FileSetInfo;
  56. Flush-: FileFlush;
  57. END;
  58. (* Information *)
  59. (* Note : the structs should have variable size! The FileName-field can NOT be CORRECTly mapped to Oberon. *)
  60. CONST MaxFileNameLength = 128;
  61. TYPE FileInfo* = RECORD
  62. Size-: EFI.Int64; (* size of the FileInfo RECORD, including the Null-terminated FileName string*)
  63. FileSize-: EFI.Int64; (* in bytes *)
  64. PhysicalSize-: EFI.Int64;
  65. CreateTime-: EFI.Time;
  66. LastAccessTime-: EFI.Time;
  67. ModificationTime-: EFI.Time;
  68. Attribute-: EFI.Int64;
  69. FileName-: ARRAY MaxFileNameLength OF EFI.Char16;
  70. END;
  71. (* Note : same here... *)
  72. TYPE FileSystemInfo* = RECORD
  73. Size-: EFI.Int64; (* size of the FileInfo RECORD, including the Null-terminated VolumeLabel string*)
  74. ReadOnly-: EFI.Boolean;
  75. VolumeSize-: EFI.Int64; (* in bytes *)
  76. FreeSpace-: EFI.Int64;
  77. BlockSize-: EFI.Int32;
  78. VolumeLabel-: ARRAY MaxFileNameLength OF EFI.Char16;
  79. END;
  80. (* Note : ... and here *)
  81. TYPE FileSystemVolumeInfo* = RECORD
  82. VolumeLabel-: ARRAY MaxFileNameLength OF EFI.Char16;
  83. END;
  84. BEGIN
  85. FileInfoGUID.Data1 := 09576E92H;
  86. FileInfoGUID.Data2 := 6D3FH;
  87. FileInfoGUID.Data3 := 11D2H;
  88. FileInfoGUID.Data4[0] := -72H; (*8EH;*)
  89. FileInfoGUID.Data4[1] := 39H;
  90. FileInfoGUID.Data4[2] := 00H;
  91. FileInfoGUID.Data4[3] := -60H; (*0A0H;*)
  92. FileInfoGUID.Data4[4] := -37H; (*0C9H;*)
  93. FileInfoGUID.Data4[5] := 69H;
  94. FileInfoGUID.Data4[6] := 72H;
  95. FileInfoGUID.Data4[7] := 3BH;
  96. FileSystemInfoGUID.Data1 := 09576E93H;
  97. FileSystemInfoGUID.Data2 := 6D3FH;
  98. FileSystemInfoGUID.Data3 := 11D2H;
  99. FileSystemInfoGUID.Data4[0] := -72H; (*8EH;*)
  100. FileSystemInfoGUID.Data4[1] := 39H;
  101. FileSystemInfoGUID.Data4[2] := 00H;
  102. FileSystemInfoGUID.Data4[3] := -60H; (*0A0H;*)
  103. FileSystemInfoGUID.Data4[4] := -37H; (*0C9H;*)
  104. FileSystemInfoGUID.Data4[5] := 69H;
  105. FileSystemInfoGUID.Data4[6] := 72H;
  106. FileSystemInfoGUID.Data4[7] := 3BH;
  107. FileSystemVolumeInfoGUID.Data1 := -24B8282DH; (*0DB47D7D3H*)
  108. FileSystemVolumeInfoGUID.Data2 := -17FH; (*0FE81H*)
  109. FileSystemVolumeInfoGUID.Data3 := 11D3H;
  110. FileSystemVolumeInfoGUID.Data4[0] := -66H; (*9AH;*)
  111. FileSystemVolumeInfoGUID.Data4[1] := 35H;
  112. FileSystemVolumeInfoGUID.Data4[2] := 00H;
  113. FileSystemVolumeInfoGUID.Data4[3] := -70H; (*090H;*)
  114. FileSystemVolumeInfoGUID.Data4[4] := 27H;
  115. FileSystemVolumeInfoGUID.Data4[5] := 3FH;
  116. FileSystemVolumeInfoGUID.Data4[6] := -3FH; (*0C1H*)
  117. FileSystemVolumeInfoGUID.Data4[7] := 4DH;
  118. END EFIFileProtocol.