//****************************************************************************
//
//                        Kontron Canada Inc.
//                      4555 Ambroise-Lafortune
//                    Boisbriand (Quebec) J7H 0A4
//
//                Kontron Canada Proprietary Information
//        Copyright (c) 2017 Kontron Canada, All Rights Reserved
//****************************************************************************
//
//  TITLE: Master.CFG             DATE CREATED:  October 5, 2017 (by KCI)
//
//*************************************************************************
// NON-INTERACTIVE UPDATE TAGS 
//*************************************************************************
//  SET "NI_FRUSDR"  // Do not prompt for FRU, SDR, or System type.
//    SET "FRU"      // Update FRU data
//    SET "SDR"      // Update SDR repository
//
//  SET "BMC_TAM"   // Enable BMC TAM - Also select one of the following four policies
//    SET "TAM_DMS" // Default Color, Most Severe
//    SET "TAM_AMS" // Alternate color, Most Severe
//    SET "TAM_DAS" // Default color, All Severities
//    SET "TAM_AAS" // Alternate color, All severities
//
//  SET "NI_FRU"    // Do not prompt for FRU Data
//****************************************************************************

CONFIGURATION   "Master.cfg, Rev 0.08"
DISPLAY         "CG2200 platform FRU & SDR package version 0.08"

//****************************************************************************
// Detect Product ID
PROBE "BASEBOARD_PRODID" "5D"
FOUND "CO"  ""

IFSET "CO"
    DISPLAY "Kontron CG2200 Server Platform"
ELSE
    DISPLAY ""
    DISPLAY "This is either the incorrect FRU/SDR package for this baseboard"
    DISPLAY "or your platform ID is incorrectly programmed."
    ERRORLEVEL 01
ENDIF

DISPLAY         "Copyright(c) 2017 Kontron Canada"
DISPLAY         " "


IFSET "NI_FRUSDR"
  DISPLAY ""
  DISPLAY "Non-Interactive mode invoked"
  DISPLAY ""
ELSE
MENUTITLE   "Select the function you desire to perform:"
MENU        "SDR"   "Update only the SDR repository"
MENU        "FRU"   "Update only the FRU repository"
MENU        "BOTH"  "Update both the FRU and the SDR repository"
MENU        "ASSET" "Modify the Product Asset Tag"
MENU        "EXIT1" "Exit"
MENUPROMPT
DISPLAY " "
ENDIF // END IFSET "NI_FRUSDR"

IFSET "EXIT1"
    DISPLAY "Exit without making any changes"
