efiprot.h revision 96755
1/* $FreeBSD: head/sys/boot/efi/include/efiprot.h 96755 2002-05-16 21:28:32Z trhodes $ */
2#ifndef _EFI_PROT_H
3#define _EFI_PROT_H
4
5/*++
6
7Copyright (c) 1998  Intel Corporation
8
9Module Name:
10
11    efiprot.h
12
13Abstract:
14
15    EFI Protocols
16
17
18
19Revision History
20
21--*/
22
23//
24// Device Path protocol
25//
26
27#define DEVICE_PATH_PROTOCOL    \
28    { 0x9576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
29
30
31//
32// Block IO protocol
33//
34
35#define BLOCK_IO_PROTOCOL \
36    { 0x964e5b21, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
37#define EFI_BLOCK_IO_INTERFACE_REVISION   0x00010000
38
39INTERFACE_DECL(_EFI_BLOCK_IO);
40
41typedef
42EFI_STATUS
43(EFIAPI *EFI_BLOCK_RESET) (
44    IN struct _EFI_BLOCK_IO     *This,
45    IN BOOLEAN                  ExtendedVerification
46    );
47
48typedef
49EFI_STATUS
50(EFIAPI *EFI_BLOCK_READ) (
51    IN struct _EFI_BLOCK_IO     *This,
52    IN UINT32                   MediaId,
53    IN EFI_LBA                  LBA,
54    IN UINTN                    BufferSize,
55    OUT VOID                    *Buffer
56    );
57
58
59typedef
60EFI_STATUS
61(EFIAPI *EFI_BLOCK_WRITE) (
62    IN struct _EFI_BLOCK_IO     *This,
63    IN UINT32                   MediaId,
64    IN EFI_LBA                  LBA,
65    IN UINTN                    BufferSize,
66    IN VOID                     *Buffer
67    );
68
69
70typedef
71EFI_STATUS
72(EFIAPI *EFI_BLOCK_FLUSH) (
73    IN struct _EFI_BLOCK_IO     *This
74    );
75
76
77
78typedef struct {
79    UINT32              MediaId;
80    BOOLEAN             RemovableMedia;
81    BOOLEAN             MediaPresent;
82
83    BOOLEAN             LogicalPartition;
84    BOOLEAN             ReadOnly;
85    BOOLEAN             WriteCaching;
86
87    UINT32              BlockSize;
88    UINT32              IoAlign;
89
90    EFI_LBA             LastBlock;
91} EFI_BLOCK_IO_MEDIA;
92
93typedef struct _EFI_BLOCK_IO {
94    UINT64                  Revision;
95
96    EFI_BLOCK_IO_MEDIA      *Media;
97
98    EFI_BLOCK_RESET         Reset;
99    EFI_BLOCK_READ          ReadBlocks;
100    EFI_BLOCK_WRITE         WriteBlocks;
101    EFI_BLOCK_FLUSH         FlushBlocks;
102
103} EFI_BLOCK_IO;
104
105
106
107//
108// Disk Block IO protocol
109//
110
111#define DISK_IO_PROTOCOL \
112    { 0xce345171, 0xba0b, 0x11d2,  0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
113#define EFI_DISK_IO_INTERFACE_REVISION   0x00010000
114
115INTERFACE_DECL(_EFI_DISK_IO);
116
117typedef
118EFI_STATUS
119(EFIAPI *EFI_DISK_READ) (
120    IN struct _EFI_DISK_IO      *This,
121    IN UINT32                   MediaId,
122    IN UINT64                   Offset,
123    IN UINTN                    BufferSize,
124    OUT VOID                    *Buffer
125    );
126
127
128typedef
129EFI_STATUS
130(EFIAPI *EFI_DISK_WRITE) (
131    IN struct _EFI_DISK_IO      *This,
132    IN UINT32                   MediaId,
133    IN UINT64                   Offset,
134    IN UINTN                    BufferSize,
135    IN VOID                     *Buffer
136    );
137
138
139typedef struct _EFI_DISK_IO {
140    UINT64              Revision;
141    EFI_DISK_READ       ReadDisk;
142    EFI_DISK_WRITE      WriteDisk;
143} EFI_DISK_IO;
144
145
146//
147// Simple filesystem protocol
148//
149
150#define SIMPLE_FILE_SYSTEM_PROTOCOL \
151    { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
152
153INTERFACE_DECL(_EFI_FILE_IO_INTERFACE);
154INTERFACE_DECL(_EFI_FILE_HANDLE);
155
156typedef
157EFI_STATUS
158(EFIAPI *EFI_VOLUME_OPEN) (
159    IN struct _EFI_FILE_IO_INTERFACE    *This,
160    OUT struct _EFI_FILE_HANDLE         **Root
161    );
162
163#define EFI_FILE_IO_INTERFACE_REVISION   0x00010000
164
165typedef struct _EFI_FILE_IO_INTERFACE {
166    UINT64                  Revision;
167    EFI_VOLUME_OPEN         OpenVolume;
168} EFI_FILE_IO_INTERFACE;
169
170//
171//
172//
173
174typedef
175EFI_STATUS
176(EFIAPI *EFI_FILE_OPEN) (
177    IN struct _EFI_FILE_HANDLE  *File,
178    OUT struct _EFI_FILE_HANDLE **NewHandle,
179    IN CHAR16                   *FileName,
180    IN UINT64                   OpenMode,
181    IN UINT64                   Attributes
182    );
183
184// Open modes
185#define EFI_FILE_MODE_READ      0x0000000000000001
186#define EFI_FILE_MODE_WRITE     0x0000000000000002
187#define EFI_FILE_MODE_CREATE    0x8000000000000000
188
189// File attributes
190#define EFI_FILE_READ_ONLY      0x0000000000000001
191#define EFI_FILE_HIDDEN         0x0000000000000002
192#define EFI_FILE_SYSTEM         0x0000000000000004
193#define EFI_FILE_RESERVIED      0x0000000000000008
194#define EFI_FILE_DIRECTORY      0x0000000000000010
195#define EFI_FILE_ARCHIVE        0x0000000000000020
196#define EFI_FILE_VALID_ATTR     0x0000000000000037
197
198typedef
199EFI_STATUS
200(EFIAPI *EFI_FILE_CLOSE) (
201    IN struct _EFI_FILE_HANDLE  *File
202    );
203
204typedef
205EFI_STATUS
206(EFIAPI *EFI_FILE_DELETE) (
207    IN struct _EFI_FILE_HANDLE  *File
208    );
209
210typedef
211EFI_STATUS
212(EFIAPI *EFI_FILE_READ) (
213    IN struct _EFI_FILE_HANDLE  *File,
214    IN OUT UINTN                *BufferSize,
215    OUT VOID                    *Buffer
216    );
217
218typedef
219EFI_STATUS
220(EFIAPI *EFI_FILE_WRITE) (
221    IN struct _EFI_FILE_HANDLE  *File,
222    IN OUT UINTN                *BufferSize,
223    IN VOID                     *Buffer
224    );
225
226typedef
227EFI_STATUS
228(EFIAPI *EFI_FILE_SET_POSITION) (
229    IN struct _EFI_FILE_HANDLE  *File,
230    IN UINT64                   Position
231    );
232
233typedef
234EFI_STATUS
235(EFIAPI *EFI_FILE_GET_POSITION) (
236    IN struct _EFI_FILE_HANDLE  *File,
237    OUT UINT64                  *Position
238    );
239
240typedef
241EFI_STATUS
242(EFIAPI *EFI_FILE_GET_INFO) (
243    IN struct _EFI_FILE_HANDLE  *File,
244    IN EFI_GUID                 *InformationType,
245    IN OUT UINTN                *BufferSize,
246    OUT VOID                    *Buffer
247    );
248
249typedef
250EFI_STATUS
251(EFIAPI *EFI_FILE_SET_INFO) (
252    IN struct _EFI_FILE_HANDLE  *File,
253    IN EFI_GUID                 *InformationType,
254    IN UINTN                    BufferSize,
255    IN VOID                     *Buffer
256    );
257
258typedef
259EFI_STATUS
260(EFIAPI *EFI_FILE_FLUSH) (
261    IN struct _EFI_FILE_HANDLE  *File
262    );
263
264
265
266#define EFI_FILE_HANDLE_REVISION         0x00010000
267typedef struct _EFI_FILE_HANDLE {
268    UINT64                  Revision;
269    EFI_FILE_OPEN           Open;
270    EFI_FILE_CLOSE          Close;
271    EFI_FILE_DELETE         Delete;
272    EFI_FILE_READ           Read;
273    EFI_FILE_WRITE          Write;
274    EFI_FILE_GET_POSITION   GetPosition;
275    EFI_FILE_SET_POSITION   SetPosition;
276    EFI_FILE_GET_INFO       GetInfo;
277    EFI_FILE_SET_INFO       SetInfo;
278    EFI_FILE_FLUSH          Flush;
279} EFI_FILE, *EFI_FILE_HANDLE;
280
281
282//
283// File information types
284//
285
286#define EFI_FILE_INFO_ID   \
287    { 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
288
289typedef struct {
290    UINT64                  Size;
291    UINT64                  FileSize;
292    UINT64                  PhysicalSize;
293    EFI_TIME                CreateTime;
294    EFI_TIME                LastAccessTime;
295    EFI_TIME                ModificationTime;
296    UINT64                  Attribute;
297    CHAR16                  FileName[1];
298} EFI_FILE_INFO;
299
300//
301// The FileName field of the EFI_FILE_INFO data structure is variable length.
302// Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to
303// be the size of the data structure without the FileName field.  The following macro
304// computes this size correctly no matter how big the FileName array is declared.
305// This is required to make the EFI_FILE_INFO data structure ANSI compilant.
306//
307
308#define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET(EFI_FILE_INFO,FileName)
309
310#define EFI_FILE_SYSTEM_INFO_ID    \
311    { 0x9576e93, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
312
313typedef struct {
314    UINT64                  Size;
315    BOOLEAN                 ReadOnly;
316    UINT64                  VolumeSize;
317    UINT64                  FreeSpace;
318    UINT32                  BlockSize;
319    CHAR16                  VolumeLabel[1];
320} EFI_FILE_SYSTEM_INFO;
321
322//
323// The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length.
324// Whenever code needs to know the size of the EFI_FILE_SYSTEM_INFO data structure, it needs
325// to be the size of the data structure without the VolumeLable field.  The following macro
326// computes this size correctly no matter how big the VolumeLable array is declared.
327// This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant.
328//
329
330#define SIZE_OF_EFI_FILE_SYSTEM_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_INFO,VolumeLabel)
331
332#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID    \
333    { 0xDB47D7D3,0xFE81, 0x11d3, 0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }
334
335typedef struct {
336    CHAR16                  VolumeLabel[1];
337} EFI_FILE_SYSTEM_VOLUME_LABEL_INFO;
338
339#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_VOLUME_LABEL_INFO,VolumeLabel)
340
341//
342// Load file protocol
343//
344
345
346#define LOAD_FILE_PROTOCOL \
347    { 0x56EC3091, 0x954C, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }
348
349INTERFACE_DECL(_EFI_LOAD_FILE_INTERFACE);
350
351typedef
352EFI_STATUS
353(EFIAPI *EFI_LOAD_FILE) (
354    IN struct _EFI_LOAD_FILE_INTERFACE  *This,
355    IN EFI_DEVICE_PATH                  *FilePath,
356    IN BOOLEAN                          BootPolicy,
357    IN OUT UINTN                        *BufferSize,
358    IN VOID                             *Buffer OPTIONAL
359    );
360
361typedef struct _EFI_LOAD_FILE_INTERFACE {
362    EFI_LOAD_FILE                       LoadFile;
363} EFI_LOAD_FILE_INTERFACE;
364
365
366//
367// Device IO protocol
368//
369
370#define DEVICE_IO_PROTOCOL \
371    { 0xaf6ac311, 0x84c3, 0x11d2, 0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
372
373INTERFACE_DECL(_EFI_DEVICE_IO_INTERFACE);
374
375typedef enum {
376    IO_UINT8,
377    IO_UINT16,
378    IO_UINT32,
379    IO_UINT64,
380//
381// Specification Change: Copy from MMIO to MMIO vs. MMIO to buffer, buffer to MMIO
382//
383    MMIO_COPY_UINT8,
384    MMIO_COPY_UINT16,
385    MMIO_COPY_UINT32,
386    MMIO_COPY_UINT64
387} EFI_IO_WIDTH;
388
389#define EFI_PCI_ADDRESS(_bus,_dev,_func) \
390    ( (UINT64) ( (((UINTN)_bus) << 24) + (((UINTN)_dev) << 16) + (((UINTN)_func) << 8) ) )
391
392
393typedef
394EFI_STATUS
395(EFIAPI *EFI_DEVICE_IO) (
396    IN struct _EFI_DEVICE_IO_INTERFACE *This,
397    IN EFI_IO_WIDTH                 Width,
398    IN UINT64                       Address,
399    IN UINTN                        Count,
400    IN OUT VOID                     *Buffer
401    );
402
403typedef struct {
404    EFI_DEVICE_IO                   Read;
405    EFI_DEVICE_IO                   Write;
406} EFI_IO_ACCESS;
407
408typedef
409EFI_STATUS
410(EFIAPI *EFI_PCI_DEVICE_PATH) (
411    IN struct _EFI_DEVICE_IO_INTERFACE  *This,
412    IN UINT64                           Address,
413    IN OUT EFI_DEVICE_PATH              **PciDevicePath
414    );
415
416typedef enum {
417    EfiBusMasterRead,
418    EfiBusMasterWrite,
419    EfiBusMasterCommonBuffer
420} EFI_IO_OPERATION_TYPE;
421
422typedef
423EFI_STATUS
424(EFIAPI *EFI_IO_MAP) (
425    IN struct _EFI_DEVICE_IO_INTERFACE  *This,
426    IN EFI_IO_OPERATION_TYPE            Operation,
427    IN EFI_PHYSICAL_ADDRESS             *HostAddress,
428    IN OUT UINTN                        *NumberOfBytes,
429    OUT EFI_PHYSICAL_ADDRESS            *DeviceAddress,
430    OUT VOID                            **Mapping
431    );
432
433typedef
434EFI_STATUS
435(EFIAPI *EFI_IO_UNMAP) (
436    IN struct _EFI_DEVICE_IO_INTERFACE  *This,
437    IN VOID                             *Mapping
438    );
439
440typedef
441EFI_STATUS
442(EFIAPI *EFI_IO_ALLOCATE_BUFFER) (
443    IN struct _EFI_DEVICE_IO_INTERFACE  *This,
444    IN EFI_ALLOCATE_TYPE                Type,
445    IN EFI_MEMORY_TYPE                  MemoryType,
446    IN UINTN                            Pages,
447    IN OUT EFI_PHYSICAL_ADDRESS         *HostAddress
448    );
449
450typedef
451EFI_STATUS
452(EFIAPI *EFI_IO_FLUSH) (
453    IN struct _EFI_DEVICE_IO_INTERFACE  *This
454    );
455
456typedef
457EFI_STATUS
458(EFIAPI *EFI_IO_FREE_BUFFER) (
459    IN struct _EFI_DEVICE_IO_INTERFACE  *This,
460    IN UINTN                            Pages,
461    IN EFI_PHYSICAL_ADDRESS             HostAddress
462    );
463
464typedef struct _EFI_DEVICE_IO_INTERFACE {
465    EFI_IO_ACCESS                       Mem;
466    EFI_IO_ACCESS                       Io;
467    EFI_IO_ACCESS                       Pci;
468    EFI_IO_MAP                          Map;
469    EFI_PCI_DEVICE_PATH                 PciDevicePath;
470    EFI_IO_UNMAP                        Unmap;
471    EFI_IO_ALLOCATE_BUFFER              AllocateBuffer;
472    EFI_IO_FLUSH                        Flush;
473    EFI_IO_FREE_BUFFER                  FreeBuffer;
474} EFI_DEVICE_IO_INTERFACE;
475
476
477//
478// Unicode Collation protocol
479//
480
481#define UNICODE_COLLATION_PROTOCOL \
482    { 0x1d85cd7f, 0xf43d, 0x11d2, 0x9a, 0xc,  0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
483
484#define UNICODE_BYTE_ORDER_MARK       (CHAR16)(0xfeff)
485
486INTERFACE_DECL(_EFI_UNICODE_COLLATION_INTERFACE);
487
488typedef
489INTN
490(EFIAPI *EFI_UNICODE_STRICOLL) (
491    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
492    IN CHAR16                         *s1,
493    IN CHAR16                         *s2
494    );
495
496typedef
497BOOLEAN
498(EFIAPI *EFI_UNICODE_METAIMATCH) (
499    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
500    IN CHAR16                         *String,
501    IN CHAR16                         *Pattern
502    );
503
504typedef
505VOID
506(EFIAPI *EFI_UNICODE_STRLWR) (
507    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
508    IN OUT CHAR16                       *Str
509    );
510
511typedef
512VOID
513(EFIAPI *EFI_UNICODE_STRUPR) (
514    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
515    IN OUT CHAR16                       *Str
516    );
517
518typedef
519VOID
520(EFIAPI *EFI_UNICODE_FATTOSTR) (
521    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
522    IN UINTN                            FatSize,
523    IN CHAR8                            *Fat,
524    OUT CHAR16                          *String
525    );
526
527typedef
528BOOLEAN
529(EFIAPI *EFI_UNICODE_STRTOFAT) (
530    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
531    IN CHAR16                           *String,
532    IN UINTN                            FatSize,
533    OUT CHAR8                           *Fat
534    );
535
536
537typedef struct _EFI_UNICODE_COLLATION_INTERFACE {
538
539    // general
540    EFI_UNICODE_STRICOLL                StriColl;
541    EFI_UNICODE_METAIMATCH              MetaiMatch;
542    EFI_UNICODE_STRLWR                  StrLwr;
543    EFI_UNICODE_STRUPR                  StrUpr;
544
545    // for supporting fat volumes
546    EFI_UNICODE_FATTOSTR                FatToStr;
547    EFI_UNICODE_STRTOFAT                StrToFat;
548
549    CHAR8                               *SupportedLanguages;
550} EFI_UNICODE_COLLATION_INTERFACE;
551
552#endif
553