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