efiprot.h revision 294981
1/* $FreeBSD: stable/10/sys/boot/efi/include/efiprot.h 294981 2016-01-28 12:11:42Z smh $ */
2#ifndef _EFI_PROT_H
3#define _EFI_PROT_H
4
5/*++
6
7Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
8This software and associated documentation (if any) is furnished
9under a license and may only be used or copied in accordance
10with the terms of the license. Except as permitted by such
11license, no part of this software or documentation may be
12reproduced, stored in a retrieval system, or transmitted in any
13form or by any means without the express written consent of
14Intel Corporation.
15
16Module Name:
17
18    efiprot.h
19
20Abstract:
21
22    EFI Protocols
23
24
25
26Revision 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
46INTERFACE_DECL(_EFI_BLOCK_IO);
47
48typedef
49EFI_STATUS
50(EFIAPI *EFI_BLOCK_RESET) (
51    IN struct _EFI_BLOCK_IO     *This,
52    IN BOOLEAN                  ExtendedVerification
53    );
54
55typedef
56EFI_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
66typedef
67EFI_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
77typedef
78EFI_STATUS
79(EFIAPI *EFI_BLOCK_FLUSH) (
80    IN struct _EFI_BLOCK_IO     *This
81    );
82
83
84
85typedef 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
100typedef 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
122INTERFACE_DECL(_EFI_DISK_IO);
123
124typedef
125EFI_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
135typedef
136EFI_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
146typedef 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
160INTERFACE_DECL(_EFI_FILE_IO_INTERFACE);
161INTERFACE_DECL(_EFI_FILE_HANDLE);
162
163typedef
164EFI_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
172typedef struct _EFI_FILE_IO_INTERFACE {
173    UINT64                  Revision;
174    EFI_VOLUME_OPEN         OpenVolume;
175} EFI_FILE_IO_INTERFACE;
176
177//
178//
179//
180
181typedef
182EFI_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
205typedef
206EFI_STATUS
207(EFIAPI *EFI_FILE_CLOSE) (
208    IN struct _EFI_FILE_HANDLE  *File
209    );
210
211typedef
212EFI_STATUS
213(EFIAPI *EFI_FILE_DELETE) (
214    IN struct _EFI_FILE_HANDLE  *File
215    );
216
217typedef
218EFI_STATUS
219(EFIAPI *EFI_FILE_READ) (
220    IN struct _EFI_FILE_HANDLE  *File,
221    IN OUT UINTN                *BufferSize,
222    OUT VOID                    *Buffer
223    );
224
225typedef
226EFI_STATUS
227(EFIAPI *EFI_FILE_WRITE) (
228    IN struct _EFI_FILE_HANDLE  *File,
229    IN OUT UINTN                *BufferSize,
230    IN VOID                     *Buffer
231    );
232
233typedef
234EFI_STATUS
235(EFIAPI *EFI_FILE_SET_POSITION) (
236    IN struct _EFI_FILE_HANDLE  *File,
237    IN UINT64                   Position
238    );
239
240typedef
241EFI_STATUS
242(EFIAPI *EFI_FILE_GET_POSITION) (
243    IN struct _EFI_FILE_HANDLE  *File,
244    OUT UINT64                  *Position
245    );
246
247typedef
248EFI_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
256typedef
257EFI_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
265typedef
266EFI_STATUS
267(EFIAPI *EFI_FILE_FLUSH) (
268    IN struct _EFI_FILE_HANDLE  *File
269    );
270
271
272
273#define EFI_FILE_HANDLE_REVISION         0x00010000
274typedef 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
296typedef 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
320typedef 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
342typedef 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
356INTERFACE_DECL(_EFI_LOAD_FILE_INTERFACE);
357
358typedef
359EFI_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
368typedef 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
380INTERFACE_DECL(_EFI_DEVICE_IO_INTERFACE);
381
382typedef 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
399typedef
400EFI_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
409typedef struct {
410    EFI_DEVICE_IO                   Read;
411    EFI_DEVICE_IO                   Write;
412} EFI_IO_ACCESS;
413
414typedef
415EFI_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
422typedef enum {
423    EfiBusMasterRead,
424    EfiBusMasterWrite,
425    EfiBusMasterCommonBuffer
426} EFI_IO_OPERATION_TYPE;
427
428typedef
429EFI_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
439typedef
440EFI_STATUS
441(EFIAPI *EFI_IO_UNMAP) (
442    IN struct _EFI_DEVICE_IO_INTERFACE  *This,
443    IN VOID                             *Mapping
444    );
445
446typedef
447EFI_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
456typedef
457EFI_STATUS
458(EFIAPI *EFI_IO_FLUSH) (
459    IN struct _EFI_DEVICE_IO_INTERFACE  *This
460    );
461
462typedef
463EFI_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
470typedef 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
492INTERFACE_DECL(_EFI_UNICODE_COLLATION_INTERFACE);
493
494typedef
495INTN
496(EFIAPI *EFI_UNICODE_COLLATION_STRICOLL) (
497    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
498    IN CHAR16                         *s1,
499    IN CHAR16                         *s2
500    );
501
502typedef
503BOOLEAN
504(EFIAPI *EFI_UNICODE_COLLATION_METAIMATCH) (
505    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
506    IN CHAR16                         *String,
507    IN CHAR16                         *Pattern
508    );
509
510typedef
511VOID
512(EFIAPI *EFI_UNICODE_COLLATION_STRLWR) (
513    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
514    IN OUT CHAR16                       *Str
515    );
516
517typedef
518VOID
519(EFIAPI *EFI_UNICODE_COLLATION_STRUPR) (
520    IN struct _EFI_UNICODE_COLLATION_INTERFACE  *This,
521    IN OUT CHAR16                       *Str
522    );
523
524typedef
525VOID
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
533typedef
534BOOLEAN
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
543typedef 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
559