// Sync570 Adapter specifics

//
//	Configures all options relating to this adapter.
//
//		$0 = Source directory
//		$1 = Option
//		$2 = Parameters Key
//		$3 = AdapterServiceName
//
//		$R0 = Status 
//
[ConfigureAdapter-Sync570]
	read-syms DriverConstants-X25

	set SrcDir = $($0)
	set Option = $($1)
	set KeyParameters = $($2)
	set AdapterServiceName = $($3)
	_Enter("ConfigureAdapter-Sync570", _Show(SrcDir)_Show(Option)_Show(KeyParameters)_Show(AdapterServiceName))
		
	// Add the Adapter to the DigiSOH List
	_LocalShell AddAdapterToMiniportAdapters $(AdapterServiceName)

	// Call the genero config
	_LocalShell ConfigureAdapter $(SrcDir) $(Option) $(KeyParameters) $(AdapterServiceName) $(!STF_CWDDIR)"DigiInf.Dll" "INFEntryPoint"

	set Status = $($R0)
   set NeedBindingReview = $($R1)

   ifstr(i) $(Status) != "STATUS_SUCCESSFUL"
      goto Exit
   endif

   set KeyX25Adapter = KEY_NULL
   set AdapterNumber = EMPTY_STR
   set NumRasPorts = 0

   _LocalShell FindAdapter $(ProductSoftwareName)
   _If($($R0))
		set AdapterNumber = $($R1)
        _Trace("Found adapter with number set to ",_Show(AdapterNumber))
		_OpenServiceParamKey($(ProductHardwareName)$(AdapterNumber), KeyX25Adapter)
		_IfValidKey($(KeyX25Adapter))
		  
			_GetRegDwordByKey $(KeyX25Adapter) "NumRASPorts"
			_If($($R0))
				set NumRasPorts = $($R1)
				_Trace("**** NumRasPorts = ",_Show(NumRasPorts))
			endif
			CloseRegKey $(KeyX25Adapter)

			// Disable WAN driver if there are no RAS ports.
			ifint $(NumRasPorts) == 0
				set Start = 4
			else
				set Start = 2
			endif
			_OpenRegKey_HKLM($(!NTN_ServiceBase)"\\"$(ProductHardwareName), KeyDriverService)
			_SetRegDwordByKey $(KeyDriverService) "Start" $(Start)
			_Assert($($R0))
			CloseRegKey $(KeyDriverService)

			_LocalShell SetTapi "X25" $(AdapterNumber) $(NumRasPorts) SETTAPI_ADDRSCHEME_ENDPOINT
		endif
   endif


   ifint $(NumRasPorts) > 0
		ifstr(i) $(!NTN_InstallMode) == "Install"
			_LocalShell InvokeRAS
		endif
   endif

	_If($(NeedBindingReview))
		set Status = "STATUS_SUCCESSFUL"
	else
		set Status = "STATUS_REBOOT"
	endif

Exit = +

	_Exit("ConfigureAdapter-Sync570", _Show(Status))
	Return $(Status)

