#!/bin/sh
source /OSM/script/os_load_base.sh

###【使用说明】###
#1、此脚本用于正常打补丁过程中的BOIS以及配套表替换
#2、此脚本涉及的修改点如下：
#1）PRODUCT_SWOFWARE_VER，产品软件版本号，决定了固件所在盘上的位置，可以在产品环境上查询/startup_disk/image/
#2）FW_BIOS_MODE_IMU/FW_BIOS_VER/FW_IMU_VER，当前此脚本只支持IMU的热升级，BIOS本身不能支持，但是要同时修改版本号以及IMU升级模式
#3）目前此脚本只支持V6 C版本的IMU升级，如果需要适配C+版本，则需要适配修改各形态固件位置等；
#   如：FW_BIOS_PATH_HIG：C版本高端BIOS，当前固件
#       FW_BIOS_PATH_HIG_BAK：C版本高端BIOS，基线版本固件备份
#       FW_BIOS_PATH_HIG_PRE：C版本高端BIOS，上一次补丁版本固件备份
#4）需要注意BIOS固件的归一性，如C版本中端和IP框均归一到了各自的PALM形态下
#5）如果后续需要同时修改多个形态的BIOS固件，则需要在函数REPLACE_BIOS/ROLLBACK_BIOS中适配对比对应的固件，用户提供的USER_BIOS_FW压缩包需要按照各形态目录结构放好，参考HIGH_PRO等宏定义
#6）IF_EQU_TEST用于判断是否在装备环境，某些要求BIOS只在装备环境下生效；0：产品环境，1：装备环境

#bios固件升级模式:只升级IMU
FW_BIOS_MODE_IMU=2
FW_PACKAGE_NAME=USER_BIOS_FW_C73SPC100
#平台类型
PANGEA_LINK=`cat /proc/osp/bsp | awk '/Product/ {print $4}'`

#是否为special场景
SPECIAL=0

#设备形态
HIGH_PRO=PANGEA_V6R1C00_HI1620_4U4C
MID_SAS=PANGEA_V6R1C00_HI1620_2U2C_SAS
MID_PALM=PANGEA_V6R1C00_HI1620_2U2C_PALM
LOW_PRO=PANGEA_V6R1C00_HI1620S_2U2C_SAS
EXP_SAS=PANGEA_V6R1C00_JBOD_SAS_EXP
EXP_PALM=PANGEA_V6R1C00_JBOF_PALM_EXP
#设备形态-V6R3C00
PLUS_MID_PALM=PANGEA_V6R3C00_HI1620_2U2C_PALM
PLUS_MID_SAS=PANGEA_V6R3C00_HI1620_2U2C_SAS
PLUS_LOW_NVME=PANGEA_V6R3C00_HI1620S_2U2C_NVME
PLUS_LOW_SAS=PANGEA_V6R3C00_HI1620S_2U2C_SAS
PLUS_HIGH=PANGEA_V6R3C10_HI1620_4U4C
LITE_1P=PANGEA_V6R3C30_HI1620S_1P_2U2C_SAS
LITE_1P1H=PANGEA_V6R3C30_HI1620S_1P1H_2U2C_SAS
LITE_1P1L=PANGEA_V6R3C30_HI1620S_1P1L_2U2C_SAS


