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