ELSE
    IFSET "BOTH"
        // Set both FRU and SDR
        SET "SDR"
        SET "FRU"
    ENDIF
    IFSET   "ASSET"
        FRUNAME     "SYSTEM"
        FRUADDRESS  "IMBDEVICE" FF 20
        FRUAREA     "PRODUCT"
        FRUFIELD    "AT" "@STDIN:ASCII"
    ELSE
        IFSET "SDR"
            SET "CG2200"
            //Probe for sensors and FRU device
            DISPLAY ""
            DISPLAY "Probing system for sensors and FRU device hardware..."
            DISPLAY ""

            SET "PROC_1"
            PROBE "PROCESSOR" 2
            FOUND "PROC_2"         ""

          IFSET "NI_FRUSDR"
            // Use values set above with NI_FRUSDR
          ELSE
            MENUTITLE	"Do you wish to enable BMC TAM?"
  		    MENU		"BMC_TAM"	"Yes - Activate BMC TAM"
            MENU		"NO_TAM"	"No  - Do not use BMC TAM"
            MENUPROMPT
	
            IFSET "BMC_TAM"
  		        DISPLAY     " "
                MENUTITLE	"Select the TAM configuration you wish to use"
  			    MENU		"TAM_DMS"   "Default LED Color, Most Severe only"
                MENU		"TAM_AMS"   "Alternate LED Color, Most Severe Only"
                MENU		"TAM_DAS"   "Default LED Color, All Severities"
                MENU		"TAM_AAS"   "Alternate LED Color, All Severities"
                MENUPROMPT
             ENDIF // BMC_TAM
          ENDIF // IFSET "NI_FRUSDR"
   		    
            // Probe for Power Supplies
            PROBE "PING"  "0F"  "B0"
            FOUND "PS1"   "NO_PS1"

            PROBE "PING"  "0F"  "B2"
            FOUND "PS2"   "NO_PS2"

            // Probe for HSBP
            PROBE "PING"    "0B"    "D0"
            FOUND "HSBP"     ""

            // Report what was found
            IFSET   "PS1"
                SET "AC_PS1"
                DISPLAY ""
                DISPLAY "Power Supply 1 is detected."
            ELSE
                DISPLAY ""
                DISPLAY "Power Supply 1 not detected."
            ENDIF

            IFSET   "PS2"
                SET "AC_PS2"
                DISPLAY "Power Supply 2 is detected."
            ELSE
                DISPLAY "Power Supply 2 not detected."
            ENDIF

            IFSET   "PS1"  "PS2"
                SET "PS_REDUNDANCY"
                DISPLAY "Redundant Power Unit"			
            ENDIF

            DISPLAY ""

            //HSBP
            IFSET   "HSBP"
                DISPLAY "Hot Swap Backplane is detected."
                SET "HS625BP"
            ELSE
                DISPLAY "Hot Swap Backplane is not detected."
            ENDIF

            //Set SDR tags for items that are standard


            //Front Panel Temp
            SET "FP_TEMP"

            //Chassis intrusion
            //SET "NO_CHASSIS_INTRU"

            SDRNAME "CG2200.SDR"        // Update SDR Repository
            BMC_REFRESH
        ENDIF     // IFSET "SDR"

        IFSET "FRU"

            // ******************************
            //   Update Base Board FRU areas
            // ******************************
            DISPLAY     ""
            DISPLAY     "Updating FRU areas"

            //Update Baseboard FRU data
            FRUNAME     "S2600CO.fru"
            FRUAREA     "HEADER"
            FRUAREA     "INTERNALUSE"
            FRUAREA     "CHASSIS"
            FRUFIELD    "CT"
            
          	// Always Program Chassis Additional Field AM1 for PDK platform detection
          	IFSET "CG2200"
          	  FRUFIELD    "CT" "17" // Set Chassis Type to Rack-Mount
                  FRUFIELD    "AM1" "CG2200"
          	ENDIF

	  IFSET "NI_FRU"
		// do not ask FRU questions
	  ELSE
            PROMPT      "Do you want to update the chassis info area of the FRU? (Y/N)"
            YES         "UPD_CHS"
            NO          ""
            IFSET   "UPD_CHS"
                PROMPT      "Do you want to enter the chassis serial number? (Y/N)"
                YES         "CHASSN"
                NO          ""
                DISPLAY     ""
                IFSET       "CHASSN"
                    FRUFIELD    "S#" "@STDIN:ASCII"
                ENDIF

                PROMPT      "Do you want to enter the chassis part number? (Y/N)"
                YES         "CHASPN"
                NO          ""
                DISPLAY     " "
                IFSET       "CHASPN"
                    FRUFIELD    "P#" "@STDIN:ASCII"
                ENDIF
            ENDIF //END IFSET "UPD_CHS"

            FRUAREA     "BOARD"
            FRUFIELD    "MN"
            FRUFIELD    "PN"
            FRUFIELD    "ID"
            DISPLAY     ""

            FRUAREA     "PRODUCT"
            PROMPT      "Do you want to update the system info area of the FRU? (Y/N)"
            YES         "UPD_PRD"
            NO          ""
            IFSET       "UPD_PRD"
                FRUFIELD    "MN"
                FRUFIELD    "PN"
                FRUFIELD    "PV"
                PROMPT     "Do you want to enter system part number? (Y/N)"
                YES        "PROD_PN"
                NO         ""
                IFSET      "PROD_PN"
                    FRUFIELD    "P#" "@STDIN:ASCII"
                ENDIF

                PROMPT     "Do you want to enter the system serial number? (Y/N)"
                YES        "PROD_SN"
                NO         ""
                IFSET      "PROD_SN"
                    FRUFIELD    "S#" "@STDIN:ASCII"
                ENDIF

                PROMPT      "Do you want to enter the product asset tag? (Y/N)"
                YES         "ASSET"
                NO          ""
                DISPLAY     ""
				IFSET   "ASSET"
                    FRUFIELD    "AT" "@STDIN:ASCII"
                ENDIF
            ENDIF // END IFSET "UPD_PRD"
	  ENDIF // END IFSET "NI_FRU"
        ENDIF // END IFSET "FRU"
    ENDIF // END IFSET ASSET TAG
ENDIF // END IFSET "EXIT1"