/**
 *  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
InitializeBBTestProtocolHandlerBootServices (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS              Status;

  EfiInitializeTestLib (ImageHandle, SystemTable);

  //
  // initialize test utility lib
  //
  InitializeLib (ImageHandle, SystemTable);

  mImageHandle = ImageHandle;

  Status = InitializeGlobalData ();
  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EfiInitAndInstallBBTestInterface (
           &ImageHandle,
           &gBBTestProtocolField,
           gBBTestEntryField,
           BBTestProtocolHandlerBootServicesUnload,
           &gBBTestProtocolInterface
           );
}
Beispiel #2
0
NTSTATUS
NTAPI
DriverEntry(IN PDRIVER_OBJECT DriverObject,
            IN PUNICODE_STRING RegistryPath)
{
    HEADLESS_RSP_QUERY_INFO HeadlessInformation;
    ULONG InfoSize = sizeof(HeadlessInformation);
    NTSTATUS Status;
    UNICODE_STRING DriverName;
    PDEVICE_OBJECT DeviceObject;
    PSAC_DEVICE_EXTENSION DeviceExtension;
    PAGED_CODE();
    SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering.\n");

    /* Check if EMS is enabled in the kernel */
    HeadlessDispatch(HeadlessCmdQueryInformation,
                     NULL,
                     0,
                     &HeadlessInformation,
                     &InfoSize);
    if ((HeadlessInformation.Serial.TerminalType != HeadlessUndefinedPortType) &&
        ((HeadlessInformation.Serial.TerminalType != HeadlessSerialPort) ||
         (HeadlessInformation.Serial.TerminalAttached)))
    {
        /* It is, so create the device */
        RtlInitUnicodeString(&DriverName, L"\\Device\\SAC");
        Status = IoCreateDevice(DriverObject,
                                sizeof(SAC_DEVICE_EXTENSION),
                                &DriverName,
                                FILE_DEVICE_UNKNOWN,
                                FILE_DEVICE_SECURE_OPEN,
                                FALSE,
                                &DeviceObject);
        if (NT_SUCCESS(Status))
        {
            /* Setup the device extension */
            DeviceExtension = DeviceObject->DeviceExtension;
            DeviceExtension->Initialized = FALSE;

            /* Initialize the driver object */
            RtlFillMemoryUlong(DriverObject->MajorFunction,
                               RTL_NUMBER_OF(DriverObject->MajorFunction),
                               (ULONG_PTR)Dispatch);
            DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl;
            DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = DispatchShutdownControl;
            DriverObject->FastIoDispatch = NULL;
            DriverObject->DriverUnload = UnloadHandler;

            /* Initialize driver data */
            if (InitializeGlobalData(RegistryPath, DriverObject))
            {
                /* Initialize device data */
                if (InitializeDeviceData(DeviceObject))
                {
                    /* We're all good, register a shutdown notification */
                    IoRegisterShutdownNotification(DeviceObject);
                    return Status;
                }
            }

            /* One of the initializations failed, bail out */
            Status = STATUS_INSUFFICIENT_RESOURCES;
        }
        else
        {
            /* Print a debug statement if enabled */
            SAC_DBG(SAC_DBG_INIT, "unable to create device object: %X\n", Status);
        }

        /* Free any data we may have allocated and exit with failure */
        FreeGlobalData();
        SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with status 0x%x\n", Status);
        return Status;
    }

    /* EMS is not enabled */
    return STATUS_PORT_DISCONNECTED;
}