Line data Source code
1 : /**
2 : * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef TSD_PACKAGE_LOADER_H
12 : #define TSD_PACKAGE_LOADER_H
13 :
14 : #include "device_comm_agent.h"
15 : #include "capability_manager.h"
16 : #include "package_env_info.h"
17 : #include "package_hash_store.h"
18 : #include "package_context.h"
19 : #include "package_process_config.h"
20 : #include "hdc_message_builder.h"
21 : #include "proto/tsd_message.pb.h"
22 : #include "basic_define.h"
23 :
24 : #include <string>
25 :
26 : namespace tsd {
27 :
28 : class PackageSender;
29 : class PackageCheckCodeService;
30 : class PluginVersionManager;
31 :
32 : class PackageLoader {
33 : public:
34 : PackageLoader(
35 : DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo,
36 : PackageHashStore& hashStore, PackageContext& ctx, PackageSender& sender, PackageCheckCodeService& checkCodeSvc,
37 : PluginVersionManager& pluginVersion);
38 : ~PackageLoader() = default;
39 :
40 : TSD_StatusT LoadSysOpKernel();
41 : TSD_StatusT LoadRuntimePkgToDevice(const MessageContext& baseCtx);
42 : TSD_StatusT LoadCannHsPkgToDevice(const std::string& pkgPureName, const MessageContext& baseCtx);
43 : TSD_StatusT LoadFileAndWaitRsp(
44 : const std::string& pkgPureName, const std::string& hostPkgHash, const int32_t peerNode,
45 : const std::string& orgFile, const std::string& dstFile, const MessageContext& baseCtx);
46 : TSD_StatusT LoadDShapePkgToDevice(const MessageContext& baseCtx);
47 : TSD_StatusT LoadOmFileToDevice(
48 : const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen,
49 : const MessageContext& baseCtx);
50 : TSD_StatusT LoadFileToDevice(
51 : const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen,
52 : const MessageContext& baseCtx);
53 : bool IsOkToLoadFileToDevice(const char_t* const fileName, const uint64_t fileNameLen) const;
54 : TSD_StatusT LoadPackageConfigInfoToDevice(const bool hasPluginVersion);
55 : bool SupportLoadPkg(const std::string& pkgName) const;
56 : TSD_StatusT LoadSinglePackageToDevice(
57 : const std::string& pkgPureName, const PackConfDetail& detail, int32_t peerNode,
58 : const std::string& dstDirPreFix);
59 : void ReportSinkPkgRspError(const std::string& pkgPureName);
60 : TSD_StatusT LoadPackageToDeviceByConfig();
61 :
62 : void Reset();
63 :
64 : bool IsAicpuPackageExistInDevice() const { return ctx_.aicpuPackageExistInDevice; }
65 22 : void SetAicpuPackageExistInDevice(bool v) { ctx_.aicpuPackageExistInDevice = v; }
66 :
67 : private:
68 : TSD_StatusT LoadHsPkgToDevice(
69 : const std::string& pkgName, const std::string& subPath, TsdLoadPackageType pkgType, HDCMessage::MsgType msgType,
70 : const MessageContext& baseCtx);
71 : bool ShouldLoadLegacyPackage() const;
72 : TSD_StatusT SendAllPackagesToPeer();
73 : bool hasSendConfigFile_ = false;
74 :
75 : DeviceCommAgent& commAgent_;
76 : CapabilityManager& capabilityMgr_;
77 : PackageEnvInfo& envInfo_;
78 : PackageHashStore& hashStore_;
79 : PackageContext& ctx_;
80 : PackageSender& sender_;
81 : PackageCheckCodeService& checkCodeSvc_;
82 : PluginVersionManager& pluginVersion_;
83 : };
84 :
85 : } // namespace tsd
86 :
87 : #endif // TSD_PACKAGE_LOADER_H
|