]>
Commit | Line | Data |
---|---|---|
7f556e4d | 1 | /** @file\r |
2 | Implement the driver binding protocol for Asix AX88772 Ethernet driver.\r | |
3 | \r | |
4986bbaf | 4 | Copyright (c) 2011-2013, Intel Corporation\r |
7f556e4d | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "Ax88772.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Verify the controller type\r | |
19 | \r | |
20 | @param [in] pThis Protocol instance pointer.\r | |
21 | @param [in] Controller Handle of device to test.\r | |
22 | @param [in] pRemainingDevicePath Not used.\r | |
23 | \r | |
24 | @retval EFI_SUCCESS This driver supports this device.\r | |
25 | @retval other This driver does not support this device.\r | |
26 | \r | |
27 | **/\r | |
28 | EFI_STATUS\r | |
29 | EFIAPI\r | |
30 | DriverSupported (\r | |
31 | IN EFI_DRIVER_BINDING_PROTOCOL * pThis,\r | |
32 | IN EFI_HANDLE Controller,\r | |
33 | IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath\r | |
34 | )\r | |
35 | {\r | |
36 | EFI_USB_DEVICE_DESCRIPTOR Device;\r | |
37 | EFI_USB_IO_PROTOCOL * pUsbIo;\r | |
38 | EFI_STATUS Status;\r | |
39 | //\r | |
40 | // Connect to the USB stack\r | |
41 | //\r | |
42 | Status = gBS->OpenProtocol (\r | |
43 | Controller,\r | |
44 | &gEfiUsbIoProtocolGuid,\r | |
45 | (VOID **) &pUsbIo,\r | |
46 | pThis->DriverBindingHandle, \r | |
47 | Controller,\r | |
48 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
49 | );\r | |
50 | if (!EFI_ERROR ( Status )) {\r | |
51 | \r | |
52 | //\r | |
53 | // Get the interface descriptor to check the USB class and find a transport\r | |
54 | // protocol handler.\r | |
55 | //\r | |
56 | Status = pUsbIo->UsbGetDeviceDescriptor ( pUsbIo, &Device );\r | |
57 | if (EFI_ERROR ( Status )) {\r | |
58 | Status = EFI_UNSUPPORTED;\r | |
59 | }\r | |
60 | else {\r | |
61 | //\r | |
62 | // Validate the adapter\r | |
63 | // \r | |
64 | if ( VENDOR_ID == Device.IdVendor ) {\r | |
65 | \r | |
66 | if (PRODUCT_ID == Device.IdProduct) {\r | |
67 | DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));\r | |
68 | }\r | |
69 | else {\r | |
70 | Status = EFI_UNSUPPORTED;\r | |
71 | }\r | |
72 | }\r | |
73 | else {\r | |
74 | Status = EFI_UNSUPPORTED;\r | |
75 | } \r | |
76 | }\r | |
77 | \r | |
78 | //\r | |
79 | // Done with the USB stack\r | |
80 | //\r | |
81 | gBS->CloseProtocol (\r | |
82 | Controller,\r | |
83 | &gEfiUsbIoProtocolGuid,\r | |
84 | pThis->DriverBindingHandle,\r | |
85 | Controller\r | |
86 | );\r | |
87 | }\r | |
88 | return Status;\r | |
89 | }\r | |
90 | \r | |
91 | \r | |
92 | /**\r | |
93 | Start this driver on Controller by opening UsbIo and DevicePath protocols.\r | |
94 | Initialize PXE structures, create a copy of the Controller Device Path with the\r | |
95 | NIC's MAC address appended to it, install the NetworkInterfaceIdentifier protocol\r | |
96 | on the newly created Device Path.\r | |
97 | \r | |
98 | @param [in] pThis Protocol instance pointer.\r | |
99 | @param [in] Controller Handle of device to work with.\r | |
100 | @param [in] pRemainingDevicePath Not used, always produce all possible children.\r | |
101 | \r | |
102 | @retval EFI_SUCCESS This driver is added to Controller.\r | |
103 | @retval other This driver does not support this device.\r | |
104 | \r | |
105 | **/\r | |
106 | EFI_STATUS\r | |
107 | EFIAPI\r | |
108 | DriverStart (\r | |
109 | IN EFI_DRIVER_BINDING_PROTOCOL * pThis,\r | |
110 | IN EFI_HANDLE Controller,\r | |
111 | IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath\r | |
112 | )\r | |
113 | {\r | |
114 | \r | |
115 | EFI_STATUS Status;\r | |
116 | NIC_DEVICE *pNicDevice;\r | |
117 | UINTN LengthInBytes;\r | |
118 | EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath = NULL;\r | |
119 | MAC_ADDR_DEVICE_PATH MacDeviceNode;\r | |
120 | \r | |
121 | //\r | |
122 | // Allocate the device structure\r | |
123 | //\r | |
124 | LengthInBytes = sizeof ( *pNicDevice );\r | |
125 | Status = gBS->AllocatePool (\r | |
126 | EfiRuntimeServicesData,\r | |
127 | LengthInBytes,\r | |
128 | (VOID **) &pNicDevice\r | |
129 | );\r | |
130 | \r | |
131 | if (EFI_ERROR (Status)) {\r | |
132 | DEBUG ((EFI_D_ERROR, "gBS->AllocatePool:pNicDevice ERROR Status = %r\n", Status));\r | |
133 | goto EXIT;\r | |
134 | }\r | |
135 | \r | |
136 | //\r | |
137 | // Set the structure signature\r | |
138 | //\r | |
139 | ZeroMem ( pNicDevice, LengthInBytes );\r | |
140 | pNicDevice->Signature = DEV_SIGNATURE;\r | |
141 | \r | |
142 | Status = gBS->OpenProtocol (\r | |
143 | Controller,\r | |
144 | &gEfiUsbIoProtocolGuid,\r | |
145 | (VOID **) &pNicDevice->pUsbIo,\r | |
146 | pThis->DriverBindingHandle,\r | |
147 | Controller,\r | |
148 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
149 | );\r | |
150 | \r | |
151 | if (EFI_ERROR (Status)) {\r | |
152 | DEBUG ((EFI_D_ERROR, "gBS->OpenProtocol:EFI_USB_IO_PROTOCOL ERROR Status = %r\n", Status));\r | |
153 | gBS->FreePool ( pNicDevice );\r | |
154 | goto EXIT;\r | |
155 | }\r | |
156 | \r | |
157 | //\r | |
158 | // Initialize the simple network protocol\r | |
159 | //\r | |
160 | Status = SN_Setup ( pNicDevice );\r | |
161 | \r | |
162 | if (EFI_ERROR(Status)){\r | |
163 | DEBUG ((EFI_D_ERROR, "SN_Setup ERROR Status = %r\n", Status));\r | |
164 | gBS->CloseProtocol (\r | |
165 | Controller,\r | |
166 | &gEfiUsbIoProtocolGuid,\r | |
167 | pThis->DriverBindingHandle,\r | |
168 | Controller\r | |
169 | );\r | |
170 | gBS->FreePool ( pNicDevice );\r | |
171 | goto EXIT;\r | |
172 | }\r | |
173 | \r | |
174 | //\r | |
175 | // Set Device Path\r | |
176 | // \r | |
177 | Status = gBS->OpenProtocol (\r | |
178 | Controller,\r | |
179 | &gEfiDevicePathProtocolGuid,\r | |
180 | (VOID **) &ParentDevicePath,\r | |
181 | pThis->DriverBindingHandle,\r | |
182 | Controller,\r | |
183 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
184 | );\r | |
185 | if (EFI_ERROR(Status)) {\r | |
186 | DEBUG ((EFI_D_ERROR, "gBS->OpenProtocol:EFI_DEVICE_PATH_PROTOCOL error. Status = %r\n",\r | |
187 | Status)); \r | |
188 | gBS->CloseProtocol (\r | |
189 | Controller,\r | |
190 | &gEfiUsbIoProtocolGuid,\r | |
191 | pThis->DriverBindingHandle,\r | |
192 | Controller\r | |
193 | );\r | |
194 | gBS->FreePool ( pNicDevice );\r | |
195 | goto EXIT;\r | |
196 | }\r | |
197 | \r | |
198 | ZeroMem (&MacDeviceNode, sizeof (MAC_ADDR_DEVICE_PATH));\r | |
199 | MacDeviceNode.Header.Type = MESSAGING_DEVICE_PATH;\r | |
200 | MacDeviceNode.Header.SubType = MSG_MAC_ADDR_DP;\r | |
201 | \r | |
202 | SetDevicePathNodeLength (&MacDeviceNode.Header, sizeof (MAC_ADDR_DEVICE_PATH));\r | |
203 | \r | |
204 | CopyMem (&MacDeviceNode.MacAddress,\r | |
205 | &pNicDevice->SimpleNetworkData.CurrentAddress,\r | |
206 | PXE_HWADDR_LEN_ETHER);\r | |
207 | \r | |
208 | MacDeviceNode.IfType = pNicDevice->SimpleNetworkData.IfType;\r | |
209 | \r | |
210 | pNicDevice->MyDevPath = AppendDevicePathNode (\r | |
211 | ParentDevicePath,\r | |
212 | (EFI_DEVICE_PATH_PROTOCOL *) &MacDeviceNode\r | |
213 | );\r | |
214 | \r | |
215 | pNicDevice->Controller = NULL;\r | |
216 | \r | |
217 | //\r | |
218 | // Install both the simple network and device path protocols.\r | |
219 | //\r | |
220 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
221 | &pNicDevice->Controller,\r | |
222 | &gEfiCallerIdGuid,\r | |
223 | pNicDevice,\r | |
224 | &gEfiSimpleNetworkProtocolGuid, \r | |
225 | &pNicDevice->SimpleNetwork,\r | |
226 | &gEfiDevicePathProtocolGuid,\r | |
227 | pNicDevice->MyDevPath,\r | |
228 | NULL\r | |
229 | );\r | |
230 | \r | |
231 | if (EFI_ERROR(Status)){\r | |
232 | DEBUG ((EFI_D_ERROR, "gBS->InstallMultipleProtocolInterfaces error. Status = %r\n",\r | |
233 | Status)); \r | |
234 | gBS->CloseProtocol (\r | |
235 | Controller,\r | |
236 | &gEfiDevicePathProtocolGuid,\r | |
237 | pThis->DriverBindingHandle,\r | |
238 | Controller);\r | |
239 | gBS->CloseProtocol (\r | |
240 | Controller,\r | |
241 | &gEfiUsbIoProtocolGuid,\r | |
242 | pThis->DriverBindingHandle,\r | |
243 | Controller\r | |
244 | );\r | |
245 | gBS->FreePool ( pNicDevice );\r | |
246 | goto EXIT;\r | |
247 | }\r | |
248 | \r | |
249 | //\r | |
250 | // Open For Child Device\r | |
251 | //\r | |
252 | Status = gBS->OpenProtocol ( \r | |
253 | Controller,\r | |
254 | &gEfiUsbIoProtocolGuid,\r | |
255 | (VOID **) &pNicDevice->pUsbIo,\r | |
256 | pThis->DriverBindingHandle,\r | |
257 | pNicDevice->Controller,\r | |
258 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r | |
259 | );\r | |
260 | \r | |
261 | if (EFI_ERROR(Status)){\r | |
262 | gBS->UninstallMultipleProtocolInterfaces (\r | |
263 | &pNicDevice->Controller,\r | |
264 | &gEfiCallerIdGuid,\r | |
265 | pNicDevice,\r | |
266 | &gEfiSimpleNetworkProtocolGuid, \r | |
267 | &pNicDevice->SimpleNetwork,\r | |
268 | &gEfiDevicePathProtocolGuid,\r | |
269 | pNicDevice->MyDevPath,\r | |
270 | NULL\r | |
271 | );\r | |
272 | gBS->CloseProtocol (\r | |
273 | Controller,\r | |
274 | &gEfiDevicePathProtocolGuid,\r | |
275 | pThis->DriverBindingHandle,\r | |
276 | Controller);\r | |
277 | gBS->CloseProtocol (\r | |
278 | Controller,\r | |
279 | &gEfiUsbIoProtocolGuid,\r | |
280 | pThis->DriverBindingHandle,\r | |
281 | Controller\r | |
282 | );\r | |
283 | gBS->FreePool ( pNicDevice );\r | |
284 | }\r | |
285 | \r | |
286 | EXIT:\r | |
287 | return Status;\r | |
288 | \r | |
289 | }\r | |
290 | \r | |
291 | /**\r | |
292 | Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and\r | |
293 | closing the DevicePath and PciIo protocols on Controller.\r | |
294 | \r | |
295 | @param [in] pThis Protocol instance pointer.\r | |
296 | @param [in] Controller Handle of device to stop driver on.\r | |
297 | @param [in] NumberOfChildren How many children need to be stopped.\r | |
298 | @param [in] pChildHandleBuffer Not used.\r | |
299 | \r | |
300 | @retval EFI_SUCCESS This driver is removed Controller.\r | |
301 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
302 | @retval other This driver was not removed from this device.\r | |
303 | \r | |
304 | **/\r | |
305 | EFI_STATUS\r | |
306 | EFIAPI\r | |
307 | DriverStop (\r | |
308 | IN EFI_DRIVER_BINDING_PROTOCOL * pThis,\r | |
309 | IN EFI_HANDLE Controller,\r | |
310 | IN UINTN NumberOfChildren,\r | |
311 | IN EFI_HANDLE * ChildHandleBuffer\r | |
312 | )\r | |
313 | {\r | |
314 | BOOLEAN AllChildrenStopped;\r | |
315 | UINTN Index;\r | |
316 | EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNetwork;\r | |
317 | EFI_STATUS Status = EFI_SUCCESS;\r | |
318 | NIC_DEVICE *pNicDevice;\r | |
319 | \r | |
320 | //\r | |
321 | // Complete all outstanding transactions to Controller.\r | |
322 | // Don't allow any new transaction to Controller to be started.\r | |
323 | //\r | |
324 | if (NumberOfChildren == 0) {\r | |
325 | \r | |
326 | Status = gBS->OpenProtocol (\r | |
327 | Controller,\r | |
328 | &gEfiSimpleNetworkProtocolGuid,\r | |
329 | (VOID **) &SimpleNetwork,\r | |
330 | pThis->DriverBindingHandle,\r | |
331 | Controller,\r | |
332 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
333 | );\r | |
334 | \r | |
335 | if (EFI_ERROR(Status)) {\r | |
336 | //\r | |
337 | // This is a 2nd type handle(multi-lun root), it needs to close devicepath\r | |
338 | // and usbio protocol.\r | |
339 | //\r | |
340 | gBS->CloseProtocol (\r | |
341 | Controller,\r | |
342 | &gEfiDevicePathProtocolGuid,\r | |
343 | pThis->DriverBindingHandle,\r | |
344 | Controller\r | |
345 | );\r | |
346 | gBS->CloseProtocol (\r | |
347 | Controller,\r | |
348 | &gEfiUsbIoProtocolGuid,\r | |
349 | pThis->DriverBindingHandle,\r | |
350 | Controller\r | |
351 | );\r | |
352 | return EFI_SUCCESS;\r | |
353 | }\r | |
354 | \r | |
355 | pNicDevice = DEV_FROM_SIMPLE_NETWORK ( SimpleNetwork );\r | |
356 | \r | |
357 | Status = gBS->UninstallMultipleProtocolInterfaces (\r | |
358 | Controller, \r | |
359 | &gEfiCallerIdGuid,\r | |
360 | pNicDevice,\r | |
361 | &gEfiSimpleNetworkProtocolGuid, \r | |
362 | &pNicDevice->SimpleNetwork,\r | |
363 | &gEfiDevicePathProtocolGuid,\r | |
364 | pNicDevice->MyDevPath,\r | |
365 | NULL\r | |
366 | );\r | |
367 | \r | |
368 | if (EFI_ERROR (Status)) {\r | |
369 | return Status;\r | |
370 | }\r | |
371 | //\r | |
372 | // Close the bus driver\r | |
373 | //\r | |
374 | Status = gBS->CloseProtocol (\r | |
375 | Controller,\r | |
376 | &gEfiDevicePathProtocolGuid,\r | |
377 | pThis->DriverBindingHandle,\r | |
378 | Controller\r | |
379 | );\r | |
380 | \r | |
381 | if (EFI_ERROR(Status)){\r | |
382 | DEBUG ((EFI_D_ERROR, "driver stop: gBS->CloseProtocol:EfiDevicePathProtocol error. Status %r\n", Status));\r | |
383 | }\r | |
384 | \r | |
385 | Status = gBS->CloseProtocol (\r | |
386 | Controller,\r | |
387 | &gEfiUsbIoProtocolGuid,\r | |
388 | pThis->DriverBindingHandle,\r | |
389 | Controller\r | |
390 | );\r | |
391 | \r | |
392 | if (EFI_ERROR(Status)){\r | |
393 | DEBUG ((EFI_D_ERROR, "driver stop: gBS->CloseProtocol:EfiUsbIoProtocol error. Status %r\n", Status));\r | |
394 | }\r | |
395 | return EFI_SUCCESS;\r | |
396 | } \r | |
397 | AllChildrenStopped = TRUE;\r | |
398 | \r | |
399 | for (Index = 0; Index < NumberOfChildren; Index++) {\r | |
400 | \r | |
401 | Status = gBS->OpenProtocol (\r | |
402 | ChildHandleBuffer[Index],\r | |
403 | &gEfiSimpleNetworkProtocolGuid,\r | |
404 | (VOID **) &SimpleNetwork,\r | |
405 | pThis->DriverBindingHandle,\r | |
406 | Controller,\r | |
407 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
408 | );\r | |
409 | \r | |
410 | if (EFI_ERROR (Status)) {\r | |
411 | AllChildrenStopped = FALSE;\r | |
412 | DEBUG ((EFI_D_ERROR, "Fail to stop No.%d multi-lun child handle when opening SimpleNetwork\n", (UINT32)Index));\r | |
413 | continue;\r | |
414 | } \r | |
415 | \r | |
416 | pNicDevice = DEV_FROM_SIMPLE_NETWORK ( SimpleNetwork );\r | |
417 | \r | |
418 | gBS->CloseProtocol (\r | |
419 | Controller,\r | |
420 | &gEfiUsbIoProtocolGuid,\r | |
421 | pThis->DriverBindingHandle,\r | |
422 | ChildHandleBuffer[Index]\r | |
423 | ); \r | |
424 | \r | |
425 | Status = gBS->UninstallMultipleProtocolInterfaces (\r | |
426 | ChildHandleBuffer[Index], \r | |
427 | &gEfiCallerIdGuid,\r | |
428 | pNicDevice,\r | |
429 | &gEfiSimpleNetworkProtocolGuid, \r | |
430 | &pNicDevice->SimpleNetwork,\r | |
431 | &gEfiDevicePathProtocolGuid,\r | |
432 | pNicDevice->MyDevPath,\r | |
433 | NULL\r | |
434 | );\r | |
435 | \r | |
436 | if (EFI_ERROR (Status)) {\r | |
437 | Status = gBS->OpenProtocol ( \r | |
438 | Controller,\r | |
439 | &gEfiUsbIoProtocolGuid,\r | |
440 | (VOID **) &pNicDevice->pUsbIo,\r | |
441 | pThis->DriverBindingHandle,\r | |
442 | ChildHandleBuffer[Index],\r | |
443 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r | |
444 | );\r | |
445 | }\r | |
446 | else {\r | |
447 | int i;\r | |
448 | RX_PKT * pCurr = pNicDevice->QueueHead;\r | |
449 | RX_PKT * pFree;\r | |
450 | \r | |
451 | for ( i = 0 ; i < MAX_QUEUE_SIZE ; i++) {\r | |
452 | if ( NULL != pCurr ) {\r | |
453 | pFree = pCurr;\r | |
454 | pCurr = pCurr->pNext;\r | |
455 | gBS->FreePool (pFree);\r | |
456 | }\r | |
457 | }\r | |
458 | \r | |
459 | if ( NULL != pNicDevice->pRxTest)\r | |
460 | gBS->FreePool (pNicDevice->pRxTest);\r | |
461 | \r | |
462 | if ( NULL != pNicDevice->pTxTest)\r | |
463 | gBS->FreePool (pNicDevice->pTxTest);\r | |
464 | \r | |
465 | if ( NULL != pNicDevice->MyDevPath)\r | |
466 | gBS->FreePool (pNicDevice->MyDevPath);\r | |
467 | \r | |
468 | if ( NULL != pNicDevice)\r | |
469 | gBS->FreePool (pNicDevice);\r | |
470 | }\r | |
471 | }\r | |
472 | \r | |
473 | if (!AllChildrenStopped) {\r | |
474 | return EFI_DEVICE_ERROR;\r | |
475 | }\r | |
476 | return EFI_SUCCESS;\r | |
477 | }\r | |
478 | \r | |
479 | \r | |
480 | /**\r | |
481 | Driver binding protocol declaration\r | |
482 | **/\r | |
483 | EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {\r | |
484 | DriverSupported,\r | |
485 | DriverStart,\r | |
486 | DriverStop,\r | |
487 | 0xa,\r | |
488 | NULL,\r | |
489 | NULL\r | |
490 | };\r | |
491 | \r | |
492 | \r | |
493 | /**\r | |
494 | Ax88772 driver unload routine.\r | |
495 | \r | |
496 | @param [in] ImageHandle Handle for the image.\r | |
497 | \r | |
498 | @retval EFI_SUCCESS Image may be unloaded\r | |
499 | \r | |
500 | **/\r | |
501 | EFI_STATUS\r | |
502 | EFIAPI\r | |
503 | DriverUnload (\r | |
504 | IN EFI_HANDLE ImageHandle\r | |
505 | )\r | |
506 | {\r | |
507 | UINTN BufferSize;\r | |
508 | UINTN Index;\r | |
509 | UINTN Max;\r | |
510 | EFI_HANDLE * pHandle;\r | |
511 | EFI_STATUS Status;\r | |
512 | \r | |
513 | //\r | |
514 | // Determine which devices are using this driver\r | |
515 | //\r | |
516 | BufferSize = 0;\r | |
517 | pHandle = NULL;\r | |
518 | Status = gBS->LocateHandle (\r | |
519 | ByProtocol,\r | |
520 | &gEfiCallerIdGuid,\r | |
521 | NULL,\r | |
522 | &BufferSize,\r | |
523 | NULL );\r | |
524 | if ( EFI_BUFFER_TOO_SMALL == Status ) {\r | |
525 | for ( ; ; ) {\r | |
526 | //\r | |
527 | // One or more block IO devices are present\r | |
528 | //\r | |
529 | Status = gBS->AllocatePool (\r | |
530 | EfiRuntimeServicesData,\r | |
531 | BufferSize,\r | |
532 | (VOID **) &pHandle\r | |
533 | );\r | |
534 | if ( EFI_ERROR ( Status )) {\r | |
535 | DEBUG ((EFI_D_ERROR, "Insufficient memory, failed handle buffer allocation\r\n"));\r | |
536 | break;\r | |
537 | }\r | |
538 | \r | |
539 | //\r | |
540 | // Locate the block IO devices\r | |
541 | //\r | |
542 | Status = gBS->LocateHandle (\r | |
543 | ByProtocol,\r | |
544 | &gEfiCallerIdGuid,\r | |
545 | NULL,\r | |
546 | &BufferSize,\r | |
547 | pHandle );\r | |
548 | if ( EFI_ERROR ( Status )) {\r | |
549 | //\r | |
550 | // Error getting handles\r | |
551 | //\r | |
552 | break;\r | |
553 | }\r | |
554 | \r | |
555 | //\r | |
556 | // Remove any use of the driver\r | |
557 | //\r | |
558 | Max = BufferSize / sizeof ( pHandle[ 0 ]);\r | |
559 | for ( Index = 0; Max > Index; Index++ ) {\r | |
560 | Status = DriverStop ( &gDriverBinding,\r | |
561 | pHandle[ Index ],\r | |
562 | 0,\r | |
563 | NULL );\r | |
564 | if ( EFI_ERROR ( Status )) {\r | |
565 | DEBUG ((EFI_D_ERROR, "WARNING - Failed to shutdown the driver on handle %08x\r\n", pHandle[ Index ]));\r | |
566 | break;\r | |
567 | }\r | |
568 | }\r | |
569 | break;\r | |
570 | }\r | |
571 | }\r | |
572 | else {\r | |
573 | if ( EFI_NOT_FOUND == Status ) {\r | |
574 | //\r | |
575 | // No devices were found\r | |
576 | //\r | |
577 | Status = EFI_SUCCESS;\r | |
578 | }\r | |
579 | }\r | |
580 | \r | |
581 | //\r | |
582 | // Free the handle array \r | |
583 | //\r | |
584 | if ( NULL != pHandle ) {\r | |
585 | gBS->FreePool ( pHandle );\r | |
586 | }\r | |
587 | \r | |
588 | //\r | |
589 | // Remove the protocols installed by the EntryPoint routine.\r | |
590 | //\r | |
591 | if ( !EFI_ERROR ( Status )) {\r | |
592 | gBS->UninstallMultipleProtocolInterfaces (\r | |
593 | ImageHandle,\r | |
594 | &gEfiDriverBindingProtocolGuid,\r | |
595 | &gDriverBinding, \r | |
596 | &gEfiComponentNameProtocolGuid,\r | |
597 | &gComponentName,\r | |
598 | &gEfiComponentName2ProtocolGuid,\r | |
599 | &gComponentName2,\r | |
600 | NULL\r | |
601 | );\r | |
602 | \r | |
603 | DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r | |
604 | "Removed: gEfiComponentName2ProtocolGuid from 0x%08x\r\n",\r | |
605 | ImageHandle ));\r | |
606 | DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r | |
607 | "Removed: gEfiComponentNameProtocolGuid from 0x%08x\r\n",\r | |
608 | ImageHandle ));\r | |
609 | DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r | |
610 | "Removed: gEfiDriverBindingProtocolGuid from 0x%08x\r\n",\r | |
611 | ImageHandle ));\r | |
612 | \r | |
613 | }\r | |
614 | \r | |
615 | return Status;\r | |
616 | }\r | |
617 | \r | |
618 | \r | |
619 | /**\r | |
620 | Ax88772 driver entry point.\r | |
621 | \r | |
622 | @param [in] ImageHandle Handle for the image.\r | |
623 | @param [in] pSystemTable Address of the system table.\r | |
624 | \r | |
625 | @retval EFI_SUCCESS Image successfully loaded.\r | |
626 | \r | |
627 | **/\r | |
628 | EFI_STATUS\r | |
629 | EFIAPI\r | |
630 | EntryPoint (\r | |
631 | IN EFI_HANDLE ImageHandle,\r | |
632 | IN EFI_SYSTEM_TABLE * pSystemTable\r | |
633 | )\r | |
634 | {\r | |
7f556e4d | 635 | EFI_STATUS Status;\r |
636 | \r | |
7f556e4d | 637 | //\r |
638 | // Add the driver to the list of drivers\r | |
639 | //\r | |
640 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
641 | ImageHandle,\r | |
642 | pSystemTable,\r | |
643 | &gDriverBinding,\r | |
644 | ImageHandle,\r | |
645 | &gComponentName,\r | |
646 | &gComponentName2\r | |
647 | );\r | |
648 | if ( !EFI_ERROR ( Status )) {\r | |
4986bbaf YP |
649 | DEBUG ((EFI_D_INFO, "Installed: gEfiDriverBindingProtocolGuid on 0x%08x\r\n",\r |
650 | ImageHandle));\r | |
651 | DEBUG ((EFI_D_INFO, "Installed: gEfiComponentNameProtocolGuid on 0x%08x\r\n",\r | |
652 | ImageHandle));\r | |
653 | DEBUG ((EFI_D_INFO,"Installed: gEfiComponentName2ProtocolGuid on 0x%08x\r\n",\r | |
654 | ImageHandle ));\r | |
7f556e4d | 655 | \r |
656 | }\r | |
657 | return Status;\r | |
658 | }\r |