2020-09-14 19:28:47 +08:00
|
|
|
/*
|
2022-02-10 00:07:36 +08:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2020-09-14 19:28:47 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
#include "shared/source/debugger/debugger_l0.h"
|
2020-10-17 06:52:18 +08:00
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
#include "shared/source/kernel/debug_data.h"
|
2022-05-12 06:36:36 +08:00
|
|
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
2022-07-05 23:54:09 +08:00
|
|
|
#include "shared/source/os_interface/windows/wddm_debug.h"
|
|
|
|
|
|
|
|
#include "KmEscape.h"
|
2020-10-17 06:52:18 +08:00
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
namespace NEO {
|
2020-11-23 22:31:20 +08:00
|
|
|
bool DebuggerL0::initDebuggingInOs(NEO::OSInterface *osInterface) {
|
2022-05-12 06:36:36 +08:00
|
|
|
|
|
|
|
if (osInterface == nullptr) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (osInterface->isDebugAttachAvailable() == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2020-09-14 19:28:47 +08:00
|
|
|
}
|
2020-10-17 06:52:18 +08:00
|
|
|
|
2022-05-28 07:37:00 +08:00
|
|
|
void DebuggerL0::initSbaTrackingMode() {
|
|
|
|
singleAddressSpaceSbaTracking = true;
|
|
|
|
}
|
|
|
|
|
2020-10-17 06:52:18 +08:00
|
|
|
void DebuggerL0::registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation) {
|
|
|
|
}
|
|
|
|
|
2022-02-10 00:07:36 +08:00
|
|
|
bool DebuggerL0::attachZebinModuleToSegmentAllocations(const StackVec<NEO::GraphicsAllocation *, 32> &kernelAlloc, uint32_t &moduleHandle) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DebuggerL0::removeZebinModule(uint32_t moduleHandle) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-05 23:54:09 +08:00
|
|
|
static NTSTATUS runEscape(NEO::Wddm *wddm, KM_ESCAPE_INFO &escapeInfo) {
|
|
|
|
D3DKMT_ESCAPE escapeCommand = {0};
|
|
|
|
|
|
|
|
escapeInfo.Header.EscapeCode = GFX_ESCAPE_KMD;
|
|
|
|
escapeInfo.Header.Size = sizeof(escapeInfo) - sizeof(escapeInfo.Header);
|
|
|
|
escapeInfo.EscapeOperation = KM_ESCAPE_EUDBG_UMD_CREATE_DEBUG_DATA;
|
|
|
|
|
|
|
|
escapeCommand.Flags.HardwareAccess = 0;
|
|
|
|
escapeCommand.Flags.Reserved = 0;
|
|
|
|
escapeCommand.hAdapter = wddm->getAdapter();
|
|
|
|
escapeCommand.hContext = (D3DKMT_HANDLE)0;
|
|
|
|
escapeCommand.hDevice = wddm->getDeviceHandle();
|
|
|
|
escapeCommand.pPrivateDriverData = &escapeInfo;
|
|
|
|
escapeCommand.PrivateDriverDataSize = sizeof(escapeInfo);
|
|
|
|
escapeCommand.Type = D3DKMT_ESCAPE_DRIVERPRIVATE;
|
|
|
|
|
|
|
|
return wddm->escape(escapeCommand);
|
|
|
|
}
|
|
|
|
|
2022-02-10 19:13:59 +08:00
|
|
|
void DebuggerL0::notifyCommandQueueCreated() {
|
2022-07-05 23:54:09 +08:00
|
|
|
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
|
|
|
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
|
|
|
|
if (++commandQueueCount == 1) {
|
|
|
|
auto pWddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Wddm>();
|
|
|
|
int val = 0;
|
|
|
|
KM_ESCAPE_INFO escapeInfo = {0};
|
|
|
|
escapeInfo.KmEuDbgUmdCreateDebugData.DataSize = sizeof(val);
|
|
|
|
escapeInfo.KmEuDbgUmdCreateDebugData.DebugDataType = static_cast<uint32_t>(NEO::DebugDataType::CMD_QUEUE_CREATED);
|
|
|
|
escapeInfo.KmEuDbgUmdCreateDebugData.hElfAddressPtr = reinterpret_cast<uint64_t>(&val);
|
|
|
|
|
|
|
|
runEscape(pWddm, escapeInfo);
|
|
|
|
}
|
|
|
|
}
|
2022-02-10 19:13:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerL0::notifyCommandQueueDestroyed() {
|
2022-07-05 23:54:09 +08:00
|
|
|
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
|
|
|
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
|
|
|
|
if (--commandQueueCount == 0) {
|
|
|
|
auto pWddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Wddm>();
|
|
|
|
int val = 0;
|
|
|
|
KM_ESCAPE_INFO escapeInfo = {0};
|
|
|
|
escapeInfo.KmEuDbgUmdCreateDebugData.DataSize = sizeof(val);
|
|
|
|
escapeInfo.KmEuDbgUmdCreateDebugData.DebugDataType = static_cast<uint32_t>(NEO::DebugDataType::CMD_QUEUE_DESTROYED);
|
|
|
|
escapeInfo.KmEuDbgUmdCreateDebugData.hElfAddressPtr = reinterpret_cast<uint64_t>(&val);
|
|
|
|
|
|
|
|
runEscape(pWddm, escapeInfo);
|
|
|
|
}
|
|
|
|
}
|
2022-02-10 19:13:59 +08:00
|
|
|
}
|
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
} // namespace NEO
|