]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcBoot.c
CommitLineData
a3bcde70
HT
1/** @file\r
2 Boot functions implementation for UefiPxeBc Driver.\r
3\r
a1c0d0fb 4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "PxeBcImpl.h"\r
17\r
18\r
19/**\r
20 Display the string of the boot item.\r
21\r
22 If the length of the boot item string beyond 70 Char, just display 70 Char.\r
23\r
24 @param[in] Str The pointer to the string.\r
25 @param[in] Len The length of the string.\r
26\r
27**/\r
28VOID\r
29PxeBcDisplayBootItem (\r
30 IN UINT8 *Str,\r
31 IN UINT8 Len\r
32 )\r
33{\r
34 UINT8 Tmp;\r
35\r
36 //\r
37 // Cut off the chars behind 70th.\r
38 //\r
39 Len = (UINT8) MIN (PXEBC_DISPLAY_MAX_LINE, Len);\r
40 Tmp = Str[Len];\r
41 Str[Len] = 0;\r
42 AsciiPrint ("%a \n", Str);\r
43\r
44 //\r
45 // Restore the original 70th char.\r
46 //\r
47 Str[Len] = Tmp;\r
48}\r
49\r
50\r
51/**\r
52 Select and maintain the boot prompt if needed.\r
53\r
54 @param[in] Private Pointer to PxeBc private data.\r
55\r
56 @retval EFI_SUCCESS Selected boot prompt done.\r
57 @retval EFI_TIMEOUT Selected boot prompt timed out.\r
58 @retval EFI_NOT_FOUND The proxy offer is not Pxe10.\r
59 @retval EFI_ABORTED User cancelled the operation.\r
60 @retval EFI_NOT_READY Reading the input key from the keyboard has not finish.\r
61\r
62**/\r
63EFI_STATUS\r
64PxeBcSelectBootPrompt (\r
65 IN PXEBC_PRIVATE_DATA *Private\r
66 )\r
67{\r
68 PXEBC_DHCP_PACKET_CACHE *Cache;\r
69 PXEBC_VENDOR_OPTION *VendorOpt;\r
70 EFI_PXE_BASE_CODE_MODE *Mode;\r
71 EFI_EVENT TimeoutEvent;\r
72 EFI_EVENT DescendEvent;\r
73 EFI_INPUT_KEY InputKey;\r
74 EFI_STATUS Status;\r
75 UINT32 OfferType;\r
76 UINT8 Timeout;\r
77 UINT8 *Prompt;\r
78 UINT8 PromptLen;\r
79 INT32 SecCol;\r
80 INT32 SecRow;\r
81\r
82 TimeoutEvent = NULL;\r
83 DescendEvent = NULL;\r
84 Mode = Private->PxeBc.Mode;\r
85 Cache = Mode->ProxyOfferReceived ? &Private->ProxyOffer : &Private->DhcpAck;\r
86 OfferType = Mode->UsingIpv6 ? Cache->Dhcp6.OfferType : Cache->Dhcp4.OfferType;\r
87\r
88 //\r
9063c328 89 // Only DhcpPxe10 and ProxyPxe10 offer needs boot prompt.\r
a3bcde70 90 //\r
9063c328 91 if (OfferType != PxeOfferTypeProxyPxe10 && OfferType != PxeOfferTypeDhcpPxe10) {\r
a3bcde70
HT
92 return EFI_NOT_FOUND;\r
93 }\r
94\r
95 //\r
96 // There is no specified ProxyPxe10 for IPv6 in PXE and UEFI spec.\r
97 //\r
98 ASSERT (!Mode->UsingIpv6);\r
99\r
100 VendorOpt = &Cache->Dhcp4.VendorOpt;\r
30a95d4d 101 //\r
102 // According to the PXE specification 2.1, Table 2-1 PXE DHCP Options,\r
103 // we must not consider a boot prompt or boot menu if all of the following hold:\r
104 // - the PXE_DISCOVERY_CONTROL tag(6) is present inside the Vendor Options(43), and has bit 3 set \r
105 // - a boot file name has been presented in the initial DHCP or ProxyDHCP offer packet.\r
106 //\r
107 if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) &&\r
108 Cache->Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {\r
109 return EFI_ABORTED;\r
110 }\r
111 \r
a3bcde70 112 if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) {\r
9063c328 113 return EFI_TIMEOUT;\r
a3bcde70
HT
114 }\r
115\r
116 Timeout = VendorOpt->MenuPrompt->Timeout;\r
117 Prompt = VendorOpt->MenuPrompt->Prompt;\r
118 PromptLen = (UINT8) (VendorOpt->MenuPromptLen - 1);\r
119\r
120 //\r
121 // The valid scope of Timeout refers to PXE2.1 spec.\r
122 //\r
123 if (Timeout == 0) {\r
9063c328 124 return EFI_TIMEOUT;\r
a3bcde70
HT
125 }\r
126 if (Timeout == 255) {\r
9063c328 127 return EFI_SUCCESS;\r
a3bcde70
HT
128 }\r
129\r
130 //\r
131 // Create and start a timer as timeout event.\r
132 //\r
133 Status = gBS->CreateEvent (\r
134 EVT_TIMER,\r
135 TPL_CALLBACK,\r
136 NULL,\r
137 NULL,\r
138 &TimeoutEvent\r
139 );\r
140 if (EFI_ERROR (Status)) {\r
141 return Status;\r
142 }\r
143\r
144 Status = gBS->SetTimer (\r
145 TimeoutEvent,\r
146 TimerRelative,\r
147 Timeout * TICKS_PER_SECOND\r
148 );\r
149 if (EFI_ERROR (Status)) {\r
150 goto ON_EXIT;\r
151 }\r
152\r
153 //\r
154 // Create and start a periodic timer as descend event by second.\r
155 //\r
156 Status = gBS->CreateEvent (\r
157 EVT_TIMER,\r
158 TPL_CALLBACK,\r
159 NULL,\r
160 NULL,\r
161 &DescendEvent\r
162 );\r
163 if (EFI_ERROR (Status)) {\r
164 goto ON_EXIT;\r
165 }\r
166\r
167 Status = gBS->SetTimer (\r
168 DescendEvent,\r
169 TimerPeriodic,\r
170 TICKS_PER_SECOND\r
171 );\r
172 if (EFI_ERROR (Status)) {\r
173 goto ON_EXIT;\r
174 }\r
175\r
176 //\r
177 // Display the boot item and cursor on the screen.\r
178 //\r
179 SecCol = gST->ConOut->Mode->CursorColumn;\r
180 SecRow = gST->ConOut->Mode->CursorRow;\r
181\r
182 PxeBcDisplayBootItem (Prompt, PromptLen);\r
183\r
184 gST->ConOut->SetCursorPosition (gST->ConOut, SecCol + PromptLen, SecRow);\r
185 AsciiPrint ("(%d) ", Timeout--);\r
186\r
9063c328 187 Status = EFI_TIMEOUT;\r
a3bcde70
HT
188 while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {\r
189 if (!EFI_ERROR (gBS->CheckEvent (DescendEvent))) {\r
190 gST->ConOut->SetCursorPosition (gST->ConOut, SecCol + PromptLen, SecRow);\r
191 AsciiPrint ("(%d) ", Timeout--);\r
192 }\r
193 if (gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey) == EFI_NOT_READY) {\r
194 gBS->Stall (10 * TICKS_PER_MS);\r
195 continue;\r
196 }\r
197 //\r
198 // Parse the input key by user.\r
9063c328 199 // If <F8> or <Ctrl> + <M> is pressed, return success to display the boot menu.\r
a3bcde70
HT
200 //\r
201 if (InputKey.ScanCode == 0) {\r
202\r
203 switch (InputKey.UnicodeChar) {\r
204\r
205 case CTRL ('c'):\r
206 Status = EFI_ABORTED;\r
207 break;\r
208\r
209 case CTRL ('m'):\r
210 case 'm':\r
211 case 'M':\r
9063c328 212 Status = EFI_SUCCESS;\r
a3bcde70
HT
213 break;\r
214\r
215 default:\r
216 continue;\r
217 }\r
218\r
219 } else {\r
220\r
221 switch (InputKey.ScanCode) {\r
222\r
223 case SCAN_F8:\r
9063c328 224 Status = EFI_SUCCESS;\r
a3bcde70
HT
225 break;\r
226\r
227 case SCAN_ESC:\r
228 Status = EFI_ABORTED;\r
229 break;\r
230\r
231 default:\r
232 continue;\r
233 }\r
234 }\r
235\r
236 break;\r
237 }\r
238\r
239 //\r
240 // Reset the cursor on the screen.\r
241 //\r
242 gST->ConOut->SetCursorPosition (gST->ConOut, 0 , SecRow + 1);\r
243\r
244ON_EXIT:\r
245 if (DescendEvent != NULL) {\r
246 gBS->CloseEvent (DescendEvent);\r
247 }\r
248 if (TimeoutEvent != NULL) {\r
249 gBS->CloseEvent (TimeoutEvent);\r
250 }\r
251\r
252 return Status;\r
253}\r
254\r
255\r
256/**\r
257 Select the boot menu by user's input.\r
258\r
259 @param[in] Private Pointer to PxeBc private data.\r
260 @param[out] Type The type of the menu.\r
261 @param[in] UseDefaultItem Use default item or not.\r
262\r
263 @retval EFI_ABORTED User cancel operation.\r
264 @retval EFI_SUCCESS Select the boot menu success.\r
265 @retval EFI_NOT_READY Read the input key from the keybroad has not finish.\r
266\r
267**/\r
268EFI_STATUS\r
269PxeBcSelectBootMenu (\r
270 IN PXEBC_PRIVATE_DATA *Private,\r
271 OUT UINT16 *Type,\r
272 IN BOOLEAN UseDefaultItem\r
273 )\r
274{\r
275 EFI_PXE_BASE_CODE_MODE *Mode;\r
276 PXEBC_DHCP_PACKET_CACHE *Cache;\r
277 PXEBC_VENDOR_OPTION *VendorOpt;\r
278 EFI_INPUT_KEY InputKey;\r
279 UINT32 OfferType;\r
280 UINT8 MenuSize;\r
281 UINT8 MenuNum;\r
282 INT32 TopRow;\r
283 UINT16 Select;\r
284 UINT16 LastSelect;\r
285 UINT8 Index;\r
286 BOOLEAN Finish;\r
287 CHAR8 Blank[PXEBC_DISPLAY_MAX_LINE];\r
288 PXEBC_BOOT_MENU_ENTRY *MenuItem;\r
289 PXEBC_BOOT_MENU_ENTRY *MenuArray[PXEBC_MENU_MAX_NUM];\r
290\r
291 Finish = FALSE;\r
a1c0d0fb 292 Select = 0;\r
a3bcde70
HT
293 Index = 0;\r
294 *Type = 0;\r
295 Mode = Private->PxeBc.Mode;\r
296 Cache = Mode->ProxyOfferReceived ? &Private->ProxyOffer : &Private->DhcpAck;\r
297 OfferType = Mode->UsingIpv6 ? Cache->Dhcp6.OfferType : Cache->Dhcp4.OfferType;\r
298\r
299 //\r
9063c328 300 // There is no specified DhcpPxe10/ProxyPxe10 for IPv6 in PXE and UEFI spec.\r
a3bcde70
HT
301 //\r
302 ASSERT (!Mode->UsingIpv6);\r
9063c328 303 ASSERT (OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeDhcpPxe10);\r
a3bcde70
HT
304\r
305 VendorOpt = &Cache->Dhcp4.VendorOpt;\r
306 if (!IS_VALID_BOOT_MENU (VendorOpt->BitMap)) {\r
307 return EFI_SUCCESS;\r
308 }\r
309\r
310 //\r
311 // Display the boot menu on the screen.\r
312 //\r
313 SetMem (Blank, sizeof(Blank), ' ');\r
314\r
315 MenuSize = VendorOpt->BootMenuLen;\r
316 MenuItem = VendorOpt->BootMenu;\r
317\r
318 if (MenuSize == 0) {\r
319 return EFI_DEVICE_ERROR;\r
320 }\r
321\r
322 while (MenuSize > 0 && Index < PXEBC_MENU_MAX_NUM) {\r
323 ASSERT (MenuItem != NULL);\r
324 MenuArray[Index] = MenuItem;\r
325 MenuSize = (UINT8) (MenuSize - (MenuItem->DescLen + 3));\r
326 MenuItem = (PXEBC_BOOT_MENU_ENTRY *) ((UINT8 *) MenuItem + MenuItem->DescLen + 3);\r
327 Index++;\r
328 }\r
329\r
330 if (UseDefaultItem) {\r
331 ASSERT (MenuArray[0] != NULL);\r
332 CopyMem (Type, &MenuArray[0]->Type, sizeof (UINT16));\r
333 *Type = NTOHS (*Type);\r
334 return EFI_SUCCESS;\r
335 }\r
336\r
337 MenuNum = Index;\r
338\r
339 for (Index = 0; Index < MenuNum; Index++) {\r
340 ASSERT (MenuArray[Index] != NULL);\r
341 PxeBcDisplayBootItem (MenuArray[Index]->DescStr, MenuArray[Index]->DescLen);\r
342 }\r
343\r
344 TopRow = gST->ConOut->Mode->CursorRow - MenuNum;\r
345\r
346 //\r
347 // Select the boot item by user in the boot menu.\r
348 //\r
349 do {\r
350 //\r
351 // Highlight selected row.\r
352 //\r
353 gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK, EFI_LIGHTGRAY));\r
354 gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + Select);\r
355 ASSERT (Select < PXEBC_MENU_MAX_NUM);\r
356 ASSERT (MenuArray[Select] != NULL);\r
357 Blank[MenuArray[Select]->DescLen] = 0;\r
358 AsciiPrint ("%a\r", Blank);\r
359 PxeBcDisplayBootItem (MenuArray[Select]->DescStr, MenuArray[Select]->DescLen);\r
360 gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + MenuNum);\r
361 LastSelect = Select;\r
362\r
363 while (gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey) == EFI_NOT_READY) {\r
364 gBS->Stall (10 * TICKS_PER_MS);\r
365 }\r
366\r
9063c328 367 if (InputKey.ScanCode == 0) {\r
a3bcde70
HT
368 switch (InputKey.UnicodeChar) {\r
369 case CTRL ('c'):\r
370 InputKey.ScanCode = SCAN_ESC;\r
371 break;\r
372\r
373 case CTRL ('j'): /* linefeed */\r
374 case CTRL ('m'): /* return */\r
375 Finish = TRUE;\r
376 break;\r
377\r
378 case CTRL ('i'): /* tab */\r
379 case ' ':\r
380 case 'd':\r
381 case 'D':\r
382 InputKey.ScanCode = SCAN_DOWN;\r
383 break;\r
384\r
385 case CTRL ('h'): /* backspace */\r
386 case 'u':\r
387 case 'U':\r
388 InputKey.ScanCode = SCAN_UP;\r
389 break;\r
390\r
391 default:\r
392 InputKey.ScanCode = 0;\r
393 }\r
394 }\r
395\r
396 switch (InputKey.ScanCode) {\r
397 case SCAN_LEFT:\r
398 case SCAN_UP:\r
399 if (Select != 0) {\r
400 Select--;\r
401 }\r
402 break;\r
403\r
404 case SCAN_DOWN:\r
405 case SCAN_RIGHT:\r
406 if (++Select == MenuNum) {\r
407 Select--;\r
408 }\r
409 break;\r
410\r
411 case SCAN_PAGE_UP:\r
412 case SCAN_HOME:\r
413 Select = 0;\r
414 break;\r
415\r
416 case SCAN_PAGE_DOWN:\r
417 case SCAN_END:\r
418 Select = (UINT16) (MenuNum - 1);\r
419 break;\r
420\r
421 case SCAN_ESC:\r
422 return EFI_ABORTED;\r
423 }\r
424\r
425 //\r
426 // Unhighlight the last selected row.\r
427 //\r
428 gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r
429 gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + LastSelect);\r
430 ASSERT (LastSelect < PXEBC_MENU_MAX_NUM);\r
431 ASSERT (MenuArray[LastSelect] != NULL);\r
432 Blank[MenuArray[LastSelect]->DescLen] = 0;\r
433 AsciiPrint ("%a\r", Blank);\r
434 PxeBcDisplayBootItem (MenuArray[LastSelect]->DescStr, MenuArray[LastSelect]->DescLen);\r
435 gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + MenuNum);\r
436 } while (!Finish);\r
437\r
438 //\r
439 // Swap the byte order.\r
440 //\r
441 ASSERT (Select < PXEBC_MENU_MAX_NUM);\r
442 ASSERT (MenuArray[Select] != NULL);\r
443 CopyMem (Type, &MenuArray[Select]->Type, sizeof (UINT16));\r
444 *Type = NTOHS (*Type);\r
445\r
446 return EFI_SUCCESS;\r
447}\r
448\r
449\r
450/**\r
451 Parse out the boot information from the last Dhcp4 reply packet.\r
452\r
453 @param[in, out] Private Pointer to PxeBc private data.\r
454 @param[out] BufferSize Size of the boot file to be downloaded.\r
455\r
456 @retval EFI_SUCCESS Successfully parsed out all the boot information.\r
457 @retval Others Failed to parse out the boot information.\r
458\r
459**/\r
460EFI_STATUS\r
461PxeBcDhcp4BootInfo (\r
462 IN OUT PXEBC_PRIVATE_DATA *Private,\r
463 OUT UINT64 *BufferSize\r
464 )\r
465{\r
466 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r
467 EFI_PXE_BASE_CODE_MODE *Mode;\r
468 EFI_STATUS Status;\r
469 PXEBC_DHCP4_PACKET_CACHE *Cache4;\r
470 UINT16 Value;\r
471\r
472 PxeBc = &Private->PxeBc;\r
473 Mode = PxeBc->Mode;\r
474 Status = EFI_SUCCESS;\r
475 *BufferSize = 0;\r
476\r
477 //\r
478 // Get the last received Dhcp4 reply packet.\r
479 //\r
480 if (Mode->PxeReplyReceived) {\r
481 Cache4 = &Private->PxeReply.Dhcp4;\r
482 } else if (Mode->ProxyOfferReceived) {\r
483 Cache4 = &Private->ProxyOffer.Dhcp4;\r
484 } else {\r
485 Cache4 = &Private->DhcpAck.Dhcp4;\r
486 }\r
487\r
488 //\r
489 // Parse the boot server Ipv4 address by next server address.\r
490 // If this field isn't available, use option 54 instead.\r
491 //\r
492 CopyMem (\r
493 &Private->ServerIp,\r
494 &Cache4->Packet.Offer.Dhcp4.Header.ServerAddr,\r
495 sizeof (EFI_IPv4_ADDRESS)\r
496 );\r
497\r
498 if (Private->ServerIp.Addr[0] == 0) {\r
499 CopyMem (\r
500 &Private->ServerIp,\r
501 Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data,\r
502 sizeof (EFI_IPv4_ADDRESS)\r
503 );\r
504 }\r
505\r
506 //\r
507 // Parse the boot file name by option.\r
508 //\r
509 ASSERT (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);\r
510 Private->BootFileName = Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data;\r
511\r
512 if (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN] != NULL) {\r
513 //\r
514 // Parse the boot file size by option.\r
515 //\r
516 CopyMem (&Value, Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN]->Data, sizeof (Value));\r
517 Value = NTOHS (Value);\r
518 //\r
519 // The field of boot file size is 512 bytes in unit.\r
520 //\r
521 *BufferSize = 512 * Value;\r
522 } else {\r
523 //\r
524 // Get the bootfile size by tftp command if no option available.\r
525 //\r
526 Status = PxeBc->Mtftp (\r
527 PxeBc,\r
528 EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,\r
529 NULL,\r
530 FALSE,\r
531 BufferSize,\r
532 &Private->BlockSize,\r
533 &Private->ServerIp,\r
534 Private->BootFileName,\r
535 NULL,\r
536 FALSE\r
537 );\r
538 }\r
539\r
540 //\r
541 // Save the value of boot file size.\r
542 //\r
543 Private->BootFileSize = (UINTN) *BufferSize;\r
544\r
545 //\r
546 // Display all the information: boot server address, boot file name and boot file size.\r
547 //\r
548 AsciiPrint ("\n Server IP address is ");\r
549 PxeBcShowIp4Addr (&Private->ServerIp.v4);\r
550 AsciiPrint ("\n NBP filename is %a", Private->BootFileName);\r
551 AsciiPrint ("\n NBP filesize is %d Bytes", Private->BootFileSize);\r
552\r
553 return Status;\r
554}\r
555\r
556\r
557/**\r
558 Parse out the boot information from the last Dhcp6 reply packet.\r
559\r
560 @param[in, out] Private Pointer to PxeBc private data.\r
561 @param[out] BufferSize Size of the boot file to be downloaded.\r
562\r
563 @retval EFI_SUCCESS Successfully parsed out all the boot information.\r
564 @retval EFI_BUFFER_TOO_SMALL\r
565 @retval Others Failed to parse out the boot information.\r
566\r
567**/\r
568EFI_STATUS\r
569PxeBcDhcp6BootInfo (\r
570 IN OUT PXEBC_PRIVATE_DATA *Private,\r
571 OUT UINT64 *BufferSize\r
572 )\r
573{\r
574 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r
575 EFI_PXE_BASE_CODE_MODE *Mode;\r
576 EFI_STATUS Status;\r
577 PXEBC_DHCP6_PACKET_CACHE *Cache6;\r
578 UINT16 Value;\r
579\r
580 PxeBc = &Private->PxeBc;\r
581 Mode = PxeBc->Mode;\r
582 Status = EFI_SUCCESS;\r
583 *BufferSize = 0;\r
584\r
585 //\r
586 // Get the last received Dhcp6 reply packet.\r
587 //\r
588 if (Mode->PxeReplyReceived) {\r
589 Cache6 = &Private->PxeReply.Dhcp6;\r
590 } else if (Mode->ProxyOfferReceived) {\r
591 Cache6 = &Private->ProxyOffer.Dhcp6;\r
592 } else {\r
593 Cache6 = &Private->DhcpAck.Dhcp6;\r
594 }\r
595\r
596 ASSERT (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] != NULL);\r
597\r
598 //\r
599 // Parse (m)tftp server ip address and bootfile name.\r
600 //\r
601 Status = PxeBcExtractBootFileUrl (\r
602 &Private->BootFileName,\r
603 &Private->ServerIp.v6,\r
604 (CHAR8 *) (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),\r
605 NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen)\r
606 );\r
607 if (EFI_ERROR (Status)) {\r
608 return Status;\r
609 }\r
610\r
611 //\r
612 // Parse the value of boot file size.\r
613 //\r
614 if (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_PARAM] != NULL) {\r
615 //\r
616 // Parse it out if have the boot file parameter option.\r
617 //\r
618 Status = PxeBcExtractBootFileParam ((CHAR8 *) Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_PARAM]->Data, &Value);\r
619 if (EFI_ERROR (Status)) {\r
620 return Status;\r
621 }\r
622 //\r
623 // The field of boot file size is 512 bytes in unit.\r
624 //\r
625 *BufferSize = 512 * Value;\r
626 } else {\r
627 //\r
628 // Send get file size command by tftp if option unavailable.\r
629 //\r
630 Status = PxeBc->Mtftp (\r
631 PxeBc,\r
632 EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,\r
633 NULL,\r
634 FALSE,\r
635 BufferSize,\r
636 &Private->BlockSize,\r
637 &Private->ServerIp,\r
638 Private->BootFileName,\r
639 NULL,\r
640 FALSE\r
641 );\r
642 }\r
643\r
644 //\r
645 // Save the value of boot file size.\r
646 //\r
647 Private->BootFileSize = (UINTN) *BufferSize;\r
648\r
649 //\r
650 // Display all the information: boot server address, boot file name and boot file size.\r
651 //\r
652 AsciiPrint ("\n Server IP address is ");\r
653 PxeBcShowIp6Addr (&Private->ServerIp.v6);\r
654 AsciiPrint ("\n NBP filename is %a", Private->BootFileName);\r
655 AsciiPrint ("\n NBP filesize is %d Bytes", Private->BootFileSize);\r
656\r
657 return Status;\r
658}\r
659\r
660\r
661/**\r
662 Extract the discover information and boot server entry from the\r
663 cached packets if unspecified.\r
664\r
665 @param[in] Private Pointer to PxeBc private data.\r
666 @param[in] Type The type of bootstrap to perform.\r
9063c328 667 @param[in, out] DiscoverInfo Pointer to EFI_PXE_BASE_CODE_DISCOVER_INFO.\r
a3bcde70
HT
668 @param[out] BootEntry Pointer to PXEBC_BOOT_SVR_ENTRY.\r
669 @param[out] SrvList Pointer to EFI_PXE_BASE_CODE_SRVLIST.\r
670\r
671 @retval EFI_SUCCESS Successfully extracted the information.\r
672 @retval EFI_DEVICE_ERROR Failed to extract the information.\r
673\r
674**/\r
675EFI_STATUS\r
676PxeBcExtractDiscoverInfo (\r
677 IN PXEBC_PRIVATE_DATA *Private,\r
678 IN UINT16 Type,\r
9063c328 679 IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO **DiscoverInfo,\r
a3bcde70
HT
680 OUT PXEBC_BOOT_SVR_ENTRY **BootEntry,\r
681 OUT EFI_PXE_BASE_CODE_SRVLIST **SrvList\r
682 )\r
683{\r
684 EFI_PXE_BASE_CODE_MODE *Mode;\r
685 PXEBC_DHCP4_PACKET_CACHE *Cache4;\r
686 PXEBC_VENDOR_OPTION *VendorOpt;\r
687 PXEBC_BOOT_SVR_ENTRY *Entry;\r
688 BOOLEAN IsFound;\r
9063c328 689 EFI_PXE_BASE_CODE_DISCOVER_INFO *Info;\r
690 UINT16 Index;\r
a3bcde70
HT
691\r
692 Mode = Private->PxeBc.Mode;\r
9063c328 693 Info = *DiscoverInfo;\r
a3bcde70
HT
694\r
695 if (Mode->UsingIpv6) {\r
696 Info->IpCnt = 1;\r
697 Info->UseUCast = TRUE;\r
698\r
699 Info->SrvList[0].Type = Type;\r
700 Info->SrvList[0].AcceptAnyResponse = FALSE;\r
701\r
702 //\r
703 // There is no vendor options specified in DHCPv6, so take BootFileUrl in the last cached packet.\r
704 //\r
705 CopyMem (&Info->SrvList[0].IpAddr, &Private->ServerIp, sizeof (EFI_IP_ADDRESS));\r
706\r
707 *SrvList = Info->SrvList;\r
708 } else {\r
709 Entry = NULL;\r
710 IsFound = FALSE;\r
711 Cache4 = (Mode->ProxyOfferReceived) ? &Private->ProxyOffer.Dhcp4 : &Private->DhcpAck.Dhcp4;\r
712 VendorOpt = &Cache4->VendorOpt;\r
713\r
714 if (!Mode->DhcpAckReceived || !IS_VALID_DISCOVER_VENDOR_OPTION (VendorOpt->BitMap)) {\r
715 //\r
716 // Address is not acquired or no discovery options.\r
717 //\r
718 return EFI_INVALID_PARAMETER;\r
719 }\r
720\r
721 //\r
722 // Parse the boot server entry from the vendor option in the last cached packet.\r
723 //\r
724 Info->UseMCast = (BOOLEAN) !IS_DISABLE_MCAST_DISCOVER (VendorOpt->DiscoverCtrl);\r
725 Info->UseBCast = (BOOLEAN) !IS_DISABLE_BCAST_DISCOVER (VendorOpt->DiscoverCtrl);\r
726 Info->MustUseList = (BOOLEAN) IS_ENABLE_USE_SERVER_LIST (VendorOpt->DiscoverCtrl);\r
9063c328 727 Info->UseUCast = (BOOLEAN) IS_VALID_BOOT_SERVERS (VendorOpt->BitMap);\r
a3bcde70
HT
728\r
729 if (Info->UseMCast) {\r
730 //\r
731 // Get the multicast discover ip address from vendor option if has.\r
732 //\r
733 CopyMem (&Info->ServerMCastIp.v4, &VendorOpt->DiscoverMcastIp, sizeof (EFI_IPv4_ADDRESS));\r
734 }\r
735\r
736 Info->IpCnt = 0;\r
737\r
9063c328 738 if (Info->UseUCast) {\r
a3bcde70
HT
739 Entry = VendorOpt->BootSvr;\r
740\r
741 while (((UINT8) (Entry - VendorOpt->BootSvr)) < VendorOpt->BootSvrLen) {\r
742 if (Entry->Type == HTONS (Type)) {\r
743 IsFound = TRUE;\r
744 break;\r
745 }\r
746 Entry = GET_NEXT_BOOT_SVR_ENTRY (Entry);\r
747 }\r
748\r
749 if (!IsFound) {\r
750 return EFI_DEVICE_ERROR;\r
751 }\r
752\r
753 Info->IpCnt = Entry->IpCnt;\r
9063c328 754 if (Info->IpCnt >= 1) {\r
755 *DiscoverInfo = AllocatePool (sizeof (*Info) + (Info->IpCnt - 1) * sizeof (**SrvList));\r
756 if (*DiscoverInfo == NULL) {\r
757 return EFI_OUT_OF_RESOURCES; \r
758 } \r
759 CopyMem (*DiscoverInfo, Info, sizeof (*Info));\r
760 Info = *DiscoverInfo;\r
761 }\r
762\r
763 for (Index = 0; Index < Info->IpCnt; Index++) {\r
764 CopyMem (&Info->SrvList[Index].IpAddr, &Entry->IpAddr[Index], sizeof (EFI_IPv4_ADDRESS));\r
765 Info->SrvList[Index].AcceptAnyResponse = !Info->MustUseList;\r
766 Info->SrvList[Index].Type = NTOHS (Entry->Type);\r
767 }\r
a3bcde70
HT
768 }\r
769\r
770 *BootEntry = Entry;\r
9063c328 771 *SrvList = Info->SrvList;\r
a3bcde70
HT
772 }\r
773\r
774 return EFI_SUCCESS;\r
775}\r
776\r
777\r
778/**\r
779 Build the discover packet and send out for boot server.\r
780\r
781 @param[in] Private Pointer to PxeBc private data.\r
782 @param[in] Type PxeBc option boot item type.\r
783 @param[in] Layer Pointer to option boot item layer.\r
784 @param[in] UseBis Use BIS or not.\r
785 @param[in] DestIp Pointer to the destination address.\r
786 @param[in] IpCount The count of the server address.\r
787 @param[in] SrvList Pointer to the server address list.\r
788\r
789 @retval EFI_SUCCESS Successfully discovered boot file.\r
790 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.\r
791 @retval EFI_NOT_FOUND Can't get the PXE reply packet.\r
792 @retval Others Failed to discover boot file.\r
793\r
794**/\r
795EFI_STATUS\r
796PxeBcDiscoverBootServer (\r
797 IN PXEBC_PRIVATE_DATA *Private,\r
798 IN UINT16 Type,\r
799 IN UINT16 *Layer,\r
800 IN BOOLEAN UseBis,\r
801 IN EFI_IP_ADDRESS *DestIp,\r
802 IN UINT16 IpCount,\r
803 IN EFI_PXE_BASE_CODE_SRVLIST *SrvList\r
804 )\r
805{\r
806 if (Private->PxeBc.Mode->UsingIpv6) {\r
807 return PxeBcDhcp6Discover (\r
808 Private,\r
809 Type,\r
810 Layer,\r
811 UseBis,\r
812 DestIp\r
813 );\r
814 } else {\r
815 return PxeBcDhcp4Discover (\r
816 Private,\r
817 Type,\r
818 Layer,\r
819 UseBis,\r
820 DestIp,\r
821 IpCount,\r
822 SrvList\r
823 );\r
824 }\r
825}\r
826\r
827\r
828/**\r
829 Discover all the boot information for boot file.\r
830\r
831 @param[in, out] Private Pointer to PxeBc private data.\r
832 @param[out] BufferSize Size of the boot file to be downloaded.\r
833\r
834 @retval EFI_SUCCESS Successfully obtained all the boot information .\r
835 @retval EFI_BUFFER_TOO_SMALL The buffer size is not enough for boot file.\r
836 @retval EFI_ABORTED User cancel current operation.\r
837 @retval Others Failed to parse out the boot information.\r
838\r
839**/\r
840EFI_STATUS\r
841PxeBcDiscoverBootFile (\r
842 IN OUT PXEBC_PRIVATE_DATA *Private,\r
843 OUT UINT64 *BufferSize\r
844 )\r
845{\r
846 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r
847 EFI_PXE_BASE_CODE_MODE *Mode;\r
848 EFI_STATUS Status;\r
849 UINT16 Type;\r
850 UINT16 Layer;\r
851 BOOLEAN UseBis;\r
852\r
853 PxeBc = &Private->PxeBc;\r
854 Mode = PxeBc->Mode;\r
855 Type = EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP;\r
856 Layer = EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL;\r
857\r
858 //\r
859 // Start D.O.R.A/S.A.R.R exchange to acquire station ip address and\r
860 // other pxe boot information.\r
861 //\r
862 Status = PxeBc->Dhcp (PxeBc, TRUE);\r
863 if (EFI_ERROR (Status)) {\r
864 return Status;\r
865 }\r
866\r
867 //\r
868 // Select a boot server from boot server list.\r
869 //\r
870 Status = PxeBcSelectBootPrompt (Private);\r
871\r
872 if (Status == EFI_SUCCESS) {\r
873 //\r
874 // Choose by user's input.\r
875 //\r
9063c328 876 Status = PxeBcSelectBootMenu (Private, &Type, FALSE);\r
a3bcde70
HT
877 } else if (Status == EFI_TIMEOUT) {\r
878 //\r
879 // Choose by default item.\r
880 //\r
9063c328 881 Status = PxeBcSelectBootMenu (Private, &Type, TRUE);\r
a3bcde70
HT
882 }\r
883\r
884 if (!EFI_ERROR (Status)) {\r
885\r
886 if (Type == EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP) {\r
887 //\r
888 // Local boot(PXE bootstrap server) need abort\r
889 //\r
890 return EFI_ABORTED;\r
891 }\r
892\r
893 //\r
894 // Start to discover the boot server to get (m)tftp server ip address, bootfile\r
895 // name and bootfile size.\r
896 //\r
897 UseBis = (BOOLEAN) (Mode->BisSupported && Mode->BisDetected);\r
898 Status = PxeBc->Discover (PxeBc, Type, &Layer, UseBis, NULL);\r
899 if (EFI_ERROR (Status)) {\r
900 return Status;\r
901 }\r
9063c328 902\r
903 if (Mode->PxeReplyReceived && !Mode->ProxyOfferReceived) {\r
904 //\r
905 // Some network boot loader only search the packet in Mode.ProxyOffer to get its server\r
906 // IP address, so we need to store a copy of Mode.PxeReply packet into Mode.ProxyOffer.\r
907 //\r
908 if (Mode->UsingIpv6) {\r
909 CopyMem (\r
910 &Mode->ProxyOffer.Dhcpv6,\r
911 &Mode->PxeReply.Dhcpv6,\r
912 Private->PxeReply.Dhcp6.Packet.Ack.Length\r
913 );\r
914 } else {\r
915 CopyMem (\r
916 &Mode->ProxyOffer.Dhcpv4,\r
917 &Mode->PxeReply.Dhcpv4,\r
918 Private->PxeReply.Dhcp4.Packet.Ack.Length\r
919 ); \r
920 }\r
921 Mode->ProxyOfferReceived = TRUE;\r
922 }\r
a3bcde70
HT
923 }\r
924\r
925 //\r
926 // Parse the boot information.\r
927 //\r
928 if (Mode->UsingIpv6) {\r
929 Status = PxeBcDhcp6BootInfo (Private, BufferSize);\r
930 } else {\r
931 Status = PxeBcDhcp4BootInfo (Private, BufferSize);\r
932 }\r
933\r
934 return Status;\r
935}\r
936\r
937\r
938/**\r
939 Install PxeBaseCodeCallbackProtocol if not installed before.\r
940\r
941 @param[in, out] Private Pointer to PxeBc private data.\r
942 @param[out] NewMakeCallback If TRUE, it is a new callback.\r
943 Otherwise, it is not new callback.\r
944 @retval EFI_SUCCESS PxeBaseCodeCallbackProtocol installed succesfully.\r
945 @retval Others Failed to install PxeBaseCodeCallbackProtocol.\r
946\r
947**/\r
948EFI_STATUS\r
949PxeBcInstallCallback (\r
950 IN OUT PXEBC_PRIVATE_DATA *Private,\r
951 OUT BOOLEAN *NewMakeCallback\r
952 )\r
953{\r
954 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r
955 EFI_STATUS Status;\r
956\r
957 //\r
958 // Check whether PxeBaseCodeCallbackProtocol already installed.\r
959 //\r
960 PxeBc = &Private->PxeBc;\r
961 Status = gBS->HandleProtocol (\r
962 Private->Controller,\r
963 &gEfiPxeBaseCodeCallbackProtocolGuid,\r
964 (VOID **) &Private->PxeBcCallback\r
965 );\r
966 if (Status == EFI_UNSUPPORTED) {\r
967\r
968 CopyMem (\r
969 &Private->LoadFileCallback,\r
970 &gPxeBcCallBackTemplate,\r
971 sizeof (EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL)\r
972 );\r
973\r
974 //\r
975 // Install a default callback if user didn't offer one.\r
976 //\r
977 Status = gBS->InstallProtocolInterface (\r
978 &Private->Controller,\r
979 &gEfiPxeBaseCodeCallbackProtocolGuid,\r
980 EFI_NATIVE_INTERFACE,\r
981 &Private->LoadFileCallback\r
982 );\r
983\r
984 (*NewMakeCallback) = (BOOLEAN) (Status == EFI_SUCCESS);\r
985\r
986 Status = PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL, NewMakeCallback);\r
987 if (EFI_ERROR (Status)) {\r
988 PxeBc->Stop (PxeBc);\r
989 return Status;\r
990 }\r
991 }\r
992\r
993 return EFI_SUCCESS;\r
994}\r
995\r
996\r
997/**\r
998 Uninstall PxeBaseCodeCallbackProtocol.\r
999\r
1000 @param[in] Private Pointer to PxeBc private data.\r
1001 @param[in] NewMakeCallback If TRUE, it is a new callback.\r
1002 Otherwise, it is not new callback.\r
1003\r
1004**/\r
1005VOID\r
1006PxeBcUninstallCallback (\r
1007 IN PXEBC_PRIVATE_DATA *Private,\r
1008 IN BOOLEAN NewMakeCallback\r
1009 )\r
1010{\r
1011 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r
1012\r
1013 PxeBc = &Private->PxeBc;\r
1014\r
1015 if (NewMakeCallback) {\r
1016\r
1017 NewMakeCallback = FALSE;\r
1018\r
1019 PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL, &NewMakeCallback);\r
1020\r
1021 gBS->UninstallProtocolInterface (\r
1022 Private->Controller,\r
1023 &gEfiPxeBaseCodeCallbackProtocolGuid,\r
1024 &Private->LoadFileCallback\r
1025 );\r
1026 }\r
1027}\r
1028\r
1029\r
1030/**\r
1031 Download one of boot file in the list, and it's special for IPv6.\r
1032\r
1033 @param[in] Private Pointer to PxeBc private data.\r
1034 @param[in, out] BufferSize Size of user buffer for input;\r
1035 required buffer size for output.\r
1036 @param[in] Buffer Pointer to user buffer.\r
1037\r
1038 @retval EFI_SUCCESS Read one of boot file in the list successfully.\r
1039 @retval EFI_BUFFER_TOO_SMALL The buffer size is not enough for boot file.\r
1040 @retval EFI_NOT_FOUND There is no proper boot file available.\r
1041 @retval Others Failed to download boot file in the list.\r
1042\r
1043**/\r
1044EFI_STATUS\r
1045PxeBcReadBootFileList (\r
1046 IN PXEBC_PRIVATE_DATA *Private,\r
1047 IN OUT UINT64 *BufferSize,\r
1048 IN VOID *Buffer OPTIONAL\r
1049 )\r
1050{\r
1051 EFI_STATUS Status;\r
1052 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r
1053\r
1054 PxeBc = &Private->PxeBc;\r
1055\r
1056 //\r
1057 // Try to download the boot file if everything is ready.\r
1058 //\r
1059 if (Buffer != NULL) {\r
1060 Status = PxeBc->Mtftp (\r
1061 PxeBc,\r
1062 EFI_PXE_BASE_CODE_TFTP_READ_FILE,\r
1063 Buffer,\r
1064 FALSE,\r
1065 BufferSize,\r
1066 &Private->BlockSize,\r
1067 &Private->ServerIp,\r
1068 Private->BootFileName,\r
1069 NULL,\r
1070 FALSE\r
1071 );\r
1072\r
1073\r
1074 } else {\r
1075 Status = EFI_BUFFER_TOO_SMALL;\r
1076 }\r
1077\r
1078 return Status;\r
1079}\r
1080\r
1081\r
1082/**\r
1083 Load boot file into user buffer.\r
1084\r
1085 @param[in] Private Pointer to PxeBc private data.\r
1086 @param[in, out] BufferSize Size of user buffer for input;\r
1087 required buffer size for output.\r
1088 @param[in] Buffer Pointer to user buffer.\r
1089\r
1090 @retval EFI_SUCCESS Get all the boot information successfully.\r
1091 @retval EFI_BUFFER_TOO_SMALL The buffer size is not enough for boot file.\r
1092 @retval EFI_ABORTED User cancelled the current operation.\r
1093 @retval Others Failed to parse out the boot information.\r
1094\r
1095**/\r
1096EFI_STATUS\r
1097PxeBcLoadBootFile (\r
1098 IN PXEBC_PRIVATE_DATA *Private,\r
1099 IN OUT UINTN *BufferSize,\r
1100 IN VOID *Buffer OPTIONAL\r
1101 )\r
1102{\r
1103 BOOLEAN NewMakeCallback;\r
1104 UINT64 RequiredSize;\r
1105 UINT64 CurrentSize;\r
1106 EFI_STATUS Status;\r
1107 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r
1108 EFI_PXE_BASE_CODE_MODE *PxeBcMode;\r
1109\r
1110 NewMakeCallback = FALSE;\r
1111 PxeBc = &Private->PxeBc;\r
1112 PxeBcMode = &Private->Mode;\r
1113 CurrentSize = *BufferSize;\r
1114 RequiredSize = 0;\r
1115\r
1116 //\r
1117 // Install pxebc callback protocol if hasn't been installed yet.\r
1118 //\r
1119 Status = PxeBcInstallCallback (Private, &NewMakeCallback);\r
1120 if (EFI_ERROR(Status)) {\r
1121 return Status;\r
1122 }\r
1123\r
1124 if (Private->BootFileSize == 0) {\r
1125 //\r
1126 // Discover the boot information about the bootfile if hasn't.\r
1127 //\r
1128 Status = PxeBcDiscoverBootFile (Private, &RequiredSize);\r
278c6019 1129 if (EFI_ERROR (Status)) {\r
1130 goto ON_EXIT;\r
1131 }\r
a3bcde70
HT
1132\r
1133 if (PXEBC_IS_SIZE_OVERFLOWED (RequiredSize)) {\r
1134 //\r
1135 // It's error if the required buffer size is beyond the system scope.\r
1136 //\r
1137 Status = EFI_DEVICE_ERROR;\r
1138 goto ON_EXIT;\r
1139 } else if (RequiredSize > 0) {\r
1140 //\r
1141 // Get the right buffer size of the bootfile required.\r
1142 //\r
1143 if (CurrentSize < RequiredSize || Buffer == NULL) {\r
1144 //\r
1145 // It's buffer too small if the size of user buffer is smaller than the required.\r
1146 //\r
1147 CurrentSize = RequiredSize;\r
1148 Status = EFI_BUFFER_TOO_SMALL;\r
1149 goto ON_EXIT;\r
1150 }\r
1151 CurrentSize = RequiredSize;\r
1152 } else if (RequiredSize == 0 && PxeBcMode->UsingIpv6) {\r
1153 //\r
1154 // Try to download another bootfile in list if failed to get the filesize of the last one.\r
1155 // It's special for the case of IPv6.\r
1156 //\r
1157 Status = PxeBcReadBootFileList (Private, &CurrentSize, Buffer);\r
1158 goto ON_EXIT;\r
1159 }\r
1160 } else if (CurrentSize < Private->BootFileSize || Buffer == NULL ) {\r
1161 //\r
1162 // It's buffer too small if the size of user buffer is smaller than the required.\r
1163 //\r
1164 CurrentSize = Private->BootFileSize;\r
1165 Status = EFI_BUFFER_TOO_SMALL;\r
1166 goto ON_EXIT;\r
1167 }\r
1168\r
1169 //\r
1170 // Begin to download the bootfile if everything is ready.\r
1171 //\r
1172 AsciiPrint ("\n Downloading NBP file...\n");\r
1173 if (PxeBcMode->UsingIpv6) {\r
1174 Status = PxeBcReadBootFileList (\r
1175 Private,\r
1176 &CurrentSize,\r
1177 Buffer\r
1178 );\r
1179 } else {\r
1180 Status = PxeBc->Mtftp (\r
1181 PxeBc,\r
1182 EFI_PXE_BASE_CODE_TFTP_READ_FILE,\r
1183 Buffer,\r
1184 FALSE,\r
1185 &CurrentSize,\r
1186 &Private->BlockSize,\r
1187 &Private->ServerIp,\r
1188 Private->BootFileName,\r
1189 NULL,\r
1190 FALSE\r
1191 );\r
1192 }\r
1193\r
1194ON_EXIT:\r
1195 *BufferSize = (UINTN) CurrentSize;\r
1196 PxeBcUninstallCallback(Private, NewMakeCallback);\r
1197\r
1198 if (Status == EFI_SUCCESS) {\r
1199 AsciiPrint ("\n Succeed to download NBP file.\n");\r
1200 return EFI_SUCCESS;\r
1201 } else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) {\r
1202 AsciiPrint ("\n PXE-E05: Buffer size is smaller than the requested file.\n");\r
1203 } else if (Status == EFI_DEVICE_ERROR) {\r
1204 AsciiPrint ("\n PXE-E07: Network device error.\n");\r
1205 } else if (Status == EFI_OUT_OF_RESOURCES) {\r
1206 AsciiPrint ("\n PXE-E09: Could not allocate I/O buffers.\n");\r
1207 } else if (Status == EFI_NO_MEDIA) {\r
1208 AsciiPrint ("\n PXE-E12: Could not detect network connection.\n");\r
1209 } else if (Status == EFI_NO_RESPONSE) {\r
1210 AsciiPrint ("\n PXE-E16: No offer received.\n");\r
1211 } else if (Status == EFI_TIMEOUT) {\r
1212 AsciiPrint ("\n PXE-E18: Server response timeout.\n");\r
1213 } else if (Status == EFI_ABORTED) {\r
1214 AsciiPrint ("\n PXE-E21: Remote boot cancelled.\n");\r
1215 } else if (Status == EFI_ICMP_ERROR) {\r
1216 AsciiPrint ("\n PXE-E22: Client received ICMP error from server.\n");\r
1217 } else if (Status == EFI_TFTP_ERROR) {\r
1218 AsciiPrint ("\n PXE-E23: Client received TFTP error from server.\n");\r
4496ff75 1219 } else if (Status == EFI_NOT_FOUND) {\r
1220 AsciiPrint ("\n PXE-E53: No boot filename received.\n");\r
a3bcde70
HT
1221 } else if (Status != EFI_BUFFER_TOO_SMALL) {\r
1222 AsciiPrint ("\n PXE-E99: Unexpected network error.\n");\r
1223 }\r
1224\r
1225 return Status;\r
1226}\r
1227\r