INIT_FW_PATCH()
{
    PRODUCT_SWOFWARE_VER=$1
    OS_echo "[BIOS] Now patch path is ${PRODUCT_SWOFWARE_VER}."

    #版本配套表
    SYS_VERSION_FILE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/${PANGEA_LINK}/product_versions.${PANGEA_LINK}.conf
    #bios固件
    FW_BIOS_PATH_HIG=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620_4U4C/bios.ROM
    FW_BIOS_PATH_MID=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620_2U2C_PALM/bios.ROM
    FW_BIOS_PATH_LOW=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620S_2U2C_SAS/bios.ROM
    FW_BIOS_PATH_EXP=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_JBOD_SAS_EXP/bios.ROM
    #bios固件-V6R3C00
    FW_BIOS_PATH_PLUS_MID=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C00_HI1620_2U2C_PALM/bios.ROM
    FW_BIOS_PATH_PLUS_LOW=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C00_HI1620S_2U2C_NVME/bios.ROM
	FW_BIOS_PATH_PLUS_HIGH=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C10_HI1620_4U4C/bios.ROM
	FW_BIOS_PATH_LITE_1P1=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/${PANGEA_LINK}/bios.ROM

    #校验和
    CHECKSUM_SYNC=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/sha256sum_sync

    #基线备份文件
	#配套表
    SYS_VERSION_FILE_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/${PANGEA_LINK}/product_versions.${PANGEA_LINK}_biosbak.conf
    #bios固件
	FW_BIOS_PATH_HIG_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620_4U4C/bios_bak.ROM
    FW_BIOS_PATH_MID_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620_2U2C_PALM/bios_bak.ROM
    FW_BIOS_PATH_LOW_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620S_2U2C_SAS/bios_bak.ROM
    FW_BIOS_PATH_EXP_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_JBOD_SAS_EXP/bios_bak.ROM
    #基线-V6R3C00
    FW_BIOS_PATH_PLUS_MID_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C00_HI1620_2U2C_PALM/bios_bak.ROM
    FW_BIOS_PATH_PLUS_LOW_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C00_HI1620S_2U2C_NVME/bios_bak.ROM
	FW_BIOS_PATH_PLUS_HIGH_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C10_HI1620_4U4C/bios_bak.ROM
	FW_BIOS_PATH_LITE_1P1_BAK=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/${PANGEA_LINK}/bios_bak.ROM

    #多次备份文件
	#配套表
    SYS_VERSION_FILE_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/${PANGEA_LINK}/product_versions.${PANGEA_LINK}_biospre.conf
	#bios固件
    FW_BIOS_PATH_HIG_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620_4U4C/bios_pre.ROM
    FW_BIOS_PATH_MID_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620_2U2C_PALM/bios_pre.ROM
    FW_BIOS_PATH_LOW_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_HI1620S_2U2C_SAS/bios_pre.ROM
    FW_BIOS_PATH_EXP_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R1C00_JBOD_SAS_EXP/bios_pre.ROM
    #备份-V6R3C00
    FW_BIOS_PATH_PLUS_MID_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C00_HI1620_2U2C_PALM/bios_pre.ROM
    FW_BIOS_PATH_PLUS_LOW_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C00_HI1620S_2U2C_NVME/bios_pre.ROM
	FW_BIOS_PATH_PLUS_HIGH_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/PANGEA_V6R3C10_HI1620_4U4C/bios_pre.ROM
	FW_BIOS_PATH_LITE_1P1_PRE=/startup_disk/image/${PRODUCT_SWOFWARE_VER}/system/firmware/${PANGEA_LINK}/bios_pre.ROM

}

#是否装备模式下，装备模式下执行；0：产品环境，1：装备环境
IF_EQU_TEST()
{
    EQU_FILE=/startup_disk/conf/equ_test/checkconfig.sh

    if [ ! -f $EQU_FILE ]; then
        OS_echo "[BIOS]now is not equ test env, exit."
        return 0
    fi
    OS_echo "[BIOS]now is equ test env, continue."
    return 1
}

FILE_BACKUP()
{
    CUR=$1
    PRE=$2
    BAK=$3

    if [ -f $BAK ]; then
        cp $CUR $PRE
        OS_echo "[BIOS]bak is exit, backup pre fw file"
    else
        if [ -f $PRE ]; then
            cp $PRE $BAK
            cp $CUR $PRE
            OS_echo "[BIOS]pre is exit, modify to bak fw file"
        else    
            cp $CUR $BAK
            OS_echo "[BIOS]pre/bak is not exit, backup bak fw file"
        fi
    fi
}

PANGEA_FwUpgradeMmlCmd()
{
    if [[ $SPECIAL == 1 ]];then
        OS_echo "[bios patch] special upgrade bios succ."
        return 0
    fi

    FW_BIOS_PATH=$1
    FW_UPG_MODE=$2

    sudo rmmod /OSM/modules/updatebios.ko
    #升级本片IMU版本
    sudo insmod /OSM/modules/updatebios.ko fname=$FW_BIOS_PATH upmode=$FW_UPG_MODE
    OS_echo "[BIOS]Begin to upgrade bios IMU."
    return 0
}

