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 : #include "adx_hdc_device.h"
11 : #include <memory>
12 : #include <vector>
13 : #include "log/adx_log.h"
14 : #include "ascend_hal.h"
15 : #include "adx_dsmi.h"
16 : using AdxDrvStateInfoPt = devdrv_state_info_t *;
17 : namespace Adx {
18 16 : void AdxHdcDevice::GetAllEnableDevices(int32_t mode, int32_t devId, std::vector<std::string> &devices)
19 : {
20 16 : devices.clear();
21 16 : std::lock_guard<std::mutex> lk(this->deviceNotifyMtx_);
22 16 : if (AdxHdcDevice::NoDevice()) {
23 4 : if (mode == 0) {
24 3 : std::vector<uint32_t> devLogIds(DEVICE_NUM_MAX, 0);
25 3 : uint32_t nums = 0;
26 3 : if (IdeGetDevList(&nums, devLogIds, DEVICE_NUM_MAX) == IDE_DAEMON_ERROR) {
27 0 : return;
28 : }
29 6 : for (uint32_t i = 0; i < nums && i < DEVICE_NUM_MAX; i++) {
30 3 : AdxHdcDevice::InitDevice(std::to_string(devLogIds[i]));
31 : }
32 3 : } else {
33 1 : if (!CheckVfId(devId)) {
34 0 : return;
35 : }
36 1 : AdxHdcDevice::InitDevice(std::to_string(devId));
37 : }
38 : }
39 16 : AdxHdcDevice::GetEnableDevices(devices);
40 16 : }
41 : }
|