]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/SnpDxe/Stop.c
rename
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Stop.c
1 /** @file
2 Copyright (c) 2004 - 2007, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module name:
12 stop.c
13
14 Abstract:
15
16 Revision history:
17 2000-Feb-09 M(f)J Genesis.
18
19 **/
20
21 #include "Snp.h"
22
23
24 /**
25 this routine calls undi to stop the interface and changes the snp state
26
27 @param snp pointer to snp driver structure
28
29
30 **/
31 EFI_STATUS
32 pxe_stop (
33 SNP_DRIVER *snp
34 )
35 {
36 snp->cdb.OpCode = PXE_OPCODE_STOP;
37 snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
38 snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
39 snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
40 snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
41 snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
42 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
43 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
44 snp->cdb.IFnum = snp->if_num;
45 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
46
47 //
48 // Issue UNDI command
49 //
50 DEBUG ((EFI_D_NET, "\nsnp->undi.stop() "));
51
52 (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
53
54 if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
55 DEBUG (
56 (EFI_D_WARN,
57 "\nsnp->undi.stop() %xh:%xh\n",
58 snp->cdb.StatCode,
59 snp->cdb.StatFlags)
60 );
61
62 return EFI_DEVICE_ERROR;
63 }
64 //
65 // Set simple network state to Started and return success.
66 //
67 snp->mode.State = EfiSimpleNetworkStopped;
68 return EFI_SUCCESS;
69 }
70
71
72 /**
73 This is the SNP interface routine for stopping the interface.
74 This routine basically retrieves snp structure, checks the SNP state and
75 calls the pxe_stop routine to actually stop the undi interface
76
77 @param this context pointer
78
79
80 **/
81 EFI_STATUS
82 EFIAPI
83 snp_undi32_stop (
84 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
85 )
86 {
87 SNP_DRIVER *snp;
88 EFI_TPL OldTpl;
89 EFI_STATUS Status;
90
91 if (this == NULL) {
92 return EFI_INVALID_PARAMETER;
93 }
94
95 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
96
97 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
98
99 switch (snp->mode.State) {
100 case EfiSimpleNetworkStarted:
101 break;
102
103 case EfiSimpleNetworkStopped:
104 Status = EFI_NOT_STARTED;
105 goto ON_EXIT;
106
107 default:
108 Status = EFI_DEVICE_ERROR;
109 goto ON_EXIT;
110 }
111
112 Status = pxe_stop (snp);
113
114 ON_EXIT:
115 gBS->RestoreTPL (OldTpl);
116
117 return Status;
118 }