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