2018-03-05 09:25:40 +01:00
|
|
|
/*
|
2025-01-20 14:17:41 +00:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2018-09-18 09:11:08 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2018-03-05 09:25:40 +01:00
|
|
|
|
2021-01-21 13:10:13 +01:00
|
|
|
#include "shared/test/common/mocks/mock_sip.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2025-11-13 09:16:13 +00:00
|
|
|
#include "shared/source/helpers/string.h"
|
2023-01-04 13:32:37 +00:00
|
|
|
#include "shared/source/memory_manager/memory_allocation.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2025-05-22 09:43:25 +00:00
|
|
|
#include "common/StateSaveAreaHeader.h"
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2025-05-22 09:43:25 +00:00
|
|
|
|
|
|
|
|
static constexpr SIP::StateSaveAreaHeaderV3 mockSipStateSaveAreaHeaderV3 = {
|
|
|
|
|
.versionHeader{
|
|
|
|
|
.magic = "tssarea",
|
|
|
|
|
.reserved1 = 0,
|
|
|
|
|
.version = {3, 0, 0},
|
|
|
|
|
.size = static_cast<uint8_t>(sizeof(SIP::StateSaveArea)),
|
|
|
|
|
.reserved2 = {0, 0, 0}},
|
|
|
|
|
.regHeader{}};
|
|
|
|
|
|
|
|
|
|
MockSipKernel::MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) : SipKernel(type, sipAlloc, {}) {
|
|
|
|
|
this->mockStateSaveAreaHeader.resize(sizeof(mockSipStateSaveAreaHeaderV3));
|
|
|
|
|
memcpy_s(this->mockStateSaveAreaHeader.data(), sizeof(mockSipStateSaveAreaHeaderV3), &mockSipStateSaveAreaHeaderV3, sizeof(mockSipStateSaveAreaHeaderV3));
|
2021-04-16 12:52:30 +00:00
|
|
|
createMockSipAllocation();
|
2019-12-03 15:57:45 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-22 09:43:25 +00:00
|
|
|
MockSipKernel::MockSipKernel() : MockSipKernel(SipKernelType::csr, nullptr) {
|
2019-12-03 15:57:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MockSipKernel::~MockSipKernel() = default;
|
|
|
|
|
|
2021-01-04 11:44:28 +00:00
|
|
|
const char *MockSipKernel::dummyBinaryForSip = "12345678";
|
2020-12-23 14:02:11 +01:00
|
|
|
|
2021-01-04 11:44:28 +00:00
|
|
|
std::vector<char> MockSipKernel::getDummyGenBinary() {
|
|
|
|
|
return std::vector<char>(dummyBinaryForSip, dummyBinaryForSip + sizeof(MockSipKernel::dummyBinaryForSip));
|
2018-03-05 09:25:40 +01:00
|
|
|
}
|
2019-12-03 15:57:45 +01:00
|
|
|
|
|
|
|
|
GraphicsAllocation *MockSipKernel::getSipAllocation() const {
|
2025-01-20 14:17:41 +00:00
|
|
|
if (tempSipMemoryAllocation) {
|
|
|
|
|
return tempSipMemoryAllocation.get();
|
|
|
|
|
}
|
2019-12-03 15:57:45 +01:00
|
|
|
return mockSipMemoryAllocation.get();
|
|
|
|
|
}
|
2021-03-30 19:31:58 -07:00
|
|
|
|
|
|
|
|
const std::vector<char> &MockSipKernel::getStateSaveAreaHeader() const {
|
|
|
|
|
return mockStateSaveAreaHeader;
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
|
|
|
|
|
void MockSipKernel::createMockSipAllocation() {
|
|
|
|
|
this->mockSipMemoryAllocation =
|
|
|
|
|
std::make_unique<MemoryAllocation>(0u,
|
2024-06-18 14:45:50 +00:00
|
|
|
1u /*num gmms*/,
|
2023-12-11 14:24:36 +00:00
|
|
|
AllocationType::kernelIsaInternal,
|
2021-04-16 12:52:30 +00:00
|
|
|
nullptr,
|
|
|
|
|
MemoryConstants::pageSize * 10u,
|
|
|
|
|
0u,
|
|
|
|
|
MemoryConstants::pageSize,
|
2023-12-12 09:11:27 +00:00
|
|
|
MemoryPool::system4KBPages,
|
2024-09-30 15:27:15 +00:00
|
|
|
256u);
|
2021-04-16 12:52:30 +00:00
|
|
|
}
|
2025-01-20 14:17:41 +00:00
|
|
|
void MockSipKernel::createTempSipAllocation(size_t osContextCount) {
|
|
|
|
|
this->tempSipMemoryAllocation =
|
|
|
|
|
std::make_unique<MemoryAllocation>(0u,
|
|
|
|
|
1u /*num gmms*/,
|
|
|
|
|
AllocationType::kernelIsaInternal,
|
|
|
|
|
nullptr,
|
|
|
|
|
MemoryConstants::pageSize * 10u,
|
|
|
|
|
0u,
|
|
|
|
|
MemoryConstants::pageSize,
|
|
|
|
|
MemoryPool::system4KBPages,
|
|
|
|
|
osContextCount);
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2019-12-17 08:11:16 +01:00
|
|
|
} // namespace NEO
|