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