-- Copyright (c) 2026 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

-- Description: 定义升级需要的通用常量和方法
local upgrade_defs = {}

upgrade_defs.RET = {
    OK = 0,
    ERR = (-1),
    OTHERS_UPGRADING = 248,
    IN_UPGRADING = 36
}

-- secbox用户UID/GID定义
upgrade_defs.SECBOX_UID = 104
upgrade_defs.SECBOX_GID = 104

-- 硬盘固件ComponentID定义
upgrade_defs.DRIVE_COMPONENT_ID = 0x22        -- 硬盘固件ComponentID (十进制34)
upgrade_defs.DRIVE_COMPONENT_IDEX = 0xffffffff -- 硬盘固件ComponentIDEx (十进制4294967295，表示所有子类型)

upgrade_defs.POWER_OFF_LOCK_REASON = 'DriveFirmwareUpgrading'

-- SMBIOS 写完成状态（用于判断 OS 是否就绪）
upgrade_defs.SMBIOS_WRITE_FINISH = 3

-- 硬盘固件类型标识
upgrade_defs.FIRMWARE_TYPE_DRIVE = 'Drive'

-- Redfish 硬盘 URI 前缀，指定硬盘升级时除最后一段数字外需严格相等
upgrade_defs.REDFISH_DRIVE_URI_PREFIX = '/redfish/v1/Chassis/1/Drives/HDDPlaneDisk'

-- 固件模式：多固件（parameters.FirmwareMode 取该值时表示请求方为多固件模式）
upgrade_defs.FIRMWARE_MODE_MULTIPLE = 'Multiple'
-- 多固件支持标识：支持（prepare 阶段回填 parameters.MultipleSupported，表示本组件支持多固件）
upgrade_defs.MULTIPLE_SUPPORTED = 'Support'

-- 生效状态：正在生效（active 阶段开始时上报 UpdateActiveStatus）
upgrade_defs.ACTIVE_STATUS_APPLY = 'Apply'
-- 生效状态：就绪（active 阶段全部成功后上报 UpdateActiveStatus）
upgrade_defs.ACTIVE_STATUS_READY = 'Ready'

return upgrade_defs