Interfaces to register resources

Change-Id: Ic587aaa5a41e4e7648211cfa730a0aa5bbc2985a
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-09-14 13:28:47 +02:00
committed by sys_ocldev
parent 9981cdd9e2
commit d363448515
23 changed files with 392 additions and 4 deletions

View File

@@ -65,6 +65,8 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
sba.BindlessSurfaceStateBaseAddress != 0;
}
MOCKABLE_VIRTUAL void registerResourceClasses();
NEO::Device *device = nullptr;
NEO::GraphicsAllocation *sbaAllocation = nullptr;
std::unordered_map<uint32_t, NEO::GraphicsAllocation *> perContextSbaAllocations;

View File

@@ -0,0 +1,14 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_DEBUGGER_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_linux.cpp
)
if(UNIX)
set_property(GLOBAL PROPERTY L0_SRCS_DEBUGGER_LINUX ${L0_SRCS_DEBUGGER_LINUX})
endif()

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/device/device.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "level_zero/core/source/debugger/debugger_l0.h"
namespace L0 {
void DebuggerL0::registerResourceClasses() {
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
auto drm = device->getRootDeviceEnvironment().osInterface->get()->getDrm();
drm->registerResourceClasses();
}
}
} // namespace L0

View File

@@ -0,0 +1,14 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_DEBUGGER_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_windows.cpp
)
if(WIN32)
set_property(GLOBAL PROPERTY L0_SRCS_DEBUGGER_WINDOWS ${L0_SRCS_DEBUGGER_WINDOWS})
endif()

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/device/device.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "level_zero/core/source/debugger/debugger_l0.h"
namespace L0 {
void DebuggerL0::registerResourceClasses() {
}
} // namespace L0

View File

@@ -9,7 +9,9 @@
namespace L0 {
std::unique_ptr<NEO::Debugger> DebuggerL0::create(NEO::Device *device) {
return std::unique_ptr<DebuggerL0>(debuggerL0Factory[device->getHardwareInfo().platform.eRenderCoreFamily](device));
auto debugger = debuggerL0Factory[device->getHardwareInfo().platform.eRenderCoreFamily](device);
debugger->registerResourceClasses();
return std::unique_ptr<DebuggerL0>(debugger);
}
} // namespace L0

View File

@@ -15,7 +15,9 @@ DebugerL0CreateFn mockDebuggerL0HwFactory[IGFX_MAX_CORE];
namespace L0 {
std::unique_ptr<NEO::Debugger> DebuggerL0::create(NEO::Device *device) {
return std::unique_ptr<DebuggerL0>(ult::mockDebuggerL0HwFactory[device->getHardwareInfo().platform.eRenderCoreFamily](device));
auto debugger = ult::mockDebuggerL0HwFactory[device->getHardwareInfo().platform.eRenderCoreFamily](device);
debugger->registerResourceClasses();
return std::unique_ptr<DebuggerL0>(debugger);
}
} // namespace L0

View File

@@ -5,14 +5,54 @@
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
#include "test.h"
#include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h"
using namespace NEO;
namespace L0 {
namespace ult {
using L0DebuggerLinuxTest = Test<L0DebuggerFixture>;
struct L0DebuggerLinuxFixture {
void SetUp() {
auto executionEnvironment = new NEO::ExecutionEnvironment();
auto mockBuiltIns = new MockBuiltins();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
executionEnvironment->initializeMemoryManager();
auto osInterface = new OSInterface();
drmMock = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface);
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setDrm(static_cast<Drm *>(drmMock));
neoDevice = NEO::MockDevice::create<NEO::MockDevice>(executionEnvironment, 0u);
NEO::DeviceVector devices;
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
driverHandle->enableProgramDebugging = true;
driverHandle->initialize(std::move(devices));
device = driverHandle->devices[0];
}
void TearDown() {
}
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
NEO::MockDevice *neoDevice = nullptr;
L0::Device *device = nullptr;
DrmMockResources *drmMock = nullptr;
};
using L0DebuggerLinuxTest = Test<L0DebuggerLinuxFixture>;
TEST_F(L0DebuggerLinuxTest, givenProgramDebuggingEnabledWhenDriverHandleIsCreatedThenItAllocatesL0Debugger) {
EXPECT_NE(nullptr, neoDevice->getDebugger());
@@ -21,5 +61,11 @@ TEST_F(L0DebuggerLinuxTest, givenProgramDebuggingEnabledWhenDriverHandleIsCreate
EXPECT_EQ(nullptr, neoDevice->getSourceLevelDebugger());
}
TEST_F(L0DebuggerLinuxTest, whenDebuggerIsCreatedThenItCallsDrmToRegisterResourceClasses) {
EXPECT_NE(nullptr, neoDevice->getDebugger());
EXPECT_TRUE(drmMock->registerClassesCalled);
}
} // namespace ult
} // namespace L0

