LCOV - code coverage report
Current view: top level - adump/exception - kernel_pc_fixer.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-07-28 10:54:24 Functions: 66.7 % 3 2

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 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              : #ifndef KERNEL_PC_FIXER_H
      11              : #define KERNEL_PC_FIXER_H
      12              : 
      13              : #include <cstdint>
      14              : #include <memory>
      15              : #include <string>
      16              : #include <vector>
      17              : 
      18              : namespace Adx {
      19              : 
      20              : struct PcFixEntry {
      21              :     uint32_t errInfoRegNum;
      22              :     uint64_t srcMask;
      23              :     uint64_t dstMask;
      24              : };
      25              : 
      26              : struct PcFixGroup {
      27              :     uint32_t moduleId;
      28              :     uint32_t aicErrMask;
      29              :     std::vector<PcFixEntry> entries;
      30              : };
      31              : 
      32              : class PcFixerInterface {
      33              : public:
      34           21 :     PcFixerInterface() = default;
      35           21 :     virtual ~PcFixerInterface() = default;
      36              : 
      37              :     uint64_t FixPc(uint64_t pc, const uint32_t errReg[], size_t errRegLen);
      38              :     virtual std::string GetErrorRegisters(const uint32_t errReg[], size_t errRegLen) const = 0;
      39              : 
      40              : protected:
      41              :     uint32_t errStartIdx_{0};
      42              :     uint32_t errCount_{0};
      43              :     std::vector<std::vector<PcFixGroup>> table_;
      44              : 
      45              :     static void ReplacePcBits(uint64_t& pc, uint32_t regValue, uint64_t srcMask, uint64_t dstMask);
      46              :     std::vector<const PcFixGroup*> GetMatchedGroups(const uint32_t errReg[], size_t errRegLen) const;
      47              :     virtual std::string GetModuleName(uint32_t moduleId) const = 0;
      48              : };
      49              : 
      50              : class CloudV2PcFixer : public PcFixerInterface {
      51              : public:
      52              :     CloudV2PcFixer();
      53              :     std::string GetErrorRegisters(const uint32_t errReg[], size_t errRegLen) const override;
      54              : 
      55              : private:
      56              :     std::string GetModuleName(uint32_t moduleId) const override;
      57              : };
      58              : 
      59              : class CloudV4PcFixer : public PcFixerInterface {
      60              : public:
      61              :     CloudV4PcFixer();
      62              :     std::string GetErrorRegisters(const uint32_t errReg[], size_t errRegLen) const override;
      63              : 
      64              : private:
      65              :     std::string GetModuleName(uint32_t moduleId) const override;
      66              : };
      67              : 
      68              : class PcFixerFactory {
      69              : public:
      70              :     static PcFixerInterface* GetInstance();
      71              : 
      72              : private:
      73              :     static std::unique_ptr<PcFixerInterface> instance_;
      74              : };
      75              : 
      76              : } // namespace Adx
      77              : 
      78              : #endif // KERNEL_PC_FIXER_H
        

Generated by: LCOV version 2.0-1