MnpDriver.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /** @file
  2. Implementation of driver entry point and driver binding protocol.
  3. Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "MnpDriver.h"
  7. #include "MnpImpl.h"
  8. #include "MnpVlan.h"
  9. EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
  10. MnpDriverBindingSupported,
  11. MnpDriverBindingStart,
  12. MnpDriverBindingStop,
  13. 0xa,
  14. NULL,
  15. NULL
  16. };
  17. /**
  18. Callback function which provided by user to remove one node in NetDestroyLinkList process.
  19. @param[in] Entry The entry to be removed.
  20. @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
  21. @retval EFI_SUCCESS The entry has been removed successfully.
  22. @retval Others Fail to remove the entry.
  23. **/
  24. EFI_STATUS
  25. EFIAPI
  26. MnpDestroyServiceDataEntry (
  27. IN LIST_ENTRY *Entry,
  28. IN VOID *Context
  29. )
  30. {
  31. MNP_SERVICE_DATA *MnpServiceData;
  32. MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
  33. return MnpDestroyServiceData (MnpServiceData);
  34. }
  35. /**
  36. Callback function which provided by user to remove one node in NetDestroyLinkList process.
  37. @param[in] Entry The entry to be removed.
  38. @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
  39. @retval EFI_SUCCESS The entry has been removed successfully.
  40. @retval Others Fail to remove the entry.
  41. **/
  42. EFI_STATUS
  43. EFIAPI
  44. MnpDestroyServiceChildEntry (
  45. IN LIST_ENTRY *Entry,
  46. IN VOID *Context
  47. )
  48. {
  49. MNP_SERVICE_DATA *MnpServiceData;
  50. MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
  51. return MnpDestroyServiceChild (MnpServiceData);
  52. }
  53. /**
  54. Test to see if this driver supports ControllerHandle. This service
  55. is called by the EFI boot service ConnectController(). In
  56. order to make drivers as small as possible, there are a few calling
  57. restrictions for this service. ConnectController() must
  58. follow these calling restrictions. If any other agent wishes to call
  59. Supported() it must also follow these calling restrictions.
  60. @param[in] This Protocol instance pointer.
  61. @param[in] ControllerHandle Handle of device to test.
  62. @param[in] RemainingDevicePath Optional parameter use to pick a specific
  63. child device to start.
  64. @retval EFI_SUCCESS This driver supports this device.
  65. @retval EFI_ALREADY_STARTED This driver is already running on this device.
  66. @retval Others This driver does not support this device.
  67. **/
  68. EFI_STATUS
  69. EFIAPI
  70. MnpDriverBindingSupported (
  71. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  72. IN EFI_HANDLE ControllerHandle,
  73. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  74. )
  75. {
  76. EFI_STATUS Status;
  77. EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
  78. //
  79. // Test to open the Simple Network protocol BY_DRIVER.
  80. //
  81. Status = gBS->OpenProtocol (
  82. ControllerHandle,
  83. &gEfiSimpleNetworkProtocolGuid,
  84. (VOID **)&Snp,
  85. This->DriverBindingHandle,
  86. ControllerHandle,
  87. EFI_OPEN_PROTOCOL_BY_DRIVER
  88. );
  89. if (EFI_ERROR (Status)) {
  90. return Status;
  91. }
  92. //
  93. // Close the opened SNP protocol.
  94. //
  95. gBS->CloseProtocol (
  96. ControllerHandle,
  97. &gEfiSimpleNetworkProtocolGuid,
  98. This->DriverBindingHandle,
  99. ControllerHandle
  100. );
  101. return EFI_SUCCESS;
  102. }
  103. /**
  104. Start this driver on ControllerHandle. This service is called by the
  105. EFI boot service ConnectController(). In order to make drivers as small
  106. as possible, there are a few calling restrictions for this service.
  107. ConnectController() must follow these calling restrictions. If any other
  108. agent wishes to call Start() it must also follow these calling restrictions.
  109. @param[in] This Protocol instance pointer.
  110. @param[in] ControllerHandle Handle of device to bind driver to.
  111. @param[in] RemainingDevicePath Optional parameter use to pick a specific
  112. child device to start.
  113. @retval EFI_SUCCESS This driver is added to ControllerHandle.
  114. @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
  115. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
  116. @retval Others This driver does not support this device.
  117. **/
  118. EFI_STATUS
  119. EFIAPI
  120. MnpDriverBindingStart (
  121. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  122. IN EFI_HANDLE ControllerHandle,
  123. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  124. )
  125. {
  126. EFI_STATUS Status;
  127. MNP_SERVICE_DATA *MnpServiceData;
  128. MNP_DEVICE_DATA *MnpDeviceData;
  129. LIST_ENTRY *Entry;
  130. VLAN_TCI *VlanVariable;
  131. UINTN NumberOfVlan;
  132. UINTN Index;
  133. VlanVariable = NULL;
  134. //
  135. // Initialize the Mnp Device Data
  136. //
  137. MnpDeviceData = AllocateZeroPool (sizeof (MNP_DEVICE_DATA));
  138. if (MnpDeviceData == NULL) {
  139. DEBUG ((DEBUG_ERROR, "MnpDriverBindingStart(): Failed to allocate the Mnp Device Data.\n"));
  140. return EFI_OUT_OF_RESOURCES;
  141. }
  142. Status = MnpInitializeDeviceData (MnpDeviceData, This->DriverBindingHandle, ControllerHandle);
  143. if (EFI_ERROR (Status)) {
  144. DEBUG ((DEBUG_ERROR, "MnpDriverBindingStart: MnpInitializeDeviceData failed, %r.\n", Status));
  145. FreePool (MnpDeviceData);
  146. return Status;
  147. }
  148. //
  149. // Check whether NIC driver has already produced VlanConfig protocol
  150. //
  151. Status = gBS->OpenProtocol (
  152. ControllerHandle,
  153. &gEfiVlanConfigProtocolGuid,
  154. NULL,
  155. This->DriverBindingHandle,
  156. ControllerHandle,
  157. EFI_OPEN_PROTOCOL_TEST_PROTOCOL
  158. );
  159. if (!EFI_ERROR (Status)) {
  160. //
  161. // NIC hardware already implement VLAN,
  162. // no need to provide software VLAN implementation in MNP driver
  163. //
  164. MnpDeviceData->NumberOfVlan = 0;
  165. ZeroMem (&MnpDeviceData->VlanConfig, sizeof (EFI_VLAN_CONFIG_PROTOCOL));
  166. MnpServiceData = MnpCreateServiceData (MnpDeviceData, 0, 0);
  167. Status = (MnpServiceData != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
  168. goto Exit;
  169. }
  170. //
  171. // Install VLAN Config Protocol
  172. //
  173. Status = gBS->InstallMultipleProtocolInterfaces (
  174. &ControllerHandle,
  175. &gEfiVlanConfigProtocolGuid,
  176. &MnpDeviceData->VlanConfig,
  177. NULL
  178. );
  179. if (EFI_ERROR (Status)) {
  180. goto Exit;
  181. }
  182. //
  183. // Get current VLAN configuration from EFI Variable
  184. //
  185. NumberOfVlan = 0;
  186. Status = MnpGetVlanVariable (MnpDeviceData, &NumberOfVlan, &VlanVariable);
  187. if (EFI_ERROR (Status)) {
  188. //
  189. // No VLAN is set, create a default MNP service data for untagged frame
  190. //
  191. MnpDeviceData->NumberOfVlan = 0;
  192. MnpServiceData = MnpCreateServiceData (MnpDeviceData, 0, 0);
  193. Status = (MnpServiceData != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
  194. goto Exit;
  195. }
  196. //
  197. // Create MNP service data for each VLAN
  198. //
  199. MnpDeviceData->NumberOfVlan = NumberOfVlan;
  200. for (Index = 0; Index < NumberOfVlan; Index++) {
  201. MnpServiceData = MnpCreateServiceData (
  202. MnpDeviceData,
  203. VlanVariable[Index].Bits.Vid,
  204. (UINT8)VlanVariable[Index].Bits.Priority
  205. );
  206. if (MnpServiceData == NULL) {
  207. Status = EFI_OUT_OF_RESOURCES;
  208. goto Exit;
  209. }
  210. }
  211. Exit:
  212. if (VlanVariable != NULL) {
  213. FreePool (VlanVariable);
  214. }
  215. if (EFI_ERROR (Status)) {
  216. //
  217. // Destroy all MNP service data
  218. //
  219. while (!IsListEmpty (&MnpDeviceData->ServiceList)) {
  220. Entry = GetFirstNode (&MnpDeviceData->ServiceList);
  221. MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
  222. MnpDestroyServiceData (MnpServiceData);
  223. }
  224. //
  225. // Uninstall the VLAN Config Protocol if any
  226. //
  227. if (MnpDeviceData->VlanConfig.Set != NULL) {
  228. gBS->UninstallMultipleProtocolInterfaces (
  229. MnpDeviceData->ControllerHandle,
  230. &gEfiVlanConfigProtocolGuid,
  231. &MnpDeviceData->VlanConfig,
  232. NULL
  233. );
  234. }
  235. //
  236. // Destroy Mnp Device Data
  237. //
  238. MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);
  239. FreePool (MnpDeviceData);
  240. }
  241. return Status;
  242. }
  243. /**
  244. Stop this driver on ControllerHandle. This service is called by the
  245. EFI boot service DisconnectController(). In order to make drivers as
  246. small as possible, there are a few calling restrictions for this service.
  247. DisconnectController() must follow these calling restrictions. If any other
  248. agent wishes to call Stop() it must also follow these calling restrictions.
  249. @param[in] This Protocol instance pointer.
  250. @param[in] ControllerHandle Handle of device to stop driver on.
  251. @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
  252. number of children is zero stop the entire
  253. bus driver.
  254. @param[in] ChildHandleBuffer List of Child Handles to Stop.
  255. @retval EFI_SUCCESS This driver is removed ControllerHandle.
  256. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
  257. **/
  258. EFI_STATUS
  259. EFIAPI
  260. MnpDriverBindingStop (
  261. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  262. IN EFI_HANDLE ControllerHandle,
  263. IN UINTN NumberOfChildren,
  264. IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
  265. )
  266. {
  267. EFI_STATUS Status;
  268. EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
  269. EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
  270. MNP_DEVICE_DATA *MnpDeviceData;
  271. MNP_SERVICE_DATA *MnpServiceData;
  272. LIST_ENTRY *List;
  273. UINTN ListLength;
  274. //
  275. // Try to retrieve MNP service binding protocol from the ControllerHandle
  276. //
  277. Status = gBS->OpenProtocol (
  278. ControllerHandle,
  279. &gEfiManagedNetworkServiceBindingProtocolGuid,
  280. (VOID **)&ServiceBinding,
  281. This->DriverBindingHandle,
  282. ControllerHandle,
  283. EFI_OPEN_PROTOCOL_GET_PROTOCOL
  284. );
  285. if (EFI_ERROR (Status)) {
  286. //
  287. // Retrieve VLAN Config Protocol from the ControllerHandle
  288. //
  289. Status = gBS->OpenProtocol (
  290. ControllerHandle,
  291. &gEfiVlanConfigProtocolGuid,
  292. (VOID **)&VlanConfig,
  293. This->DriverBindingHandle,
  294. ControllerHandle,
  295. EFI_OPEN_PROTOCOL_GET_PROTOCOL
  296. );
  297. if (EFI_ERROR (Status)) {
  298. DEBUG ((DEBUG_ERROR, "MnpDriverBindingStop: try to stop unknown Controller.\n"));
  299. return EFI_DEVICE_ERROR;
  300. }
  301. MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (VlanConfig);
  302. } else {
  303. MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (ServiceBinding);
  304. MnpDeviceData = MnpServiceData->MnpDeviceData;
  305. }
  306. if (NumberOfChildren == 0) {
  307. //
  308. // Destroy all MNP service data
  309. //
  310. List = &MnpDeviceData->ServiceList;
  311. Status = NetDestroyLinkList (
  312. List,
  313. MnpDestroyServiceDataEntry,
  314. NULL,
  315. &ListLength
  316. );
  317. if (EFI_ERROR (Status) || (ListLength != 0)) {
  318. return EFI_DEVICE_ERROR;
  319. }
  320. //
  321. // Uninstall the VLAN Config Protocol if any
  322. //
  323. if (MnpDeviceData->VlanConfig.Set != NULL) {
  324. gBS->UninstallMultipleProtocolInterfaces (
  325. MnpDeviceData->ControllerHandle,
  326. &gEfiVlanConfigProtocolGuid,
  327. &MnpDeviceData->VlanConfig,
  328. NULL
  329. );
  330. }
  331. //
  332. // Destroy Mnp Device Data
  333. //
  334. MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);
  335. FreePool (MnpDeviceData);
  336. if (gMnpControllerNameTable != NULL) {
  337. FreeUnicodeStringTable (gMnpControllerNameTable);
  338. gMnpControllerNameTable = NULL;
  339. }
  340. return EFI_SUCCESS;
  341. }
  342. //
  343. // Stop all MNP child
  344. //
  345. List = &MnpDeviceData->ServiceList;
  346. Status = NetDestroyLinkList (
  347. List,
  348. MnpDestroyServiceChildEntry,
  349. NULL,
  350. &ListLength
  351. );
  352. if (EFI_ERROR (Status)) {
  353. return EFI_DEVICE_ERROR;
  354. }
  355. return EFI_SUCCESS;
  356. }
  357. /**
  358. Creates a child handle with a set of I/O services.
  359. @param[in] This Protocol instance pointer.
  360. @param[in, out] ChildHandle Pointer to the handle of the child to create. If
  361. it is NULL, then a new handle is created. If
  362. it is not NULL, then the I/O services are added
  363. to the existing child handle.
  364. @retval EFI_SUCCESS The protocol was added to ChildHandle.
  365. @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
  366. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
  367. create the child.
  368. @retval Others The child handle was not created.
  369. **/
  370. EFI_STATUS
  371. EFIAPI
  372. MnpServiceBindingCreateChild (
  373. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  374. IN OUT EFI_HANDLE *ChildHandle
  375. )
  376. {
  377. EFI_STATUS Status;
  378. MNP_SERVICE_DATA *MnpServiceData;
  379. MNP_INSTANCE_DATA *Instance;
  380. VOID *MnpSb;
  381. EFI_TPL OldTpl;
  382. if ((This == NULL) || (ChildHandle == NULL)) {
  383. return EFI_INVALID_PARAMETER;
  384. }
  385. MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (This);
  386. //
  387. // Allocate buffer for the new instance.
  388. //
  389. Instance = AllocateZeroPool (sizeof (MNP_INSTANCE_DATA));
  390. if (Instance == NULL) {
  391. DEBUG ((DEBUG_ERROR, "MnpServiceBindingCreateChild: Failed to allocate memory for the new instance.\n"));
  392. return EFI_OUT_OF_RESOURCES;
  393. }
  394. //
  395. // Init the instance data.
  396. //
  397. MnpInitializeInstanceData (MnpServiceData, Instance);
  398. Status = gBS->InstallMultipleProtocolInterfaces (
  399. ChildHandle,
  400. &gEfiManagedNetworkProtocolGuid,
  401. &Instance->ManagedNetwork,
  402. NULL
  403. );
  404. if (EFI_ERROR (Status)) {
  405. DEBUG (
  406. (DEBUG_ERROR,
  407. "MnpServiceBindingCreateChild: Failed to install the MNP protocol, %r.\n",
  408. Status)
  409. );
  410. goto ErrorExit;
  411. }
  412. //
  413. // Save the instance's childhandle.
  414. //
  415. Instance->Handle = *ChildHandle;
  416. Status = gBS->OpenProtocol (
  417. MnpServiceData->ServiceHandle,
  418. &gEfiManagedNetworkServiceBindingProtocolGuid,
  419. (VOID **)&MnpSb,
  420. gMnpDriverBinding.DriverBindingHandle,
  421. Instance->Handle,
  422. EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
  423. );
  424. if (EFI_ERROR (Status)) {
  425. goto ErrorExit;
  426. }
  427. //
  428. // Add the child instance into ChildrenList.
  429. //
  430. OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  431. InsertTailList (&MnpServiceData->ChildrenList, &Instance->InstEntry);
  432. MnpServiceData->ChildrenNumber++;
  433. gBS->RestoreTPL (OldTpl);
  434. ErrorExit:
  435. if (EFI_ERROR (Status)) {
  436. if (Instance->Handle != NULL) {
  437. gBS->UninstallMultipleProtocolInterfaces (
  438. Instance->Handle,
  439. &gEfiManagedNetworkProtocolGuid,
  440. &Instance->ManagedNetwork,
  441. NULL
  442. );
  443. }
  444. FreePool (Instance);
  445. }
  446. return Status;
  447. }
  448. /**
  449. Destroys a child handle with a set of I/O services.
  450. The DestroyChild() function does the opposite of CreateChild(). It removes a
  451. protocol that was installed by CreateChild() from ChildHandle. If the removed
  452. protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
  453. @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
  454. instance.
  455. @param[in] ChildHandle Handle of the child to destroy.
  456. @retval EFI_SUCCESS The protocol was removed from ChildHandle.
  457. @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
  458. is being removed.
  459. @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
  460. @retval EFI_ACCESS_DENIED The protocol could not be removed from the
  461. ChildHandle because its services are being
  462. used.
  463. @retval Others The child handle was not destroyed.
  464. **/
  465. EFI_STATUS
  466. EFIAPI
  467. MnpServiceBindingDestroyChild (
  468. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  469. IN EFI_HANDLE ChildHandle
  470. )
  471. {
  472. EFI_STATUS Status;
  473. MNP_SERVICE_DATA *MnpServiceData;
  474. EFI_MANAGED_NETWORK_PROTOCOL *ManagedNetwork;
  475. MNP_INSTANCE_DATA *Instance;
  476. EFI_TPL OldTpl;
  477. if ((This == NULL) || (ChildHandle == NULL)) {
  478. return EFI_INVALID_PARAMETER;
  479. }
  480. MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (This);
  481. //
  482. // Try to retrieve ManagedNetwork Protocol from ChildHandle.
  483. //
  484. Status = gBS->OpenProtocol (
  485. ChildHandle,
  486. &gEfiManagedNetworkProtocolGuid,
  487. (VOID **)&ManagedNetwork,
  488. gMnpDriverBinding.DriverBindingHandle,
  489. ChildHandle,
  490. EFI_OPEN_PROTOCOL_GET_PROTOCOL
  491. );
  492. if (EFI_ERROR (Status)) {
  493. return EFI_UNSUPPORTED;
  494. }
  495. Instance = MNP_INSTANCE_DATA_FROM_THIS (ManagedNetwork);
  496. //
  497. // MnpServiceBindingDestroyChild may be called twice: first called by
  498. // MnpServiceBindingStop, second called by uninstalling the MNP protocol
  499. // in this ChildHandle. Use destroyed to make sure the resource clean code
  500. // will only excecute once.
  501. //
  502. if (Instance->Destroyed) {
  503. return EFI_SUCCESS;
  504. }
  505. Instance->Destroyed = TRUE;
  506. //
  507. // Close the Simple Network protocol.
  508. //
  509. gBS->CloseProtocol (
  510. MnpServiceData->ServiceHandle,
  511. &gEfiManagedNetworkServiceBindingProtocolGuid,
  512. MnpServiceData->MnpDeviceData->ImageHandle,
  513. ChildHandle
  514. );
  515. //
  516. // Uninstall the ManagedNetwork protocol.
  517. //
  518. Status = gBS->UninstallMultipleProtocolInterfaces (
  519. ChildHandle,
  520. &gEfiManagedNetworkProtocolGuid,
  521. &Instance->ManagedNetwork,
  522. NULL
  523. );
  524. if (EFI_ERROR (Status)) {
  525. DEBUG (
  526. (DEBUG_ERROR,
  527. "MnpServiceBindingDestroyChild: Failed to uninstall the ManagedNetwork protocol, %r.\n",
  528. Status)
  529. );
  530. Instance->Destroyed = FALSE;
  531. return Status;
  532. }
  533. OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  534. //
  535. // Reset the configuration.
  536. //
  537. ManagedNetwork->Configure (ManagedNetwork, NULL);
  538. //
  539. // Try to flush the RcvdPacketQueue.
  540. //
  541. MnpFlushRcvdDataQueue (Instance);
  542. //
  543. // Clean the RxTokenMap.
  544. //
  545. NetMapClean (&Instance->RxTokenMap);
  546. //
  547. // Remove this instance from the ChildrenList.
  548. //
  549. RemoveEntryList (&Instance->InstEntry);
  550. MnpServiceData->ChildrenNumber--;
  551. gBS->RestoreTPL (OldTpl);
  552. FreePool (Instance);
  553. return Status;
  554. }
  555. /**
  556. The entry point for Mnp driver which installs the driver binding and component
  557. name protocol on its ImageHandle.
  558. @param[in] ImageHandle The image handle of the driver.
  559. @param[in] SystemTable The system table.
  560. @retval EFI_SUCCESS The driver binding and component name protocols are
  561. successfully installed.
  562. @retval Others Other errors as indicated.
  563. **/
  564. EFI_STATUS
  565. EFIAPI
  566. MnpDriverEntryPoint (
  567. IN EFI_HANDLE ImageHandle,
  568. IN EFI_SYSTEM_TABLE *SystemTable
  569. )
  570. {
  571. return EfiLibInstallDriverBindingComponentName2 (
  572. ImageHandle,
  573. SystemTable,
  574. &gMnpDriverBinding,
  575. ImageHandle,
  576. &gMnpComponentName,
  577. &gMnpComponentName2
  578. );
  579. }