2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2025-02-18 14:35:36 +00:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2022-08-28 23:20:29 +00:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/built_ins/sip_kernel_type.h"
|
2025-02-18 14:35:36 +00:00
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-08-28 23:20:29 +00:00
|
|
|
#include <string>
|
2020-12-02 10:22:27 +00:00
|
|
|
#include <vector>
|
2022-08-28 23:20:29 +00:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
class Device;
|
2018-03-09 11:52:14 +01:00
|
|
|
class GraphicsAllocation;
|
2021-04-16 12:52:30 +00:00
|
|
|
class MemoryManager;
|
2022-12-15 14:57:31 +00:00
|
|
|
class GfxCoreHelper;
|
2023-03-27 12:03:02 +00:00
|
|
|
class OsContext;
|
2022-08-28 23:20:29 +00:00
|
|
|
|
2021-04-16 12:52:30 +00:00
|
|
|
struct RootDeviceEnvironment;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2025-02-18 14:35:36 +00:00
|
|
|
class SipKernel : NEO::NonCopyableAndNonMovableClass {
|
2017-12-21 00:45:38 +01:00
|
|
|
public:
|
2023-08-08 15:18:53 +00:00
|
|
|
SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc, std::vector<char> ssah, std::vector<char> binary);
|
2021-03-30 19:31:58 -07:00
|
|
|
SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc, std::vector<char> ssah);
|
2019-12-03 15:57:45 +01:00
|
|
|
virtual ~SipKernel();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-01-08 03:25:27 +01:00
|
|
|
SipKernelType getType() const {
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-08 15:18:53 +00:00
|
|
|
size_t getCtxOffset() const {
|
|
|
|
|
return contextIdOffsets[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t getPidOffset() const {
|
|
|
|
|
return contextIdOffsets[1];
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-03 15:57:45 +01:00
|
|
|
MOCKABLE_VIRTUAL GraphicsAllocation *getSipAllocation() const;
|
2021-03-30 19:31:58 -07:00
|
|
|
MOCKABLE_VIRTUAL const std::vector<char> &getStateSaveAreaHeader() const;
|
2022-03-16 16:08:37 +00:00
|
|
|
MOCKABLE_VIRTUAL size_t getStateSaveAreaSize(Device *device) const;
|
2023-08-08 15:18:53 +00:00
|
|
|
MOCKABLE_VIRTUAL const std::vector<char> &getBinary() const;
|
|
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL void parseBinaryForContextId();
|
2021-04-16 12:52:30 +00:00
|
|
|
|
|
|
|
|
static bool initSipKernel(SipKernelType type, Device &device);
|
|
|
|
|
static void freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager);
|
|
|
|
|
|
2023-07-28 13:22:38 +00:00
|
|
|
static const SipKernel &getSipKernel(Device &device, OsContext *context);
|
2024-10-01 20:53:41 +00:00
|
|
|
static const SipKernel &getDebugSipKernel(Device &device);
|
|
|
|
|
static const SipKernel &getDebugSipKernel(Device &device, OsContext *context);
|
2021-04-16 12:52:30 +00:00
|
|
|
static SipKernelType getSipKernelType(Device &device);
|
2021-08-18 11:05:17 +00:00
|
|
|
static SipKernelType getSipKernelType(Device &device, bool debuggingEnable);
|
2021-04-16 12:52:30 +00:00
|
|
|
static SipClassType classType;
|
2018-03-09 11:52:14 +01:00
|
|
|
|
2023-12-19 11:02:07 +00:00
|
|
|
enum class Command : uint32_t {
|
|
|
|
|
resume,
|
|
|
|
|
ready,
|
|
|
|
|
slmRead,
|
|
|
|
|
slmWrite
|
2021-10-29 15:06:11 +00:00
|
|
|
};
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
2023-03-27 12:03:02 +00:00
|
|
|
static bool initSipKernelImpl(SipKernelType type, Device &device, OsContext *context);
|
2021-04-16 12:52:30 +00:00
|
|
|
static const SipKernel &getSipKernelImpl(Device &device);
|
|
|
|
|
|
2023-03-27 12:03:02 +00:00
|
|
|
static bool initBuiltinsSipKernel(SipKernelType type, Device &device, OsContext *context);
|
2021-04-16 12:52:30 +00:00
|
|
|
static bool initRawBinaryFromFileKernel(SipKernelType type, Device &device, std::string &fileName);
|
2021-09-22 17:45:29 +02:00
|
|
|
static std::vector<char> readStateSaveAreaHeaderFromFile(const std::string &fileName);
|
|
|
|
|
static std::string createHeaderFilename(const std::string &filename);
|
|
|
|
|
|
2021-08-29 23:41:42 +00:00
|
|
|
static bool initHexadecimalArraySipKernel(SipKernelType type, Device &device);
|
2025-03-18 18:19:14 +00:00
|
|
|
static bool initSipKernelFromExternalLib(SipKernelType type, Device &device);
|
2024-01-16 19:42:54 +00:00
|
|
|
static void selectSipClassType(std::string &fileName, Device &device);
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-03-30 19:31:58 -07:00
|
|
|
const std::vector<char> stateSaveAreaHeader;
|
2023-08-08 15:18:53 +00:00
|
|
|
const std::vector<char> binary;
|
|
|
|
|
size_t contextIdOffsets[2] = {0, 0};
|
2021-04-16 12:52:30 +00:00
|
|
|
GraphicsAllocation *sipAllocation = nullptr;
|
2023-12-11 11:02:15 +00:00
|
|
|
SipKernelType type = SipKernelType::count;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2022-08-28 23:20:29 +00:00
|
|
|
|
2025-02-18 14:35:36 +00:00
|
|
|
static_assert(NEO::NonCopyableAndNonMovable<SipKernel>);
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|