#!/usr/bin/python
# -*- coding: latin-1 -*-
# INTEL CONFIDENTIAL
# Copyright 2007 Intel Corporation All Rights Reserved.
#
# The source code contained or described herein and all documents related to the
# source code (Material) are owned by Intel Corporation or its suppliers or
# licensors. Title to the Material remains with Intel Corporation or its
# suppliers and licensors. The Material may contain trade secrets and
# proprietary and confidential information of Intel Corporation and its
# suppliers and licensors, and is protected by worldwide copyright and trade
# secret laws and treaty provisions. No part of the Material may be used,
# copied, reproduced, modified, published, uploaded, posted, transmitted,
# distributed, or disclosed in any way without Intels prior express written
# permission. 
# No license under any patent, copyright, trade secret or other intellectual
# property right is granted to or conferred upon you by disclosure or delivery
# of the Materials, either expressly, by implication, inducement, estoppel or
# otherwise. Any license under such intellectual property rights must be express
# and approved by Intel in writing.
#
# Include any supplier copyright notices as supplier requires Intel to use.
#
# Include supplier trademarks or logos as supplier requires Intel to use, preceded
# by an asterisk. An asterisked footnote can be added as follows:
# *Third Party trademarks are the property of their respective owners.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intels suppliers
# or licensors in any way.

"""
This module sets the BIOS settings for SW RAID
"""
__author__ = 'Todd C Davis'
__Product__ = 'Intel_PDK'

import detectBIOSRAID, sys

Usage = """Usage: %s [enable|disable] [SATA|SAS] [Matrix]
       where 'disable' and 'SAS' are defaults
 e.g. 'setBIOS4RAID SATA' will disable SATA SW RAID in BIOS
      'setBIOS4RAID enable' will enable SAS SW RAID in BIOS
      'setBIOS4RAID enable SATA Matrix' will enable the Intel Matrix SATA SW RAID in BIOS
Usage: 'setBIOS4RAID ?' displays this usage statement
Return values:
    0 - BIOS is already set for SW RAID configuration
    1 - BIOS was set to new SW RAID configuration, requires a reboot to take effect.
    2 - BIOS reconfiguration failed
"""

tokens = ['enable','disable','SATA','SAS','Matrix','?']
if __name__ == '__main__':
    #print "executing setBIOS4RAID ... "
    enable = 0
    SATA = 0
    Matrix = 0
    for arg in sys.argv[1:]:
        if not arg in tokens:
            print "invalid argument: %s"%arg
            print Usage%sys.argv[0]
            sys.exit(1)
        if arg == '?':
            print Usage%sys.argv[0]
            sys.exit()
        if arg == 'enable':
            enable = 1
        if arg == 'SATA':
            SATA = 1
        if arg == 'Matrix':
            Matrix = 1
    sys.exit(detectBIOSRAID.setSWRAID(enable,SATA,Matrix))
