Example #1
0
BOOL
CNdasUnitDiskDevice::HasSameDIBInfo()
{
	CNdasUnitDeviceCreator udCreator(GetParentDevice(), GetUnitNo());

	CNdasUnitDevicePtr pUnitDeviceNow( udCreator.CreateUnitDevice() );

	if (CNdasUnitDeviceNullPtr== pUnitDeviceNow) 
	{
		return FALSE;
	}

	if (GetType() != pUnitDeviceNow->GetType()) 
	{
		return FALSE;
	}

	CNdasUnitDiskDevice* pUnitDiskDeviceNow = 
		reinterpret_cast<CNdasUnitDiskDevice*>(pUnitDeviceNow.get());

	if (!HasSameDIBInfo(*pUnitDiskDeviceNow)) 
	{
		return FALSE;
	}

	return TRUE;
}
Example #2
0
BOOL
CNdasUnitDiskDevice::HasSameDIBInfo()
{
	CNdasUnitDeviceCreator udCreator(*GetParentDevice(), GetUnitNo());

	CNdasUnitDevice* pUnitDeviceNow = udCreator.CreateUnitDevice();

	if(NULL == pUnitDeviceNow) {
		return FALSE;
	}

	if (GetType() != pUnitDeviceNow->GetType()) {
		delete pUnitDeviceNow;
		return FALSE;
	}

	CNdasUnitDiskDevice* pUnitDiskDeviceNow = 
		reinterpret_cast<CNdasUnitDiskDevice*>(pUnitDeviceNow);

	if(!HasSameDIBInfo(*pUnitDiskDeviceNow)) {
		delete pUnitDeviceNow;
		return FALSE;
	}

	delete pUnitDeviceNow;
	return TRUE;
}
Example #3
0
VOID DisplayEntries(EFI_DEVICE_PATH *ldr, UINTN slice, UINTN index, VOID *ctx) {
    EFI_DEVICE_PATH *pDevice = GetParentDevice(ldr);
    CHAR16 *pszDevice = DevicePathToStr(GetLastDevicePath(pDevice));
    Print(L"[%d] %s\n", index - slice + 1, pszDevice);
    FreePool(pszDevice);
    FreePool(pDevice);
}
void FD3D12BuddyAllocator::Initialize()
{
	FD3D12Device* Device = GetParentDevice();
	FD3D12Adapter* Adapter = Device->GetParentAdapter();

	if (AllocationStrategy == eBuddyAllocationStrategy::kPlacedResourceStrategy)
	{
		D3D12_HEAP_PROPERTIES HeapProps = CD3DX12_HEAP_PROPERTIES(HeapType);
		HeapProps.CreationNodeMask = GetNodeMask();
		HeapProps.VisibleNodeMask = GetVisibilityMask();

		D3D12_HEAP_DESC Desc = {};
		Desc.SizeInBytes = MaxBlockSize;
		Desc.Properties = HeapProps;
		Desc.Alignment = 0;
		Desc.Flags = HeapFlags;

		ID3D12Heap* Heap = nullptr;
		VERIFYD3D12RESULT(Adapter->GetD3DDevice()->CreateHeap(&Desc, IID_PPV_ARGS(&Heap)));
		SetName(Heap, L"Placed Resource Allocator Backing Heap");

		BackingHeap = new FD3D12Heap(GetParentDevice(), GetVisibilityMask());
		BackingHeap->SetHeap(Heap);

		if (IsCPUWritable(HeapType) == false)
		{
			BackingHeap->BeginTrackingResidency(Desc.SizeInBytes);
		}
	}
	else
	{
		VERIFYD3D12RESULT(Adapter->CreateBuffer(HeapType, GetNodeMask(), GetVisibilityMask(), MaxBlockSize, BackingResource.GetInitReference(), ResourceFlags));
		SetName(BackingResource, L"Resource Allocator Underlying Buffer");

		if (IsCPUWritable(HeapType))
		{
			BackingResource->Map();
		}
	}
}
Example #5
0
// The enumerated device nodes/instances are "empty" PDO's that act as interfaces for the HID Class
// Driver.
// Since those PDO's normaly don't have a FDO and therefore no driver loaded, we need to move one
// device node up in the device tree.
// Then check the provider of the device driver, which will be "Microsoft" in case of the default
// HID Class Driver
// or "TOSHIBA" in case of the Toshiba Bluetooth Stack, because it provides its own Class Driver.
static bool CheckForToshibaStack(const DEVINST& hid_interface_device_instance)
{
  HDEVINFO parent_device_info = nullptr;
  SP_DEVINFO_DATA parent_device_data = {};
  parent_device_data.cbSize = sizeof(SP_DEVINFO_DATA);

  if (GetParentDevice(hid_interface_device_instance, &parent_device_info, &parent_device_data))
  {
    std::wstring class_driver_provider =
        GetDeviceProperty(parent_device_info, &parent_device_data, &DEVPKEY_Device_DriverProvider);

    SetupDiDestroyDeviceInfoList(parent_device_info);

    return (class_driver_provider == L"TOSHIBA");
  }

  DEBUG_LOG(WIIMOTE, "Unable to detect class driver provider!");

  return false;
}
	void FD3DGPUProfiler::BeginFrame(FD3D12DynamicRHI* InRHI)
	{
		CurrentEventNode = NULL;
		check(!bTrackingEvents);
		check(!CurrentEventNodeFrame); // this should have already been cleaned up and the end of the previous frame

		// latch the bools from the game thread into our private copy
		bLatchedGProfilingGPU = GTriggerGPUProfile;
		bLatchedGProfilingGPUHitches = GTriggerGPUHitchProfile;
		if (bLatchedGProfilingGPUHitches)
		{
			bLatchedGProfilingGPU = false; // we do NOT permit an ordinary GPU profile during hitch profiles
		}

		if (bLatchedGProfilingGPU)
		{
			// Issue a bunch of GPU work at the beginning of the frame, to make sure that we are GPU bound
			// We can't isolate idle time from GPU timestamps
			InRHI->IssueLongGPUTask();
		}

		// if we are starting a hitch profile or this frame is a gpu profile, then save off the state of the draw events
		if (bLatchedGProfilingGPU || (!bPreviousLatchedGProfilingGPUHitches && bLatchedGProfilingGPUHitches))
		{
			bOriginalGEmitDrawEvents = GEmitDrawEvents;
		}

		if (bLatchedGProfilingGPU || bLatchedGProfilingGPUHitches)
		{
			if (bLatchedGProfilingGPUHitches && GPUHitchDebounce)
			{
				// if we are doing hitches and we had a recent hitch, wait to recover
				// the reasoning is that collecting the hitch report may itself hitch the GPU
				GPUHitchDebounce--;
			}
			else
			{
				GEmitDrawEvents = true;  // thwart an attempt to turn this off on the game side
				bTrackingEvents = true;
				CurrentEventNodeFrame = new FD3D12EventNodeFrame(GetParentDevice());
				CurrentEventNodeFrame->StartFrame();
			}
		}
		else if (bPreviousLatchedGProfilingGPUHitches)
		{
			// hitch profiler is turning off, clear history and restore draw events
			GPUHitchEventNodeFrames.Empty();
			GEmitDrawEvents = bOriginalGEmitDrawEvents;
		}
		bPreviousLatchedGProfilingGPUHitches = bLatchedGProfilingGPUHitches;

		// Skip timing events when using SLI, they will not be accurate anyway
		if (GNumActiveGPUsForRendering == 1)
		{
			FrameTiming.StartTiming();
		}

		if (GEmitDrawEvents)
		{
			PushEvent(TEXT("FRAME"), FColor(0, 255, 0, 255));
		}
	}