REPLACE_BIOS()
{
    CURFW=$1
    PREFW=$2
    BAKFW=$3
    HARDWARE=$4

    if [ ! -f /OSM/modules/BIOStmp/${HARDWARE}/bios.ROM ]; then
        OS_echo "[BIOS] No Firmware here, return."
        rm -rf /OSM/modules/BIOStmp
        return
    fi

    #这里的固件包后续可以扩展，按照形态名放好文件结构
    cmp $CURFW /OSM/modules/BIOStmp/${HARDWARE}/bios.ROM
    if [ "$?" == "0" ] ; then 
        OS_echo "[BIOS - $HARDWARE] Firmware already replaced, return."
        rm -rf /OSM/modules/BIOStmp
        return
    fi

    #备份version文件
    FILE_BACKUP $SYS_VERSION_FILE $SYS_VERSION_FILE_PRE $SYS_VERSION_FILE_BAK

    #备份bios固件文件
    FILE_BACKUP $CURFW $PREFW $BAKFW

    #替换bios固件文件
    cp /OSM/modules/BIOStmp/${HARDWARE}/bios.ROM $CURFW

    #替换version文件中bios版本号
    fwnum=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE" | tail -1 | awk -F "-" '{print $1}'`
    fwver=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE" | tail -1 | awk -F "=" '{print $2}'`
	sed -i "$fwnum s/$fwver/$FW_IMU_VER/" $SYS_VERSION_FILE
	fwbiosnum=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE" | tail -1 | awk -F "-" '{print $1}'`
    fwbiosver=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE" | tail -1 | awk -F "=" '{print $2}'`
	sed -i "$fwbiosnum s/$fwbiosver/$FW_BIOS_VER/" $SYS_VERSION_FILE

    #删除bios固件文件的sha256
    sudo sed -i "/bios.ROM/d" $CHECKSUM_SYNC
    #替换配套表的sha256
    sudo sed -i "/product_versions.${PANGEA_LINK}.conf/d" $CHECKSUM_SYNC

    #IF_EQU_TEST
    #equ_env=$?
    #if [[ $equ_env == 0 ]]; then
        #非装备模式下，执行bios IMU固件升级命令
    #    PANGEA_FwUpgradeMmlCmd $CURFW $FW_BIOS_MODE_IMU
    #fi
}

REPLACE_BIOS_VERSION()
{
    #装备模式下替换，非装备模式直接退出
    IF_EQU_TEST
    equ_env=$?
    if [[ $equ_env == 0 && $SPECIAL == 0 ]]; then
        return
    fi

    patch_path=$(readlink -f "$(dirname "$0")")
    cp -rf ${patch_path}/${FW_PACKAGE_NAME}.tgz /OSM/${FW_PACKAGE_NAME}.tgz
    rm -rf /OSM/modules/BIOStmp
    mkdir -p /OSM/modules/BIOStmp
    tar -zxvf /OSM/${FW_PACKAGE_NAME}.tgz -C /OSM/modules/BIOStmp

    mount -o remount,rw /startup_disk/image
	#V6R1C00
    #4P
    if [ $PANGEA_LINK == $HIGH_PRO ] ; then
        FW_IMU_VER=27.11.10T51
        FW_BIOS_VER=27.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_HIG $FW_BIOS_PATH_HIG_PRE $FW_BIOS_PATH_HIG_BAK $HIGH_PRO
    fi
    #3P
    if [[ $PANGEA_LINK == $MID_SAS || $PANGEA_LINK == $MID_PALM ]] ; then
        FW_IMU_VER=28.11.10T51
        FW_BIOS_VER=28.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_MID $FW_BIOS_PATH_MID_PRE $FW_BIOS_PATH_MID_BAK $MID_PALM
    fi
    #1P1
    if [[ $PANGEA_LINK == $LOW_PRO || $PANGEA_LINK == $PLUS_LOW_SAS ]] ; then
        FW_IMU_VER=25.11.10T51
        FW_BIOS_VER=25.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_LOW $FW_BIOS_PATH_LOW_PRE $FW_BIOS_PATH_LOW_BAK $LOW_PRO
    fi
    #1P1
    if [[ $PANGEA_LINK == $EXP_SAS || $PANGEA_LINK == $EXP_PALM ]] ; then
        FW_IMU_VER=25.11.10T51
        FW_BIOS_VER=25.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_EXP $FW_BIOS_PATH_EXP_PRE $FW_BIOS_PATH_EXP_BAK $EXP_SAS
    fi
    #1P2
    if [[ $PANGEA_LINK == $PLUS_MID_PALM || $PANGEA_LINK == $PLUS_MID_SAS ]] ; then
        FW_IMU_VER=26.11.10T51
        FW_BIOS_VER=26.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_PLUS_MID $FW_BIOS_PATH_PLUS_MID_PRE $FW_BIOS_PATH_PLUS_MID_BAK $PLUS_MID_PALM
    fi
    #1P1
    if [[ $PANGEA_LINK == $PLUS_LOW_NVME ]] ; then
        FW_IMU_VER=25.11.10T51
        FW_BIOS_VER=25.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_PLUS_LOW $FW_BIOS_PATH_PLUS_LOW_PRE $FW_BIOS_PATH_PLUS_LOW_BAK $PLUS_LOW_NVME
    fi
	#2p1
	if [[ $PANGEA_LINK == $PLUS_HIGH ]] ; then
        FW_IMU_VER=25.11.10T51
        FW_BIOS_VER=25.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_PLUS_HIGH $FW_BIOS_PATH_PLUS_HIGH_PRE $FW_BIOS_PATH_PLUS_HIGH_BAK $PLUS_HIGH
	fi
	#lite
	if [[ $PANGEA_LINK == $LITE_1P || $PANGEA_LINK == $LITE_1P1H || $PANGEA_LINK == $LITE_1P1L ]] ; then
        FW_IMU_VER=25.11.10T51
        FW_BIOS_VER=25.11.10T51
        REPLACE_BIOS $FW_BIOS_PATH_LITE_1P1 $FW_BIOS_PATH_LITE_1P1_PRE $FW_BIOS_PATH_LITE_1P1_BAK $LITE_1P
	fi

    mount -o remount,ro /startup_disk/image
    rm -rf /OSM/modules/BIOStmp
    return
}

