1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
|
/** @file
Copyright (c) 2016 Socionext Inc. All rights reserved.<BR>
Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "NetsecDxe.h"
EFI_CPU_ARCH_PROTOCOL *mCpu;
STATIC
VOID
GetCurrentMacAddress (
IN UINT64 EepromBase,
OUT UINT8 *Mac)
{
Mac[0] = MmioRead8 (EepromBase + MAC_ADDRESS + 3);
Mac[1] = MmioRead8 (EepromBase + MAC_ADDRESS + 2);
Mac[2] = MmioRead8 (EepromBase + MAC_ADDRESS + 1);
Mac[3] = MmioRead8 (EepromBase + MAC_ADDRESS + 0);
Mac[4] = MmioRead8 (EepromBase + MAC_ADDRESS + 7);
Mac[5] = MmioRead8 (EepromBase + MAC_ADDRESS + 6);
}
/*
* Probe()
*/
STATIC
EFI_STATUS
Probe (
IN EFI_HANDLE Handle,
IN NETSEC_DRIVER *LanDriver
)
{
ogma_param_t Param;
ogma_err_t ogma_err;
UINT64 dmac_hm_cmd_base, dmac_mh_cmd_base, core_cmd_base;
UINT32 dmac_hm_cmd_size, dmac_mh_cmd_size, core_cmd_size;
UINT64 EepromBase;
SetMem (&Param, sizeof (Param), 0);
Param.use_gmac_flag = OGMA_TRUE;
Param.use_jumbo_pkt_flag = FixedPcdGet8 (PcdJumboPacket);
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].valid_flag = OGMA_TRUE;
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].little_endian_flag = OGMA_TRUE;
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].tmr_mode_flag = OGMA_FALSE;
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_TX].entry_num = FixedPcdGet16 (PcdEncTxDescNum);
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].valid_flag = OGMA_TRUE;
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].little_endian_flag = OGMA_TRUE;
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].tmr_mode_flag = OGMA_FALSE;
Param.desc_ring_param[OGMA_DESC_RING_ID_NRM_RX].entry_num = FixedPcdGet16 (PcdDecRxDescNum);
// phy-interface
Param.gmac_config.phy_interface = OGMA_PHY_INTERFACE_RGMII;
Param.phy_addr = LanDriver->Dev->Resources[2].AddrRangeMin;
// Read and save the Permanent MAC Address
EepromBase = LanDriver->Dev->Resources[1].AddrRangeMin;
GetCurrentMacAddress (EepromBase, LanDriver->SnpMode.PermanentAddress.Addr);
LanDriver->SnpMode.CurrentAddress = LanDriver->SnpMode.PermanentAddress;
DEBUG ((DEBUG_NET | DEBUG_INFO,
"Netsec: HW MAC Address: %02x-%02x-%02x-%02x-%02x-%02x\n",
LanDriver->SnpMode.PermanentAddress.Addr[0],
LanDriver->SnpMode.PermanentAddress.Addr[1],
LanDriver->SnpMode.PermanentAddress.Addr[2],
LanDriver->SnpMode.PermanentAddress.Addr[3],
LanDriver->SnpMode.PermanentAddress.Addr[4],
LanDriver->SnpMode.PermanentAddress.Addr[5]));
//
// The NETSEC microcode for the core engine and the TX and RX engines
// is loaded from a separate memory mapped ROM.
//
// Get hm microcode's physical addresses
dmac_hm_cmd_base = MmioRead32 (EepromBase + HM_ME_ADDRESS_H);
dmac_hm_cmd_base <<= 32;
dmac_hm_cmd_base |= MmioRead32 (EepromBase + HM_ME_ADDRESS_L);
dmac_hm_cmd_size = MmioRead32 (EepromBase + HM_ME_SIZE);
// Get mh microcode's physical addresses
dmac_mh_cmd_base = MmioRead32 (EepromBase + MH_ME_ADDRESS_H);
dmac_mh_cmd_base <<= 32;
dmac_mh_cmd_base |= MmioRead32 (EepromBase + MH_ME_ADDRESS_L);
dmac_mh_cmd_size = MmioRead32 (EepromBase + MH_ME_SIZE);
// Get core microcode's physical addresses
core_cmd_base = MmioRead32 (EepromBase + PACKET_ME_ADDRESS);
core_cmd_size = MmioRead32 (EepromBase + PACKET_ME_SIZE);
ogma_err = ogma_init (
(VOID *)(UINTN)LanDriver->Dev->Resources[0].AddrRangeMin,
Handle, &Param,
(VOID *)(UINTN)dmac_hm_cmd_base, dmac_hm_cmd_size,
(VOID *)(UINTN)dmac_mh_cmd_base, dmac_mh_cmd_size,
(VOID *)(UINTN)core_cmd_base, core_cmd_size,
&LanDriver->Handle);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR, "NETSEC: ogma_init() failed with error code %d\n",
ogma_err));
return EFI_DEVICE_ERROR;
}
ogma_enable_top_irq (LanDriver->Handle,
OGMA_TOP_IRQ_REG_NRM_RX | OGMA_TOP_IRQ_REG_NRM_TX);
return EFI_SUCCESS;
}
/*
* UEFI Stop() function
*/
STATIC
EFI_STATUS
EFIAPI
SnpStop (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
)
{
NETSEC_DRIVER *LanDriver;
EFI_TPL SavedTpl;
EFI_STATUS Status;
// Check Snp Instance
if (Snp == NULL) {
return EFI_INVALID_PARAMETER;
}
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
// Check state of the driver
switch (Snp->Mode->State) {
case EfiSimpleNetworkStarted:
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n"));
ReturnUnlock (EFI_NOT_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
gBS->CloseEvent (LanDriver->ExitBootEvent);
gBS->SetTimer (LanDriver->PhyStatusEvent, TimerCancel, 0);
gBS->CloseEvent (LanDriver->PhyStatusEvent);
LanDriver->PhyStatusEvent = NULL;
// Change the state
Snp->Mode->State = EfiSimpleNetworkStopped;
Status = EFI_SUCCESS;
// Restore TPL and return
ExitUnlock:
gBS->RestoreTPL (SavedTpl);
return Status;
}
/*
* UEFI Initialize() function
*/
STATIC
EFI_STATUS
EFIAPI
SnpInitialize (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
IN UINTN RxBufferSize OPTIONAL,
IN UINTN TxBufferSize OPTIONAL
)
{
NETSEC_DRIVER *LanDriver;
EFI_TPL SavedTpl;
EFI_STATUS Status;
ogma_phy_link_status_t phy_link_status;
ogma_err_t ogma_err;
ogma_gmac_mode_t ogma_gmac_mode;
// Check Snp Instance
if (Snp == NULL) {
return EFI_INVALID_PARAMETER;
}
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
// Check that driver was started but not initialised
switch (Snp->Mode->State) {
case EfiSimpleNetworkStarted:
break;
case EfiSimpleNetworkInitialized:
DEBUG ((DEBUG_WARN, "NETSEC: Driver already initialized\n"));
ReturnUnlock (EFI_SUCCESS);
case EfiSimpleNetworkStopped:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n"));
ReturnUnlock (EFI_NOT_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
// Find the LanDriver structure
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
// Clean all descriptors on the RX ring.
ogma_err = ogma_clean_rx_desc_ring (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_RX);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_clean_rx_desc_ring() failed with error code %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_err = ogma_clean_tx_desc_ring (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_TX);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_clean_tx_desc_ring() failed with error code %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_clear_desc_ring_irq_status (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX,
OGMA_CH_IRQ_REG_EMPTY);
// Start the RX queue
ogma_err = ogma_start_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_RX);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_start_desc_ring(ring_id=%d) failed with error code %d\n",
OGMA_DESC_RING_ID_NRM_RX,
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_err = ogma_set_irq_coalesce_param (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_RX,
RXINT_PKTCNT, OGMA_FALSE,
RXINT_TMR_CNT_US);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_set_irq_coalesce_param() failed with error code %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_err = ogma_start_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_start_desc_ring(ring_id=%d) failed with error code %d\n",
OGMA_DESC_RING_ID_NRM_TX,
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_disable_desc_ring_irq (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX,
OGMA_CH_IRQ_REG_EMPTY);
// Stop and restart the physical link
ogma_err = ogma_stop_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_stop_gmac() failed with error status %d\n",
ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_err = ogma_get_phy_link_status (LanDriver->Handle,
&phy_link_status);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_get_phy_link_status() failed error code %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
SetMem (&ogma_gmac_mode, sizeof (ogma_gmac_mode_t), 0);
ogma_gmac_mode.link_speed = phy_link_status.link_speed;
ogma_gmac_mode.half_duplex_flag = (ogma_bool)phy_link_status.half_duplex_flag;
if ((!phy_link_status.half_duplex_flag) && FixedPcdGet8 (PcdFlowCtrl)) {
ogma_gmac_mode.flow_ctrl_enable_flag = FixedPcdGet8 (PcdFlowCtrl);
ogma_gmac_mode.flow_ctrl_start_threshold = FixedPcdGet16 (PcdFlowCtrlStartThreshold);
ogma_gmac_mode.flow_ctrl_stop_threshold = FixedPcdGet16 (PcdFlowCtrlStopThreshold);
ogma_gmac_mode.pause_time = FixedPcdGet16 (PcdPauseTime);
}
ogma_err = ogma_set_gmac_mode (LanDriver->Handle, &ogma_gmac_mode);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_set_gmac() failed with error status %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_err = ogma_start_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_start_gmac() failed with error status %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
// Declare the driver as initialized
Snp->Mode->State = EfiSimpleNetworkInitialized;
Status = EFI_SUCCESS;
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "NETSEC: Driver started\n"));
// Restore TPL and return
ExitUnlock:
gBS->RestoreTPL (SavedTpl);
return Status;
}
/*
* UEFI Shutdown () function
*/
STATIC
EFI_STATUS
EFIAPI
SnpShutdown (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
)
{
NETSEC_DRIVER *LanDriver;
EFI_TPL SavedTpl;
EFI_STATUS Status;
// Check Snp Instance
if (Snp == NULL) {
return EFI_INVALID_PARAMETER;
}
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
// First check that driver has already been initialized
switch (Snp->Mode->State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStarted:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n"));
ReturnUnlock (EFI_DEVICE_ERROR);
case EfiSimpleNetworkStopped:
DEBUG ((DEBUG_WARN, "NETSEC: Driver in stopped state\n"));
ReturnUnlock (EFI_NOT_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
// Find the LanDriver structure
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
ogma_stop_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE);
ogma_stop_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_RX);
ogma_stop_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX);
Snp->Mode->State = EfiSimpleNetworkStarted;
Status = EFI_SUCCESS;
// Restore TPL and return
ExitUnlock:
gBS->RestoreTPL (SavedTpl);
return Status;
}
STATIC
VOID
EFIAPI
NotifyExitBoot (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_STATUS Status;
Snp = Context;
if (Snp->Mode != EfiSimpleNetworkStopped) {
Status = SnpShutdown (Snp);
if (!EFI_ERROR (Status)) {
SnpStop (Snp);
}
}
gBS->CloseEvent (Event);
}
/**
Polling function to check the physical link status with GMAC
@param[in] Timer Event
@param[in] Context Pointer to the Snp structure
**/
STATIC
VOID
EFIAPI
NetsecPollPhyStatus (
IN EFI_EVENT Timer,
IN VOID *Context
)
{
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
NETSEC_DRIVER *LanDriver;
ogma_phy_link_status_t phy_link_status;
ogma_gmac_mode_t ogma_gmac_mode;
ogma_err_t ogma_err;
BOOLEAN ValidFlag;
ogma_gmac_mode_t GmacMode;
BOOLEAN RxRunningFlag;
BOOLEAN TxRunningFlag;
Snp = (EFI_SIMPLE_NETWORK_PROTOCOL *)Context;
if (Snp == NULL) {
DEBUG((DEBUG_ERROR, "NETSEC: PollPhyStatus() invalid Snp\n"));
return;
}
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
// Update the media status
ogma_err = ogma_get_phy_link_status (LanDriver->Handle,
&phy_link_status);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_get_phy_link_status failed with error code: %d\n",
(INT32)ogma_err));
return;
}
// Update the GMAC status
ogma_err = ogma_get_gmac_status (LanDriver->Handle, &ValidFlag, &GmacMode,
&RxRunningFlag, &TxRunningFlag);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_get_gmac_status failed with error code: %d\n",
(INT32)ogma_err));
return;
}
// Stop GMAC when GMAC is running and physical link is down
if (RxRunningFlag && TxRunningFlag && !phy_link_status.up_flag) {
ogma_err = ogma_stop_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_stop_gmac() failed with error status %d\n",
ogma_err));
return;
}
}
// Start GMAC when GMAC is stopped and physical link is up
if (!RxRunningFlag && !TxRunningFlag && phy_link_status.up_flag) {
ZeroMem (&ogma_gmac_mode, sizeof (ogma_gmac_mode_t));
ogma_gmac_mode.link_speed = phy_link_status.link_speed;
ogma_gmac_mode.half_duplex_flag = (ogma_bool)phy_link_status.half_duplex_flag;
if (!phy_link_status.half_duplex_flag && FixedPcdGet8 (PcdFlowCtrl)) {
ogma_gmac_mode.flow_ctrl_enable_flag = FixedPcdGet8 (PcdFlowCtrl);
ogma_gmac_mode.flow_ctrl_start_threshold = FixedPcdGet16 (PcdFlowCtrlStartThreshold);
ogma_gmac_mode.flow_ctrl_stop_threshold = FixedPcdGet16 (PcdFlowCtrlStopThreshold);
ogma_gmac_mode.pause_time = FixedPcdGet16 (PcdPauseTime);
}
ogma_err = ogma_set_gmac_mode (LanDriver->Handle, &ogma_gmac_mode);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_set_gmac() failed with error status %d\n",
(INT32)ogma_err));
return;
}
ogma_err = ogma_start_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_start_gmac() failed with error status %d\n",
(INT32)ogma_err));
}
}
}
/*
* UEFI Start() function
*/
STATIC
EFI_STATUS
EFIAPI
SnpStart (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
)
{
EFI_SIMPLE_NETWORK_MODE *Mode;
EFI_TPL SavedTpl;
EFI_STATUS Status;
NETSEC_DRIVER *LanDriver;
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
// Check Snp instance
if (Snp == NULL) {
return EFI_INVALID_PARAMETER;
}
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
Mode = Snp->Mode;
// Check state of the driver
switch (Mode->State) {
case EfiSimpleNetworkStopped:
break;
case EfiSimpleNetworkStarted:
case EfiSimpleNetworkInitialized:
DEBUG ((DEBUG_WARN, "NETSEC: Driver already started\n"));
ReturnUnlock (EFI_ALREADY_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
NotifyExitBoot, Snp, &LanDriver->ExitBootEvent);
ASSERT_EFI_ERROR (Status);
Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
NetsecPollPhyStatus, Snp, &LanDriver->PhyStatusEvent);
ASSERT_EFI_ERROR (Status);
Status = gBS->SetTimer (
LanDriver->PhyStatusEvent,
TimerPeriodic,
NETSEC_PHY_STATUS_POLL_INTERVAL
);
ASSERT_EFI_ERROR (Status);
// Change state
Mode->State = EfiSimpleNetworkStarted;
Status = EFI_SUCCESS;
// Restore TPL and return
ExitUnlock:
gBS->RestoreTPL (SavedTpl);
return Status;
}
/*
* UEFI ReceiveFilters() function
*/
STATIC
EFI_STATUS
EFIAPI
SnpReceiveFilters (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
IN UINT32 Enable,
IN UINT32 Disable,
IN BOOLEAN Reset,
IN UINTN NumMfilter OPTIONAL,
IN EFI_MAC_ADDRESS *Mfilter OPTIONAL
)
{
EFI_TPL SavedTpl;
EFI_STATUS Status;
// Check Snp Instance
if (Snp == NULL) {
return EFI_INVALID_PARAMETER;
}
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
// First check that driver has already been initialized
switch (Snp->Mode->State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStarted:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n"));
ReturnUnlock (EFI_DEVICE_ERROR);
case EfiSimpleNetworkStopped:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n"));
ReturnUnlock (EFI_NOT_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
Status = EFI_SUCCESS;
// Restore TPL and return
ExitUnlock:
gBS->RestoreTPL (SavedTpl);
return Status;
}
/*
* UEFI GetStatus () function
*/
STATIC
EFI_STATUS
EFIAPI
SnpGetStatus (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
OUT UINT32 *IrqStat OPTIONAL,
OUT VOID **TxBuff OPTIONAL
)
{
NETSEC_DRIVER *LanDriver;
EFI_TPL SavedTpl;
EFI_STATUS Status;
pfdep_pkt_handle_t pkt_handle;
LIST_ENTRY *Link;
ogma_phy_link_status_t phy_link_status;
ogma_err_t ogma_err;
// Check preliminaries
if (Snp == NULL) {
return EFI_INVALID_PARAMETER;
}
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
// Check that driver was started and initialised
switch (Snp->Mode->State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStarted:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n"));
ReturnUnlock (EFI_DEVICE_ERROR);
case EfiSimpleNetworkStopped:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n"));
ReturnUnlock (EFI_NOT_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
// Find the LanDriver structure
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
// Update the media status
ogma_err = ogma_get_phy_link_status (LanDriver->Handle,
&phy_link_status);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_get_phy_link_status failed with error code: %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
Snp->Mode->MediaPresent = phy_link_status.up_flag;
ogma_err = ogma_clean_tx_desc_ring (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_TX);
if (TxBuff != NULL) {
*TxBuff = NULL;
//
// Find a buffer in the list that has been released
//
for (Link = GetFirstNode (&LanDriver->TxBufferList);
!IsNull (&LanDriver->TxBufferList, Link);
Link = GetNextNode (&LanDriver->TxBufferList, Link)) {
pkt_handle = BASE_CR (Link, PACKET_HANDLE, Link);
if (pkt_handle->Released) {
*TxBuff = pkt_handle->Buffer;
RemoveEntryList (Link);
FreePool (pkt_handle);
break;
}
}
}
if (IrqStat != 0) {
*IrqStat = 0;
}
Status = EFI_SUCCESS;
// Restore TPL and return
ExitUnlock:
gBS->RestoreTPL (SavedTpl);
return Status;
}
/*
* UEFI Transmit() function
*/
STATIC
EFI_STATUS
EFIAPI
SnpTransmit (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
IN UINTN HdrSize,
IN UINTN BufSize,
IN VOID *BufAddr,
IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
IN EFI_MAC_ADDRESS *DstAddr OPTIONAL,
IN UINT16 *Protocol OPTIONAL
)
{
NETSEC_DRIVER *LanDriver;
EFI_TPL SavedTpl;
EFI_STATUS Status;
ogma_tx_pkt_ctrl_t tx_pkt_ctrl;
ogma_frag_info_t scat_info;
ogma_uint16 tx_avail_num;
ogma_err_t ogma_err;
UINT16 Proto;
pfdep_pkt_handle_t pkt_handle;
// Check preliminaries
if ((Snp == NULL) || (BufAddr == NULL)) {
DEBUG ((DEBUG_ERROR,
"NETSEC: SnpTransmit(): NULL Snp (%p) or BufAddr (%p)\n", Snp, BufAddr));
return EFI_DEVICE_ERROR;
}
pkt_handle = AllocateZeroPool (sizeof (*pkt_handle));
if (pkt_handle == NULL) {
return EFI_OUT_OF_RESOURCES;
}
pkt_handle->Buffer = BufAddr;
pkt_handle->RecycleForTx = TRUE;
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
// Check that driver was started and initialised
switch (Snp->Mode->State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStarted:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n"));
ReturnUnlock (EFI_DEVICE_ERROR);
case EfiSimpleNetworkStopped:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n"));
ReturnUnlock (EFI_NOT_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
// Find the LanDriver structure
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
ogma_err = ogma_clear_desc_ring_irq_status (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_TX,
OGMA_CH_IRQ_REG_EMPTY);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_clear_desc_ring_irq_status failed with error code: %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
ogma_err = ogma_clean_tx_desc_ring (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_TX);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_clean_tx_desc_ring failed with error code: %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
// Ensure header is correct size if non-zero
if (HdrSize) {
if (HdrSize != Snp->Mode->MediaHeaderSize) {
DEBUG ((DEBUG_ERROR, "NETSEC: SnpTransmit(): Invalid HdrSize %d\n",
HdrSize));
ReturnUnlock (EFI_INVALID_PARAMETER);
}
if ((DstAddr == NULL) || (Protocol == NULL)) {
DEBUG ((DEBUG_ERROR,
"NETSEC: SnpTransmit(): NULL DstAddr %p or Protocol %p\n",
DstAddr, Protocol));
ReturnUnlock (EFI_INVALID_PARAMETER);
}
// Copy destination address
CopyMem (BufAddr, (VOID *)DstAddr, NET_ETHER_ADDR_LEN);
// Copy source address
CopyMem (BufAddr + NET_ETHER_ADDR_LEN, (VOID *)SrcAddr, NET_ETHER_ADDR_LEN);
// Copy protocol
Proto = HTONS (*Protocol);
CopyMem (BufAddr + (NET_ETHER_ADDR_LEN * 2), (VOID *)&Proto,
sizeof (UINT16));
}
Status = DmaMap (MapOperationBusMasterRead, BufAddr, &BufSize,
&scat_info.phys_addr, &pkt_handle->Mapping);
if (EFI_ERROR (Status)) {
goto ExitUnlock;
}
scat_info.addr = BufAddr;
scat_info.len = BufSize;
SetMem (&tx_pkt_ctrl, sizeof (ogma_tx_pkt_ctrl_t), 0);
tx_pkt_ctrl.pass_through_flag = OGMA_TRUE;
tx_pkt_ctrl.target_desc_ring_id = OGMA_DESC_RING_ID_GMAC;
// check empty slot
do {
tx_avail_num = ogma_get_tx_avail_num (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_TX);
} while (tx_avail_num < SCAT_NUM);
// send
ogma_err = ogma_set_tx_pkt_data (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_TX,
&tx_pkt_ctrl,
SCAT_NUM,
&scat_info,
pkt_handle);
if (ogma_err != OGMA_ERR_OK) {
DmaUnmap (pkt_handle->Mapping);
FreePool (pkt_handle);
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_set_tx_pkt_data failed with error code: %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
//
// Queue the descriptor so we can release the buffer once it has been
// consumed by the hardware.
//
InsertTailList (&LanDriver->TxBufferList, &pkt_handle->Link);
gBS->RestoreTPL (SavedTpl);
return EFI_SUCCESS;
// Restore TPL and return
ExitUnlock:
FreePool (pkt_handle);
gBS->RestoreTPL (SavedTpl);
return Status;
}
/*
* UEFI Receive() function
*/
EFI_STATUS
EFIAPI
SnpReceive (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
OUT UINTN *HdrSize OPTIONAL,
IN OUT UINTN *BuffSize,
OUT VOID *Data,
OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
OUT EFI_MAC_ADDRESS *DstAddr OPTIONAL,
OUT UINT16 *Protocol OPTIONAL
)
{
EFI_TPL SavedTpl;
EFI_STATUS Status;
NETSEC_DRIVER *LanDriver;
ogma_err_t ogma_err;
ogma_rx_pkt_info_t rx_pkt_info;
ogma_frag_info_t rx_data;
ogma_uint16 len;
pfdep_pkt_handle_t pkt_handle;
// Check preliminaries
if ((Snp == NULL) || (Data == NULL)) {
return EFI_INVALID_PARAMETER;
}
// Serialize access to data and registers
SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
// Check that driver was started and initialised
switch (Snp->Mode->State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStarted:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not yet initialized\n"));
ReturnUnlock (EFI_DEVICE_ERROR);
case EfiSimpleNetworkStopped:
DEBUG ((DEBUG_WARN, "NETSEC: Driver not started\n"));
ReturnUnlock (EFI_NOT_STARTED);
default:
DEBUG ((DEBUG_ERROR, "NETSEC: Driver in an invalid state: %u\n",
(UINTN)Snp->Mode->State));
ReturnUnlock (EFI_DEVICE_ERROR);
}
// Find the LanDriver structure
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
if (ogma_get_rx_num (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_RX) > 0) {
ogma_err = ogma_get_rx_pkt_data (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_RX,
&rx_pkt_info, &rx_data, &len, &pkt_handle);
if (ogma_err != OGMA_ERR_OK) {
DEBUG ((DEBUG_ERROR,
"NETSEC: ogma_get_rx_pkt_data failed with error code: %d\n",
(INT32)ogma_err));
ReturnUnlock (EFI_DEVICE_ERROR);
}
DmaUnmap (pkt_handle->Mapping);
pkt_handle->Mapping = NULL;
CopyMem (Data, (VOID *)rx_data.addr, len);
*BuffSize = len;
pfdep_free_pkt_buf (LanDriver->Handle, rx_data.len, rx_data.addr,
rx_data.phys_addr, PFDEP_TRUE, pkt_handle);
} else {
// not received any packets
ReturnUnlock (EFI_NOT_READY);
}
if (HdrSize != NULL) {
*HdrSize = LanDriver->SnpMode.MediaHeaderSize;
}
ogma_clear_desc_ring_irq_status (LanDriver->Handle,
OGMA_DESC_RING_ID_NRM_TX,
OGMA_CH_IRQ_REG_EMPTY);
ogma_clean_tx_desc_ring (LanDriver->Handle, OGMA_DESC_RING_ID_NRM_TX);
ogma_enable_top_irq (LanDriver->Handle,
OGMA_TOP_IRQ_REG_NRM_TX | OGMA_TOP_IRQ_REG_NRM_RX);
Status = EFI_SUCCESS;
// Restore TPL and return
ExitUnlock:
gBS->RestoreTPL (SavedTpl);
return Status;
}
EFI_STATUS
NetsecInit (
IN EFI_HANDLE DriverBindingHandle,
IN EFI_HANDLE ControllerHandle
)
{
EFI_STATUS Status;
NETSEC_DRIVER *LanDriver;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
// Allocate Resources
LanDriver = AllocateZeroPool (sizeof (NETSEC_DRIVER));
if (LanDriver == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = gBS->OpenProtocol (ControllerHandle,
&gEdkiiNonDiscoverableDeviceProtocolGuid,
(VOID **)&LanDriver->Dev,
DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR (Status)) {
goto FreeDevice;
}
// Initialize pointers
Snp = &(LanDriver->Snp);
SnpMode = &(LanDriver->SnpMode);
Snp->Mode = SnpMode;
// Set the signature of the LAN Driver structure
LanDriver->Signature = NETSEC_SIGNATURE;
// Probe the device
Status = Probe (DriverBindingHandle, LanDriver);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,
"NETSEC:%a(): Probe failed with status %d\n", __FUNCTION__, Status));
goto CloseDeviceProtocol;
}
// Assign fields and func pointers
Snp->Revision = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION;
Snp->WaitForPacket = NULL;
Snp->Initialize = SnpInitialize;
Snp->Start = SnpStart;
Snp->Stop = SnpStop;
Snp->Reset = NULL;
Snp->Shutdown = SnpShutdown;
Snp->ReceiveFilters = SnpReceiveFilters;
Snp->StationAddress = NULL;
Snp->Statistics = NULL;
Snp->MCastIpToMac = NULL;
Snp->NvData = NULL;
Snp->GetStatus = SnpGetStatus;
Snp->Transmit = SnpTransmit;
Snp->Receive = SnpReceive;
// Fill in simple network mode structure
SnpMode->State = EfiSimpleNetworkStopped;
SnpMode->HwAddressSize = NET_ETHER_ADDR_LEN;
SnpMode->MediaHeaderSize = sizeof (ETHER_HEAD);
SnpMode->MaxPacketSize = EFI_PAGE_SIZE;
// Supported receive filters
SnpMode->ReceiveFilterMask = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |
EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |
EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS |
EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;
// Initially-enabled receive filters
SnpMode->ReceiveFilterSetting = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |
EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;
// Netsec has 64bit hash table. We can filter an infinite MACs, but
// higher-level software must filter out any hash collisions.
SnpMode->MaxMCastFilterCount = MAX_MCAST_FILTER_CNT;
SnpMode->MCastFilterCount = 0;
ZeroMem (&SnpMode->MCastFilter,
MAX_MCAST_FILTER_CNT * sizeof (EFI_MAC_ADDRESS));
// Set the interface type (1: Ethernet or 6: IEEE 802 Networks)
SnpMode->IfType = NET_IFTYPE_ETHERNET;
// Mac address is changeable
SnpMode->MacAddressChangeable = TRUE;
// We can only transmit one packet at a time
SnpMode->MultipleTxSupported = FALSE;
// MediaPresent checks for cable connection and partner link
SnpMode->MediaPresentSupported = TRUE;
SnpMode->MediaPresent = FALSE;
// Set broadcast address
SetMem (&SnpMode->BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF);
InitializeListHead (&LanDriver->TxBufferList);
LanDriver->DevicePath.Netsec.Header.Type = MESSAGING_DEVICE_PATH;
LanDriver->DevicePath.Netsec.Header.SubType = MSG_MAC_ADDR_DP;
SetDevicePathNodeLength (&LanDriver->DevicePath.Netsec.Header,
sizeof (LanDriver->DevicePath.Netsec));
CopyMem (&LanDriver->DevicePath.Netsec.MacAddress,
&SnpMode->PermanentAddress, PXE_HWADDR_LEN_ETHER);
LanDriver->DevicePath.Netsec.IfType = SnpMode->IfType;
SetDevicePathEndNode (&LanDriver->DevicePath.End);
// Initialise the protocol
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
&gEfiSimpleNetworkProtocolGuid, Snp,
&gEfiDevicePathProtocolGuid, &LanDriver->DevicePath,
NULL);
LanDriver->ControllerHandle = ControllerHandle;
// Say what the status of loading the protocol structure is
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: InstallMultipleProtocolInterfaces failed - %r\n",
__FUNCTION__, Status));
ogma_terminate (LanDriver->Handle);
goto CloseDeviceProtocol;
}
return EFI_SUCCESS;
CloseDeviceProtocol:
gBS->CloseProtocol (ControllerHandle,
&gEdkiiNonDiscoverableDeviceProtocolGuid, DriverBindingHandle,
ControllerHandle);
FreeDevice:
FreePool (LanDriver);
return Status;
}
EFI_STATUS
NetsecRelease (
IN EFI_HANDLE DriverBindingHandle,
IN EFI_HANDLE ControllerHandle
)
{
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
NETSEC_DRIVER *LanDriver;
EFI_STATUS Status;
Status = gBS->HandleProtocol (ControllerHandle,
&gEfiSimpleNetworkProtocolGuid,
(VOID **)&Snp);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
}
LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
Status = gBS->UninstallMultipleProtocolInterfaces (ControllerHandle,
&gEfiSimpleNetworkProtocolGuid, Snp,
&gEfiDevicePathProtocolGuid, &LanDriver->DevicePath,
NULL);
if (EFI_ERROR (Status)) {
return Status;
}
if (Snp->Mode->State == EfiSimpleNetworkInitialized) {
SnpShutdown (Snp);
}
ogma_terminate (LanDriver->Handle);
gBS->CloseEvent (LanDriver->ExitBootEvent);
Status = gBS->CloseProtocol (ControllerHandle,
&gEdkiiNonDiscoverableDeviceProtocolGuid,
DriverBindingHandle,
ControllerHandle);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
}
gBS->FreePool (LanDriver);
return EFI_SUCCESS;
}
|