]> code.delx.au - refind/blob - refind/bootsvcs.h
New documentation page; just a stub, for now....
[refind] / refind / bootsvcs.h
1 /*
2 * File to implement an full version of EFI_BOOT_SERVICES, to go beyond
3 * what GNU-EFI provides. Most of the data structures in this file are taken
4 * from the Tianocore UDK's UefiSpec.h file or HandleParsingLib.h files.
5 * The EFI_DEVICE_PATH_PROTOCOL definition is from
6 * http://wiki.phoenix.com/wiki/index.php/EFI_DEVICE_PATH_PROTOCOL.
7 * The UefiSpec.h and HandleParsingLib files include the following copyright
8 * notice:
9 *
10 * Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
11 * This program and the accompanying materials are licensed and made available under
12 * the terms and conditions of the BSD License that accompanies this distribution.
13 * The full text of the license may be found at
14 * http://opensource.org/licenses/bsd-license.php.
15 *
16 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 *
19 */
20
21 #include <efi/efi.h>
22 #include <efi/efilib.h>
23
24 #ifndef _MY_BOOT_SERVICES_FILE
25 #define _MY_BOOT_SERVICES_FILE
26
27 typedef struct _EFI_DEVICE_PATH_PROTOCOL {
28 UINT8 Type;
29 UINT8 SubType;
30 UINT8 Length[2];
31 } EFI_DEVICE_PATH_PROTOCOL;
32
33 typedef
34 EFI_STATUS
35 (EFIAPI *EFI_CONNECT_CONTROLLER)(
36 IN EFI_HANDLE ControllerHandle,
37 IN EFI_HANDLE *DriverImageHandle, OPTIONAL
38 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath, OPTIONAL
39 IN BOOLEAN Recursive
40 );
41
42 typedef
43 EFI_STATUS
44 (EFIAPI *EFI_DISCONNECT_CONTROLLER)(
45 IN EFI_HANDLE ControllerHandle,
46 IN EFI_HANDLE DriverImageHandle, OPTIONAL
47 IN EFI_HANDLE ChildHandle OPTIONAL
48 );
49
50 typedef
51 EFI_STATUS
52 (EFIAPI *EFI_OPEN_PROTOCOL) (
53 IN EFI_HANDLE Handle,
54 IN EFI_GUID * Protocol,
55 OUT VOID **Interface,
56 IN EFI_HANDLE ImageHandle,
57 IN EFI_HANDLE ControllerHandle, OPTIONAL
58 IN UINT32 Attributes
59 );
60
61 typedef
62 EFI_STATUS
63 (EFIAPI *EFI_CLOSE_PROTOCOL) (
64 IN EFI_HANDLE Handle,
65 IN EFI_GUID * Protocol,
66 IN EFI_HANDLE ImageHandle,
67 IN EFI_HANDLE DeviceHandle
68 );
69
70 typedef struct {
71 EFI_HANDLE AgentHandle;
72 EFI_HANDLE ControllerHandle;
73 UINT32 Attributes;
74 UINT32 OpenCount;
75 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
76
77 typedef
78 EFI_STATUS
79 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
80 IN EFI_HANDLE UserHandle,
81 IN EFI_GUID * Protocol,
82 IN EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
83 OUT UINTN *EntryCount
84 );
85
86 typedef
87 EFI_STATUS
88 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
89 IN EFI_HANDLE UserHandle,
90 OUT EFI_GUID ***ProtocolBuffer,
91 OUT UINTN *ProtocolBufferCount
92 );
93
94 typedef
95 EFI_STATUS
96 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
97 IN EFI_LOCATE_SEARCH_TYPE SearchType,
98 IN EFI_GUID * Protocol OPTIONAL,
99 IN VOID *SearchKey OPTIONAL,
100 IN OUT UINTN *NumberHandles,
101 OUT EFI_HANDLE **Buffer
102 );
103
104 typedef
105 EFI_STATUS
106 (EFIAPI *EFI_LOCATE_PROTOCOL) (
107 EFI_GUID * Protocol,
108 VOID *Registration, OPTIONAL
109 VOID **Interface
110 );
111
112 ///
113 /// EFI Boot Services Table.
114 ///
115 typedef struct _MY_BOOT_SERVICES {
116 ///
117 /// The table header for the EFI Boot Services Table.
118 ///
119 EFI_TABLE_HEADER Hdr;
120
121 //
122 // Task Priority Services
123 //
124 EFI_RAISE_TPL RaiseTPL;
125 EFI_RESTORE_TPL RestoreTPL;
126
127 //
128 // Memory Services
129 //
130 EFI_ALLOCATE_PAGES AllocatePages;
131 EFI_FREE_PAGES FreePages;
132 EFI_GET_MEMORY_MAP GetMemoryMap;
133 EFI_ALLOCATE_POOL AllocatePool;
134 EFI_FREE_POOL FreePool;
135
136 //
137 // Event & Timer Services
138 //
139 EFI_CREATE_EVENT CreateEvent;
140 EFI_SET_TIMER SetTimer;
141 EFI_WAIT_FOR_EVENT WaitForEvent;
142 EFI_SIGNAL_EVENT SignalEvent;
143 EFI_CLOSE_EVENT CloseEvent;
144 EFI_CHECK_EVENT CheckEvent;
145
146 //
147 // Protocol Handler Services
148 //
149 EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
150 EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
151 EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
152 EFI_HANDLE_PROTOCOL HandleProtocol;
153 VOID *Reserved;
154 EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
155 EFI_LOCATE_HANDLE LocateHandle;
156 EFI_LOCATE_DEVICE_PATH LocateDevicePath;
157 EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
158
159 //
160 // Image Services
161 //
162 EFI_IMAGE_LOAD LoadImage;
163 EFI_IMAGE_START StartImage;
164 EFI_EXIT Exit;
165 EFI_IMAGE_UNLOAD UnloadImage;
166 EFI_EXIT_BOOT_SERVICES ExitBootServices;
167
168 //
169 // Miscellaneous Services
170 //
171 EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
172 EFI_STALL Stall;
173 EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
174
175 //
176 // DriverSupport Services
177 //
178 EFI_CONNECT_CONTROLLER ConnectController;
179 EFI_DISCONNECT_CONTROLLER DisconnectController;
180
181 //
182 // Open and Close Protocol Services
183 //
184 EFI_OPEN_PROTOCOL OpenProtocol;
185 EFI_CLOSE_PROTOCOL CloseProtocol;
186 EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
187
188 //
189 // Library Services
190 //
191 EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
192 EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
193 EFI_LOCATE_PROTOCOL LocateProtocol;
194 // EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
195 // EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
196 //
197 // //
198 // // 32-bit CRC Services
199 // //
200 // EFI_CALCULATE_CRC32 CalculateCrc32;
201 //
202 // //
203 // // Miscellaneous Services
204 // //
205 // EFI_COPY_MEM CopyMem;
206 // EFI_SET_MEM SetMem;
207 // EFI_CREATE_EVENT_EX CreateEventEx;
208 } MY_BOOT_SERVICES;
209
210 // Below is from http://git.etherboot.org/?p=mirror/efi/shell/.git;a=commitdiff;h=b1b0c63423cac54dc964c2930e04aebb46a946ec;
211 // Seems to have been replaced by ParseHandleDatabaseByRelationshipWithType(), but the latter isn't working for me....
212 EFI_STATUS
213 LibScanHandleDatabase (
214 EFI_HANDLE DriverBindingHandle, OPTIONAL
215 UINT32 *DriverBindingHandleIndex, OPTIONAL
216 EFI_HANDLE ControllerHandle, OPTIONAL
217 UINT32 *ControllerHandleIndex, OPTIONAL
218 UINTN *HandleCount,
219 EFI_HANDLE **HandleBuffer,
220 UINT32 **HandleType
221 );
222
223 extern MY_BOOT_SERVICES *gBS;
224
225 #define EFI_HANDLE_TYPE_UNKNOWN 0x000
226 #define EFI_HANDLE_TYPE_IMAGE_HANDLE 0x001
227 #define EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE 0x002
228 #define EFI_HANDLE_TYPE_DEVICE_DRIVER 0x004
229 #define EFI_HANDLE_TYPE_BUS_DRIVER 0x008
230 #define EFI_HANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE 0x010
231 #define EFI_HANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE 0x020
232 #define EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE 0x040
233 #define EFI_HANDLE_TYPE_DEVICE_HANDLE 0x080
234 #define EFI_HANDLE_TYPE_PARENT_HANDLE 0x100
235 #define EFI_HANDLE_TYPE_CONTROLLER_HANDLE 0x200
236 #define EFI_HANDLE_TYPE_CHILD_HANDLE 0x400
237
238
239 // Below from EfiApi.h
240 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
241 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
242 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
243 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
244 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
245 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
246
247
248 #endif