8.2 Write DXE Driver Entry Point

The [Defines] section of the INF file defines the entry point of the DXE driver.

Unlike the UEFI driver entry point, which is only allowed to install protocol instances onto its own image handle and may not touch any hardware, a DXE driver entry point has no such restriction. It may install any protocol into the system and perform necessary hardware and software initializations.

In the following example (from the WatchDogTimerDxe driver in the MdeModulePkg) the DXE driver entry point installs its Architectural Protocol if the protocol is not yet installed.

EFI_STATUS
EFIAPI
WatchdogTimerDriverInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
//
// Make sure the Watchdog Timer Architectural Protocol has not been
// installed in the system yet.
//
ASSERT_PROTOCOL_ALREADY_INSTALLED (
NULL,
&gEfiWatchdogTimerArchProtocolGuid
);
//
// Create the timer event to implement a simple watchdog timer
//
Status = gBS->CreateEvent (
EVT_TIMER | EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
WatchdogTimerDriverExpires,
NULL,
&mWatchdogTimerEvent
);
ASSERT_EFI_ERROR (Status);

The two parameters for the DXE driver entry point are ImageHandle and SystemTable. ImageHandle refers to the image handle of the DXE driver.

SystemTable points to the EFI System Table.