LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_dfx - ccu_error_info_v2.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 17 17
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 7 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 CCU_ERROR_INFO_V2_H
      12              : #define CCU_ERROR_INFO_V2_H
      13              : #include <cstdint>
      14              : 
      15              : namespace hcomm {
      16              : 
      17              : struct CcuLoopContextV2 {
      18              :     union {
      19              :         uint16_t value;
      20              :         uint16_t xnOffset;
      21              :     } part0;
      22              : 
      23              :     union {
      24              :         uint16_t value;
      25              :         struct {
      26              :             uint16_t ckeOffset : 12;
      27              :             uint16_t msOffset : 4;
      28              :         };
      29              :     } part1;
      30              : 
      31              :     union {
      32              :         uint16_t value;
      33              :         struct {
      34              :             uint16_t msOffset : 7;
      35              :             uint16_t addrOffset : 9;
      36              :         };
      37              :     } part2;
      38              : 
      39              :     union {
      40              :         uint16_t value;
      41              :         uint16_t addrOffset;
      42              :     } part3;
      43              : 
      44              :     union {
      45              :         uint16_t value;
      46              :         struct {
      47              :             uint16_t addrOffset : 7;
      48              :             uint16_t currentIns : 9;
      49              :         };
      50              :     } part4;
      51              : 
      52              :     union {
      53              :         uint16_t value;
      54              :         struct {
      55              :             uint16_t currentIns : 7;
      56              :             uint16_t addrStride : 9;
      57              :         };
      58              :     } part5;
      59              : 
      60              :     union {
      61              :         uint16_t value;
      62              :         uint16_t addrStride;
      63              :     } part6;
      64              : 
      65              :     union {
      66              :         uint16_t value;
      67              :         struct {
      68              :             uint16_t addrStride : 7;
      69              :             uint16_t loopWishCheckBit : 9;
      70              :         };
      71              :     } part7;
      72              : 
      73              :     union {
      74              :         uint16_t value;
      75              :         struct {
      76              :             uint16_t loopWishCheckBit : 7;
      77              :             uint16_t waitLoopCheckBit : 9;
      78              :         };
      79              :     } part8;
      80              : 
      81              :     union {
      82              :         uint16_t value;
      83              :         struct {
      84              :             uint16_t waitLoopCheckBit : 7;
      85              :             uint16_t waitLoopCheckBitVld : 1;
      86              :             uint16_t loopMode : 1;
      87              :             uint16_t denyCnt : 7;
      88              :         };
      89              :     } part9;
      90              : 
      91              :     union {
      92              :         uint16_t value;
      93              :         struct {
      94              :             uint16_t denyCnt : 3;
      95              :             uint16_t currentCnt : 13;
      96              :         };
      97              :     } part10;
      98              : 
      99              :     union {
     100              :         uint16_t value;
     101              :         struct {
     102              :             uint16_t totalCnt : 13;
     103              :             uint16_t endIns : 3;
     104              :         };
     105              :     } part11;
     106              : 
     107              :     union {
     108              :         uint16_t value;
     109              :         struct {
     110              :             uint16_t endIns : 13;
     111              :             uint16_t startIns : 3;
     112              :         };
     113              :     } part12;
     114              : 
     115              :     union {
     116              :         uint16_t value;
     117              :         struct {
     118              :             uint16_t startIns : 13;
     119              :             uint16_t missionId : 3;
     120              :         };
     121              :     } part13;
     122              : 
     123              :     union {
     124              :         uint16_t value;
     125              :         struct {
     126              :             uint16_t missionId : 1;
     127              :             uint16_t loopVld : 1;
     128              :             uint16_t mprofileen : 1;
     129              :             uint16_t reserved : 13;
     130              :         };
     131              :     } part14;
     132              :     uint16_t reserved[17];
     133              : 
     134            1 :     uint16_t GetCurrentIns() const
     135              :     {
     136            1 :         return (part5.currentIns << 9) | (part4.currentIns);  // 偏移9位
     137              :     }
     138              : 
     139            2 :     uint16_t GetCurrentCnt() const
     140              :     {
     141            2 :         return part10.currentCnt;
     142              :     }
     143              : 
     144            2 :     uint32_t GetAddrStride() const
     145              :     {
     146            2 :         const uint32_t low = static_cast<uint32_t>(part5.addrStride);
     147            2 :         const uint32_t mid = static_cast<uint32_t>(part6.addrStride) << 9;  // 偏移9位
     148            2 :         const uint32_t high = static_cast<uint32_t>(part7.addrStride) << 25;  // 偏移25位
     149            2 :         return high | mid | low;
     150              :     }
     151              : };
     152              : 
     153              : struct CcuMissionContextV2 {
     154              :     union {
     155              :         uint16_t value;
     156              :         uint16_t taskIdRaw; // same hw register as V1::taskId
     157              :     } part0;
     158              : 
     159              :     union {
     160              :         uint16_t value;
     161              :         uint16_t streamIdRaw; // same hw register as V1::streamId
     162              :     } part1;
     163              : 
     164              :     union {
     165              :         uint16_t value;
     166              :         struct {
     167              :             uint16_t taskKillRaw : 1;
     168              :             uint16_t dieIdRaw : 2;
     169              :             uint16_t statusLo : 13;
     170              :         };
     171              :     } part2;
     172              : 
     173              :     union {
     174              :         uint16_t value;
     175              :         struct {
     176              :             uint16_t statusHi : 3;
     177              :             uint16_t counter : 10;
     178              :             uint16_t denyCnt : 3;
     179              :         };
     180              :     } part3;
     181              : 
     182              :     union {
     183              :         uint16_t value;
     184              :         struct {
     185              :             uint16_t denyCnt : 7;
     186              :             uint16_t currentIns : 9;
     187              :         };
     188              :     } part4;
     189              : 
     190              :     union {
     191              :         uint16_t value;
     192              :         struct {
     193              :             uint16_t currentIns : 7;
     194              :             uint16_t endIns : 9;
     195              :         };
     196              :     } part5;
     197              : 
     198              :     union {
     199              :         uint16_t value;
     200              :         struct {
     201              :             uint16_t endIns : 7;
     202              :             uint16_t startIns : 9;
     203              :         };
     204              :     } part6;
     205              : 
     206              :     union {
     207              :         uint16_t value;
     208              :         struct {
     209              :             uint16_t startIns : 7;
     210              :             uint16_t profileEn : 1;
     211              :             uint16_t missionVld : 1;
     212              :             uint16_t cqeInfoPart1 : 7;
     213              :         };
     214              :     } part7;
     215              : 
     216              :     union {
     217              :         uint16_t value;
     218              :         uint16_t cqeInfoPart2;
     219              :     } part8;
     220              : 
     221              :     union {
     222              :         uint16_t value;
     223              :         uint16_t cqeInfoPart3;
     224              :     } part9;
     225              : 
     226              :     union {
     227              :         uint16_t value;
     228              :         uint16_t cqeInfoPart4;
     229              :     } part10;
     230              : 
     231              :     union {
     232              :         uint16_t value;
     233              :         uint16_t cqeInfoPart5;
     234              :     } part11;
     235              : 
     236              :     union {
     237              :         uint16_t value;
     238              :         uint16_t cqeInfoPart6;
     239              :     } part12;
     240              : 
     241              :     union {
     242              :         uint16_t value;
     243              :         struct {
     244              :             uint16_t cqeInfoPart7 : 9;
     245              :             uint16_t reserved : 7;
     246              :         };
     247              :     } part13;
     248              : 
     249              :     uint16_t reserved[18];
     250              : 
     251            1 :     uint16_t GetStatus() const
     252              :     {
     253            1 :         return (part3.statusHi << 13) | (part2.statusLo);  // 偏移13位
     254              :     }
     255              : 
     256            2 :     uint16_t GetCurrentIns() const
     257              :     {
     258            2 :         return (part5.currentIns << 9) | (part4.currentIns);  // 偏移9位
     259              :     }
     260              : 
     261            2 :     uint16_t GetStartIns() const
     262              :     {
     263            2 :         return (part7.startIns << 9) | (part6.startIns);  // 偏移9位
     264              :     }
     265              : 
     266            2 :     uint16_t GetEndIns() const
     267              :     {
     268            2 :         return (part6.endIns << 9) | (part5.endIns);  // 偏移9位
     269              :     }
     270              : };
     271              : 
     272              : } // namespace hcomm
     273              : 
     274              : #endif // CCU_ERROR_INFO_V2_H
        

Generated by: LCOV version 2.0-1