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

            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              : 
      11              : #ifndef REGISTER_CONFIG_H
      12              : #define REGISTER_CONFIG_H
      13              : 
      14              : #include <cstdint>
      15              : #include <vector>
      16              : #include <memory>
      17              : #include <map>
      18              : #include <string>
      19              : 
      20              : namespace Adx {
      21              : 
      22              : namespace {
      23              : constexpr uint32_t HIGH_ADDR_SHIFT = 48U;
      24              : constexpr uint32_t MOUDLE_TYPE_SHIFT = 52U;
      25              : }
      26              : 
      27              : struct RegisterTable {
      28         4871 :     RegisterTable(uint64_t regStartAddr, uint32_t regNum, uint8_t regByteWidth):
      29         4871 :         startAddr(regStartAddr), num(regNum), byteWidth(regByteWidth) {}
      30              :     uint64_t startAddr;
      31              :     uint32_t num;
      32              :     uint8_t byteWidth;
      33              : };
      34              : 
      35              : struct RegisterStepTable {
      36              :     uint64_t startAddr;
      37              :     uint32_t num;
      38              :     uint8_t byteWidth;
      39              :     uint8_t step;
      40              : };
      41              : 
      42              : struct ErrorRegisterTable {
      43          542 :     ErrorRegisterTable(uint8_t regErrIndex, uint64_t regOffsetAddr, uint8_t regByteWidth, std::string regName):
      44          542 :         errIndex(regErrIndex), offsetAddr(regOffsetAddr), byteWidth(regByteWidth), name(regName) {}
      45              :     uint8_t errIndex;
      46              :     uint64_t offsetAddr;
      47              :     uint8_t byteWidth;
      48              :     std::string name;
      49              : };
      50              : 
      51              : enum class RegisterType {
      52              :     SU,
      53              :     VEC,
      54              :     MTE,
      55              :     CUBE,
      56              :     BIU,
      57              :     VEC_RB,
      58              :     BIF,
      59              :     L1,
      60              :     MTE_AIV,
      61              :     AIC,
      62              :     AIV,
      63              :     AIC_DBG,
      64              :     AIV_DBG
      65              : };
      66              : 
      67              : class RegisterInterface {
      68              : public:
      69           21 :     RegisterInterface() = default;
      70           21 :     virtual ~RegisterInterface() = default;
      71              :     const std::vector<RegisterTable>& GetRegisterTable(RegisterType type) const;
      72              :     const std::vector<RegisterType>& GetRegisterTypes(uint8_t coreType) const;
      73              :     const std::vector<ErrorRegisterTable>& GetErrorRegisterTable() const;
      74              : protected:
      75              :     std::map<RegisterType, std::vector<RegisterTable>> registerTableMap_;
      76              :     std::map<uint8_t, std::vector<RegisterType>> registerTypeMap_;
      77              :     std::vector<ErrorRegisterTable> ErrorRegisterMap_;
      78              : };
      79              : 
      80              : class CloudV2Register : public RegisterInterface {
      81              : public:
      82              :     CloudV2Register();
      83           10 :     ~CloudV2Register() override {};
      84              : private:
      85              :     uint64_t GetAddr(uint64_t regAddrHigh, uint64_t regAddrLow) const;
      86              : };
      87              : 
      88              : class CloudV4Register : public RegisterInterface {
      89              : public:
      90              :     CloudV4Register();
      91           11 :     ~CloudV4Register() override {};
      92              : private:
      93              :     uint64_t GetAddr(uint64_t type, uint64_t regAddrHigh, uint64_t regAddrLow) const;
      94              :     void GenAddrByStep(RegisterType regType, const std::vector<RegisterStepTable> &regStepTab);
      95              :     void InitErrorRegisterMap();
      96              :     void GenAICDbgAddr();
      97              :     void GenAIVDbgAddr();
      98              :     void GenAICOffsetAddr();
      99              :     void GenAIVOffsetAddr();
     100              :     std::vector<RegisterTable> GenAIVDbgSUAddr();
     101              :     std::vector<RegisterTable> GenAIVDbgMTEAddr();
     102              :     std::vector<RegisterTable> GenAIVDbgVECRBAddr();
     103              :     std::vector<RegisterTable> GenAIVDbgOthersAddr();
     104              : };
     105              : 
     106              : class RegisterManager {
     107              : public:
     108              :     RegisterManager();
     109           22 :     ~RegisterManager() {}
     110              :     static RegisterManager &GetInstance();
     111              :     const std::shared_ptr<RegisterInterface> GetRegister();
     112              : 
     113              : private:
     114              :     void CreateRegister();
     115              : 
     116              :     std::shared_ptr<RegisterInterface> register_;
     117              : };
     118              : }
     119              : #endif
        

Generated by: LCOV version 2.0-1