From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x22a.google.com (mail-oi0-x22a.google.com [IPv6:2607:f8b0:4003:c06::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D8AA620945C1F for ; Thu, 7 Sep 2017 21:00:09 -0700 (PDT) Received: by mail-oi0-x22a.google.com with SMTP id z73so5492613oia.2 for ; Thu, 07 Sep 2017 21:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=vPA6+FTQdmEyTkFwWHj4t7GYeKonEwmQmJwZtM5aZJo=; b=giGzakW8jM/SzTm90XtCu+/UjWJTFWAavWNOnzfezFWZpmpZD9lNCwzfDRFLT2MPfL PMz14VqFbVKcpMysDBYmV+GVWL66MOqhCf+qo97SeERl0M6/93A3BpjBR7iog+B1H2Ya 2IamovtR8ubHwSuG+FiJt/H6aHWPT5Og6x6ucE7GIgw19C1ZfLr+yIPM7lLBzhM0t8K+ ya1fSX1iTIQuKSFIZxOxjq/mH99TboP9NCmLqZUpQ+mi7WzK95LPFJCr+pxHwaSlq3yA Py49Pcer6FLEvR/bVKxQ9UAbKEdG+nNQF/3PhGI9aqYcPQiveLD263+5DqaAQ2QyhLsH eqvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=vPA6+FTQdmEyTkFwWHj4t7GYeKonEwmQmJwZtM5aZJo=; b=ZpKAWu4bYHZiS6N1FkSu1O+XpXPHdUvS58tqq52RgYEapRsz8zZzCtvWCHPydM7qO0 2XQPcIOGapGJFwWwxEvAVz1Q+IcSHJdRecHzQ6Nap5VwM6QalaJzAmbst1fG41kmdL+N SM/vRkCbuxEul39qv/50SW/oUdipRslAUze4QyGEMlMnZwhbEip4koboQgy5P9kO+I4y EedhKhxb9B2zMaGQdSz1p3ZejgdPpr62pAvZpPNINPrKyrb/+mnUKz2n3AbbHtQ1gPa7 TidAdtohkvCCNR0r36IZlgzwfLri5qp7tMe1bT2Nq1p0Xi5vBPPtR3XZ6oP/0I7uC7TV G7cg== X-Gm-Message-State: AHPjjUgBwC6UotJBQIH4mwnxbI4kiCpubkNgnB3hzxPSM+vDFqBFWg6X 7X4CERZvbl2qfjAvUJjMWP6wsrvzJUhw X-Google-Smtp-Source: AOwi7QAASdoon09da94rxuKIkpOjEqe3dl8kvm4j56EzPshxbq70z8r6WgdAyf+LGLO8Iae/Rf9ttG2BU/Y6ACPPItw= X-Received: by 10.202.208.193 with SMTP id j62mr1469042oiy.12.1504843380404; Thu, 07 Sep 2017 21:03:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.143.24 with HTTP; Thu, 7 Sep 2017 21:02:59 -0700 (PDT) From: david moheban Date: Fri, 8 Sep 2017 00:02:59 -0400 Message-ID: To: edk2-devel@lists.01.org X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: WARNING: No source level debug X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 04:00:10 -0000 Content-Type: text/plain; charset="UTF-8" Hi, Was having trouble getting the debug messages to show in the debug log list in the developer window that launches the simulated shell window. I started out following the driver building edk2 lab pdf instructions in building one of the test drivers. In the lab they have you enter the debug macro such as "DEBUG (L"[mydriver] Feature unsupported\r\n") and when the Nt32Pkg is compiled by issuing build and thus 'build run' that Debug message shows up in the developer window and message logs. Later I tried my hand at making another driver and compiled it like this: 'build -p mdemodulepkg\mdemodulepkg.dsc -m mydriver\mydriver.inf'. Next I tried to issue a 'build run -p mdemodulepkg\mdemodulepkg.dsc' and at first failed to run secmain vm until I copied the secmain utility manually to the mdemodule build directory and then that worked. The problem I noticed was that those 'Debug' messages werent going through with MdeModulePkg and were just appearing on the shell window as if you typed 'Print'. At first I thought maybe it was my driver code or the Inf file or header file was missing something but running 'build -p nt32pkg' allowed all my Debug macro messages to appear on the developer window debug logs and I didn't get this 'Warning: No source level debug' error message in the logs. Also I added to [PCDfixedAtBuild] gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000040. This only allowed debug messages showing up in the shell and not in the other developer window logs as it should be. Heres my driver code though the fault is not with the code as it works when compiled against Nt32Pkg: Inf File: [Defines] INF_VERSION = 0x00010005 BASE_NAME = EmptyDriver FILE_GUID = 785a3ef0-9016-11e7-a9b3-acd1b8bf61e6 MODULE_TYPE = UEFI_DRIVER VERSION_STRING = 1.0 ENTRY_POINT = EmptyDriverDriverEntryPoint UNLOAD_IMAGE = EmptyDriverUnload UEFI_HII_RESOURCE_SECTION = TRUE [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec #IntelFrameworkPkg/IntelFrameworkPkg.dec #IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec [Sources] EmptyDriver.h EmptyDriver.c ComponentName.c ComponentName.h SimpleTextOutput.c SimpleTextOutput.h [LibraryClasses] UefiDriverEntryPoint UefiBootServicesTableLib MemoryAllocationLib BaseMemoryLib BaseLib UefiLib DevicePathLib DebugLib [Protocols] gEfiDriverBindingProtocolGuid gEfiPciIoProtocolGuid gEfiDriverSupportedEfiVersionProtocolGuid gEfiHiiPackageListProtocolGuid gEfiHiiDatabaseProtocolGuid gEfiComponentName2ProtocolGuid gEfiComponentNameProtocolGuid gEfiHiiConfigAccessProtocolGuid gEfiSimpleTextOutProtocolGuid gEfiSerialIoProtocolGuid gEfiSimpleTextInputExProtocolGuid [Guids] [Depex] AFTER gFvSimpleFileSystemDxeGuid Header File: #ifndef __EFI_EMPTY_DRIVER_H__ #define __EFI_EMPTY_DRIVER_H__ #include // // Libraries // #include #include #include #include #include #include #include #include // // UEFI Driver Model Protocols // #include #include #include #include #include #include #include #include // // Consumed Protocols // #include #include // // Produced Protocols // #include #include // // Guids // // // Driver Version // #define EMPTY_DRIVER_VERSION 0x00000000 // // Protocol instances // extern EFI_DRIVER_BINDING_PROTOCOL gEmptyDriverDriverBinding; extern EFI_COMPONENT_NAME2_PROTOCOL gEmptyDriverComponentName2; extern EFI_COMPONENT_NAME_PROTOCOL gEmptyDriverComponentName; // // Include files with function prototypes // #include "DriverBinding.h" #include "ComponentName.h" #include "SimpleTextOutput.h" #endif driver.C file: **/ #include "EmptyDriver.h" static CHAR16* FileMemPath = L"\\file.efi"; EFI_HANDLE MainImageHandle = NULL; #define SafeFree(p) do { FreePool(p); p = NULL;} while(0) /// /// Driver Support EFI Version Protocol instance /// GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gEmptyDriverDriverSupportedEfiVersion = { sizeof (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL), 0x0002001E }; /// /// Driver Binding Protocol instance /// EFI_DRIVER_BINDING_PROTOCOL gEmptyDriverDriverBinding = { EmptyDriverDriverBindingSupported, EmptyDriverDriverBindingStart, EmptyDriverDriverBindingStop, EMPTY_DRIVER_VERSION, NULL, NULL }; /** Unloads an image. @param ImageHandle Handle that identifies the image to be unloaded. @retval EFI_SUCCESS The image has been unloaded. @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. **/ EFI_STATUS EFIAPI EmptyDriverUnload ( IN EFI_HANDLE ImageHandle ) { EFI_STATUS Status; EFI_HANDLE *HandleBuffer; UINTN HandleCount; UINTN Index; Status = EFI_SUCCESS; // // Retrieve array of all handles in the handle database // Status = gBS->LocateHandleBuffer ( AllHandles, NULL, NULL, &HandleCount, &HandleBuffer ); if (EFI_ERROR (Status)) { return Status; } // // Disconnect the current driver from handles in the handle database // for (Index = 0; Index < HandleCount; Index++) { Status = gBS->DisconnectController (HandleBuffer[Index], gImageHandle, NULL); } // // Free the array of handles // FreePool (HandleBuffer); // // Uninstall protocols installed in the driver entry point // Status = gBS->UninstallMultipleProtocolInterfaces ( ImageHandle, &gEfiDriverBindingProtocolGuid, &gEmptyDriverDriverBinding, &gEfiComponentNameProtocolGuid, &gEmptyDriverComponentName, &gEfiComponentName2ProtocolGuid, &gEmptyDriverComponentName2, NULL ); if (EFI_ERROR (Status)) { return Status; } // // Uninstall Driver Supported EFI Version Protocol onto ImageHandle // Status = gBS->UninstallMultipleProtocolInterfaces ( ImageHandle, &gEfiDriverSupportedEfiVersionProtocolGuid, &gEmptyDriverDriverSupportedEfiVersion, NULL ); if (EFI_ERROR (Status)) { return Status; } // // Do any additional cleanup that is required for this driver // return EFI_SUCCESS; } /** This is the declaration of an EFI image entry point. This entry point is the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including both device drivers and bus drivers. @param ImageHandle The firmware allocated handle for the UEFI image. @param SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The operation completed successfully. @retval Others An unexpected error occurred. **/ EFI_STATUS EFIAPI EmptyDriverDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { //#pragma warning(disable:4101) // #pragma warning(disable:4189) EFI_DEVICE_PATH *DevicePath; EFI_HANDLE DriverHandle, *Handles = NULL; UINTN HandleCount = 0, Index = 0; EFI_GUID gsguid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* Volume; EFI_FILE_HANDLE Root; CHAR16 *DeviceStr = NULL; //EFI_BOOT_SERVICES *BS = NULL; DEBUG ((EFI_D_INFO, "[EmptyDriver] About to start empty driver \r\n") ); EFI_STATUS Status; //BS = SystemTable->BootServices; MainImageHandle = ImageHandle; Status = EFI_SUCCESS; // // Install UEFI Driver Model protocol(s). // Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gEmptyDriverDriverBinding, ImageHandle, &gEmptyDriverComponentName, &gEmptyDriverComponentName2 ); ASSERT_EFI_ERROR (Status); // // Install Driver Supported EFI Version Protocol onto ImageHandle // Status = gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, &gEfiDriverSupportedEfiVersionProtocolGuid, &gEmptyDriverDriverSupportedEfiVersion, NULL ); ASSERT_EFI_ERROR (Status); Status = gBS->LocateHandleBuffer(ByProtocol, &gsguid, NULL, &HandleCount, &Handles); ASSERT_EFI_ERROR (Status); for (Index = 0; Index < HandleCount; Index++) { // Note: The Device Path obtained from DevicePathFromHandle() should NOT be freed! DevicePath = DevicePathFromHandle(Handles[Index]); DeviceStr = ConvertDevicePathToText(DevicePath, FALSE, FALSE); //DeviceStr = DevicePathToStr(DevicePath); if (DevicePathSubType(DevicePath) != HW_MEMMAP_DP) { continue; } else { break; } } DEBUG ((EFI_D_ERROR, "About to load file \r\n") ); /* if (Index >= HandleCount) { Status = EFI_NOT_FOUND; goto out; } */ Status = gBS->LocateHandleBuffer(ByProtocol, &gsguid, NULL, &HandleCount, &Handles); if (EFI_ERROR(Status)) { goto out; } Status = gBS->HandleProtocol( Handles[1], &gsguid, (void**)&Volume); Root = NULL; Status = Volume->OpenVolume(Volume, &Root); if ((EFI_ERROR(Status)) || (Root == NULL)) { goto out; } DevicePath = FileDevicePath(Handles[1], FileMemPath); if (DevicePath == NULL) { Status = EFI_DEVICE_ERROR; goto out; } Status = gBS->LoadImage(FALSE, ImageHandle, DevicePath, NULL, 0, &DriverHandle); SafeFree(DevicePath); if (EFI_ERROR(Status)) { goto out; } Status = gBS->StartImage(DriverHandle, NULL, NULL); if (EFI_ERROR(Status)) { goto out; } out: SafeFree(Handles); return Status; } /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. This function checks to see if the driver specified by This supports the device specified by ControllerHandle. Drivers will typically use the device path attached to ControllerHandle and/or the services from the bus I/O abstraction attached to ControllerHandle to determine if the driver supports ControllerHandle. This function may be called many times during platform initialization. In order to reduce boot times, the tests performed by this function must be very small, and take as little time as possible to execute. This function must not change the state of any hardware devices, and this function must be aware that the device specified by ControllerHandle may already be managed by the same driver or a different driver. This function must match its calls to AllocatePages() with FreePages(), AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). Because ControllerHandle may have been previously started by the same driver, if a protocol is already in the opened state, then it must not be closed with CloseProtocol(). This is required to guarantee the state of ControllerHandle is not modified by this function. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param[in] ControllerHandle The handle of the controller to test. This handle must support a protocol interface that supplies an I/O abstraction to the driver. @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For bus drivers, if this parameter is not NULL, then the bus driver must determine if the bus controller specified by ControllerHandle and the child controller specified by RemainingDevicePath are both supported by this bus driver. @retval EFI_SUCCESS The device specified by ControllerHandle and RemainingDevicePath is supported by the driver specified by This. @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and RemainingDevicePath is already being managed by the driver specified by This. @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and RemainingDevicePath is already being managed by a different driver or an application that requires exclusive access. Currently not implemented. @retval EFI_UNSUPPORTED The device specified by ControllerHandle and RemainingDevicePath is not supported by the driver specified by This. **/ EFI_STATUS EFIAPI EmptyDriverDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { EFI_STATUS Status; EFI_SERIAL_IO_PROTOCOL *SerialIo; Status = gBS->OpenProtocol ( ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **) &SerialIo, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE ); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_INFO, "[EmptyDriver] Not Supported \r\n") ); return Status; // Bail out if OpenProtocol returns an error } // We're here because OpenProtocol was a success, so clean up gBS->CloseProtocol ( ControllerHandle, &gEfiSerialIoProtocolGuid, This->DriverBindingHandle, ControllerHandle ); DEBUG ((EFI_D_INFO,"[MyWizardDriver] Supported SUCCESS\r\n") ); return EFI_SUCCESS; //return EFI_UNSUPPORTED; } /** Starts a device controller or a bus controller. The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic. 1. ControllerHandle must be a valid EFI_HANDLE. 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned EFI_DEVICE_PATH_PROTOCOL. 3. Prior to calling Start(), the Supported() function for the driver specified by This must have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param[in] ControllerHandle The handle of the controller to start. This handle must support a protocol interface that supplies an I/O abstraction to the driver. @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For a bus driver, if this parameter is NULL, then handles for all the children of Controller are created by this driver. If this parameter is not NULL and the first Device Path Node is not the End of Device Path Node, then only the handle for the child device specified by the first Device Path Node of RemainingDevicePath is created by this driver. If the first Device Path Node of RemainingDevicePath is the End of Device Path Node, no child handle is created by this driver. @retval EFI_SUCCESS The device was started. @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. @retval Others The driver failded to start the device. **/ EFI_STATUS EFIAPI EmptyDriverDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { return EFI_UNSUPPORTED; } /** Stops a device controller or a bus controller. The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). As a result, much of the error checking on the parameters to Stop() has been moved into this common boot service. It is legal to call Stop() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic. 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this same driver's Start() function. 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid EFI_HANDLE. In addition, all of these handles must have been created in this driver's Start() function, and the Start() function must have called OpenProtocol() on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param[in] ControllerHandle A handle to the device being stopped. The handle must support a bus specific I/O protocol for the driver to use to stop the device. @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL if NumberOfChildren is 0. @retval EFI_SUCCESS The device was stopped. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. **/ EFI_STATUS EFIAPI EmptyDriverDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { return EFI_UNSUPPORTED; }