ROLLBACK_BIOS()
{
    CUR_FW=$1
    PRE_FW=$2
    BAK_FW=$3

    #回退固件
    if [ -f $SYS_VERSION_FILE_PRE ]; then
        fwnumcur=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE" | tail -1 | awk -F "-" '{print $1}'`
        fwvercur=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE" | tail -1 | awk -F "=" '{print $2}'`
        fwverorg=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE_PRE" | tail -1 | awk -F "=" '{print $2}'`
        sed -i "$fwnumcur s/$fwvercur/$fwverorg/" $SYS_VERSION_FILE
		fwnumcurbios=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE" | tail -1 | awk -F "-" '{print $1}'`
        fwvercurbios=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE" | tail -1 | awk -F "=" '{print $2}'`
        fwverorgbios=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE_PRE" | tail -1 | awk -F "=" '{print $2}'`
        sed -i "$fwnumcurbios s/$fwvercurbios/$fwverorgbios/" $SYS_VERSION_FILE
        mv $PRE_FW $CUR_FW
        OS_echo "[BIOS]roll back pre fw file."
    elif [ -f $SYS_VERSION_FILE_BAK ]; then
        fwnumcur=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE" | tail -1 | awk -F "-" '{print $1}'`
        fwvercur=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE" | tail -1 | awk -F "=" '{print $2}'`
        fwverorg=`grep -n -A 2 "IMU" "$SYS_VERSION_FILE_BAK" | tail -1 | awk -F "=" '{print $2}'`
        sed -i "$fwnumcur s/$fwvercur/$fwverorg/" $SYS_VERSION_FILE
		fwnumcurbios=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE" | tail -1 | awk -F "-" '{print $1}'`
        fwvercurbios=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE" | tail -1 | awk -F "=" '{print $2}'`
        fwverorgbios=`grep -n -A 2 "BIOS" "$SYS_VERSION_FILE_BAK" | tail -1 | awk -F "=" '{print $2}'`
        sed -i "$fwnumcurbios s/$fwvercurbios/$fwverorgbios/" $SYS_VERSION_FILE
        mv $BAK_FW $CUR_FW
        OS_echo "[BIOS]roll back bak fw file."
    else
        OS_echo "[BIOS]Not find BIOS backup fw file."
    fi

    #IF_EQU_TEST
    #equ_env=$?
    #if [[ $equ_env == 0 ]]; then
        #非装备模式下，执行bios IMU固件升级命令
    #    PANGEA_FwUpgradeMmlCmd $CUR_FW $FW_BIOS_MODE_IMU
    #fi
}