View File

@@ -13,6 +13,7 @@ namespace NEO {
class MockBufferObject : public BufferObject {
public:
using BufferObject::bindExtHandles;
using BufferObject::bindInfo;
using BufferObject::BufferObject;
using BufferObject::handle;

View File

@@ -16,6 +16,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_mm_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_mapper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_engine_info_tests.cpp

View File

@@ -329,3 +329,30 @@ TEST(DrmBufferObject, givenPerContextVmRequiredWhenBoBoundAndUnboundThenCorrectB
bo.unbind(osContext, 0);
EXPECT_FALSE(bo.bindInfo[contextId][0]);
}
TEST(DrmBufferObject, whenBindExtHandleAddedThenItIsStored) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
MockBufferObject bo(&drm, 0, 0, 1);
bo.addBindExtHandle(4);
EXPECT_EQ(1u, bo.bindExtHandles.size());
EXPECT_EQ(4u, bo.bindExtHandles[0]);
}
TEST(DrmBufferObject, givenBoWithBindExtHandlesWhenBoIsDestructedThenHandlesAreUnregistered) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
{
MockBufferObject bo(&drm, 0, 0, 1);
bo.addBindExtHandle(4);
bo.addBindExtHandle(5);
bo.addBindExtHandle(6);
}
EXPECT_EQ(6u, drm.unregisteredHandle);
EXPECT_EQ(3u, drm.unregisterCalledCount);
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_neo.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(DrmTest, whenRegisterResourceClassesCalledThenFalseIsReturned) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
auto result = drmMock.registerResourceClasses();
EXPECT_FALSE(result);
}
TEST(DrmTest, whenResourceClassIsUsedToIndexClassNamesThenCorrectNamesAreReturned) {
EXPECT_STREQ(Drm::classNames[static_cast<uint32_t>(Drm::ResourceClass::Elf)], "I915_CLASS_ELF_FILE");
EXPECT_STREQ(Drm::classNames[static_cast<uint32_t>(Drm::ResourceClass::Isa)], "I915_CLASS_ISA");
EXPECT_STREQ(Drm::classNames[static_cast<uint32_t>(Drm::ResourceClass::ContextSaveArea)], "I915_CLASS_CONTEXT_SAVE_AREA");
EXPECT_STREQ(Drm::classNames[static_cast<uint32_t>(Drm::ResourceClass::ModuleHeapDebugArea)], "I915_CLASS_MODULE_HEAP_DEBUG_AREA");
EXPECT_STREQ(Drm::classNames[static_cast<uint32_t>(Drm::ResourceClass::SbaTrackingBuffer)], "I915_CLASS_SBA_TRACKING_BUFFER");
}
TEST(DrmTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
auto handle = drmMock.registerResource(Drm::ResourceClass::MaxSize, nullptr, 0);
EXPECT_EQ(0u, handle);
drmMock.unregisterResource(handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}

View File

@@ -33,11 +33,13 @@
#include "opencl/source/mem_obj/image.h"
#include "opencl/source/os_interface/linux/drm_command_stream.h"
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
#include "opencl/test/unit_test/mocks/linux/mock_drm_allocation.h"
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_gfx_partition.h"
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
#include "test.h"
#include "drm/i915_drm.h"
@@ -3803,4 +3805,69 @@ TEST(DrmMemoryMangerTest, givenMultipleRootDeviceWhenMemoryManagerGetsDrmThenDrm
}
EXPECT_EQ(CommonConstants::unspecifiedDeviceIndex, drmMemoryManager.getRootDeviceIndex(nullptr));
}
TEST(DrmAllocationTest, givenResourceRegistrationEnabledWhenAllocationTypeShouldBeRegisteredThenBoHasBindExtHandleAdded) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
drm.classHandles.push_back(i);
}
{
MockBufferObject bo(&drm, 0, 0, 1);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA, MemoryPool::System4KBPages);
allocation.bufferObjects[0] = &bo;
allocation.registerBOBindExtHandle(&drm);
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
EXPECT_EQ(Drm::ResourceClass::ContextSaveArea, drm.registeredClass);
}
drm.registeredClass = Drm::ResourceClass::MaxSize;
{
MockBufferObject bo(&drm, 0, 0, 1);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER, MemoryPool::System4KBPages);
allocation.bufferObjects[0] = &bo;
allocation.registerBOBindExtHandle(&drm);
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
EXPECT_EQ(Drm::ResourceClass::SbaTrackingBuffer, drm.registeredClass);
}
drm.registeredClass = Drm::ResourceClass::MaxSize;
{
MockBufferObject bo(&drm, 0, 0, 1);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::KERNEL_ISA, MemoryPool::System4KBPages);
allocation.bufferObjects[0] = &bo;
allocation.registerBOBindExtHandle(&drm);
EXPECT_EQ(DrmMockResources::registerResourceReturnHandle, bo.bindExtHandles[0]);
EXPECT_EQ(Drm::ResourceClass::Isa, drm.registeredClass);
}
drm.registeredClass = Drm::ResourceClass::MaxSize;
{
MockBufferObject bo(&drm, 0, 0, 1);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, MemoryPool::System4KBPages);
allocation.bufferObjects[0] = &bo;
allocation.registerBOBindExtHandle(&drm);
EXPECT_EQ(0u, bo.bindExtHandles.size());
EXPECT_EQ(Drm::ResourceClass::MaxSize, drm.registeredClass);
}
}
TEST(DrmAllocationTest, givenResourceRegistrationNotEnabledWhenRegisteringBindExtHandleThenHandleIsNotAddedToBo) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMockResources drm(*executionEnvironment->rootDeviceEnvironments[0]);
EXPECT_EQ(0u, drm.classHandles.size());
MockBufferObject bo(&drm, 0, 0, 1);
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA, MemoryPool::System4KBPages);
allocation.bufferObjects[0] = &bo;
allocation.registerBOBindExtHandle(&drm);
EXPECT_EQ(0u, bo.bindExtHandles.size());
EXPECT_EQ(Drm::ResourceClass::MaxSize, drm.registeredClass);
}
} // namespace NEO