Example #7
0
str InputElement::GetFullName() const {
	str id = GetIdentifier();
	id = strutil::ReplaceAll(id, ' ', '_');
	id = strutil::ReplaceAll(id, '-', '_');
	return GetParentDevice()->GetUniqueIdentifier() + "." + id;
}
Example #8
0
EFI_STATUS EfiMain(EFI_HANDLE hImage, EFI_SYSTEM_TABLE *pST)
{
    EFI_LOADED_IMAGE *pImage;
    EFI_STATUS nStatus;
    EFI_HANDLE hDriver, *hBlkDevs;
    UINTN nBlkDevs;
    EFI_DEVICE_PATH *pBootPart, *pBootDisk = NULL;

    g_hImage = hImage;
    InitializeLib(hImage, pST);
    Print(L"%H\n*** UEFI:NTFS multiboot ***");

    if (EFI_ERROR((nStatus = BS->OpenProtocol(hImage, &LoadedImageProtocol, &pImage, hImage, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL)))) {
        Print(L"%E\nUnable to convert handle to interface: %r\n", nStatus);
        goto end;
    }

    pBootPart = DevicePathFromHandle(pImage->DeviceHandle);
    pBootDisk = GetParentDevice(pBootPart);

    CHAR16 *pszDev = DevicePathToStr(pBootDisk);
    Print(L"%N\nDisk: %s\n", pszDev);
    FreePool(pszDev);

    Print(L"%H\n[ INFO ] Disconnecting problematic File System drivers\n");
    DisconnectBlockingDrivers();

    Print(L"%H\n[ WAIT ] Loading NTFS driver");
    EFI_DEVICE_PATH *pDrvPath = FileDevicePath(pImage->DeviceHandle, DriverPath);
    if (pDrvPath == NULL) {
        Print(L"%E\r[ FAIL ] Unable to construct path to NTFS driver\n");
        goto end;
    }
    nStatus = BS->LoadImage(FALSE, hImage, pDrvPath, NULL, 0, &hDriver);
    FreePool(pDrvPath);
    if (EFI_ERROR(nStatus)) {
        Print(L"%E\r[ FAIL ] Unable to load NTFS driver: %r\n", nStatus);
        goto end;
    }
    if (EFI_ERROR((nStatus = BS->StartImage(hDriver, NULL, NULL)))) {
        Print(L"%E\r[ FAIL ] Unable to start NTFS driver: %r\n", nStatus);
        goto end;
    }

    Print(L"%H\r[  OK  ] NTFS driver loaded and started\n");

    LINKED_LOADER_PATH_LIST_NODE *list = NULL;
    EFI_DEVICE_PATH *ldr;

    if (EFI_ERROR((nStatus = BS->LocateHandleBuffer(ByProtocol, &BlockIoProtocol, NULL, &nBlkDevs, &hBlkDevs)))) {
        Print(L"%E\r[ FAIL ] Unable to enumerate block devices: %r\n", nStatus);
        goto end;
    }
    for (UINTN i = 0; i < nBlkDevs; i++) {
        EFI_DEVICE_PATH *pDevice = DevicePathFromHandle(hBlkDevs[i]);
        pszDev = DevicePathToStr(pDevice);
        Print(L"%N\r[ INFO ] Probing %d devices... [%d] %s", nBlkDevs, i + 1, pszDev);
        FreePool(pszDev);

        if (CompareDevicePaths(pDevice, pBootPart) == 0) continue;
        if (CompareDevicePaths(pDevice, pBootDisk) == 0) continue;

        EFI_DEVICE_PATH *pDisk = GetParentDevice(pDevice);
        _Bool probe = CompareDevicePaths(pDisk, pBootDisk) == 0;
        FreePool(pDisk);
#if !defined(_DEBUG)
        if (!probe) continue;
#endif

        EFI_BLOCK_IO *blkIo;
        if (EFI_ERROR((nStatus = BS->OpenProtocol(hBlkDevs[i], &BlockIoProtocol, &blkIo, hImage, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL)))) {
            Print(L"%E\n[ WARN ] Unable to open block device, skipping: %r\n", nStatus);
            continue;
        }

        //No media or not a partition.
        if ((blkIo->Media == NULL) || (!blkIo->Media->LogicalPartition))
            continue;

        CHAR8 *buffer = AllocatePool(blkIo->Media->BlockSize);
        if (buffer == NULL) {
            Print(L"%E\n[ WARN ] Unable to allocate buffer of size %d\n", blkIo->Media->BlockSize);
            continue;
        }

        nStatus = blkIo->ReadBlocks(blkIo, blkIo->Media->MediaId, 0, blkIo->Media->BlockSize, buffer);
        _Bool isNTFS = CompareMem(&buffer[3], NTFSMagic, sizeof(NTFSMagic)) == 0;
        FreePool(buffer);
        if (EFI_ERROR(nStatus)) {
            Print(L"%E\n[ WARN ] Unable to read block device, skipping: %r\n", nStatus);
            continue;
        }
        if (!isNTFS) continue;

        Print(L"%H\n[ WAIT ] Attaching NTFS driver to device");
        EFI_FILE_IO_INTERFACE *fs;
        nStatus = BS->OpenProtocol(hBlkDevs[i], &FileSystemProtocol, NULL, hImage, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
        if (nStatus == EFI_UNSUPPORTED) {
            nStatus = BS->ConnectController(hBlkDevs[i], NULL, NULL, TRUE);
        }
        for (UINTN j = 0; j < NUM_RETRIES; j++) {
            if ((!EFI_ERROR((nStatus = BS->OpenProtocol(hBlkDevs[i], &FileSystemProtocol, &fs, hImage, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL))))) {
                break;
            }
            Print(L".");
            BS->Stall(DELAY * 1000000);
        }
        if(EFI_ERROR(nStatus)) {
            Print(L"%E\r[ WARN ] Unable to attach NTFS driver, skipping: %r\n", nStatus);
            continue;
        }
        Print(L"%H\r[  OK  ] NTFS driver attached to current device\n");

        Print(L"%H\r[ WAIT ] Locating EFI boot loader");
        EFI_FILE *fsRoot;
        if (EFI_ERROR((nStatus = fs->OpenVolume(fs, &fsRoot)))) {
            Print(L"%E\r[ WARN ] Unable to open root directory, skipping: %r\n", nStatus);
            continue;
        }
        CHAR16 *loader = StrDuplicate(LoaderPath);
        if (EFI_ERROR((nStatus = SetPathCase(fsRoot, loader)))) {
            FreePool(loader);
            Print(L"%E\r[ WARN ] Unable to locate EFI boot loader on this device: %r\n", nStatus);
            continue;
        }
        Print(L"%H\r[  OK  ] EFI boot loader located at %s\n", loader);

        ldr = FileDevicePath(hBlkDevs[i], loader);
        ListAppend(&list, ldr);
        FreePool(loader);
    }

    UINTN nListEntries = 0, nBootEntry = 0, nPage = 0, nTotalPage = 0;
    EFI_INPUT_KEY key;
    _Bool interactive = FALSE;
    ListTraverse(&list, CountEntries, 0, 0, &nListEntries);

    switch (nListEntries) {
    case 0:
        Print(L"%E\n[ FAIL ] No bootable partition\n", nStatus);
        nStatus = EFI_NOT_FOUND;
        goto end;
    case 1:
        goto boot;
    default:
        nTotalPage = (nListEntries - 1) / PAGE_SIZE + 1;
        while (1) {
            ST->ConOut->ClearScreen(ST->ConOut);
            Print(L"%H*** UEFI:NTFS Multiboot ***\n");
            pszDev = DevicePathToStr(pBootDisk);
            Print(L"%NDisk: %s\n\n%H", pszDev);
            FreePool(pszDev);

            ListTraverse(&list, DisplayEntries, nPage * PAGE_SIZE, PAGE_SIZE, NULL);

            Print(L"%N\nPage %hd / %hd, %hd entries\n", nPage + 1, nTotalPage, nListEntries);
            Print(L"%H\n[F1 - F8] [1 - 8] %N Boot corresponding entry");
            Print(L"%H\n[PgUp]  [<]  [-]  %N Previous page");
            Print(L"%H\n[PgDn]  [>]  [+]  %N Next page");

            if (!interactive) {
                INTN nCountDown = AUTOBOOT_TIME;
                Print(L"%N\n\n");
                while (nCountDown >= 0) {
                    Print(L"\rWill automatically boot the first entry in %d seconds...", nCountDown);
                    if (WaitForSingleEvent(ST->ConIn->WaitForKey, 1000 * 1000 * 10) != EFI_TIMEOUT) {
                        interactive = TRUE;
                        break;
                    }
                    nCountDown--;
                }
                if (!interactive) {
                    goto boot;
                }
            }
            else {
                WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
            }
            ST->ConIn->ReadKeyStroke(ST->ConIn, &key);
            switch (key.UnicodeChar) {
            case L'1':case L'2':case L'3':case L'4':case L'5':case L'6':case L'7':case L'8':
                nBootEntry = nPage * PAGE_SIZE + (key.UnicodeChar - L'1');
                goto boot;
            case L'+':case L'=':case L'>':case L'.':
                if ((nPage + 1) != nTotalPage) {
                    nPage++;
                }
                break;
            case L'-':case L'_': case L'<': case L',':
                if (nPage != 0) {
                    nPage--;
                }
                break;
            default:
                switch (key.ScanCode) {
                case 0x09:
                    if (nPage != 0) {
                        nPage--;
                    }
                    break;
                case 0x0a:
                    if ((nPage + 1) != nTotalPage) {
                        nPage++;
                    }
                    break;
                case 0x0b:case 0x0c:case 0x0d:case 0x0e:case 0x0f:case 0x10:case 0x11:case 0x12:
                    nBootEntry = nPage * PAGE_SIZE + (key.ScanCode - 0x0b);
                    goto boot;
                }
            }
        }
    }

boot:
    ldr = NULL;
    Print(L"%H");
    ST->ConOut->ClearScreen(ST->ConOut);
    ListTraverse(&list, ReadEntry, nBootEntry, 1, &ldr);
    ListTraverse(&list, DisplayEntries, nBootEntry, 1, NULL);
    if (ldr == NULL) {
        Print(L"%E\n[ FAIL ] No such boot entry\n", nStatus);
        nStatus = EFI_NOT_FOUND;
        goto end;
    }

    ldr = DuplicateDevicePath(ldr);
    ListTraverse(&list, DestroyEntries, 0, 0, NULL);
    ListDestroy(&list);

    EFI_HANDLE hChain;
    nStatus = BS->LoadImage(FALSE, hImage, ldr, NULL, 0, &hChain);
    FreePool(ldr);
    if (EFI_ERROR(nStatus)) {
        Print(L"%E\n[ FAIL ] Unable to load boot loader: %r\n", nStatus);
        goto end;
    }
    Print(L"%N");
    if (EFI_ERROR((nStatus = BS->StartImage(hChain, NULL, NULL)))) {
        Print(L"%E\n[ FAIL ] Unable to start boot loader: %r\n", nStatus);
        goto end;
    }

end:
    if (pBootDisk) FreePool(pBootDisk);
    if (EFI_ERROR(nStatus)) {
        Print(L"Press any key to exit\n");
        WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
        ST->ConIn->ReadKeyStroke(ST->ConIn, &key);
    }
    return nStatus;
}