]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/Network/Snp32_64/Dxe/start.c
Fix capitalization.
[mirror_edk2.git] / EdkModulePkg / Universal / Network / Snp32_64 / Dxe / start.c
CommitLineData
878ddf1f 1/*++\r
2Copyright (c) 2006, Intel Corporation \r
3All rights reserved. This program and the accompanying materials \r
4are licensed and made available under the terms and conditions of the BSD License \r
5which accompanies this distribution. The full text of the license may be found at \r
6http://opensource.org/licenses/bsd-license.php \r
7 \r
8THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
9WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
10\r
11Module name:\r
12 start.c\r
13\r
14Abstract:\r
15\r
16Revision history:\r
17 2000-Feb-07 M(f)J Genesis.\r
18--*/\r
19\r
20\r
21#include "snp.h"\r
22\r
23EFI_STATUS\r
24pxe_start (\r
25 SNP_DRIVER *snp\r
26 )\r
27/*++\r
28\r
29Routine Description:\r
30 this routine calls undi to start the interface and changes the snp state!\r
31\r
32Arguments:\r
33 snp - pointer to snp driver structure\r
34\r
35Returns:\r
36\r
37--*/\r
38{\r
39 PXE_CPB_START_30 *cpb;\r
40 PXE_CPB_START_31 *cpb_31;\r
41\r
42 cpb = snp->cpb;\r
43 cpb_31 = snp->cpb;\r
44 //\r
45 // Initialize UNDI Start CDB for H/W UNDI\r
46 //\r
47 snp->cdb.OpCode = PXE_OPCODE_START;\r
48 snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;\r
49 snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
50 snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;\r
51 snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
52 snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;\r
53 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
54 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
55 snp->cdb.IFnum = snp->if_num;\r
56 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
57\r
58 //\r
59 // Make changes to H/W UNDI Start CDB if this is\r
60 // a S/W UNDI.\r
61 //\r
62 if (snp->is_swundi) {\r
63 if (snp->IsOldUndi) {\r
64 snp->cdb.CPBsize = sizeof (PXE_CPB_START_30);\r
65 snp->cdb.CPBaddr = (UINT64) (UINTN) cpb;\r
66\r
67 cpb->Delay = (UINT64) &snp_undi32_callback_delay_30;\r
68 cpb->Block = (UINT64) &snp_undi32_callback_block_30;\r
69\r
70 //\r
71 // Virtual == Physical. This can be set to zero.\r
72 //\r
73 cpb->Virt2Phys = (UINT64) &snp_undi32_callback_v2p_30;\r
74 cpb->Mem_IO = (UINT64) &snp_undi32_callback_memio_30;\r
75 } else {\r
76 snp->cdb.CPBsize = sizeof (PXE_CPB_START_31);\r
77 snp->cdb.CPBaddr = (UINT64) (UINTN) cpb_31;\r
78\r
79 cpb_31->Delay = (UINT64) &snp_undi32_callback_delay;\r
80 cpb_31->Block = (UINT64) &snp_undi32_callback_block;\r
81\r
82 //\r
83 // Virtual == Physical. This can be set to zero.\r
84 //\r
85 cpb_31->Virt2Phys = (UINT64) 0;\r
86 cpb_31->Mem_IO = (UINT64) &snp_undi32_callback_memio;\r
87\r
88 cpb_31->Map_Mem = (UINT64) &snp_undi32_callback_map;\r
89 cpb_31->UnMap_Mem = (UINT64) &snp_undi32_callback_unmap;\r
90 cpb_31->Sync_Mem = (UINT64) &snp_undi32_callback_sync;\r
91\r
92 cpb_31->Unique_ID = (UINT64) (UINTN) snp;\r
93 }\r
94 }\r
95 //\r
96 // Issue UNDI command and check result.\r
97 //\r
98 DEBUG ((EFI_D_NET, "\nsnp->undi.start() "));\r
99\r
100 (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);\r
101\r
102 if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
103 //\r
104 // UNDI could not be started. Return UNDI error.\r
105 //\r
106 DEBUG (\r
107 (EFI_D_ERROR,\r
108 "\nsnp->undi.start() %xh:%xh\n",\r
109 snp->cdb.StatCode,\r
110 snp->cdb.StatFlags)\r
111 );\r
112\r
113 return EFI_DEVICE_ERROR;\r
114 }\r
115 //\r
116 // Set simple network state to Started and return success.\r
117 //\r
118 snp->mode.State = EfiSimpleNetworkStarted;\r
119\r
120 return EFI_SUCCESS;\r
121}\r
122\r
123EFI_STATUS\r
124EFIAPI\r
125snp_undi32_start (\r
126 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
127 )\r
128/*++\r
129\r
130Routine Description:\r
131 This is the SNP interface routine for starting the interface\r
132 This routine basically retrieves snp structure, checks the SNP state and\r
133 calls the pxe_start routine to actually do start undi interface\r
134\r
135Arguments:\r
136 This - context pointer\r
137\r
138Returns:\r
139 EFI_INVALID_PARAMETER - "This" is Null\r
140 - No SNP driver can be extracted from "This"\r
141 EFI_ALREADY_STARTED - The state of SNP is EfiSimpleNetworkStarted\r
142 or EfiSimpleNetworkInitialized\r
143 EFI_DEVICE_ERROR - The state of SNP is other than EfiSimpleNetworkStarted,\r
144 EfiSimpleNetworkInitialized, and EfiSimpleNetworkStopped\r
145 EFI_SUCCESS - UNDI interface is succesfully started\r
146 Other - Error occurs while calling pxe_start function.\r
147 \r
148--*/\r
149{\r
150 SNP_DRIVER *Snp;\r
151 EFI_STATUS Status;\r
152 UINTN Index;\r
153\r
154 if (This == NULL) {\r
155 return EFI_INVALID_PARAMETER;\r
156 }\r
157\r
158 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
159\r
160 if (Snp == NULL) {\r
161 return EFI_INVALID_PARAMETER;\r
162 }\r
163\r
164 switch (Snp->mode.State) {\r
165 case EfiSimpleNetworkStopped:\r
166 break;\r
167\r
168 case EfiSimpleNetworkStarted:\r
169 case EfiSimpleNetworkInitialized:\r
170 return EFI_ALREADY_STARTED;\r
171\r
172 default:\r
173 return EFI_DEVICE_ERROR;\r
174 }\r
175\r
176 Status = pxe_start (Snp);\r
177 if (Status != EFI_SUCCESS) {\r
178 return Status;\r
179 }\r
180 //\r
181 // clear the map_list in SNP structure\r
182 //\r
183 for (Index = 0; Index < MAX_MAP_LENGTH; Index++) {\r
184 Snp->map_list[Index].virt = 0;\r
185 Snp->map_list[Index].map_cookie = 0;\r
186 }\r
187\r
188 Snp->mode.MCastFilterCount = 0;\r
189\r
190 return Status;\r
191}\r