View File

@@ -13,6 +13,7 @@
#include <cstring>
const int DrmMock::mockFd;
const uint32_t DrmMockResources::registerResourceReturnHandle = 3;
int DrmMock::ioctl(unsigned long request, void *arg) {
ioctlCallsCount++;

View File

@@ -29,6 +29,7 @@ using namespace NEO;
class DrmMock : public Drm {
public:
using Drm::checkQueueSliceSupport;
using Drm::classHandles;
using Drm::engineInfo;
using Drm::generateUUID;
using Drm::getQueueSliceCount;
@@ -199,3 +200,30 @@ class DrmMockEngine : public DrmMock {
}
}
};
class DrmMockResources : public DrmMock {
public:
using DrmMock::DrmMock;
bool registerResourceClasses() override {
registerClassesCalled = true;
return true;
}
uint32_t registerResource(ResourceClass classType, void *data, size_t size) override {
registeredClass = classType;
return registerResourceReturnHandle;
}
void unregisterResource(uint32_t handle) override {
unregisterCalledCount++;
unregisteredHandle = handle;
}
static const uint32_t registerResourceReturnHandle;
uint32_t unregisteredHandle = 0;
uint32_t unregisterCalledCount = 0;
ResourceClass registeredClass = ResourceClass::MaxSize;
bool registerClassesCalled = false;
};

View File

@@ -15,6 +15,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_buffer_object_extended.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager.cpp

View File

@@ -65,4 +65,36 @@ void DrmAllocation::bindBO(BufferObject *bo, OsContext *osContext, uint32_t vmHa
}
}
void DrmAllocation::registerBOBindExtHandle(Drm *drm) {
if (!drm->resourceRegistrationEnabled()) {
return;
}
Drm::ResourceClass resourceClass = Drm::ResourceClass::MaxSize;
switch (this->allocationType) {
case GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA:
resourceClass = Drm::ResourceClass::ContextSaveArea;
break;
case GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER:
resourceClass = Drm::ResourceClass::SbaTrackingBuffer;
break;
case GraphicsAllocation::AllocationType::KERNEL_ISA:
resourceClass = Drm::ResourceClass::Isa;
break;
default:
break;
}
if (resourceClass != Drm::ResourceClass::MaxSize) {
uint64_t gpuAddress = getGpuAddress();
auto handle = drm->registerResource(resourceClass, &gpuAddress, sizeof(gpuAddress));
auto &bos = getBOs();
for (auto bo : bos) {
bo->addBindExtHandle(handle);
}
}
}
} // namespace NEO

View File

