]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/Snp32_64/Dxe/stop.c
Initial import.
[mirror_edk2.git] / EdkModulePkg / Universal / Network / Snp32_64 / Dxe / stop.c
1 /*++
2 Copyright (c) 2006, 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 EFI_STATUS
24 pxe_stop (
25 SNP_DRIVER *snp
26 )
27 /*++
28
29 Routine Description:
30 this routine calls undi to stop the interface and changes the snp state
31
32 Arguments:
33 snp - pointer to snp driver structure
34
35 Returns:
36
37 --*/
38 {
39 snp->cdb.OpCode = PXE_OPCODE_STOP;
40 snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
41 snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
42 snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
43 snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
44 snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
45 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
46 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
47 snp->cdb.IFnum = snp->if_num;
48 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
49
50 //
51 // Issue UNDI command
52 //
53 DEBUG ((EFI_D_NET, "\nsnp->undi.stop() "));
54
55 (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);
56
57 if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
58 DEBUG (
59 (EFI_D_WARN,
60 "\nsnp->undi.stop() %xh:%xh\n",
61 snp->cdb.StatCode,
62 snp->cdb.StatFlags)
63 );
64
65 return EFI_DEVICE_ERROR;
66 }
67 //
68 // Set simple network state to Started and return success.
69 //
70 snp->mode.State = EfiSimpleNetworkStopped;
71 return EFI_SUCCESS;
72 }
73
74 EFI_STATUS
75 EFIAPI
76 snp_undi32_stop (
77 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
78 )
79 /*++
80
81 Routine Description:
82 This is the SNP interface routine for stopping the interface.
83 This routine basically retrieves snp structure, checks the SNP state and
84 calls the pxe_stop routine to actually stop the undi interface
85
86 Arguments:
87 this - context pointer
88
89 Returns:
90
91 --*/
92 {
93 SNP_DRIVER *snp;
94
95 if (this == NULL) {
96 return EFI_INVALID_PARAMETER;
97 }
98
99 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
100
101 if (snp == NULL) {
102 return EFI_DEVICE_ERROR;
103 }
104
105 switch (snp->mode.State) {
106 case EfiSimpleNetworkStarted:
107 break;
108
109 case EfiSimpleNetworkStopped:
110 return EFI_NOT_STARTED;
111
112 case EfiSimpleNetworkInitialized:
113 return EFI_DEVICE_ERROR;
114
115 default:
116 return EFI_DEVICE_ERROR;
117 }
118
119 return pxe_stop (snp);
120 }