11CHAR16 mVlanStorageName[] = L
"VlanNvData";
15 VLAN_CONFIG_PRIVATE_DATA_SIGNATURE,
32 VLAN_CONFIG_FORM_SET_GUID
66 OUT EFI_STRING *Progress,
67 OUT EFI_STRING *Results
74 EFI_STRING ConfigRequestHdr;
75 EFI_STRING ConfigRequest;
76 BOOLEAN AllocatedRequest;
79 if ((Progress ==
NULL) || (Results ==
NULL)) {
80 return EFI_INVALID_PARAMETER;
88 ConfigRequestHdr =
NULL;
90 AllocatedRequest =
FALSE;
96 if (mHiiConfigRouting ==
NULL) {
97 gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid,
NULL, (VOID **)&mHiiConfigRouting);
100 ASSERT (mHiiConfigRouting !=
NULL);
105 PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);
107 BufferSize =
sizeof (Configuration);
108 ConfigRequest = Request;
115 ConfigRequestHdr =
HiiConstructConfigHdr (&gVlanConfigFormSetGuid, mVlanStorageName, PrivateData->DriverHandle);
116 Size = (
StrLen (ConfigRequestHdr) + 32 + 1) *
sizeof (CHAR16);
118 ASSERT (ConfigRequest !=
NULL);
119 AllocatedRequest =
TRUE;
120 UnicodeSPrint (ConfigRequest, Size, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
124 Status = mHiiConfigRouting->BlockToConfig (
127 (UINT8 *)&Configuration,
135 if (AllocatedRequest) {
137 ConfigRequest =
NULL;
143 if (Request ==
NULL) {
145 }
else if (
StrStr (Request, L
"OFFSET") ==
NULL) {
146 *Progress = Request +
StrLen (Request);
174 IN CONST EFI_STRING Configuration,
175 OUT EFI_STRING *Progress
178 if ((Configuration ==
NULL) || (Progress ==
NULL)) {
179 return EFI_INVALID_PARAMETER;
182 *Progress = Configuration;
184 return EFI_NOT_FOUND;
187 *Progress = Configuration +
StrLen (Configuration);
217 IN EFI_BROWSER_ACTION Action,
218 IN EFI_QUESTION_ID QuestionId,
221 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
230 PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);
232 if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {
236 if ((Action != EFI_BROWSER_ACTION_CHANGED) && (Action != EFI_BROWSER_ACTION_CHANGING)) {
240 return EFI_UNSUPPORTED;
247 ASSERT (Configuration !=
NULL);
250 VlanConfig = PrivateData->VlanConfig;
252 if (Action == EFI_BROWSER_ACTION_CHANGED) {
253 switch (QuestionId) {
254 case VLAN_ADD_QUESTION_ID:
258 VlanConfig->Set (VlanConfig, Configuration->VlanId, Configuration->Priority);
265 if (VlanHandle ==
NULL) {
269 VlanHandle = PrivateData->ControllerHandle;
277 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
278 Configuration->VlanId = 0;
279 Configuration->Priority = 0;
282 case VLAN_REMOVE_QUESTION_ID:
286 ASSERT (PrivateData->NumberOfVlan <= MAX_VLAN_NUMBER);
287 for (Index = 0; Index < PrivateData->NumberOfVlan; Index++) {
288 if (Configuration->VlanList[Index] != 0) {
292 VlanConfig->Remove (VlanConfig, PrivateData->VlanId[Index]);
297 if (PrivateData->NumberOfVlan == 0) {
302 gBS->ConnectController (PrivateData->ControllerHandle,
NULL,
NULL,
TRUE);
305 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
306 ZeroMem (Configuration->VlanList, MAX_VLAN_NUMBER);
312 }
else if (Action == EFI_BROWSER_ACTION_CHANGING) {
313 switch (QuestionId) {
314 case VLAN_UPDATE_QUESTION_ID:
346 VOID *StartOpCodeHandle;
348 VOID *EndOpCodeHandle;
354 EFI_STRING_ID StringId;
361 VlanConfig = PrivateData->VlanConfig;
362 VlanConfig->Find (VlanConfig,
NULL, &NumberOfVlan, &VlanData);
367 if (NumberOfVlan > MAX_VLAN_NUMBER) {
368 NumberOfVlan = MAX_VLAN_NUMBER;
371 PrivateData->NumberOfVlan = NumberOfVlan;
377 ASSERT (StartOpCodeHandle !=
NULL);
380 ASSERT (EndOpCodeHandle !=
NULL);
392 StartLabel->
Number = LABEL_VLAN_LIST;
404 EndLabel->
Number = LABEL_END;
406 ZeroMem (PrivateData->VlanId, MAX_VLAN_NUMBER);
407 for (Index = 0; Index < NumberOfVlan; Index++) {
410 StrCpyS (String, (
sizeof (VlanStr) /
sizeof (CHAR16)), L
" VLAN ID:");
417 SetMem16 (String, (4 - DigitalCount) *
sizeof (CHAR16), L
' ');
418 StrCpyS (String + 4 - DigitalCount, (
sizeof (VlanStr) /
sizeof (CHAR16)) - 10 - (4 - DigitalCount), VlanIdStr);
421 StrCpyS (String, (
sizeof (VlanStr) /
sizeof (CHAR16)) - 10 - (4 - DigitalCount) - 4, L
", Priority:");
425 sizeof (VlanStr) - ((
UINTN)String - (
UINTN)VlanStr),
427 VlanData[Index].Priority,
434 ASSERT (StringId != 0);
438 (EFI_QUESTION_ID)(VLAN_LIST_VAR_OFFSET + Index),
439 VLAN_CONFIGURATION_VARSTORE_ID,
440 (UINT16)(VLAN_LIST_VAR_OFFSET + Index),
451 PrivateData->VlanId[Index] = VlanData[Index].
VlanId;
455 PrivateData->HiiHandle,
456 &gVlanConfigFormSetGuid,
457 VLAN_CONFIGURATION_FORM_ID,
465 if (VlanData !=
NULL) {
500 PrivateData->ParentDevicePath,
503 if (ChildDevicePath ==
NULL) {
504 return EFI_OUT_OF_RESOURCES;
507 PrivateData->ChildDevicePath = ChildDevicePath;
510 ConfigAccess = &PrivateData->ConfigAccess;
511 Status =
gBS->InstallMultipleProtocolInterfaces (
513 &gEfiDevicePathProtocolGuid,
515 &gEfiHiiConfigAccessProtocolGuid,
519 if (EFI_ERROR (Status)) {
523 PrivateData->DriverHandle = DriverHandle;
529 Status =
gBS->OpenProtocol (
530 PrivateData->ControllerHandle,
531 &gEfiVlanConfigProtocolGuid,
532 (VOID **)&VlanConfig,
533 PrivateData->ImageHandle,
534 PrivateData->DriverHandle,
535 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
537 if (EFI_ERROR (Status)) {
545 &gVlanConfigFormSetGuid,
547 VlanConfigDxeStrings,
551 if (HiiHandle ==
NULL) {
552 return EFI_OUT_OF_RESOURCES;
555 PrivateData->HiiHandle = HiiHandle;
561 Status =
NetLibGetMacString (PrivateData->ControllerHandle, PrivateData->ImageHandle, &MacString);
562 if (EFI_ERROR (Status)) {
566 PrivateData->MacString = MacString;
568 StrCpyS (Str,
sizeof (Str) /
sizeof (CHAR16), L
"VLAN Configuration (MAC:");
569 StrCatS (Str,
sizeof (Str) /
sizeof (CHAR16), MacString);
570 StrCatS (Str,
sizeof (Str) /
sizeof (CHAR16), L
")");
612 Status =
gBS->CloseProtocol (
613 PrivateData->ControllerHandle,
614 &gEfiVlanConfigProtocolGuid,
615 PrivateData->ImageHandle,
616 PrivateData->DriverHandle
618 if (EFI_ERROR (Status)) {
625 if (PrivateData->DriverHandle !=
NULL) {
626 Status =
gBS->UninstallMultipleProtocolInterfaces (
627 PrivateData->DriverHandle,
628 &gEfiDevicePathProtocolGuid,
629 PrivateData->ChildDevicePath,
630 &gEfiHiiConfigAccessProtocolGuid,
631 &PrivateData->ConfigAccess,
634 if (EFI_ERROR (Status)) {
636 PrivateData->ControllerHandle,
637 &gEfiVlanConfigProtocolGuid,
638 (VOID **)&VlanConfig,
639 PrivateData->ImageHandle,
640 PrivateData->DriverHandle,
641 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
646 PrivateData->DriverHandle =
NULL;
648 if (PrivateData->ChildDevicePath !=
NULL) {
649 FreePool (PrivateData->ChildDevicePath);
650 PrivateData->ChildDevicePath =
NULL;
657 if (PrivateData->MacString !=
NULL) {
659 PrivateData->MacString =
NULL;
665 if (PrivateData->HiiHandle !=
NULL) {
667 PrivateData->HiiHandle =
NULL;
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
UINTN EFIAPI StrnLenS(IN CONST CHAR16 *String, IN UINTN MaxSize)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
VOID *EFIAPI SetMem16(OUT VOID *Buffer, IN UINTN Length, IN UINT16 Value)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define HARDWARE_DEVICE_PATH
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING EFIAPI HiiConstructConfigHdr(IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL, IN EFI_HANDLE DriverHandle)
BOOLEAN EFIAPI HiiGetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, OUT UINT8 *Buffer)
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
UINT8 *EFIAPI HiiCreateCheckBoxOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 CheckBoxFlags, IN VOID *DefaultsOpCodeHandle OPTIONAL)
BOOLEAN EFIAPI HiiSetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, IN CONST UINT8 *Buffer, IN CONST CHAR16 *RequestElement OPTIONAL)
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
BOOLEAN EFIAPI HiiIsConfigHdrMatch(IN CONST EFI_STRING ConfigHdr, IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL)
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
#define EFI_IFR_EXTEND_OP_LABEL
RETURN_STATUS EFIAPI UnicodeValueToStringS(IN OUT CHAR16 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
#define ARRAY_SIZE(Array)
EFI_STATUS EFIAPI NetLibGetMacString(IN EFI_HANDLE ServiceHandle, IN EFI_HANDLE ImageHandle OPTIONAL, OUT CHAR16 **MacString)
EFI_HANDLE EFIAPI NetLibGetVlanHandle(IN EFI_HANDLE ControllerHandle, IN UINT16 VlanId)
VOID VlanUpdateForm(IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData)
EFI_STATUS EFIAPI VlanRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
EFI_STATUS UninstallVlanConfigForm(IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData)
EFI_STATUS InstallVlanConfigForm(IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData)
EFI_STATUS EFIAPI VlanCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
EFI_STATUS EFIAPI VlanExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
UINT16 VlanId
Vlan Identifier.