@@ -12,6 +12,7 @@
namespace NEO {
class BufferObject;
class OsContext;
class Drm;
struct OsHandle {
BufferObject *bo = nullptr;
@@ -65,6 +66,7 @@ class DrmAllocation : public GraphicsAllocation {
void makeBOsResident(OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
void bindBO(BufferObject *bo, OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
void bindBOs(OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
void registerBOBindExtHandle(Drm *drm);
protected:
BufferObjects bufferObjects{};

View File

@@ -47,6 +47,12 @@ BufferObject::BufferObject(Drm *drm, int handle, size_t size, size_t maxOsContex
}
}
BufferObject::~BufferObject() {
for (auto &i : bindExtHandles) {
drm->unregisterResource(i);
}
};
uint32_t BufferObject::getRefCount() const {
return this->refCount.load();
}
@@ -200,4 +206,8 @@ int BufferObject::pin(BufferObject *const boToPin[], size_t numberOfBos, OsConte
return this->exec(4u, 0u, 0u, false, osContext, vmHandleId, drmContextId, boToPin, numberOfBos, &execObject[0]);
}
void BufferObject::addBindExtHandle(uint32_t handle) {
bindExtHandles.push_back(handle);
}
} // namespace NEO

View File

@@ -7,6 +7,8 @@
#pragma once
#include "shared/source/utilities/stackvec.h"
#include "drm/i915_drm.h"
#include "engine_limits.h"
@@ -30,7 +32,7 @@ class BufferObject {
public:
BufferObject(Drm *drm, int handle, size_t size, size_t maxOsContextCount);
MOCKABLE_VIRTUAL ~BufferObject(){};
MOCKABLE_VIRTUAL ~BufferObject();
struct Deleter {
void operator()(BufferObject *bo) {
@@ -67,6 +69,7 @@ class BufferObject {
void setUnmapSize(uint64_t unmapSize) { this->unmapSize = unmapSize; }
uint64_t peekUnmapSize() const { return unmapSize; }
bool peekIsReusableAllocation() const { return this->isReused; }
void addBindExtHandle(uint32_t handle);
protected:
Drm *drm = nullptr;
@@ -90,5 +93,6 @@ class BufferObject {
uint64_t unmapSize = 0;
std::vector<std::array<bool, EngineLimits::maxHandleCount>> bindInfo;
StackVec<uint32_t, 2> bindExtHandles;
};
} // namespace NEO

View File

@@ -0,0 +1,21 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "drm_neo.h"
namespace NEO {
bool Drm::registerResourceClasses() {
return false;
}
uint32_t Drm::registerResource(ResourceClass classType, void *data, size_t size) {
return 0;
}
void Drm::unregisterResource(uint32_t handle) {
}
} // namespace NEO

View File

@@ -56,6 +56,12 @@ constexpr const char *getIoctlParamString(int param) {
} // namespace IoctlHelper
const std::array<const char *, size_t(Drm::ResourceClass::MaxSize)> Drm::classNames = {"I915_CLASS_ELF_FILE",
"I915_CLASS_ISA",
"I915_CLASS_MODULE_HEAP_DEBUG_AREA",
"I915_CLASS_CONTEXT_SAVE_AREA",
"I915_CLASS_SBA_TRACKING_BUFFER"};
Drm::Drm(std::unique_ptr<HwDeviceId> hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment) : hwDeviceId(std::move(hwDeviceIdIn)), rootDeviceEnvironment(rootDeviceEnvironment) {
requirePerContextVM = rootDeviceEnvironment.executionEnvironment.isPerContextMemorySpaceRequired();
}

View File

@@ -11,11 +11,13 @@
#include "shared/source/os_interface/linux/hw_device_id.h"
#include "shared/source/os_interface/linux/memory_info.h"
#include "shared/source/utilities/api_intercept.h"
#include "shared/source/utilities/stackvec.h"
#include "drm/i915_drm.h"
#include "engine_node.h"
#include "igfxfmid.h"
#include <array>
#include <cerrno>
#include <fcntl.h>
#include <memory>
@@ -48,6 +50,16 @@ class Drm {
friend DeviceFactory;
public:
enum class ResourceClass : uint32_t {
Elf,
Isa,
ModuleHeapDebugArea,
ContextSaveArea,
SbaTrackingBuffer,
MaxSize
};
static const std::array<const char *, size_t(ResourceClass::MaxSize)> classNames;
virtual ~Drm();
virtual int ioctl(unsigned long request, void *arg);
@@ -100,6 +112,11 @@ class Drm {
return requirePerContextVM;
}
MOCKABLE_VIRTUAL bool registerResourceClasses();
MOCKABLE_VIRTUAL uint32_t registerResource(ResourceClass classType, void *data, size_t size);
MOCKABLE_VIRTUAL void unregisterResource(uint32_t handle);
MemoryInfo *getMemoryInfo() const {
return memoryInfo.get();
}
@@ -111,6 +128,10 @@ class Drm {
return rootDeviceEnvironment;
}
bool resourceRegistrationEnabled() {
return classHandles.size() > 0;
}
static inline uint32_t createMemoryRegionId(uint16_t type, uint16_t instance) {
return (1u << (type + 16)) | (1u << instance);
}
@@ -144,6 +165,8 @@ class Drm {
std::string getSysFsPciPath();
std::unique_ptr<uint8_t[]> query(uint32_t queryId, int32_t &length);
StackVec<uint32_t, size_t(ResourceClass::MaxSize)> classHandles;
#pragma pack(1)
struct PCIConfig {
uint16_t VendorID;