/** * UGA Draw Protocol Test Driver Entry point. * @param ImageHandle the driver image handle. * @param SystemTable the system table. * @return EFI_SUCCESS the driver is loaded successfully. */ EFI_STATUS InitializeBBTestUgaDraw ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EfiInitializeTestLib (ImageHandle, SystemTable); InitializeLib (ImageHandle, SystemTable); EfiInitializeDriverLib (ImageHandle, SystemTable); // // Initialize Demo Data // DemoResolutionMax = sizeof (DemoResolution) / sizeof (DEMO_RESOLUTION_TYPE); DemoRefreshRateMax = sizeof (DemoRefreshRate) / sizeof (DEMO_REFRESH_RATE_TYPE); DemoColorDepthMax = sizeof (DemoColorDepth) / sizeof (DEMO_COLOR_DEPTH_TYPE); gtBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent); return EfiInitAndInstallBBTestInterface ( &ImageHandle, &gBBTestProtocolField, gBBTestEntryField, BBTestUgaDrawProtocolUnload, &gBBTestProtocolInterface ); }
EFI_STATUS DxeInitializeDriverLib ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Intialize Driver Lib if it has not yet been initialized. Arguments: ImageHandle - Standard EFI Image entry parameter SystemTable - Standard EFI Image entry parameter Returns: EFI_STATUS always returns EFI_SUCCESS --*/ { EFI_STATUS Status; Status = EfiInitializeDriverLib (ImageHandle, SystemTable); if (!EFI_ERROR (Status)) { Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); } return Status; }
/********************************************************************************* * Creates/installs the BlackBox Interface and eminating Entry Point node list. * @param ImageHandle The test driver image handle * @param SystemTable Pointer to System Table * @return EFI_SUCCESS Indicates the interface was installed * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value. ********************************************************************************/ EFI_STATUS InitializeTapeTest ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EfiInitializeTestLib (ImageHandle, SystemTable); InitializeLib (ImageHandle, SystemTable); EfiInitializeDriverLib (ImageHandle, SystemTable); // // Make sure the Protocol is not already installed in the system // //ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTapeIoProtocolGuid); Status = gtBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent); if (EFI_ERROR(Status)) { return Status; } Status = EfiInitAndInstallBBTestInterface ( &ImageHandle, &gEfiTapeTestProtField, gTapeTestEntryField, UnloadTapeTest, &gTapeTestProtocol ); return Status; }
/** * Creates/installs the BlackBox Interface and eminating Entry Point node list. * @param ImageHandle The test driver image handle * @param SystemTable Pointer to System Table * @return EFI_SUCCESS Indicates the interface was installed * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value. */ EFI_STATUS InitializeBBTestPxeBCProtocol ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EfiInitializeTestLib (ImageHandle, SystemTable); InitializeLib (ImageHandle, SystemTable); EfiInitializeDriverLib (ImageHandle, SystemTable); Status = gtBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent); if (EFI_ERROR(Status)) { return Status; } Status = GetSystemDevicePathAndFilePath (ImageHandle); if (EFI_ERROR(Status)) { return Status; } return EfiInitAndInstallBBTestInterface ( &ImageHandle, &gEfiPxeBcTestProtField, gPxeTestEntryField, BBTestPxeBcUnload, &gBBTestProtocolInterface ); }
EFI_STATUS InitializeGraphicsOutputBBTest ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: GraphicsOutput Protocol Test Driver Entry point. Arguments: ImageHandle - The driver image handle SystemTable - The system table Returns: EFI_SUCCESS - The driver is loaded successfully. --*/ { EfiInitializeTestLib (ImageHandle, SystemTable); InitializeLib (ImageHandle, SystemTable); EfiInitializeDriverLib (ImageHandle, SystemTable); return EfiInitAndInstallIHVBBTestInterface ( &ImageHandle, &gBBTestProtocolField, gBBTestEntryField, UnloadEfiGraphicsOutputBBTest, &gBBTestProtocolInterface ); }
EFI_STATUS EFIAPI DevicePathDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Entry point for EFI drivers. Arguments: ImageHandle - EFI_HANDLE SystemTable - EFI_SYSTEM_TABLE Returns: EFI_SUCCESS others --*/ { EFI_STATUS Status; EfiInitializeDriverLib (ImageHandle, SystemTable); mPrivateData.Signature = DEVICE_PATH_DRIVER_SIGNATURE; mPrivateData.DevicePathUtilities.GetDevicePathSize = GetDevicePathSize; mPrivateData.DevicePathUtilities.DuplicateDevicePath = DuplicateDevicePath; mPrivateData.DevicePathUtilities.AppendDevicePath = AppendDevicePath; mPrivateData.DevicePathUtilities.AppendDeviceNode = AppendDeviceNode; mPrivateData.DevicePathUtilities.AppendDevicePathInstance = AppendDevicePathInstance; mPrivateData.DevicePathUtilities.GetNextDevicePathInstance = GetNextDevicePathInstance; mPrivateData.DevicePathUtilities.IsDevicePathMultiInstance = IsDevicePathMultiInstance; mPrivateData.DevicePathUtilities.CreateDeviceNode = CreateDeviceNode; mPrivateData.DevicePathToText.ConvertDeviceNodeToText = ConvertDeviceNodeToText; mPrivateData.DevicePathToText.ConvertDevicePathToText = ConvertDevicePathToText; mPrivateData.DevicePathFromText.ConvertTextToDeviceNode = ConvertTextToDeviceNode; mPrivateData.DevicePathFromText.ConvertTextToDevicePath = ConvertTextToDevicePath; mPrivateData.Handle = NULL; Status = gBS->InstallMultipleProtocolInterfaces ( &mPrivateData.Handle, &gEfiDevicePathUtilitiesProtocolGuid, &mPrivateData.DevicePathUtilities, &gEfiDevicePathToTextProtocolGuid, &mPrivateData.DevicePathToText, &gEfiDevicePathFromTextProtocolGuid, &mPrivateData.DevicePathFromText, NULL ); return Status; }
EFI_STATUS EFIAPI AmdiGpuVgaControlDxeInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; // // Initialize Global Variable // EfiInitializeDriverLib (ImageHandle, SystemTable); // // Locate Root Bridge IO // Status = gBS->LocateProtocol ( &gEfiPciRootBridgeIoProtocolGuid, NULL, &mPciRootBridgeIo ); ASSERT_EFI_ERROR (Status); // // Locate boot dcript // Status = gBS->LocateProtocol ( &gEfiBootScriptSaveGuid, NULL, &mBootScriptSave ); ASSERT_EFI_ERROR (Status); // // Register the event handling function for PCIO install protocol // Status = gBS->CreateEventEx ( EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_NOTIFY, HookiGpuPciIo, NULL, NULL, &PciIoEvent ); ASSERT_EFI_ERROR (Status); Status = gBS->RegisterProtocolNotify ( &gEfiPciIoProtocolGuid, PciIoEvent, &mRegistrationForPciIo ); ASSERT_EFI_ERROR (Status); // // Disable VGA decoding by default (enablement would have to be requested through PciIo protocol) // SetVgaDecode (FALSE); return Status; }
EFI_STATUS EFIAPI SecurityStubInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Initialize the state information for the Security Architectural Protocol Arguments: ImageHandle of the loaded driver Pointer to the System Table Returns: Status EFI_SUCCESS - successful installation of the service EFI_OUT_OF_RESOURCES - cannot allocate protocol data structure EFI_DEVICE_ERROR - cannot create the timer service --*/ { EFI_STATUS Status; // // Initialize the EFI Driver Library // EfiInitializeDriverLib (ImageHandle, SystemTable); // // Make sure the Security Architectural Protocol is not already installed in the system // ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiSecurityArchProtocolGuid); // // Install the Security Architectural Protocol onto a new handle // Status = gBS->InstallMultipleProtocolInterfaces ( &mSecurityArchProtocolHandle, &gEfiSecurityArchProtocolGuid, &mSecurityStub, NULL ); ASSERT_EFI_ERROR (Status); return Status; }
/** * SimpleNetwork Protocol Test Driver Entry point. * @param ImageHandle the driver image handle. * @param SystemTable the system table. * @return EFI_SUCCESS the driver is loaded successfully. */ EFI_STATUS InitializeBBTestSimpleNetworkProtocol ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { // // Initialize library // EfiInitializeTestLib (ImageHandle, SystemTable); InitializeLib (ImageHandle, SystemTable); EfiInitializeDriverLib (ImageHandle, SystemTable); return EfiInitAndInstallBBTestInterface ( &ImageHandle, &gBBTestProtocolField, gBBTestEntryField, BBTestSimpleNetworkUnload, &gBBTestProtocolInterface ); }
EFI_STATUS EFIAPI WatchdogTimerDriverInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Initialize the Watchdog Timer Architectural Protocol driver Arguments: ImageHandle - ImageHandle of the loaded driver SystemTable - Pointer to the System Table Returns: EFI_SUCCESS - Timer Architectural Protocol created EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver. EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver. --*/ { EFI_STATUS Status; // // Initialize the EFI Driver Library // EfiInitializeDriverLib (ImageHandle, SystemTable); EfiLibReportStatusCode ( EFI_PROGRESS_CODE, (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_SW_PC_INIT_BEGIN), 0, &gEfiCallerIdGuid, NULL ); // // Make sure the Watchdog Timer Architectural Protocol is not already installed in the system // ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiWatchdogTimerArchProtocolGuid); // // Create the timer event used to implement a simple watchdog timer // Status = gBS->CreateEvent ( EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_NOTIFY, WatchdogTimerDriverExpires, NULL, &mWatchdogTimerEvent ); ASSERT_EFI_ERROR (Status); // // Install the Watchdog Timer Arch Protocol onto a new handle // Status = gBS->InstallMultipleProtocolInterfaces ( &mWatchdogTimerHandle, &gEfiWatchdogTimerArchProtocolGuid, &mWatchdogTimer, NULL ); ASSERT_EFI_ERROR (Status); EfiLibReportStatusCode ( EFI_PROGRESS_CODE, (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_SW_PC_INIT_END), 0, &gEfiCallerIdGuid, NULL ); return Status; }
EFI_STATUS TestRecoveryEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Test recovery library driver's entry point. Arguments: ImageHandle - the driver image handle. SystemTable - the system table. Returns: EFI_SUCCESS - the driver is loaded successfully. EFI_ALREADY_STARTED - the driver has already been loaded before. --*/ { EFI_STATUS Status; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; TSL_INIT_PRIVATE_DATA *Private; // Initialize driver lib EfiInitializeDriverLib (ImageHandle, SystemTable); // // Fill in the Unload() function // Status = gBS->OpenProtocol ( ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImage, ImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return Status; } LoadedImage->Unload = TslInitUnload; // // Open the TslInit protocol to perform the supported test. // Status = gBS->OpenProtocol ( ImageHandle, &gEfiTslInitInterfaceGuid, NULL, ImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL ); if (!EFI_ERROR (Status)) { return EFI_ALREADY_STARTED; } // // Initialize the TslInit private data // Status = gBS->AllocatePool( EfiBootServicesData, sizeof (TSL_INIT_PRIVATE_DATA), (VOID **)&Private ); if (EFI_ERROR (Status)) { return Status; } EfiZeroMem (Private, sizeof(TSL_INIT_PRIVATE_DATA)); Private->Signature = TSL_INIT_PRIVATE_DATA_SIGNATURE; Private->ImageHandle = ImageHandle; Private->TslInit.Revision = 0x10000; Private->TslInit.LibraryGuid = gEfiTestRecoveryLibraryGuid; Private->TslInit.Open = TslOpen; Private->TslInit.Close = TslClose; // // Install TslInit protocol // Status = gBS->InstallProtocolInterface ( &ImageHandle, &gEfiTslInitInterfaceGuid, EFI_NATIVE_INTERFACE, &(Private->TslInit) ); return Status; }
EFI_STATUS EFIAPI DriverSampleInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_HII_DATABASE_PROTOCOL *HiiDatabase; EFI_HII_PACKAGE_LIST_HEADER *PackageList; // // Initialize the library and our protocol. // EfiInitializeDriverLib (ImageHandle, SystemTable); // // Locate Hii Database protocol // Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, &HiiDatabase); if (EFI_ERROR (Status)) { return Status; } // // Retrieve HII package list from ImageHandle // Status = gBS->OpenProtocol ( ImageHandle, &gEfiHiiPackageListProtocolGuid, (VOID **) &PackageList, ImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return Status; } // // Create a child handle by installing Vendor Device Path // Status = gBS->InstallProtocolInterface ( &mDriverHandle, &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, &mHiiVendorDevicePath ); if (EFI_ERROR (Status)) { return Status; } // // Publish HII package list to HII Database. // Status = HiiDatabase->NewPackageList ( HiiDatabase, PackageList, mDriverHandle, &mHiiHandle ); if (EFI_ERROR (Status)) { // // Destroy child handle // gBS->UninstallProtocolInterface ( mDriverHandle, &gEfiDevicePathProtocolGuid, &mHiiVendorDevicePath ); return Status; } return EFI_SUCCESS; }
EFI_STATUS EFIAPI MiscSubclassDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Description: Standard EFI driver point. This driver parses the mMiscSubclassDataTable structure and reports any generated data to the DataHub. Arguments: ImageHandle Handle for the image of this driver SystemTable Pointer to the EFI System Table Returns: EFI_SUCCESS The data was successfully reported to the Data Hub. --*/ { EFI_MISC_SUBCLASS_DRIVER_DATA RecordData; EFI_DATA_HUB_PROTOCOL *DataHub; #if (EFI_SPECIFICATION_VERSION >= 0x0002000A) EFI_HII_DATABASE_PROTOCOL *HiiDatabase; EFI_HII_PACKAGE_LIST_HEADER *PackageList; #else EFI_HII_PROTOCOL *Hii; EFI_HII_PACKAGES *PackageList; #endif EFI_HII_HANDLE HiiHandle; EFI_STATUS EfiStatus; UINTN Index; BOOLEAN LogRecordData; EFI_EVENT Event; VOID *Registration; // // // EfiInitializeDriverLib (ImageHandle, SystemTable); // // Initialize constant portion of subclass header. // RecordData.Header.Version = EFI_MISC_SUBCLASS_VERSION; RecordData.Header.HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER); RecordData.Header.Instance = 1; RecordData.Header.SubInstance = 1; // // Locate data hub protocol. // EfiStatus = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &DataHub); if (EFI_ERROR (EfiStatus)) { DEBUG ((EFI_D_ERROR, "Could not locate DataHub protocol. %r\n", EfiStatus)); return EfiStatus; } else if (DataHub == NULL) { DEBUG ((EFI_D_ERROR, "LocateProtocol(DataHub) returned NULL pointer!\n")); return EFI_DEVICE_ERROR; } // // Locate hii protocol. // #if (EFI_SPECIFICATION_VERSION >= 0x0002000A) EfiStatus = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, &HiiDatabase); if (EFI_ERROR (EfiStatus)) { DEBUG ((EFI_D_ERROR, "Could not locate HiiDatabase protocol. %r\n", EfiStatus)); return EfiStatus; } else if (HiiDatabase == NULL) { DEBUG ((EFI_D_ERROR, "LocateProtocol(HiiDatabase) returned NULL pointer!\n")); return EFI_DEVICE_ERROR; } // // Add our default strings to the HII database. They will be modified later. // PackageList = PreparePackageList (1, &gEfiMiscSubClassGuid, MiscSubclassStrings); EfiStatus = HiiDatabase->NewPackageList (HiiDatabase, PackageList, ImageHandle, &HiiHandle); #else EfiStatus = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, &Hii); if (EFI_ERROR (EfiStatus)) { DEBUG ((EFI_D_ERROR, "Could not locate Hii protocol. %r\n", EfiStatus)); return EfiStatus; } else if (Hii == NULL) { DEBUG ((EFI_D_ERROR, "LocateProtocol(Hii) returned NULL pointer!\n")); return EFI_DEVICE_ERROR; } // // Add our default strings to the HII database. They will be modified later. // PackageList = PreparePackages (1, &gEfiMiscSubClassGuid, MiscSubclassStrings); EfiStatus = Hii->NewPack (Hii, PackageList, &HiiHandle); #endif gBS->FreePool (PackageList); if (EFI_ERROR (EfiStatus)) { DEBUG ((EFI_D_ERROR, "Could not log default strings to Hii. %r\n", EfiStatus)); return EfiStatus; } // // // for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) { // // Stupidity check! Do nothing if RecordLen is zero. // %%TBD - Should this be an error or a mechanism for ignoring // records in the Data Table? // if (mMiscSubclassDataTable[Index].RecordLen == 0) { DEBUG ( (EFI_D_ERROR, "mMiscSubclassDataTable[%d].RecordLen == 0\n", Index) ); continue; } // // Initialize per-record portion of subclass header and // copy static data into data portion of subclass record. // RecordData.Header.RecordType = mMiscSubclassDataTable[Index].RecordType; if (mMiscSubclassDataTable[Index].RecordData == NULL) { EfiZeroMem ( &RecordData.Record, mMiscSubclassDataTable[Index].RecordLen ); } else { EfiCopyMem ( &RecordData.Record, mMiscSubclassDataTable[Index].RecordData, mMiscSubclassDataTable[Index].RecordLen ); } // // If the entry does not have a function pointer, just log the data. // if (mMiscSubclassDataTable[Index].Function == NULL) { // // Log RecordData to Data Hub. // EfiStatus = DataHub->LogData ( DataHub, &gEfiMiscSubClassGuid, &gEfiMiscSubClassGuid, EFI_DATA_RECORD_CLASS_DATA, &RecordData, sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen ); if (EFI_ERROR (EfiStatus)) { DEBUG ( (EFI_D_ERROR, "LogData(%d bytes) == %r\n", sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen, EfiStatus) ); } continue; } // // The entry has a valid function pointer. // Keep calling the function and logging data until there // is no more data to log. // for (;;) { // // // EfiStatus = (*mMiscSubclassDataTable[Index].Function) ( mMiscSubclassDataTable[Index].RecordType, &mMiscSubclassDataTable[Index].RecordLen, &RecordData.Record, & LogRecordData ); // // // if (EFI_ERROR (EfiStatus)) { break; } if (!LogRecordData) { break; } // // // EfiStatus = DataHub->LogData ( DataHub, &gEfiMiscSubClassGuid, &gEfiMiscSubClassGuid, EFI_DATA_RECORD_CLASS_DATA, &RecordData, sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen ); if (EFI_ERROR (EfiStatus)) { DEBUG ( (EFI_D_ERROR, "LogData(%d bytes) == %r\n", sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen, EfiStatus) ); } } } // // Install notify function to fetch memory data through WinNtIo protocol and store to data hub. // EfiStatus = gBS->CreateEvent ( EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_CALLBACK, WinNtIoProtocolNotifyFunction, ImageHandle, &Event ); ASSERT (!EFI_ERROR (EfiStatus)); EfiStatus = gBS->RegisterProtocolNotify ( &gEfiWinNtIoProtocolGuid, Event, &Registration ); ASSERT (!EFI_ERROR (EfiStatus)); return EFI_SUCCESS; }
EFI_STATUS EFIAPI MonotonicCounterDriverInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Arguments: (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) Returns: --*/ { EFI_STATUS Status; UINT32 HighCount; UINTN BufferSize; EfiInitializeDriverLib (ImageHandle, SystemTable); // // Make sure the Monotonic Counter Architectural Protocol is not already installed in the system // ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiMonotonicCounterArchProtocolGuid); // // Register our ExitBootServices notify function // Status = gBS->CreateEvent ( EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, EFI_TPL_NOTIFY, MonotonicCounterDriverExitBootServices, NULL, &mMonotonicCounterNotifyEvent ); ASSERT_EFI_ERROR (Status); // // Register our SetVirtualAddressMap notify function // Status = gBS->CreateEvent ( EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, EFI_TPL_NOTIFY, MonotonicCounterDriverSetVirtualAddressMap, NULL, &mMonotonicCounterSetVirtualAddressMapNotifyEvent ); ASSERT_EFI_ERROR (Status); // // Initialize event to handle overflows // Status = gBS->CreateEvent ( EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_CALLBACK, EfiMtcEventHandler, NULL, &mEfiMtcEvent ); ASSERT_EFI_ERROR (Status); // // Read the last high part // BufferSize = sizeof (UINT32); Status = gRT->GetVariable ( mEfiMtcName, &mEfiMtcGuid, NULL, &BufferSize, &HighCount ); if (EFI_ERROR (Status)) { HighCount = 0; } // // Set the current value // mEfiMtc = LShiftU64 (HighCount, 32); // // Increment the upper 32 bits for this boot // Continue even if it fails. It will only fail if the variable services are // not functional. // Status = MonotonicCounterDriverGetNextHighMonotonicCount (&HighCount); // // Fill in the EFI Boot Services and EFI Runtime Services Monotonic Counter Fields // gBS->GetNextMonotonicCount = MonotonicCounterDriverGetNextMonotonicCount; gRT->GetNextHighMonotonicCount = MonotonicCounterDriverGetNextHighMonotonicCount; // // Install the Monotonic Counter Architctural Protocol onto a new handle // Status = gBS->InstallMultipleProtocolInterfaces ( &mMonotonicCounterHandle, &gEfiMonotonicCounterArchProtocolGuid, NULL, NULL ); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
EFI_STATUS EFIAPI SetOptionsInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: The driver Entry Point. The funciton will export a disk device class formset and its callback function to hii database Arguments: ImageHandle - EFI_HANDLE SystemTable - EFI_SYSTEM_TABLE Returns: EFI_STATUS --*/ { EFI_STATUS Status; EFI_HII_PROTOCOL *Hii; EFI_HII_PACKAGES *PackageList; EFI_HII_HANDLE HiiHandle; EFI_HII_UPDATE_DATA *UpdateData; EFI_CALLBACK_INFO *CallbackInfo; EFI_HANDLE Handle; UINTN ChoiceIndex; EFI_GUID SetOptionsGuid = SET_OPTIONS_GUID; // // Initialize the library and our protocol. // EfiInitializeDriverLib (ImageHandle, SystemTable); // // There should only be one HII protocol // Status = gBS->LocateProtocol ( &gEfiHiiProtocolGuid, NULL, &Hii ); if (EFI_ERROR (Status)) { return Status ; } CallbackInfo = EfiLibAllocateZeroPool (sizeof (EFI_CALLBACK_INFO)); if (CallbackInfo == NULL) { return EFI_BAD_BUFFER_SIZE; } CallbackInfo->Signature = EFI_CALLBACK_INFO_SIGNATURE; CallbackInfo->Hii = Hii; // // This driver not implement worker functions for the NV accessor functions. Only a callback evaluator // CallbackInfo->DriverCallback.NvRead = NULL; CallbackInfo->DriverCallback.NvWrite = NULL; CallbackInfo->DriverCallback.Callback = SetOptionsCallback; // // Install protocol interface // Handle = NULL; Status = gBS->InstallProtocolInterface ( &Handle, &gEfiFormCallbackProtocolGuid, EFI_NATIVE_INTERFACE, &CallbackInfo->DriverCallback ); ASSERT_EFI_ERROR (Status); CallbackInfo->CallbackHandle = Handle; PackageList = PreparePackages (2, &SetOptionsGuid, VfrBin, SetOptionsStrings); Status = Hii->NewPack (Hii, PackageList, &HiiHandle); gBS->FreePool (PackageList); CallbackInfo->RegisteredHandle = HiiHandle; // // Allocate space for creation of Buffer // UpdateData = EfiLibAllocateZeroPool (0x1000); ASSERT (UpdateData != NULL); // // Flag update pending in FormSet // UpdateData->FormSetUpdate = TRUE; // // Register CallbackHandle data for FormSet // UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackInfo->CallbackHandle; UpdateData->FormUpdate = FALSE; UpdateData->FormTitle = 0; UpdateData->DataCount = 0; Hii->UpdateForm (Hii, HiiHandle, (EFI_FORM_LABEL) 0x0, TRUE, UpdateData); gBS->FreePool (UpdateData); // // Clear all the mChoices // for (ChoiceIndex = 0; ChoiceIndex < MAX_CHOICE_NUM; ChoiceIndex++) { mChoice[ChoiceIndex].DriverImageHandle = NULL; mChoice[ChoiceIndex].DriverConfiguration = NULL; mChoice[ChoiceIndex].ControllerHandle = NULL; mChoice[ChoiceIndex].ChildControllerHandle = NULL; mChoice[ChoiceIndex].DescriptionToken = 0; } return EFI_SUCCESS; }
EFI_STATUS EFIAPI InitializeHiiDatabase ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Initialize HII Database Arguments: (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) Returns: EFI_SUCCESS - other - --*/ { EFI_STATUS Status; EFI_HANDLE Handle; EFI_HANDLE *HandleBuffer; UINTN HandleCount; EfiInitializeDriverLib (ImageHandle, SystemTable); // // There will be only one HII Database in the system // If there is another out there, someone is trying to install us // again. Fail that scenario. // Status = gBS->LocateHandleBuffer ( ByProtocol, &gEfiHiiDatabaseProtocolGuid, NULL, &HandleCount, &HandleBuffer ); // // If there was no error, assume there is an installation and fail to load // if (!EFI_ERROR (Status)) { if (HandleBuffer != NULL) { gBS->FreePool (HandleBuffer); } return EFI_DEVICE_ERROR; } InitializeListHead (&mPrivate.DatabaseList); InitializeListHead (&mPrivate.DatabaseNotifyList); InitializeListHead (&mPrivate.HiiHandleList); InitializeListHead (&mPrivate.FontInfoList); // // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type. // Status = gBS->CreateEventEx ( EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_NOTIFY, KeyboardLayoutChangeNullEvent, NULL, &gHiiSetKbdLayoutEventGuid, &gHiiKeyboardLayoutChanged ); if (EFI_ERROR (Status)) { return Status; } Handle = NULL; return gBS->InstallMultipleProtocolInterfaces ( &Handle, &gEfiHiiFontProtocolGuid, &mPrivate.HiiFont, #ifndef DISABLE_UNUSED_HII_PROTOCOLS &gEfiHiiImageProtocolGuid, &mPrivate.HiiImage, #endif &gEfiHiiStringProtocolGuid, &mPrivate.HiiString, &gEfiHiiDatabaseProtocolGuid, &mPrivate.HiiDatabase, &gEfiHiiConfigRoutingProtocolGuid, &mPrivate.ConfigRouting, NULL ); }
EFI_STATUS EFIAPI AgesaDxeDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; AMD_INTERFACE_PARAMS AmdInterfaceParams; AGESA_STATUS AgesaStatus; AMD_ENV_PARAMS AmdInitEnvParams; EFI_EVENT ReadyToBootEvent; EFI_HANDLE Handle; AMD_BUFFER_MANAGER_PROTOCOL *BufferMgr; // // Initialize Global Variable // EfiInitializeDriverLib (ImageHandle, SystemTable); // // Initialize the configuration structure and private data area // // Allocate memory for the private data Status = gBS->AllocatePool ( EfiBootServicesData, sizeof (AGESA_DXE_PRIVATE_DATA), &mAgesaDxePrivate); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { return Status; } // // Install the AMD_AGESA_MMIO_PROTOCOL // mAgesaDxePrivate->MmioMapManager.AmdMmioMapManager = AmdMmioMapManager; Handle = NULL; gBS->InstallProtocolInterface ( &Handle, &gAmdAgesaMmioProtocolGuid, EFI_NATIVE_INTERFACE, &mAgesaDxePrivate->MmioMapManager ); // // Initialize the private data structure // mAgesaDxePrivate->Signature = AGESA_DXE_PRIVATE_DATA_SIGNATURE; // // Create the first buffer for AGESA_ALLOCATE_BUFFER Manager // Status = gBS->AllocatePool ( EfiBootServicesData, sizeof (AGESA_DXE_BUFFER_MANAGER), &mAgesaDxePrivate->BufferManagerPtr ); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { return Status; } EfiZeroMem (mAgesaDxePrivate->BufferManagerPtr, sizeof (AGESA_DXE_BUFFER_MANAGER)); mAgesaDxePrivate->BufferManagerPtr->NextAgesaBufferManagerPtr = NULL; AgesaBufferManager = mAgesaDxePrivate->BufferManagerPtr; // // Rebuild persist heap from HOB. // Status = RebuildHeap (&mAgesaDxePrivate->HeapManagerPtr); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } // // Invoke AmdInitEnv // EfiZeroMem (&AmdInterfaceParams, sizeof (AMD_INTERFACE_PARAMS)); EfiZeroMem (&AmdInitEnvParams, sizeof (AMD_ENV_PARAMS)); AmdInterfaceParams.StdHeader.ImageBasePtr = 0; AmdInterfaceParams.StdHeader.HeapStatus = HEAP_SYSTEM_MEM; AmdInterfaceParams.AllocationMethod = ByHost; AmdInterfaceParams.AgesaFunctionName = AMD_INIT_ENV; AmdInterfaceParams.NewStructPtr = &AmdInitEnvParams; AmdInterfaceParams.NewStructSize = sizeof (AMD_ENV_PARAMS); AgesaStatus = AmdCreateStruct (&AmdInterfaceParams); AmdInitEnvParams.StdHeader = AmdInterfaceParams.StdHeader; OemCustomizeInitEnv (gBS, &AmdInitEnvParams); AgesaStatus = AmdInitEnv (&AmdInitEnvParams); OemHookAfterInitEnv (gBS, &AmdInitEnvParams); if ((AgesaStatus == AGESA_CRITICAL) || (AgesaStatus == AGESA_FATAL)) { return EFI_DEVICE_ERROR; } // // Install AmdBufferManagerProtocol which notifies other dependent drivers // Status = gBS->AllocatePool ( EfiBootServicesData, sizeof (AMD_BUFFER_MANAGER_PROTOCOL), &BufferMgr ); ASSERT_EFI_ERROR (Status); BufferMgr->StdHeader = AmdInitEnvParams.StdHeader; BufferMgr->DxeBufferManager = mAgesaDxePrivate->BufferManagerPtr; BufferMgr->AmdBufferCallout = AgesaDxeCallout; Handle = NULL; gBS->InstallProtocolInterface ( &Handle, &gAmdBufferManagerProtocolGuid, EFI_NATIVE_INTERFACE, BufferMgr ); // // Register the event handling function for AmdInitMid to be launched after // PciIo protocol // Status = gBS->CreateEventEx ( EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_NOTIFY, InvokeAmdInitMid, NULL, &PciIoProtocolInstallEventGuid, &PciIoEvent ); Status = gBS->RegisterProtocolNotify ( &gEfiPciIoProtocolGuid, PciIoEvent, &mRegistrationForPciIo ); // // Set up call back for AmdInitLate after AmdInitMid has been launched. // Status = gBS->CreateEventEx ( EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_NOTIFY, InvokeAmdInitLate, NULL, &AmdInitMidProtocolInstallEventGuid, &AmdInitMidEvent ); Status = gBS->RegisterProtocolNotify ( &gAmdDxeInitMidProtocolGuid, AmdInitMidEvent, &(mRegistrationForAmdInitMid) ); // // Initialize AMD CPU Interface protocol // mAgesaDxePrivate->CpuInterface.CreateProcessorTables = AmdCpuCreateProcessorTables; // Invoke AmdInitRtb // Register the event handling function to do last minute configuration and // preparation for system suspend-to-RAM mode. // Status = gBS->CreateEventEx ( EFI_EVENT_NOTIFY_SIGNAL, EFI_TPL_NOTIFY, AgesaInitRtb, NULL, &gEfiEventReadyToBootGuid, &ReadyToBootEvent ); return EFI_SUCCESS; }
EFI_STATUS Ip4ConfigENTSTestMain ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Entry point for Ip4Config protocol ENTS Test. Arguments: ImageHandle - The image handle. SystemTable - The system table. Returns: EFI_SUCCESS - Operation succeeded. Others - Some failure happened. --*/ { EFI_STATUS Status; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; EfiInitializeDriverLib (ImageHandle, SystemTable); EfiInitializeEntsLib (ImageHandle, SystemTable); gBS->HandleProtocol ( ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage ); LoadedImage->Unload = Ip4ConfigENTSTestUnload; Status = gBS->AllocatePool ( EfiBootServicesData, sizeof (EFI_ENTS_PROTOCOL), (VOID **)&gIp4ConfigEntsProtocolInterface ); if (EFI_ERROR (Status)) { goto Error; } gIp4ConfigEntsProtocolInterface->ClientName = gIp4ConfigProtocolName; gIp4ConfigEntsProtocolInterface->ClientAttribute = ENTS_PROTOCOL_ATTRIBUTE_PROTOCOL; gIp4ConfigEntsProtocolInterface->ClientGuid = &gEfiIp4ConfigProtocolGuid; gIp4ConfigEntsProtocolInterface->ClientHandle = NULL; gIp4ConfigEntsProtocolInterface->ClientInterface = NULL; gIp4ConfigEntsProtocolInterface->EntsInterfaceList = gIp4ConfigEntsInterfaceList; gIp4ConfigEntsProtocolInterface->RuntimeInfo = gIp4ConfigRuntimeInfo; gIp4ConfigEntsProtocolInterface->RuntimeInfoSize = gIp4ConfigRuntimeInfoSize; Status = gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, &gEfiEntsProtocolGuid, gIp4ConfigEntsProtocolInterface, NULL ); if (EFI_ERROR (Status)) { goto Error; } return EFI_SUCCESS; Error: if (gIp4ConfigEntsProtocolInterface != NULL) { gBS->FreePool (gIp4ConfigEntsProtocolInterface); } return Status; }
// // External functions implementations // EFI_STATUS ManagedNetworkMonitorEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Entry point of ManagedNetworkMonitor. Arguments: ImageHandle - The image handle. SystemTable - The system table. Returns: EFI_SUCCESS - Operation succeeded. Others - Some failure happened. --*/ { EFI_STATUS Status; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; EfiInitializeDriverLib (ImageHandle, SystemTable); EfiInitializeEntsLib (ImageHandle, SystemTable); mImageHandle = ImageHandle; gBS->HandleProtocol ( ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID *) &LoadedImage ); LoadedImage->Unload = ManagedNetworkMonitorUnload; Status = gBS->AllocatePool ( EfiBootServicesData, sizeof (EFI_ENTS_MONITOR_PROTOCOL), (VOID **)&gManagedNetworkMonitorInterface ); if (EFI_ERROR (Status)) { goto Error; } gManagedNetworkMonitorInterface->MonitorName = ENTS_MNP_MONITOR_NAME; gManagedNetworkMonitorInterface->MonitorIo = NULL; gManagedNetworkMonitorInterface->CleanUpEnvironmentFlag = FALSE; gManagedNetworkMonitorInterface->InitMonitor = InitManagedNetwork; gManagedNetworkMonitorInterface->ResetMonitor = ResetManagedNetwork; gManagedNetworkMonitorInterface->MonitorListener = ManagedNetworkListener; gManagedNetworkMonitorInterface->MonitorSender = ManagedNetworkSender; gManagedNetworkMonitorInterface->MonitorSaveContext = ManagedNetworkSaveContext; gManagedNetworkMonitorInterface->MonitorRestoreContext = ManagedNetworkRestoreContext; Status = gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, &gEfiEntsMonitorProtocolGuid, gManagedNetworkMonitorInterface, NULL ); if (EFI_ERROR (Status)) { goto Error; } return EFI_SUCCESS; Error: if (gManagedNetworkMonitorInterface != NULL) { gBS->FreePool (gManagedNetworkMonitorInterface); } return Status; }