ROLLBACK_BIOS_VERSION()
{

    OS_echo "BIOS rollback begin"
    mount -o remount,rw /startup_disk/image
    
    if [ $PANGEA_LINK == $HIGH_PRO ] ; then
        ROLLBACK_BIOS $FW_BIOS_PATH_HIG $FW_BIOS_PATH_HIG_PRE $FW_BIOS_PATH_HIG_BAK
    fi

    if [[ $PANGEA_LINK == $MID_SAS || $PANGEA_LINK == $MID_PALM ]] ; then
        ROLLBACK_BIOS $FW_BIOS_PATH_MID $FW_BIOS_PATH_MID_PRE $FW_BIOS_PATH_MID_BAK
    fi

    if [[ $PANGEA_LINK == $LOW_PRO || $PANGEA_LINK == $PLUS_LOW_SAS ]] ; then
	echo "$PLUS_LOW_SAS"
        ROLLBACK_BIOS $FW_BIOS_PATH_LOW $FW_BIOS_PATH_LOW_PRE $FW_BIOS_PATH_LOW_BAK
    fi

    if [[ $PANGEA_LINK == $EXP_SAS || $PANGEA_LINK == $EXP_PALM ]] ; then
        ROLLBACK_BIOS $FW_BIOS_PATH_EXP $FW_BIOS_PATH_EXP_PRE $FW_BIOS_PATH_EXP_BAK
    fi 
    
    if [[ $PANGEA_LINK == $PLUS_MID_PALM || $PANGEA_LINK == $PLUS_MID_SAS ]] ; then
        ROLLBACK_BIOS $FW_BIOS_PATH_PLUS_MID $FW_BIOS_PATH_PLUS_MID_PRE $FW_BIOS_PATH_PLUS_MID_BAK
    fi

    if [[ $PANGEA_LINK == $PLUS_LOW_NVME ]] ; then
        ROLLBACK_BIOS $FW_BIOS_PATH_PLUS_LOW $FW_BIOS_PATH_PLUS_LOW_PRE $FW_BIOS_PATH_PLUS_LOW_BAK
    fi
	
	#2p1
	if [[ $PANGEA_LINK == $PLUS_HIGH ]] ; then
        ROLLBACK_BIOS $FW_BIOS_PATH_PLUS_HIGH $FW_BIOS_PATH_PLUS_HIGH_PRE $FW_BIOS_PATH_PLUS_HIGH_BAK
	fi
	#lite
	if [[ $PANGEA_LINK == $LITE_1P || $PANGEA_LINK == $LITE_1P1H || $PANGEA_LINK == $LITE_1P1L ]] ; then
        ROLLBACK_BIOS $FW_BIOS_PATH_LITE_1P1 $FW_BIOS_PATH_LITE_1P1_PRE $FW_BIOS_PATH_LITE_1P1_BAK
	fi

    if [ -f $SYS_VERSION_FILE_PRE ]; then
        rm $SYS_VERSION_FILE_PRE
        OS_echo "[BIOS]roll back pre version file."
    elif [ -f $SYS_VERSION_FILE_BAK ]; then
        rm $SYS_VERSION_FILE_BAK
        OS_echo "[BIOS]roll back bak version file."
    else
        OS_echo "[BIOS]Not find BIOS backup version file."
    fi

    mount -o remount,ro /startup_disk/image
    rm -rf /OSM/modules/BIOStmp
    OS_echo "BIOS rollback end"
    return
}

PATCH_START()
{
    REPLACE_BIOS_VERSION
    return
}

PATCH_END()
{
    return
}

PATCH_ROLLBACK()
{
    ROLLBACK_BIOS_VERSION
    return
}

PATCH_ROLLEND()
{
    return
}

BIOS_START()
{
	return
    if [ -d "/startup_disk/image/6200819073" ]; then
        INIT_FW_PATCH "6200819073"
        PATCH_START
    fi
}

BIOS_ROLLBACK()
{
	return
    if [ -d "/startup_disk/image/6200819073" ]; then
        INIT_FW_PATCH "6200819073"
        PATCH_ROLLBACK
    fi
}

L_CMD=$1
case $L_CMD in
    "start")
        SPECIAL=0
        BIOS_START
        ;;
    "end")
        PATCH_END
        ;;
    "rollstart")
        SPECIAL=0
        BIOS_ROLLBACK
        ;;
    "rollend")
        PATCH_ROLLEND
        ;;
    "special_upgrade")
        SPECIAL=1
        BIOS_START
        ;;
    "special_resume")
        SPECIAL=1
        BIOS_ROLLBACK
        ;;
    *)
        echo "unsupported option."
esac
exit 0
