;----------------------------------------------------------------------------
; Atheros AR5001 Wireless Network Card 
;
; INF file for installing Atheros AR5001 Wireless Network Card 
; on Windows NT 4.0
;
;----------------------------------------------------------------------------

[Identification]
    OptionType = NetAdapter

[PlatformsSupported]
    ISA
    EISA
    MCA
    PCI

[Options]
    ATH 

[OptionsTextENG]
    ATH = "Atheros Wireless Network Adapter"
 
[AllFileConstants]
GenericInfVersion       = "3.1.1.54"
UtilityInf              = "UTILITY.INF"
ParamInf                = "NCPARAM.INF"
subroutineinf           = "SUBROUTN.INF"
SoftwareType            = "driver"
Exit_Code               = 0
NetEventDLL             = "%SystemRoot%\System32\netevent.dll"
IoLogMsgDLL             = "%SystemRoot%\System32\IoLogMsg.dll"
Manufacturer            = "Atheros Communications, Inc."
CardName                = "AR5001-0000-0000"
DISABLEPCMCIASYS        = "0"               ; "1"

PCIVendorID             = 5772       ; 0x168c
; Devices: 0x0011, 0x0012, 0x0013
PCIDeviceIDList         = { 17, 18, 19 } 


[FileConstants-ATH]
GenericAdapterName      = "Atheros Wireless Network Adapter"
GenericTitleName        = "Atheros Wireless Network Adapter"
GenericDriverName       = "Atheros Wireless Network Driver" 
GenericSysName          = "AR5211N4.SYS"
GenericName             = "AR5211N4"
ProductMajorVersion     = "2"
ProductMinorVersion     = "10"
ProductVersion          = $(ProductMajorVersion)"."$(ProductMinorVersion)
ProductSoftwareName     = "AR5211N4"
ProductSoftwareDesc     = "Atheros Wireless Network Adapter" 
ProductSoftwarePath     = "\SystemRoot\System32\drivers\"$(GenericSysName)
NetRuleSoftwareType     = "ar5211n4Sys ndisDriver ar5211n4Driver"
NetRuleSoftwareUse      = $(SoftwareType)
NetRuleSoftwareBindForm = """ar5211n4Sys"" yes no container"
NetRuleSoftwareClass    = {"ar5211n4Driver basic"}
NetRuleSoftwareBindable = {"ar5211n4Driver ar5211n4Adapter non exclusive 100"}
ProductHardwareName     = "AR5211N4"
ProductHardwareDesc     = "Atheros Wireless Network Adapter"
NetRuleHardwareType     = "AR5211N4 ar5211n4Adapter"
NetRuleHardwareBindForm = " yes yes container"
NetRuleHardwareClass    = {"ar5211n4Adapter basic"}

ProductKeyName          = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"

VERS1Manufacturer       = "Atheros"
VERS1Product            = "AR5001 Wireless Network Adapter"  
VERS1Type               = "AR5001"
PCMCIA                  = 0

[GeneralConstants]
From            = ""
To              = ""
ExitCodeOk      = 0
ExitCodeCancel  = 1
ExitCodeFatal   = 2
KeyNull         = ""
MaximumAllowed  = 33554432
RegistryError   = NO_ERROR
KeyProduct      = ""
KeyParameters   = ""
TRUE            = 1
FALSE           = 0
NoTitle         = 0
ExitState       = "Active"
OldVersionExist = $(FALSE)
DriverPath      = $(!STF_NTPATH)\drivers
DefaultConfigName = "Default"
Nictype         = 2

[date]
; Now is a list which contains { Sec From 1-1-1970, Year, Month, Day, Hour,
; Minute, Second }
Now = {} ? $(!LIBHANDLE) GetSystemDate

;---------------------------------------------------------------------------
; 1. Identify
;
; DESCRIPTION:   To verify that this INF deals with the same type of options
;                as we are choosing currently.
;
; INPUT:         None
;
; OUTPUT:        $($R0): STATUS: STATUS_SUCCESSFUL
;                $($R1): Option Type (COMPUTER ...)
;                $($R2): Diskette description
;---------------------------------------------------------------------------

[Identify]
    read-syms Identification
    set Status     = STATUS_SUCCESSFUL
    set Identifier = $(OptionType)
    set Media      = #("Source Media Descriptions", 1, 1)
    Return $(Status) $(Identifier) $(Media)

;------------------------------------------------------------------------
; 2. ReturnOptions:
;
; DESCRIPTION:   To return the option list supported by this INF and the
;                localised text list representing the options.
;
;
; INPUT:         $($0):  Language used. ( ENG | FRN | ... )
;
; OUTPUT:        $($R0): STATUS: STATUS_SUCCESSFUL |
;                                STATUS_NOLANGUAGE
;                                STATUS_FAILED
;                                STATUS_NOTSUPPORTED
;                $($R1): Option List
;                $($R2): Option Text List
;------------------------------------------------------------------------

[ReturnOptions]
    set Status          = STATUS_FAILED
    set OptionList      = {}
    set OptionTextList  = {}

    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) in $(LanguageList)
        ifstr(i) $($1) == $(KeyNull)
            goto returnoptions
        endif
        set PlatformList = ^(PlatformsSupported, 1)
        Ifcontains(i) $($1) in $(PlatformList)
            goto returnoptions
        else
            set Status = STATUS_NOTSUPPORTED
            goto finish_ReturnOptions
        endif
    else
        set Status = STATUS_NOLANGUAGE
        goto finish_ReturnOptions
    endif

returnoptions = +
    set OptionList     = ^(Options, 1)
    set OptionTextList = ^(OptionsText$($0), 1)
    set Status         = STATUS_SUCCESSFUL

finish_ReturnOptions = +
    Return $(Status) $(OptionList) $(OptionTextList)

;------------------------------------------------------------------------
; InstallOption:
;
;      This section is shelled to by main installation processing
;      or by NCPASHEL.INF during reconfig, removal, update, etc.
;
; FUNCTION:  To copy files representing Options
;            To configure the installed option
;            To update the registry for the installed option
;
; INPUT:     $($0):  Language to use
;            $($1):  OptionID to install
;            $($2):  SourceDirectory
;            $($3):  AddCopy  (YES | NO)
;            $($4):  DoCopy   (YES | NO)
;            $($5):  DoConfig (YES | NO)
;
; OUTPUT:    $($R0): STATUS: STATUS_SUCCESSFUL |
;                            STATUS_NOLANGUAGE |
;                            STATUS_USERCANCEL |
;                            STATUS_FAILED
;------------------------------------------------------------------------

[InstallOption]
    set Status   = STATUS_FAILED

    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)

    Set !DebugOutputControl = 1
    Debug-Output "INF: InstallOption"

    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) NOT-IN $(LanguageList)
        Return STATUS_NOLANGUAGE
    endif

    set-subst LF = "\n"
    read-syms GeneralConstants
    read-syms AllFileConstants
    read-syms FileConstants"-"$(Option)
    read-syms DialogConstants$(!STF_LANGUAGE)"-"$(Option)
    ifstr(i) $(!NTN_Origination) == "NCPA"
        set Continue = $(OK)
    endif

    read-syms AllFileConstants$(!STF_LANGUAGE)
    read-syms FileConstants$(!STF_LANGUAGE)"-"$(Option)

    detect date
    set-title  $(FunctionTitle)
    set To   = Begin
    set From = Begin
    set CommonStatus = STATUS_SUCCESSFUL
    EndWait

Begin = +
    Set ActivateDetection = FALSE

    Ifstr(i) $(!NTN_InstallMode) == deinstall
        set StartLabel = removeadapter
    else-Ifstr(i) $(!NTN_InstallMode) == Update
        set StartLabel = UpgradeSoftware
    else-Ifstr(i) $(!NTN_InstallMode) == bind
        set StartLabel = bindingadapter
    else-Ifstr(i) $(!NTN_InstallMode) == configure
        set StartLabel = configureadapter
        Ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
            Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                goto ShellCodeError
            endif
            set Error = $($R0)
            set From = end
            set To = end
            goto nonfatalinfo
        endif
    else
        set StartLabel = installadapter
        set OEM_ABANDON_OPTIONS = {}
        set OEM_ABANDON_SOFTWARE = FALSE
        set OEM_ABANDON_ON = TRUE
    endif

    ; Set the Default values

    set bssTypeValue        = "1"       ; bssType = AP (Infratructure)
    set defaultKeyValue     = "0"       ; defaultKey = Shared Key 1 (key0)
    set uniqKeyLengthValue  = "0"       ; uniqKeyLength = 40 bits
    set keyLength0Value     = "0"       ; keyLength0 = 40 bits
    set keyLength1Value     = "0"       ; keyLength1 = 40 bits
    set keyLength2Value     = "0"       ; keyLength2 = 40 bits
    set keyLength3Value     = "0"       ; keyLength3 = 40 bits
    set MapRegistersValue   = "256"
    set QoSValue            = "0"       ; QoS = Disabled
    set sleepModeValue      = "2"       ; sleepMode = Normal Power Save
    set AdHocBandValue      = "0"       ; 11b mode
    set AwakeTimePerfValue  = "200"     ; 200 msec
    set beaconIntervalValue = "100"     ; 100 msec
    set ccodeValue          = "US"      ; US reg domain
    set clistValue          = ""
    set EncryptionAlgValue  = "2"       ; Auto
    set FragThresholdValue  = "2346"    ; No Fragmentation
    set HwTxRetriesValue    = "4"       ; # of xmit retries done by hardware
    set NetBandValue        = "3"       ; A + A turbo default
    set NetworkAddressValue = ""
    set privacyInvokedValue = "0"       ; Disabled
    set uniqKeyValue        = ""
    set key0Value           = ""
    set key1Value           = ""
    set key2Value           = ""
    set Key3Value           = ""
    set rateCtrlEnableValue = "1"       ; enable rate control
    set RTSThresholdValue   = "2346"    ; request-to-send disabled
    set scanTypeValue       = "2"       ; use reg domain for scan type
    set SsidValue           = ""
    set SwTxRetryScaleValue = "6"       ; 6 xmit s/w reties 
    set BusNum              = 0
    set SlotNum             = 0
    set FunctionNum         = 0
    set cNetBandValue       = 3         ; NCP netband value

    Set From = $(fatal)
    Set To = $(fatal)
    Goto $(StartLabel)

;-----------------------------------------------
; Installation Section
;-----------------------------------------------

installadapter = +

    ; PCI Support. 
    ; If a device is not found, don't error out => assume it's Cardbus.

    Debug-Output "INF: Starting Install"
    Debug-Output "INF: Vendor ID = $(PCIVendorID)"
    Debug-Output "INF: Device ID List= $(PCIDeviceIDList)"

    set AdapterList = {}

    ForListDo $(PCIDeviceIDList)

        set PCIDeviceID = $($)
        Shell $(UtilityInf), GetPCIInformation, $(PCIVendorID) $(PCIDeviceID)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            goto ShellCodeError
        endif

        ; append all adapters onto the adapter list
        ForListDo $($R0)
            set AdapterList = >( $(AdapterList), {*($($),1), *($($),2), *($($),3)} )
        EndForListDo

    EndForListDo

    Debug-Output "INF: Adapter List= $(AdapterList)"

    ifstr(i) $(AdapterList) != {}
        ; Only support one PCI adapter 
        set BusNum      = *(*($(AdapterList),1),1)
        set SlotNum = *(*($(AdapterList),1),2)
        set FunctionNum = *(*($(AdapterList),1),3)
    endif

    ; Check whether the same version of the software exists
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MaximumAllowed) KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)
        ; Same version already existed in the local machine
        ; Popup the dialog and ask the user whether he wants to continue
        CloseRegKey $(KeyProduct)
        ifstr(i) !(NTN_RegBase) == $(ProductKeyName)
           Shell $(UtilityInf), VerExistedDlg, $(ProductSoftwareTitle),+
               $(ProductVersion)
           ifint $($ShellCode) != $(!SHELL_CODE_OK)
               Debug-Output "ShellCode error: cannot get an error string."
               goto ShellCodeError
           endif
           goto end
        else
           ; Add a new adapter card?
           Shell $(UtilityInf), CardExistedDlg
           ifint $($ShellCode) != $(!SHELL_CODE_OK)
               Debug-Output "ShellCode error: cannot get an error string."
               goto ShellCodeError
           endif
           ifstr(i) $($R1) != "OK"
               goto end
           endif
           set OldVersionExist = $(TRUE)
        endif
    endif

    ; prompt for media
    ;

   IfStr(i) $(SrcDir) == ""
        Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) NO
        Ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Goto ShellCodeError
        Else-Ifstr(i) $($R0) == STATUS_FAILED
            Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                goto ShellCodeError
            endif
            set Error = $($R0)
            Goto fatal
        Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
            Goto successful
        Endif
        Set SrcDir = $($R1)
    endif

    Debug-Output "INF: install control panel"
    install "Install-Cpl"
    goto adaptersetup

;-----------------------------------------------
; Configuration Section
;-----------------------------------------------

; Confugure the adapter by invoking the NCP
;
configureadapter = +
    Debug-Output "INF: configure adapter"
    shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) "NONFATAL" "Configure is not supported, use control panel to do configuration"
    goto successful



adaptersetup = +
    Set From = adapteroptions

adapteroptions = +
    set ENABLER = 0

; If installing, go create the necessary keys;
; if configuring, they're already open
;
skipoptions =+
    Debug-Output "INF: skipoptions"
    ifint $(OldVersionExist) == $(TRUE)
        ifstr(i) $(!NTN_InstallMode) == configure
            goto writeparameters
        endif
    endif
    StartWait

    ; Add Software Component
    ifint $(OldVersionExist) == $(FALSE)
        ifstr(i) $(!NTN_InstallMode) == "install"
           Ifstr(i) $(DoCopy) == "YES"
              Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) YES
              Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                  Goto ShellCodeError
              Else-Ifstr(i) $($R0) == STATUS_FAILED
                  Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
                  ifint $($ShellCode) != $(!SHELL_CODE_OK)
                      goto ShellCodeError
                  endif
                  set Error = $($R0)
                  Goto fatal
              Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
                  Goto successful
              Endif
              Set SrcDir = $($R1)
           Endif
           Debug-Output "INF: install driver"
           install "Install-Option"
           ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
              Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"
              ifint $($ShellCode) != $(!SHELL_CODE_OK)
                  goto ShellCodeError
              endif
              set Error = $($R0)
              goto fatal
           endif
        endif

        Debug-Output "INF: add software component"
        Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
            $(ProductSoftwareName), +
            $(ProductSoftwareName), +
            $(ProductSoftwareTitle), $(STF_CONTEXTINFNAME), +
            $(ProductSoftwarePath), "kernel", "NDIS", {}, "",+
            $(NetEventDLL)

        Set OEM_ABANDON_SOFTWARE = TRUE
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif

        ; $R1 contains the product version key handle
        ; $R2 contains the NetRules subkey handle
        ; $R3 contains the new Services key handle
        ; $R4 contains the Parameters key
        ; $R5 contains the Linkage Key
        set RegistryError = $($R0)
        set KeyProduct      = $($R1)
        Set SoftNetRulesKey = $($R2)
        CloseRegKey $($R3)
        CloseRegKey $($R4)
        CloseRegKey $($R5)

        Ifstr(i) $(RegistryError) != NO_ERROR
            EndWait
            Debug-Output "Registry error: add software components"
            CloseRegKey $(KeyProduct)
            CloseRegKey $(SoftNetRulesKey)
            goto fatalregistry
        endif

        set NewValueList = {{SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)},+
                           {MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
                           {MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
                           {Title,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareTitle)},+
                           {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareDesc)},+
                           {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareName)},+
                           {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}

        Debug-Output "INF set product keys"
        Shell  $(UtilityInf), AddValueList, $(KeyProduct), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error."
            goto ShellCodeError
        endif

        set RegistryError = $($R0)

        Ifstr(i) $(RegistryError) != NO_ERROR
            EndWait
            Debug-Output "Registry error: add value list."
            CloseRegKey $(KeyProduct)
            CloseRegKey $(SoftNetRulesKey)
            goto fatalregistry
        endif

        set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareType)},+
                            {use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareUse)}, +
                            {bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareBindForm)}, +
                            {class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareClass)}, +
                            {bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareBindable)}, +
                            {InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}

        Debug-Output "INF set software keys"
        Shell  $(UtilityInf), AddValueList, $(SoftNetRulesKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error."
            goto ShellCodeError
        endif

        set RegistryError = $($R0)

        CloseRegKey $(KeyProduct)
        CloseRegKey $(SoftNetRulesKey)

        Ifstr(i) $(RegistryError) != NO_ERROR
            EndWait
            Debug-Output "Registry error: add value list."
            goto fatalregistry
        endif
    endif

    ; Create the HARDWARE\Netcard region and its corresponding service
    ;
    Debug-Output "INF set hardware keys"
    Shell $(UtilityInf), AddHardwareComponent, $(ProductHardwareName),$(STF_CONTEXTINFNAME),$(ProductKeyName)
    ifint $($R4) != -1
        Set OEM_ABANDON_OPTIONS = >($(OEM_ABANDON_OPTIONS), $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards\"$($R4))
    endif

    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "Cannot add hardware component"
        goto ShellCodeError
    endif

    set RegistryError = $($R0)
    Ifstr(i) $(RegistryError) != NO_ERROR
        EndWait
        Debug-Output "Registry error: add hardware component"
        CloseRegKey $($R1)
        CloseRegKey $($R2)
        CloseRegKey $($R3)
        goto fatalregistry
    endif

    ; $R1  Registry key variable for HARDWARE\Netcard\(n)
    ; $R2  Registry key variable for HARDWARE\Netcard\(n)\\NetRules
    ; $R3  Registry key handle for <service>\Parameters key
    ; $R4  Adapter number assigned to adapter
    ; $R5  Service name generated by combining svc name with adapter number
    set KeyParameters = $($R3)
    set KeyAdapterRules = $($R2)
    set AdapterNumber = $($R4)

    set NewValueList = {{Manufacturer,$(NoTitle),$(!REG_VT_SZ),$(Manufacturer)},+
                       {Title,$(NoTitle),$(!REG_VT_SZ),"["$($R4)"] "$(ProductHardwareTitle)},+
                       {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductHardwareDesc)},+
                       {ProductName,$(NoTitle),$(!REG_VT_SZ),$(ProductHardwareName)},+
                       {ServiceName,$(NoTitle),$(!REG_VT_SZ),$($R5)},+
                       {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}

    Debug-Output "INF set mfg keys"
    Shell  $(UtilityInf), AddValueList, $($R1), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error"
        goto ShellCodeError
    endif
    CloseRegKey $($R1)

    set TempProdName = """"$(ProductHardwareName)$(AdapterNumber)""""
    set TempBindForm = $(TempProdName)$(NetRuleHardwareBindForm)

    set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleHardwareType)},+
                        {bindform,$(NoTitle),$(!REG_VT_SZ),$(TempBindForm)}, +
                        {class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleHardwareClass)}, +
                        {InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}

    Debug-Output "INF set rule keys"
    Shell  $(UtilityInf), AddValueList, $(KeyAdapterRules), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error."
        goto ShellCodeError
    endif

    set RegistryError = $($R0)

    Ifstr(i) $(RegistryError) != NO_ERROR
        EndWait
        Debug-Output "Resgitry error: add value list."
        CloseRegKey $(KeyParameters)
        CloseRegKey $(KeyAdapterRules)
        goto fatalregistry
    endif

    CloseRegKey $(KeyAdapterRules)
    goto writeparameters

; REQUIRED: $(KeyParameters) contains service Parameters key handle
;
writeparameters = +

    Shell $(UtilityInf), GetBusTypeNum
    set BusTypeNum = $($R1)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error."
        goto ShellCodeError
    endif

    ; Add the rest of the parameters to the Services area
    Debug-Output "INF Create Driver Parameters"


    set NewValueList        = {{bssType, $(NoTitle),$(!REG_VT_SZ),$(bssTypeValue)},+
                              {sleepMode, $(NoTitle),$(!REG_VT_SZ),$(sleepModeValue)},+
                              {defaultKey, $(NoTitle),$(!REG_VT_SZ),$(defaultKeyValue)},+
                              {uniqKeyLength, $(NoTitle),$(!REG_VT_SZ),$(uniqKeyLengthValue)},+
                              {keyLength0, $(NoTitle),$(!REG_VT_SZ),$(keyLength0Value)},+
                              {keyLength1, $(NoTitle),$(!REG_VT_SZ),$(keyLength1Value)},+
                              {keyLength2, $(NoTitle),$(!REG_VT_SZ),$(keyLength2Value)},+
                              {keyLength3, $(NoTitle),$(!REG_VT_SZ),$(keyLength3Value)},+
                              {MapRegisters, $(NoTitle),$(!REG_VT_SZ),$(MapRegistersValue)},+
                              {QoS, $(NoTitle),$(!REG_VT_SZ),$(QoSValue)},+
                              {tpc, $(NoTitle),$(!REG_VT_SZ),$(tpcValue)},+
                              {AdHocBand, $(NoTitle),$(!REG_VT_SZ),$(AdHocBandValue)},+
                              {AwakeTimePerf, $(NoTitle),$(!REG_VT_SZ),$(AwakeTimePerfValue)},+
                              {beaconInterval, $(NoTitle),$(!REG_VT_SZ),$(beaconIntervalValue)},+
                              {ccode, $(NoTitle),$(!REG_VT_SZ),$(ccodeValue)},+
                              {clist, $(NoTitle),$(!REG_VT_SZ),$(clistValue)},+
                              {EncryptionAlg, $(NoTitle),$(!REG_VT_SZ),$(EncryptionAlgValue)},+
                              {FragThreshold, $(NoTitle),$(!REG_VT_SZ),$(FragThresholdValue)},+
                              {Ssid, $(NoTitle),$(!REG_VT_SZ),$(SsidValue)},+
                              {NetworkAddress, $(NoTitle),$(!REG_VT_SZ),$(NetworkAddressValue)},+
                              {uniqKey, $(NoTitle),$(!REG_VT_SZ),$(uniqKeyValue)},+
                              {key0, $(NoTitle),$(!REG_VT_SZ),$(key0Value)},+
                              {key1, $(NoTitle),$(!REG_VT_SZ),$(key1Value)},+
                              {key2, $(NoTitle),$(!REG_VT_SZ),$(key2Value)},+
                              {key3, $(NoTitle),$(!REG_VT_SZ),$(key3Value)},+
                              {privacyInvoked, $(NoTitle),$(!REG_VT_SZ),$(privacyInvokedValue)},+
                              {rateCtrlEnable, $(NoTitle),$(!REG_VT_SZ),$(rateCtrlEnableValue)},+
                              {RTSThreshold, $(NoTitle),$(!REG_VT_SZ),$(RTSThresholdValue)},+
                              {scanType, $(NoTitle),$(!REG_VT_SZ),$(scanTypeValue)},+
                              {HwTxRetries, $(NoTitle),$(!REG_VT_SZ),$(HwTxRetriesValue)},+
                              {SwTxRetryScale, $(NoTitle),$(!REG_VT_SZ),$(SwTxRetryScaleValue)},+
                              {BusType, $(NoTitle),$(!REG_VT_DWORD),$(BusTypeNum)},+
                              {BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNum)},+
                              {SlotNumber,$(NoTitle),$(!REG_VT_DWORD),$(SlotNum)},+
                              {FunctionNumber,$(NoTitle),$(!REG_VT_DWORD),$(FunctionNum)},+
                              {DriverDesc,$(NoTitle),$(!REG_VT_SZ),$(GenericAdapterName)},+
                              {AdapterType, $(NoTitle),$(!REG_VT_DWORD),0},+
                              {PCMCIA, $(NoTitle),$(!REG_VT_DWORD),0},+
                              {DriverType,$(NoTitle),$(!REG_VT_DWORD),1},+
                              {MediaType,$(NoTitle),$(!REG_VT_DWORD),1},+
                              {NwayProtocol,$(NoTitle),$(!REG_VT_DWORD),1},+
                              {PlatformType,$(NoTitle),$(!REG_VT_DWORD),1}}
   
    Shell  $(UtilityInf), AddValueList, $(KeyParameters), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error."
        goto ShellCodeError
    endif

    ; go get the subsystem ID so the correct NIC type can be set
    ;
    ; 1.) Call Executable to populate the reg keys with the PCI data for the current instance of the NIC
    RunProgram ExitCode  "" "" ANTPCIEX.EXE 


    ; 2.) Check open key for the data of interest. *** DeviceID, SubSystemID, SubVendorID, and VendorID are present

    GetRegValue $(KeyParameters) "ANTDeviceID" Array_DeviceID
    GetRegValue $(KeyParameters) "ANTVendorID" Array_VendorID
    GetRegValue $(KeyParameters) "ANTSubSystemID" Array_SubSystemID
    GetRegValue $(KeyParameters) "ANTSubVendorID" Array_SubVendorID

    Set Value_DeviceID      = *($(Array_DeviceID),4)
    Set Value_VendorID      = *($(Array_VendorID),4)
    Set Value_SubSystemID   = *($(Array_SubSystemID),4)
    Set Value_SubVendorID   = *($(Array_SubVendorID),4)


    ifint $(Value_DeviceID) == 17               ; 0x11 - MAUI2
        Set Nictype = 0
        set NetBandValue = "3"                  ; 11a mode
        set cNetBandValue = 3
    endif
    ifint $(Value_DeviceID) == 18               ; 0x12 - Oahu
        ifint $(Value_SubSystemID) == 4129      ; 0x1021 - CB-21
            Set Nictype = 0
            set NetBandValue = "3"              ; 11a mode
            set cNetBandValue = 3
        endif
        ifint $(Value_SubSystemID) == 8225      ; 0x2021 - MB-21
            Set Nictype = 2
            set NetBandValue = "3"              ; 11a mode
            set cNetBandValue = 3
        endif
        ifint $(Value_SubSystemID) == 4130      ; 0x1022 - CB-22
            Set Nictype = 1
            set NetBandValue = "7"              ; 11ab mode
            set cNetBandValue = 7
        endif
        ifint $(Value_SubSystemID) == 8226      ; 0x2022 - MB-22
            Set Nictype = 2
            set NetBandValue = "7"              ; 11ab mode
            set cNetBandValue = 7
        endif
    endif
    ifint $(Value_DeviceID) == 19               ; 0x13 - Venice
        ifint $(Value_SubSystemID) == 4133      ; 0x1025 - CB-21g
            Set Nictype = 1
            set NetBandValue = "12"             ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 8229      ; 0x2025 - CB-21g
            Set Nictype = 2
            set NetBandValue = "12"             ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 4134      ; 0x1026 - CB-22ag
            Set Nictype = 1
            set NetBandValue = "15"             ; 11abg mode
            set cNetBandValue = 15
        endif
        ifint $(Value_SubSystemID) == 8230      ; 0x2026 - MB-22ag
            Set Nictype = 2
            set NetBandValue = "15"             ; 11 abg mode
            set cNetBandValue = 15 
        endif
        ifint $(Value_SubSystemID) == 4135      ; 0x1027 - CB-22g
            Set Nictype = 1
            set NetBandValue = "12"             ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 8231      ; 0x2027 - MB-22g
            Set Nictype = 2
            set NetBandValue = "12"             ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 4144      ; 0x1030 - CB-31
            Set Nictype = 1
            set NetBandValue = "12"             ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 8240      ; 0x2030 - MB-31
            Set Nictype = 2
            set NetBandValue = "12"              ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 4145      ; 0x1031 - CB-32
            Set Nictype = 1
            set NetBandValue = "15"             ; 11ag mode
            set cNetBandValue = 15
        endif
        ifint $(Value_SubSystemID) == 8241      ; 0x2031 - MB-32
            Set Nictype = 2
            set NetBandValue = "15"              ; 11ag mode
            set cNetBandValue = 15
        endif
        ifint $(Value_SubSystemID) == 4161      ; 0x1041 - CB-41
            Set Nictype = 1
            set NetBandValue = "12"             ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 8257      ; 0x2041 - MB-41
            Set Nictype = 2
            set NetBandValue = "12"             ; 11bg mode
            set cNetBandValue = 12
        endif
        ifint $(Value_SubSystemID) == 4162      ; 0x1042 - CB-42
            Set Nictype = 1
            set NetBandValue = "15"             ; 11ag mode
            set cNetBandValue = 15
        endif
        ifint $(Value_SubSystemID) == 8258      ; 0x2042 - MB-42
            Set Nictype = 2
            set NetBandValue = "15"             ; 11abg mode
            set cNetBandValue = 15
        endif
    endif

    ; now write the driver's wireless mode key
    ;
    SetRegValue $(KeyParameters) {"NetBand", 0,$(!REG_VT_SZ),$(NetBandValue)}

    ; add parameters below the driver list
    ;
    set CfgParameters = "CustomParams\Configurations"

    CreateRegKey $(KeyParameters) {$(CfgParameters),0,GenericClass} "" $(!REG_KEY_ALL_ACCESS) "" MyCfgParmHandle
    CloseRegKey $(KeyParameters)
    ifstr $(MyCfgParmHandle) == $(KeyNull)
        shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) "NONFATAL" "ConfigParm registry create failed. Could not create key:"$($)" ("$(RegLastError)")"
        goto successful
    endif
    set NewValueList = {{MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
                        {MinorVersion, $(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
                        {NicType, $(NoTitle),$(!REG_VT_DWORD),$(Nictype)},+
                        {SelectedConfigurationIndex,$(NoTitle),$(!REG_VT_DWORD),0},+
                        {SelectedConfigurationName,$(NoTitle),$(!REG_VT_SZ),$(DefaultConfigName)}}

    Shell  $(UtilityInf), AddValueList, $(MyCfgParmHandle), $(NewValueList)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error."
        CloseRegKey $(MyCfgParmHandle)
        goto ShellCodeError
    endif

    ifint $(DISABLEPCMCIASYS) == 1
        set PCMCIAKeyName = $(!NTN_ServiceBase)"\Pcmcia"
        OpenRegKey $(!REG_H_LOCAL) "" $(PCMCIAKeyName) $(MaximumAllowed) PCMCIAKey
        SetRegValue $(PCMCIAKey) {Start, 0, $(!REG_VT_DWORD),4}  ; '4' disables the driver
        CloseRegKey $(PCMCIAKey)
    endif
     
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error."
        goto ShellCodeError
    endif

    set RegistryError = $($R0)

    Ifstr(i) $(RegistryError) != NO_ERROR
        Debug-Output "Registry error: Add value list"
        goto fatalregistry
    endif
    EndWait

    ; ----------------------------------------------------------------------------------------------------------
    ; add driver info to the SYSTEM\CurrentControlSet\Services\resman\Database\Atheros for CardWizard
    ; ----------------------------------------------------------------------------------------------------------
    set CWKey               = "SYSTEM\CurrentControlSet\Services\resman"
    set CWDatabaseKey       = $(CWKey)"\Database"
    set CWManufacturerKey   = $(CWDatabaseKey)"\"$(Manufacturer)
    set CWCardNameKey       = $(CWManufacturerKey)"\"$(CardName)
    Debug-Output "INF Check the presence of CardWizard"
    OpenRegKey $(!REG_H_LOCAL) "" $(CWKey) $(MaximumAllowed) MyPcmciaHandle
    Ifstr $(MyPcmciaHandle) == $(KeyNull)
        goto successful
    endif

    Debug-Output "INF Create Registry Keys for CardWizard"

    OpenRegKey $(!REG_H_LOCAL) "" $(CWCardNameKey) $(MaximumAllowed) MyPcmciaHandle
    Ifstr $(MyPcmciaHandle) == $(KeyNull)
        Debug-Output "INF: Create Registry Keys (for CardName)"
        OpenRegKey $(!REG_H_LOCAL) "" $(CWDatabaseKey) $(MaximumAllowed) MyPcmciaKey
        CreateRegKey $(MyPcmciaKey) {$(Manufacturer),0,GenericClass} "" $(MaximumAllowed) "" MyPcmcialHandle
        CloseRegKey $(MyPcmciaKey)
        OpenRegKey $(!REG_H_LOCAL) "" $(CWManufacturerKey) $(MaximumAllowed) MyPcmciaKey
        CreateRegKey $(MyPcmciaKey) {$(CardName),0,GenericClass} "" $(MaximumAllowed) "" MyPcmcialHandle
        CloseRegKey $(MyPcmciaKey)
        OpenRegKey $(!REG_H_LOCAL) "" $(CWCardNameKey) $(MaximumAllowed) MyPcmciaHandle
    endif
    set NewValueList = {{Driver,$(NoTitle),$(!REG_VT_SZ),$(GenericName)}}
    Shell  $(UtilityInf), AddValueList, $(MyPcmciaHandle), $(NewValueList)
    Debug-Output "<DBG> AddValueList - Driver:REG_SZ:"$(CardName)
    CloseRegKey $(MyPcmciaHandle)

    goto successful

;-----------------------------------------------
; Binding section
;-----------------------------------------------

bindingadapter =+
    Debug-Output "INF - binding not suppported"
    set Error = "Binding: Sorry, not yet implemented."
    goto fatal

;-----------------------------------------------
; Removeadapter section
;-----------------------------------------------

removeadapter = +
    Debug-Output "INF - remove adapter"
    Ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
        ; Remove Software Component
        Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
            $(ProductSoftwareName)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif
        set RegistryError = $($R0)
        Ifstr(i) $(RegistryError) != NO_ERROR
            goto fatalregistry
        endif
    else
        Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
            $(ProductSoftwareName), $(!NTN_RegBase)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif
        set RegistryError = $($R0)
        Ifstr(i) $(RegistryError) != NO_ERROR
            goto fatalregistry
        endif
    endif
    ifint $(DISABLEPCMCIASYS) == 1
        set PCMCIAKeyName = $(!NTN_ServiceBase)"\Pcmcia"
        OpenRegKey $(!REG_H_LOCAL) "" $(PCMCIAKeyName) $(MaximumAllowed) PCMCIAKey
        SetRegValue $(PCMCIAKey) {Start, 0, $(!REG_VT_DWORD),0}  ; '0' restores the driver to "BOOT"
        CloseRegKey $(PCMCIAKey)
    endif
    goto end

;-----------------------------------------------
; Upgrade Software section
;-----------------------------------------------

UpgradeSoftware = +

    ; Update Software\ManufacturerName\ProductName\CurrentVersion and
    ; install new drivers and INF

    Debug-Output "INF - upgrade"
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MaximumAllowed) KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)

        Shell $(UtilityInf), GetInfFileNameFromRegistry, $(KeyProduct)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
           Debug-Output "ShellCode error"
           goto ShellCodeError
        endif
        set !UG_Filename = $($R0)
        ifstr(i) $(!UG_Filename) != ""
            install "Install-Update"
            ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
                goto fatal
            endif
        endif

        SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMajorVersion)}
        SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMinorVersion)}

        CloseRegKey $(KeyProduct)
    else
       goto fatalregistry
    endif

    goto end

successful = +
    goto end

abandon = +
    Debug-Output "INF adandon"
    ForListDo $(OEM_ABANDON_OPTIONS)
        Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
            $(ProductSoftwareName), $($)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif
        set RegistryError = $($R0)
        Ifstr(i) $(RegistryError) != NO_ERROR
            goto fatalregistry
        endif
    EndForListDo
    Ifstr(i) $(OEM_ABANDON_SOFTWARE) == TRUE
        Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
            $(ProductSoftwareName), FALSE
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif
        set RegistryError = $($R0)
        Ifstr(i) $(RegistryError) != NO_ERROR
            goto fatalregistry
        endif
    endif
    goto end

warning = +
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    ifstr(i) $($R1) == "OK"
        goto $(to)
    else-ifstr(i) $($R1) == "CANCEL"
        goto $(From)
    else
        goto "end"
    endif

nonfatalinfo = +
    Set Severity = STATUS
    Set CommonStatus = STATUS_USERCANCEL
    goto nonfatalmsg

nonfatal = +
    Set Severity = NONFATAL
    goto nonfatalmsg

nonfatalmsg = +
    ifstr(i) $(Error) == ""
        Set Severity = NONFATAL
        Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            goto ShellCodeError
        endif
        set Error = $($R0)
    endif
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), $(Severity), $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    ifstr(i) $($R1) == "OK"
        goto $(From)
    else
        goto "end"
    endif

fatalregistry = +
    Shell $(UtilityInf) RegistryErrorString $(RegistryError)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    set Error = $($R0)
    goto fatal

fataldetect = +
    Shell $(UtilityInf),RegistryErrorString,CANNOT_DETECT
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error: cannot get an error string."
        goto ShellCodeError
    endif
    set Error = $($R0)
    Goto fatal

fatal = +
    ifstr(i) $(Error) == ""
        Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            goto ShellCodeError
        endif
        set Error = $($R0)
    endif
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    goto setfailed

ShellCodeError = +
    set DlgType      = "MessageBox"
    set STF_MB_TITLE = $(ShellCodeErrorTitle)
    set STF_MB_TEXT  = $(ShellCodeErrorText)
    set STF_MB_TYPE  = 1
    set STF_MB_ICON  = 3
    set STF_MB_DEF   = 1
    ui start "Error Message"
    goto setfailed

setfailed = +
    set CommonStatus = STATUS_FAILED
    ifstr(i) $(OEM_ABANDON_ON) == TRUE
        set OEM_ABANDON_ON = FALSE
        goto abandon
    endif
    goto end

end = +
    goto term

term = +
    Return $(CommonStatus)

[DebugConfiguration]
    Set InfName = "OEMSETUP.INF"
    return

[Install-Option]
    set STF_VITAL = ""
    ifstr(i) $(AddCopy) == "YES"
        AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
    endif
    ifstr(i) $(DoCopy) == "YES"
        set !STF_NCPA_FLUSH_COPYLIST = TRUE
        CopyFilesInCopyList
    endif
    Exit

[Install-Update]
    set STF_VITAL = ""
    set STF_OVERWRITE = "VERIFYSOURCEOLDER"
    AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
    AddSectionFilesToCopyList Files-Inf $(SrcDir) $(!STF_WINDOWSSYSPATH)
    AddSectionFilesToCopyList Files-Cpl $(SrcDir) $(!STF_WINDOWSSYSPATH)
    set !STF_NCPA_FLUSH_COPYLIST = TRUE
    CopyFilesInCopyList
    exit

[Install-Cpl]
    set STF_VITAL = ""
    AddSectionFilesToCopyList Files-Cpl $(SrcDir) $(!STF_WINDOWSSYSPATH)
    set !STF_NCPA_FLUSH_COPYLIST = TRUE
    CopyFilesInCopyList
    exit

[Source Media Descriptions]
    1  = "Atheros Setup Disk for NT"

[ProductType]
STF_PRODUCT  = Winnt
STF_PLATFORM = I386

[Files-Inf]
1, OEMSETUP.INF, SIZE=58000, RENAME=$(!UG_Filename)

[Files-Cpl]
1, ANTPCIEX.EXE , SIZE=184000
1, ANTPCISY.SYS , SIZE=4000

[Files-ATH]
1, AR5211N4.SYS, SIZE=53000

[LanguagesSupported]
    ENG

[AllFileConstantsENG]
ProCaption      = "Windows NT Setup"
ProCancel       = "Cancel"
ProCancelMsg    = "Windows NT Networking is not correctly installed.  "+
                  "Are you sure you want to cancel copying files?"
ProCancelCap    = "Network Setup Message"
ProText1        = "Copying:"
ProText2        = "To:"

[FileConstantsENG-ATH]
FunctionTitle           = $(GenericTitleName)" Setup"$(GenericInfVersion)
ProductSoftwareTitle    = $(GenericDriverName)
ProductHardwareTitle    = $(GenericAdapterName)

[DialogConstantsENG-ATH]
Help        = "&Help"
Exit        = "Cancel"
OK          = "OK"
HelpContext = ""
Continue    = "Continue"
Cancel      = "Cancel"

