// install.inc - Handles install mode.


//	********************************************************************************
//	Install Shell Sections
//	********************************************************************************


[DetectionFilesList]
// Desc.               Section                Dest. Dir
// ---------------------------------------------------------------------------------
   "Detection Files"   = Files-Detect,        $(!STF_WINDOWSSYSPATH)
   "Detection Drivers" = Files-Detect-Driver, $(!STF_WINDOWSSYSPATH)"\\drivers"

//
// Silently copies any detection files needed.
//
//		$0 = Source Dir [$(SrcDir)]
//
//    $R0 = Success
//
[CopyDetectionFiles]

	set SrcDir = $($0)
	_Enter("CopyDetectionFiles", _Show(SrcDir))

   set Success = FALSE

   set DescList = ^(DetectionFilesList, 0)
   ForListDo $(DescList)

      set Desc = $($)
      set Section = #(DetectionFilesList, $(Desc), 1)
      set DstDir = #(DetectionFilesList, $(Desc), 2)

	   _Trace("Copying "$(Desc), _Show(Section)_Show(SrcDir)_Show(DstDir))

      set FileList = ^($(Section), 2)
      ForListDo $(FileList)
         // Do it this way so progress bar doesn't show up.
		   _Call("CopySingleFile", _Show($))
         ifstr(i) $(!NTVER) == "3.51"
            LibraryProcedure Result $(!LIBHANDLE) CopySingleFile $(SrcDir)"\\"$($) $(DstDir)"\\"$($)
         else
            LibraryProcedure Result $(!NCPA_HANDLE) CopySingleFile $(!STF_HWND) $(SrcDir)"\\"$($) $(DstDir)"\\"$($)
         endif
		   _Return("CopySingleFile", _Show(Result))

         _LocalShell AddSingleFileToRemoveList $(DstDir)"\\"$($)

      EndForListDo

   EndForListDo

   set Success = TRUE

Exit = +

	_Exit("CopyDetectionFiles", _Show(Success))
	Return $(Success)

//
// Dependencies:
//
//	$(AddCopy)
// $(Section)
//	$(SrcDir)
//	$(DstDir)
//
[Install-AddFiles]
	ifstr(i) $(AddCopy) == "YES"
      Ifcontains $(Section)$(SrcDir)$(DstDir) not-in $(!DIGI_FileSectionsToCopyCoalesceList)
         set !DIGI_FileSectionsToCopyCoalesceList = >($(!DIGI_FileSectionsToCopyCoalesceList), $(Section)$(SrcDir)$(DstDir))
         AddSectionFilesToCopyList $(Section) $(SrcDir) $(DstDir)
      else
   	   _Trace("Coalescing", _Show(Section)_Show(SrcDir)_Show(DstDir))
   	endif
	endif
   Exit

//
// Dependencies:
//
//	$(DoCopy)
//
[Install-CopyFiles]
	ifstr(i) $(DoCopy) == "YES"
	   set STF_VITAL = EMPTY_STR
      set STF_VERSION = DXBVER_VERSION_MAJOR","DXBVER_VERSION_MINOR","DXBVER_BUILDNUMBER","0
	   set STF_OVERWRITE = "OLDER"
		set !STF_NCPA_FLUSH_COPYLIST = TRUE
		CopyFilesInCopyList
      set !DIGI_FileSectionsToCopyCoalesceList = EMPTY_LIST;
	endif
	Exit

[CoreFilesList]
// Desc.                   Section                       Dest. Dir
// ----------------------------------------------------------------------------------
   "SNMP Files"            = Files-SNMP,                 $(!STF_WINDOWSSYSPATH)
   "Redistributable Files" = Files-Redistributable,      $(!STF_WINDOWSSYSPATH)
   "Config Files All"      = Files-Config,               $(!STF_WINDOWSSYSPATH)

#if defined(SUPPORT_HOUSTON)
[CoreFilesList-Houston]
// Desc.                     Section                     Dest. Dir
// ---------------------------------------------------------------------------------------
   "Config Files"          = Files-Config-Houston,       $(!STF_WINDOWSSYSPATH)
   "Modem Files"           = Files-Modem,                $(!STF_WINDOWSPATH)"\\INF"
   "Firmware Files"        = Files-Firmware-Houston,     $(!STF_WINDOWSSYSPATH)"\\drivers"
   "Driver Files"          = Files-Driver-Houston,       $(!STF_WINDOWSSYSPATH)"\\drivers"
#endif
#if defined(SUPPORT_LONDON)
[CoreFilesList-London]
// Desc.                     Section                     Dest. Dir
// --------------------------------------------------------------------------------------
   "Config Files"          = Files-Config-London,        $(!STF_WINDOWSSYSPATH)
   "Modem Files"           = Files-Modem,                $(!STF_WINDOWSPATH)"\\INF"
   "Firmware Files"        = Files-Firmware-London,      $(!STF_WINDOWSSYSPATH)"\\drivers"
   "Driver Files"          = Files-Driver-London,        $(!STF_WINDOWSSYSPATH)"\\drivers"
#endif
#if defined(SUPPORT_CHASKA)
[CoreFilesList-Chaska]
// Desc.              Section                            Dest. Dir
// ---------------------------------------------------------------------------------------
   "Config Files"          = Files-Config-Chaska,        $(!STF_WINDOWSSYSPATH)
   "Modem Files"           = Files-Modem,                $(!STF_WINDOWSPATH)"\\INF"
   "Firmware Files"        = Files-Firmware-Chaska,      $(!STF_WINDOWSSYSPATH)"\\drivers"
   "Driver Files"          = Files-Driver-Chaska,        $(!STF_WINDOWSSYSPATH)"\\drivers"
#endif
#if defined(SUPPORT_CLYDESDALE)
[CoreFilesList-Clydesdale]
// Desc.              Section                            Dest. Dir
// ---------------------------------------------------------------------------------------
   "Config Files"          = Files-Config-Clydesdale,     $(!STF_WINDOWSSYSPATH)
   "Firmware Files"        = Files-Firmware-Clydesdale,   $(!STF_WINDOWSSYSPATH)"\\drivers"
   "Driver Files"          = Files-Driver-Clydesdale,     $(!STF_WINDOWSSYSPATH)"\\drivers"
   "SNA Driver Files"      = Files-SNA-Driver-Clydesdale, $(!STF_WINDOWSSYSPATH)
   "SNA Config Files"      = Files-SNA-Config-Clydesdale, $(!STF_WINDOWSSYSPATH)
#endif
#if defined(SUPPORT_PRIME)
[CoreFilesList-Prime]
// Desc.                     Section                     Dest. Dir
// ---------------------------------------------------------------------------------------
   "Config Files"          = Files-Config-Prime,         $(!STF_WINDOWSSYSPATH)
   "Firmware Files"        = Files-Firmware-Prime,       $(!STF_WINDOWSSYSPATH)"\\drivers"
   "Driver Files"          = Files-Driver-Prime,         $(!STF_WINDOWSSYSPATH)"\\drivers"
#endif
#if defined(SUPPORT_SYNC570)
[CoreFilesList-Sync570]
// Desc.              Section                            Dest. Dir
// ---------------------------------------------------------------------------------------
   "Config Files"          = Files-Config-Sync570,		 $(!STF_WINDOWSSYSPATH)
   "Driver Files"          = Files-Driver-Sync570,		 $(!STF_WINDOWSSYSPATH)"\\drivers"
   "SNA Driver Files"      = Files-SNA-Driver-Sync570,	 $(!STF_WINDOWSSYSPATH)
   "SNA Config Files"      = Files-SNA-Config-Sync570,	 $(!STF_WINDOWSSYSPATH)
   "PerfMon Files"		   = Files-PERFMON-Streams,		 $(!STF_WINDOWSSYSPATH)
#endif
#if defined(SUPPORT_ACCELEPORT_2000)
[CoreFilesList-AccelePort2000]
// Desc.              Section                            Dest. Dir
// ---------------------------------------------------------------------------------------
   "Config Files"          = Files-Config-AccelePort2000,		$(!STF_WINDOWSSYSPATH)
   "Firmware Files"        = Files-Firmware-AccelePort2000,	$(!STF_WINDOWSSYSPATH)"\\drivers"
   "Driver Files"          = Files-Driver-AccelePort2000,		$(!STF_WINDOWSSYSPATH)"\\drivers"
#endif

//
// Adds files to copy list, and then copies them.
//
//		$0 = Option (Adapter type to install) [$(Option)]
//		$1 = Source Dir [$(SrcDir)]
//		$2 = $(AddCopy)
//		$3 = $(DoCopy)
//
//    $R0 = Success
//
[CopyCoreFiles]

	set Option = $($0)
	set SrcDir = $($1)
	set AddCopy = $($2)
	set DoCopy = $($3)
	_Enter("CopyCoreFiles", _Show(Option)_Show(SrcDir)_Show(AddCopy)_Show(DoCopy))

   set Success = FALSE

   set FilesListList = { +
      CoreFilesList, +
      CoreFilesList-$(Option), +
      }

   ForListDo $(FilesListList)

      set FilesList = $($)
      set DescList = ^($(FilesList), 0)

      ForListDo $(DescList)

         set Desc = $($)
         set Section = #($(FilesList), $(Desc), 1)
         set DstDir = #($(FilesList), $(Desc), 2)

	      _Trace("Adding "$(Desc), _Show(Section)_Show(SrcDir)_Show(DstDir))
         Install Install-AddFiles
	     // Add the Files to the list of installed files
	     ifstr(i) $(Section) != "Files-Redistributable"                             // don't delete redist. mfc/msvcrt dlls
	           _Trace("Adding "$(Desc)" for deletion", _Show(Section)_Show(DstDir))
              _LocalShell AddSectionFilesToRemoveList $(Section) $(DstDir)
	     endif

	   EndForListDo

	EndForListDo

   set DescList = ^(MiscDeleteFileList, 0)
   ForListDo $(DescList)

      set Desc = $($)
      set Section = #(MiscDeleteFileList, $(Desc), 1)
      set DstDir = #(MiscDeleteFileList, $(Desc), 2)
	   _Trace("Adding "$(Desc)" for deletion", _Show(Section)_Show(DstDir))
      _LocalShell AddSectionFilesToRemoveList $(Section) $(DstDir)

   EndForListDo

	read-syms $(Option)-Strings-$(!STF_LANGUAGE)
	read-syms InstallProgress-Strings-$(!STF_LANGUAGE)
   Install Install-CopyFiles
	ifstr(i) $(STF_INSTALL_OUTCOME) != "STF_SUCCESS"
      _AssertMsg(FALSE, _Show1(STF_INSTALL_OUTCOME))
      _OnUtilityShellErrorGoto("UNABLE_COPY_FILE", Exit)
   endif

   set Success = TRUE

Exit = +

	_Exit("CopyCoreFiles", _Show(Success))
	Return $(Success)


//	********************************************************************************
//	Local Shell Data Sections
//	********************************************************************************

//
// Usage:
//
//	read-syms GlobalConstants
//	read-syms GlobalRegistryConstants
//	read-syms OldDriverConstants
//
[OldDriverConstants]
OldManufacturer = "DigiBoard"
OldProductSoftwareName = "DigiSxb"
OldProductKeyNameList = { $(!NTN_SoftwareBase)"\\"$(Manufacturer)"\\"$(OldProductSoftwareName)"\\CurrentVersion", +
                          $(!NTN_SoftwareBase)"\\"$(OldManufacturer)"\\"$(OldProductSoftwareName)"\\CurrentVersion" }

//
//	Get product key independent of version.
//
//		$R0 = Key [KEY_NULL if not found]
//
[GetPackageKey]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
   read-syms DriverPackageConstants

	_Enter("GetPackageKey", "")

	set KeyPackage = KEY_NULL

   // Try current package location 1st
	_OpenRegKey_HKLM($(PackageKeyName), KeyPackage)
   _IfValidKey($(KeyPackage))
	   goto Exit
   endif

#if defined(OLD_PRODUCT_VERSION)
   // Look for old keys
	read-syms OldDriverConstants
   ForListDo $(OldProductKeyNameList)
      set OldProductKeyName = $($)
		_OpenRegKey_HKLM($(OldProductKeyName), KeyPackage)
      _IfValidKey($(KeyPackage))
	      goto Exit
      endif
	EndForListDo
#endif

Exit = +

	_Exit("GetPackageKey", _Show(KeyPackage))
	Return $(KeyPackage)

//
//	Is package installed?
//
//		$R0 = Boolean value (TRUE = installed)
//
[IsPackageInstalled]
	_Enter("IsPackageInstalled", "")

	_LocalShell GetExistingSoftwareVersion
	set Installed = $($R0)

	_Exit("IsPackageInstalled", _Show(Installed))
	Return $(Installed)

//
//	Is option installed?
//
// Note: call this only on 3.00 or later versions!
//
//		$0 = $(Option)
//
//		$R0 = Boolean value (TRUE = installed)
//
[IsOptionInstalled]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants

	set Option = $($0)
	_Enter("IsOptionInstalled", _Show(Option))

   read-syms DriverPackageConstants

   set Installed = FALSE

	_Call("IsRefCountEqualZero", _Show(PackageOptionInstalledKeyName))
   _UtilityShell IsRefCountEqualZero $(PackageOptionInstalledKeyName)
	_Return("IsRefCountEqualZero", _Show($R0)_Show($R1))

   _NOT($($R1))
   set Installed = $($R0)

	_Exit("IsOptionInstalled", _Show(Installed))
	Return $(Installed)

//
//	Make numeric version suitable for integer comparisons.
//
//		$0 = Version number in the form ##.##.##
//
//		$R0 = Integer representation of version.
//
[NumericVersion]

	set StrVersion = $($0)

	_Enter("NumericVersion", _Show(StrVersion))

	Split-String $(StrVersion) "." ComponentList
   _Trace("Split", _Show(ComponentList))

#if defined(_DEBUG)
	QueryListSize NumComponents $(ComponentList)
   _Trace("Number", _Show(NumComponents))
   _ToBoolean(ifint $(NumComponents) <= 5, NotTooManyComponents)     // n.n.n
   _Assert($(NotTooManyComponents))
#endif

#define MAJOR_INDEX 1
#define MINOR_INDEX 3
#define BUILD_INDEX 5

	set Major = *($(ComponentList), MAJOR_INDEX)
	set Minor = *($(ComponentList), MINOR_INDEX)
	set Build = *($(ComponentList), BUILD_INDEX)

   _Trace("Version components", _Show(Major)_Show(Minor)_Show(Build))

#define SHIFT_24 16777216
#define SHIFT_16 65536

	set-mul HiByteHiWord = $(Major), SHIFT_24
	set-mul LoByteHiWord = $(Minor), SHIFT_16
	set-add HiWord = $(HiByteHiWord), $(LoByteHiWord)
   _Trace("Shifted", _Show(HiByteHiWord)_Show(LoByteHiWord)_Show(HiWord))

   set IntVersion = 0
	set-add IntVersion = $(HiWord), $(Build)

	_Exit("NumericVersion", _Show(IntVersion))
	Return $(IntVersion)

//
//	Get the software version of the software currently installed.
//
//		$R0 = Success
//		$R1 = Version string [returns current version on error]
//
[GetExistingSoftwareVersion]
	read-syms Identification

	_Enter("GetExistingSoftwareVersion", "")

   set Success = FALSE
	set Version = $(InstallVersion)

	_LocalShell GetPackageKey
	set KeyPackage = $($R0)
	_IfNotValidKey($(KeyPackage))
		goto Error
	endif

	_GetRegSzByKey $(KeyPackage) "SoftwareVersion"
	_If($($R0))
		set Version = $($R1)
		goto Exit
	endif

#if defined(OLD_PRODUCT_VERSION)
	_GetRegSzByKey $(KeyPackage) "MajorVersion"
   _AssertGoto($($R0), Error)
	set Major = $($R1)

	_GetRegSzByKey $(KeyPackage) "MinorVersion"
   _AssertGoto($($R0), Error)
	set Minor = $($R1)

	_IfAnd(ifint $(Major) == 3, ifint $(Minor) == 51)
		set Version = "1.02"
		goto Exit
	_EndIfAnd

	_IfAnd(ifint $(Major) == 4, ifint $(Minor) == 0)
		set Version = "2.00"
		goto Exit
	_EndIfAnd
#endif

   goto Error

Exit = +

   set Success = TRUE

Error = +
	_CloseRegKey($(KeyPackage))

	_Exit("GetExistingSoftwareVersion", _Show(Success)_Show(Version))
	Return $(Success) $(Version)

//
//	Get source directory from user.
//
//		$0 = Current source dir
//
//		$R0 = Status (STATUS_*)
//		$R1 = User-specified source directory
//
[GetSourceDir]

	set SrcDir = $($0)
	_Enter("GetSourceDir", _Show(SrcDir))

	set Status = "STATUS_FAILED"
	set UserDir = $(SrcDir)

	_UtilityShell DoAskSource $(!STF_CWDDIR) $(SrcDir) "NO"
   _OnShellErrorGoto(Exit)

	set Status = $($R0)
	ifstr(i) $(Status) != "STATUS_SUCCESSFUL"
      _AssertMsg(FALSE, "DoAskSource returned "$($R0))
      _OnUtilityShellErrorGoto("ASK_SOURCE_FAIL", Exit)
	endif

	set UserDir = $($R1)
	set !STF_SRCDIR_OVERRIDE = $(UserDir)

Exit = +

	_Exit("GetSourceDir", _Show(Status)_Show(UserDir))
	Return $(Status) $(UserDir)

[AdapterDataMap]
   AdapterDataMap = { +
   //   Option                           Bus    Vendor ID          Pci ID                      Pci SubID                                 # Lines  Enum
   // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#if defined(SUPPORT_HOUSTON)
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_HOUSTON,  DIGI_PCI_SUBDEVICEID_HOUSTON_T1_SINGLE,   1,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_T1_SINGLE }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_HOUSTON,  DIGI_PCI_SUBDEVICEID_HOUSTON_T1_DUAL,     2,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_T1_DUAL   }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_HOUSTON,  DIGI_PCI_SUBDEVICEID_HOUSTON_E1_SINGLE,   1,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_E1_SINGLE }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_HOUSTON,  DIGI_PCI_SUBDEVICEID_HOUSTON_E1_DUAL,     2,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_E1_DUAL   }, +

      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_HOUSTON, DIGI_CPCI_SUBDEVICEID_HOUSTON_T1_SINGLE,  1,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_T1_SINGLE }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_HOUSTON, DIGI_CPCI_SUBDEVICEID_HOUSTON_T1_DUAL,    2,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_T1_DUAL   }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_HOUSTON, DIGI_CPCI_SUBDEVICEID_HOUSTON_E1_SINGLE,  1,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_E1_SINGLE }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_HOUSTON, DIGI_CPCI_SUBDEVICEID_HOUSTON_E1_DUAL,    2,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_E1_DUAL   }, +
#endif
#if defined(SUPPORT_LONDON)
      { DXB_REGVAL_OPTION_ENUM_LONDON,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_LONDON,   DIGI_PCI_SUBDEVICEID_LONDON_ST,           4,       DXB_REGVAL_ADAPTER_ENUM_LONDON_ST }, +
      { DXB_REGVAL_OPTION_ENUM_LONDON,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_LONDON,   DIGI_PCI_SUBDEVICEID_LONDON_U,            4,       DXB_REGVAL_ADAPTER_ENUM_LONDON_U  }, +
#endif
#if defined(SUPPORT_CHASKA)
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_40,           4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_41,           4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_42,           4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_43,           4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_44,           4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_45,           4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +

      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_80,           8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_81,           8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_82,           8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_83,           8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_84,           8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CHASKA,   DIGI_PCI_SUBDEVICEID_CHASKA_85,           8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
#endif
#if defined(SUPPORT_CLYDESDALE)
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_2,       DIGI_PCI_SUBDEVICEID_CLYDE_NON_CSU_2,     2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_2       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_4,       DIGI_PCI_SUBDEVICEID_CLYDE_NON_CSU_4,     4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_4       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_603_2,   DIGI_PCI_SUBDEVICEID_CLYDE_NON_CSU_603_2, 2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_2   }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_603_4,   DIGI_PCI_SUBDEVICEID_CLYDE_NON_CSU_603_4, 4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_4   }, +

      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_2,       DIGI_PCI_SUBDEVICEID_NONE,     2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_2       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_4,       DIGI_PCI_SUBDEVICEID_NONE,     4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_4       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_603_2,   DIGI_PCI_SUBDEVICEID_NONE, 2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_2   }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_CLYDE_NON_CSU_603_4,   DIGI_PCI_SUBDEVICEID_NONE, 4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_4   }, +

      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_2,       DIGI_CPCI_SUBDEVICEID_CLYDE_NON_CSU_2,     2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_2       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_4,       DIGI_CPCI_SUBDEVICEID_CLYDE_NON_CSU_4,     4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_4       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_603_2,   DIGI_CPCI_SUBDEVICEID_CLYDE_NON_CSU_603_2, 2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_2   }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_603_4,   DIGI_CPCI_SUBDEVICEID_CLYDE_NON_CSU_603_4, 4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_4   }, +

      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_2,       DIGI_CPCI_SUBDEVICEID_NONE,     2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_2       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_4,       DIGI_CPCI_SUBDEVICEID_NONE,     4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_4       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_603_2,   DIGI_CPCI_SUBDEVICEID_NONE, 2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_2   }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_CPCI_DEVICEID_CLYDE_NON_CSU_603_4,   DIGI_CPCI_SUBDEVICEID_NONE, 4, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_4   }, +

      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PMC_DEVICEID_CLYDE_NON_CSU_2,       DIGI_PMC_SUBDEVICEID_CLYDE_NON_CSU_2,     2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_2       }, +
      { DXB_REGVAL_OPTION_ENUM_CLYDE,    "PCI", DIGI_PCI_VENDORID, DIGI_PMC_DEVICEID_CLYDE_NON_CSU_603_2,   DIGI_PMC_SUBDEVICEID_CLYDE_NON_CSU_603_2, 2, DXB_REGVAL_ADAPTER_ENUM_CLYDE_NONCSU_603_2   }, +
#endif
#if defined(SUPPORT_SYNC570)
      { DXB_REGVAL_OPTION_ENUM_SYNC570,  "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_SYNC570_PCI_2PORT,     DIGI_PCI_SUBDEVICEID_SYNC570_PCI_2PORT,   2, DXB_REGVAL_ADAPTER_ENUM_SYNC570_PCI_2PORT       }, +
      { DXB_REGVAL_OPTION_ENUM_SYNC570,  "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_SYNC570_PCI_4PORT,     DIGI_PCI_SUBDEVICEID_SYNC570_PCI_4PORT,   4, DXB_REGVAL_ADAPTER_ENUM_SYNC570_PCI_4PORT       }, +
      { DXB_REGVAL_OPTION_ENUM_SYNC570,  "ISA", 0,                 0,										0,										  2, DXB_REGVAL_ADAPTER_ENUM_SYNC570_ISA_2PORT }, +
      { DXB_REGVAL_OPTION_ENUM_SYNC570,  "ISA", 0,                 0,										0,										  4, DXB_REGVAL_ADAPTER_ENUM_SYNC570_ISA_4PORT }, +
#endif
#if defined(SUPPORT_PRIME)
      { DXB_REGVAL_OPTION_ENUM_PRIME,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_PRIME_T1_SINGLE,       DIGI_PCI_SUBDEVICEID_PRIME_T1_SINGLE,     1, DXB_REGVAL_ADAPTER_ENUM_PRIME_T1_PCI }, +
      { DXB_REGVAL_OPTION_ENUM_PRIME,    "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_PRIME_E1_SINGLE,       DIGI_PCI_SUBDEVICEID_PRIME_E1_SINGLE,     1, DXB_REGVAL_ADAPTER_ENUM_PRIME_E1_PCI }, +
#endif
#if defined(SUPPORT_HOUSTON)
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_HOUSTON,   IBM_PCI_SUBDEVICEID_HOUSTON_T1_SINGLE,    1,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_T1_SINGLE }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_HOUSTON,   IBM_PCI_SUBDEVICEID_HOUSTON_T1_DUAL,      2,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_T1_DUAL   }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_HOUSTON,   IBM_PCI_SUBDEVICEID_HOUSTON_E1_SINGLE,    1,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_E1_SINGLE }, +
      { DXB_REGVAL_OPTION_ENUM_HOUSTON,  "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_HOUSTON,   IBM_PCI_SUBDEVICEID_HOUSTON_E1_DUAL,      2,       DXB_REGVAL_ADAPTER_ENUM_HOUSTON_E1_DUAL   }, +
#endif
#if defined(SUPPORT_LONDON)
      { DXB_REGVAL_OPTION_ENUM_LONDON,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_LONDON,    IBM_PCI_SUBDEVICEID_LONDON_ST,            4,       DXB_REGVAL_ADAPTER_ENUM_LONDON_ST }, +
      { DXB_REGVAL_OPTION_ENUM_LONDON,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_LONDON,    IBM_PCI_SUBDEVICEID_LONDON_U,             4,       DXB_REGVAL_ADAPTER_ENUM_LONDON_U  }, +
#endif
#if defined(SUPPORT_CHASKA)
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_40,            4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_41,            4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_42,            4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_43,            4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_44,            4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_45,            4,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_4 }, +

      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_80,            8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_81,            8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_82,            8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_83,            8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_84,            8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
      { DXB_REGVAL_OPTION_ENUM_CHASKA,   "PCI", IBM_PCI_VENDORID,  IBM_PCI_DEVICEID_CHASKA,    IBM_PCI_SUBDEVICEID_CHASKA_85,            8,       DXB_REGVAL_ADAPTER_ENUM_CHASKA_8 }, +
#endif
#if defined(SUPPORT_ACCELEPORT_2000)
      { DXB_REGVAL_OPTION_ENUM_ACCELEPORT_2000,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_ACCELEPORT_2000,   DIGI_PCI_SUBDEVICEID_HERCULES_TEST,             8.       DXB_REGVAL_ADAPTER_ENUM_ACCELEPORT_8R_2000 }, +
      { DXB_REGVAL_OPTION_ENUM_ACCELEPORT_2000,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_ACCELEPORT_2000,   DIGI_PCI_SUBDEVICEID_ACCELEPORT_2R_2000,           2,       DXB_REGVAL_ADAPTER_ENUM_ACCELEPORT_2R_2000 }, +
      { DXB_REGVAL_OPTION_ENUM_ACCELEPORT_2000,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_ACCELEPORT_2000,   DIGI_PCI_SUBDEVICEID_ACCELEPORT_4R_2000,           4,       DXB_REGVAL_ADAPTER_ENUM_ACCELEPORT_4R_2000 }, +
      { DXB_REGVAL_OPTION_ENUM_ACCELEPORT_2000,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_ACCELEPORT_2000,   DIGI_PCI_SUBDEVICEID_ACCELEPORT_8R_2000,           8,       DXB_REGVAL_ADAPTER_ENUM_ACCELEPORT_8R_2000 }, +
      { DXB_REGVAL_OPTION_ENUM_ACCELEPORT_2000,   "PCI", DIGI_PCI_VENDORID, DIGI_PCI_DEVICEID_ACCELEPORT_2000,   DIGI_PCI_SUBDEVICEID_ACCELEPORT_16R_2000,           16,       DXB_REGVAL_ADAPTER_ENUM_ACCELEPORT_16R_2000 }, +
#endif
      }

//
//	Figures out what the REAL option should be
//
//		$0 = $(Option)
//    $1 = VendorID
//		$2 = PciID
//    $3 = SubPciID
//
//		$R0 = Success
//		$R1 = Real $(Option)
//
[ResetInfOption]

	set Option = $($0)
	set VendorID = $($1)
	set PciID = $($2)
	set SubPciID = $($3)
	_Enter("ResetInfOption", _Show(Option)_Show(VendorID)_Show(PciID)_Show(SubPciID))

   set Success = FALSE
   set RealOption = $(Option)

   set OptionsThatGetReset = { WANLINKS_RAS_BOARD_NAME_QUOT, "PowerSync" }
	Ifcontains $(Option) in $(OptionsThatGetReset)
      read-syms AdapterDataMap

      ForListDo $(AdapterDataMap)
         set MapVendorID  = *($($), 3)

         _Trace("Comparing to ", _Show(MapVendorID))
         ifint $(MapVendorID) == $(VendorID)

            set MapPciID  = *($($), 4)
            set MapSubPciID  = *($($), 5)

            _Trace("Matched!  Now comparing  ", _Show(MapPciID)_Show(MapSubPciID))
            _IfAnd(ifint $(MapPciID) == $(PciID), ifint $(MapSubPciID) == $(SubPciID))
               set RealOption  = *($($), 1)
               _Trace("Overriding option ", _Show(RealOption))
               goto Exit
            endif
         endif
	   EndForListDo

      // Didn't find a match
      goto Error

   endif

Exit = +
   set Success = TRUE

Error = +
	_Exit("ResetInfOption", _Show(Success)_Show(RealOption))
	Return $(Success) $(RealOption)

//
//	Get the firmware image names for this option
//
//		$0 = $(Option)
//		$1 = $(BusName)
//
//		$R0 = Bios image name
//		$R1 = Fep image name
//
[FirmwareImageNames]

	set Option = $($0)
	set BusName = $($1)
	_Enter("FirmwareImageNames", _Show(Option)_Show(BusName))

   set BiosImage = "N/A"
   set FepImage = "N/A"

   set OptionsThatHaveBiosImages = { +
      }
	Ifcontains $(Option) in $(OptionsThatHaveBiosImages)
      set BiosImage = #(Files-Firmware-$(Option), BIOS$(BusName), 2)
   endif

   set OptionsThatHaveFepImages = { +
#if defined(SUPPORT_HOUSTON)
      DXB_REGVAL_OPTION_ENUM_HOUSTON, +
#endif
#if defined(SUPPORT_LONDON)
      DXB_REGVAL_OPTION_ENUM_LONDON, +
#endif
#if defined(SUPPORT_CHASKA)
      DXB_REGVAL_OPTION_ENUM_CHASKA, +
#endif
#if defined(SUPPORT_CLYDESDALE)
      DXB_REGVAL_OPTION_ENUM_CLYDE, +
#endif
#if defined(SUPPORT_ACCELEPORT_2000)
      DXB_REGVAL_OPTION_ENUM_ACCELEPORT_2000, +
#endif
      }
	Ifcontains $(Option) in $(OptionsThatHaveFepImages)
      set FepImage = #(Files-Firmware-$(Option), FEP$(BusName), 2)
   endif

Exit = +

	_Exit("FirmwareImageNames", _Show(BiosImage)_Show(FepImage))
	Return $(BiosImage) $(FepImage)

//
//	Figures out how many lines this option has
//
//		$0 = $(Option)
//    $1 = $(BusName)
//    $2 = VendorID
//		$3 = PciID
//    $4 = SubPciID
//
//		$R0 = # of lines
//
[CalculateNumberOfLines]

	set Option = $($0)
    set BusName = $($1)
	set VendorID = $($2)
	set PciID = $($3)
	set SubPciID = $($4)
	set Identity = $($5)
	_Enter("CalculateNumberOfLines", _Show(Option)_Show(BusName)_Show(VendorID)_Show(PciID)_Show(SubPciID)_Show(Identity))

   set NumberOfLines = 1

   read-syms AdapterDataMap

   ForListDo $(AdapterDataMap)
      set MapOption  = *($($), 1)
      set MapBusName  = *($($), 2)

		_Trace("CalculateNumberOfLines", _Show(MapOption)_Show(MapBusName))

	   _IfAnd(ifstr(i) $(MapOption) == $(Option), ifstr(i) $(MapBusName) == $(BusName))

         ifstr(i) $(BusName) == "PCI"
            set MapVendorID  = *($($), 3)

            ifint $(MapVendorID) == $(VendorID)
               set MapPciID  = *($($), 4)
               set MapSubPciID  = *($($), 5)

               _IfAnd(ifint $(MapPciID) == $(PciID), ifint $(MapSubPciID) == $(SubPciID))
                  set NumberOfLines  = *($($), 6)
                  set Identity = *($($), 7)
                  goto Exit
               endif

            endif
         else
            set MapIdentity  = *($($), 7)
			_Trace("CalculateNumberOfLines", _Show(MapIdentity))
            ifstr(i) $(Identity) == $(MapIdentity)
            set NumberOfLines  = *($($), 6)
            goto Exit
         endif
         endif

      endif
	EndForListDo

   _AssertMsg(FALSE, "Unable to calculate number of ports for "$(Option))

Exit = +

  _Exit("CalculateNumberOfLines", _Show(NumberOfLines))
  Return $(NumberOfLines) $(Identity)

//
//	Figures out adapter enum string
//
//		$0 = $(Option)
//    $1 = $(BusName)
//    $2 = VendorID     - optional
//		$3 = PciID        - optional
//    $4 = SubPciID     - optional
//
//		$R1 = adapter enum
//
[GetAdapterEnum]

	set Option = $($0)
   set BusName = $($1)
	set VendorID = $($2)
	set PciID = $($3)
	set SubPciID = $($4)
	_Enter("GetAdapterEnum", _Show(Option)_Show(BusName)_Show(VendorID)_Show(PciID)_Show(SubPciID))

   set AdapterEnum = EMPTY_STR

   read-syms AdapterDataMap

   ForListDo $(AdapterDataMap)

      set MapOption  = *($($), 1)
      set MapBusName  = *($($), 2)

	   _IfAnd(ifstr(i) $(MapOption) == $(Option), ifstr(i) $(MapBusName) == $(BusName))

         ifstr(i) $(BusName) == "PCI"
            set MapVendorID  = *($($), 3)

            _Trace("Comparing to ", _Show(MapVendorID))
            ifint $(MapVendorID) == $(VendorID)

               set MapPciID  = *($($), 4)
               set MapSubPciID  = *($($), 5)

               _IfAnd(ifint $(MapPciID) == $(PciID), ifint $(MapSubPciID) == $(SubPciID))
                  set AdapterEnum  = *($($), 7)
                  goto Exit
               endif
            endif
         else
            set AdapterEnum  = *($($), 7)
            goto Exit
         endif
      endif
	EndForListDo

Exit = +

	_Exit("GetAdapterEnum", _Show(AdapterEnum))
	Return $(AdapterEnum)

//	********************************************************************************
//	Global Shells
//	********************************************************************************

//
//	Installs an adapter
//
//		$0 = Option (Adapter type to install)
//		$1 = Source Dir
//		$2 = $(AddCopy)
//		$3 = $(DoCopy)
//		$4 = $(DoConfig)
//
//		$R0 = Status (STATUS_*)
//
[InstallMode]
	read-syms GlobalConstants
	read-syms GlobalRegistryConstants
	read-syms GlobalPathConstants
	read-syms DriverConstants
	read-syms Identification
	read-syms DriverPackageConstants
	read-syms InstallMessages-$(!STF_LANGUAGE)

	set Option = $($0)
	set SrcDir = $($1)
	set AddCopy = $($2)
	set DoCopy = $($3)
	set DoConfig = $($4)
	_Enter("InstallMode", _Show(Option)_Show(SrcDir)_Show(AddCopy)_Show(DoCopy)_Show(DoConfig))

	StartWait

	// Check to see that all the registry is in a state that allows the installation.
	// If a service was deleted it is marked for deletion if it is running.  It is
	// not deleted until the next boot.  If any of our services are in this state then
	// we need to reboot before and adpater can be added.
	ForListDo $(ServicesToDeinstallList)
		set Service = $($)
		_Trace("Checking DeleteFlag on Service", _Show(Service))
		read-syms DriverConstants-$(Service)

      _GetRegSzByName $(!NTN_ServiceBase)"\\"$(ProductSoftwareName) "DeleteFlag"
   	_If($($R0))
			_LocalShell MessageBox $(DeleteCheckTitle) $(DeleteCheck) MB_OK MB_ICONSTOP MB_DEFBUTTON1
			set Status = "STATUS_USERCANCEL"
			goto Exit
		endif

	EndForListDo

	set Status = "STATUS_FAILED"
	set DeleteInfOnExit = FALSE

	// Set to defaults for auto key closing at end of shell.
	set KeyPackage = KEY_NULL
	set KeyInstalledOptions = KEY_NULL
	set KeyOptionInstalled = KEY_NULL

   set IncrementedPackageRefCount = FALSE
   set IncrementedInstalledOptionRefCount = FALSE

	set InstalledDriverList = EMPTY_LIST
	set InstalledAdapterList = EMPTY_LIST              // { { "Type", "Number" } }

   _LocalShell ClearRemoveList

	_LocalShell GetExistingSoftwareVersion
	set OnDiskVersion = $($R1)

	// Convert version strings to integers for comparison.
	_LocalShell NumericVersion $(OnDiskVersion)
	set IntOnDiskVersion = $($R0)
	_LocalShell NumericVersion $(InstallVersion)
	set IntInstallVersion = $($R0)

	ifint $(IntInstallVersion) > $(IntOnDiskVersion)
      _LocalShell MessageBox $(UpdateNowTitle) $(UpdateNow) MB_YESNO MB_ICONQUESTION MB_DEFBUTTON1
      ifstr(i) $($R0) == "YES"
         _LocalShell UpdateMode $(Option) $(SrcDir) $(AddCopy) $(DoCopy) $(DoConfig)
      	set Status = $($R0)
	      ifstr(i) $(Status) != "STATUS_SUCCESSFUL"
		      goto Error
	      endif
      else
		   _LocalShell StatusMessage $(UpdateLater)
         set Status = "STATUS_USERCANCEL"
		   goto Exit
      endif
	endif

	ifint $(IntInstallVersion) < $(IntOnDiskVersion)
		_LocalShell StatusMessage $(NewerInstalled)
		goto Exit
	endif

	// At this point we know the software versions are the same.
	// Since we want to have only one copy of the inf around
	// we'll have the existing one install and this one will be
	// deleted later.

   // This is really kinda freaky!

	_Trace("This INF Path", _Show(STF_CONTEXTINFNAME))
	_GetRegSzByName $(PackageKeyName)"\\NetRules" "InfName"
	_If($($R0))
		set InfName = $($R1)
		set InfPath = $(!STF_WINDOWSSYSPATH)"\\"$(InfName)
		ifstr(i) $(InfPath) != $(STF_CONTEXTINFNAME)          // recursion stopper
			_Trace("Executing existing INF", _Show(InfPath))
			_ExternalShell($(InfPath)) InstallOption $(!STF_LANGUAGE) $(Option) $(SrcDir) $(AddCopy) $(DoCopy) $(DoConfig)
         _OnShellErrorGoto(Exit)
			set Status = $($R0)
	      set DeleteInfOnExit = TRUE
			goto Exit
		endif
	endif

	// Notify user that the product is already installed.
	// ASK - This seems to be the wrong dialog. It claims they should update.

   // Right, ... so let's just skip this stupid VerExistedDlg.  Seeing as how
   // this INF installs a number of dissimilar adapters, so it doesn't really
   // make sense to put this dialog up and confuse the user anyway.

#if defined(SHOW_VEREXISTEDLDG)
	_Trace("Compare", _Show(!NTN_RegBase)_Show(ProductKeyName))
	ifstr(i) $(!NTN_RegBase) == $(ProductKeyName)
	   read-syms $(Option)-Strings-$(!STF_LANGUAGE)
		_UtilityShell VerExistedDlg $(AdapterTitle) $(ProductVersion)
      _OnShellErrorGoto(Error)
      _OnUtilityShellErrorGoto($($R0), Error)
		goto Exit
	endif

	// Let the user cancel a second install of same card type.
	_UtilityShell CardExistedDlg
   _OnShellErrorGoto(Error)
	ifstr(i) $($R1) != "OK"
		goto Exit
	endif
#endif

	_LocalShell IsPackageInstalled
	_IfNot($($R0))
      _Trace("Installing package.", _Show(Option))

	   // Sets up the package section in the software tree.
	   _Call("InstallSoftwareProduct", _Show(Manufacturer)_Show(PackageSoftwareName)_Show(STF_CONTEXTINFNAME))
	   _UtilityShell InstallSoftwareProduct $(Manufacturer) $(PackageSoftwareName) $(STF_CONTEXTINFNAME)
	   _Return("InstallSoftwareProduct", _Show($R0)_Show($R1)_Show($R2))
      _OnShellErrorGoto(Error)
      _OnUtilityShellErrorGoto($($R0), Error)

	   set KeyPackage = $($R1)
	   set KeyNetRules = $($R2)

      _SetRegSzByKey $(KeyPackage) "SoftwareVersion" $(InstallVersion)
      _AssertGoto($($R0), Error)

      // Hide this, else it shows up in the list of installed services.
	   _SetRegDwordByKey $(KeyPackage) "Hidden" TRUE
      _AssertGoto($($R0), Error)
      // Another solution might be to delete the NetRules key

	   _CloseRegKey($(KeyPackage))
	   _CloseRegKey($(KeyNetRules))

#if defined(OLD_PRODUCT_VERSION)
      // NOTE: This is a hack to prevent users from installing an older version over this
      //       newer one, since the software version values have moved around to different keys.
	   read-syms OldDriverConstants
	   _Call("InstallSoftwareProduct", _Show(Manufacturer)_Show(OldProductSoftwareName)_Show(STF_CONTEXTINFNAME))
	   _UtilityShell InstallSoftwareProduct $(Manufacturer) $(OldProductSoftwareName) $(STF_CONTEXTINFNAME)
	   _Return("InstallSoftwareProduct", _Show($R0)_Show($R1)_Show($R2))
      _OnShellErrorGoto(Error)
      _OnUtilityShellErrorGoto($($R0), Error)

	   set KeyOldPackage = $($R1)
	   set KeyOldNetRules = $($R2)

	   _SetRegSzByKey $(KeyOldPackage) "MajorVersion" "99"
      _AssertGoto($($R0), Error)

	   _SetRegSzByKey $(KeyOldPackage) "MinorVersion" "99"
      _AssertGoto($($R0), Error)

	   _CloseRegKey($(KeyOldPackage))
	   _CloseRegKey($(KeyOldNetRules))
#endif

		_IfEmptyStr($(SrcDir))
			_LocalShell GetSourceDir $(SrcDir)
			ifstr $($R0) != "STATUS_SUCCESSFUL"
			   set Status = $($R0)
            _AssertMsgGoto(FALSE, "GetSourceDir failed: "$(Status), Error)
			endif
			set SrcDir = $($R1)
		endif

		// All products use the DStreams Group.  We will add this
		// Group at the package level.
	   _LocalShell AddGroupToServiceGroupOrder $(DStreamsDependOnGroup) $(DStreamsBeforeGroup)
      _AssertGoto($($R0), Error)

	endif

GetBusInfo = +

	_LocalShell CopyDetectionFiles $(SrcDir)
   _AssertGoto($($R0), Error)

	_LocalShell AddService "PCI"
   _AssertGoto($($R0), Error)
	set InstalledDriverList = >($(InstalledDriverList), "PCI")

	_LocalShell GetBusData $(Option) $(ProductHardwareDescription)
   _AssertGoto($($R0), Error)

	set BusName = $($R1)
	set BusType = $($R2)
	set BusNumber = $($R3)
   _Trace("Bus data: ", _Show(BusName)_Show(BusType)_Show(BusNumber))

	_LocalShell Find$(BusName) $(BusType) $(BusNumber) $(Option)
	set AdapterData = $($R0)

	// We need to have an adapter to install.
	_IfEmptyList($(AdapterData))
#if defined(FAKE_ADAPTER)
      _DebugBreakpoint("No adapter found!  You will have to pick an adapter.")

	   read-syms DialogConstants$(!STF_LANGUAGE)
      read-syms AdapterDataMap

      set DlgType = "Combination"
      set DlgTemplate = "ADAP_PROTO_COMBO"

      // Do adapter
      set Caption = "Select Adapter"
      set Combo1Label = "&Adapter:"
      set Combo1List = EMPTY_LIST
      ForListDo $(AdapterDataMap)
         _Trace("Adapter choice", _Show($))
         set Combo1List = >($(Combo1List), *($($), 7)","*($($), 3)","*($($), 4)","*($($), 5))
	   EndForListDo
      set Combo1Out  = *($(Combo1List), 1)
      set ComboListItemsIn  = {Combo1List}
      set ComboListItemsOut = {Combo1Out}

      ui start "InputDlg"
      ui pop 1
      ifstr(i) $(DLGEVENT) != "CONTINUE"
         _AssertMsgGoto(FALSE, "You didn't pick an adapter.  Exiting!", Error)
      endif

      _Trace("Splitting ", _Show(Combo1Out))
		Split-String $(Combo1Out) "," AdapterChoiceList

      set VendorID = *($(AdapterChoiceList), 3)
      set SubVendorID = *($(AdapterChoiceList), 3)
      set PciID = *($(AdapterChoiceList), 5)
      set SubPciID = *($(AdapterChoiceList), 7)

      // Do bus number
      set Caption = "Select Bus Number"
      set Combo1Label = "&Bus Number:"
      set Combo1List = { 0, 1, 2, 3, 4, 5, 6, 7 }
      set Combo1Out  = *($(Combo1List), 1)
      set ComboListItemsIn  = {Combo1List}
      set ComboListItemsOut = {Combo1Out}

      ui start "InputDlg"
      ui pop 1
      ifstr(i) $(DLGEVENT) != "CONTINUE"
         _AssertMsgGoto(FALSE, "You didn't pick a bus number.  Exiting!", Error)
      endif

	   set BusNumber = $(Combo1Out)

      // Do slot number
      set Caption = "Select Slot Number"
      set Combo1Label = "&Slot Number:"
      set Combo1List = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, +
                         10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, +
                         20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, +
                         30, 31, 32 +
                       }
      set Combo1Out  = *($(Combo1List), 1)
      set ComboListItemsIn  = {Combo1List}
      set ComboListItemsOut = {Combo1Out}

      ui start "InputDlg"
      ui pop 1
      ifstr(i) $(DLGEVENT) != "CONTINUE"
         _AssertMsgGoto(FALSE, "You didn't pick slot number.  Exiting!", Error)
      endif

	   set SlotNumber = $(Combo1Out)

	   set AdapterData = { +
         $(BusNumber), $(SlotNumber), +
         $(VendorID), $(PciID), +
         $(SubVendorID), $(SubPciID), 0 }
      _Warning("Default bus/adapter info ", _Show(AdapterData))
#else
		_LocalShell SetupMessage "FATAL" $(NoNetworkCard)
		goto Error
#endif
	endif

	set BusNumber = 0
	set SlotNumber = 0
   set IOBaseAddress = 0
   set MemoryAddress = 0
   set InterruptNumber = 0
   set VendorID = 0
   set PciID = 0
   set SubVendorID = 0
   set SubPciID = 0
   set RevisionID = 0
   set CardID = 0

	   set BusNumber = *($(AdapterData), 1)
	   set SlotNumber = *($(AdapterData), 2)
	ifstr $(BusName) == "ISA"
      set IOBaseAddress   = *($(AdapterData), 3)
      set MemoryAddress   = *($(AdapterData), 4)
      set InterruptNumber = *($(AdapterData), 5)
      set Identity		  = *($(AdapterData), 6)
	else-ifstr $(BusName) == "PCI"
      set VendorID   = *($(AdapterData), 3)
      set PciID   = *($(AdapterData), 4)
      set SubVendorID = *($(AdapterData), 5)
      set SubPciID = *($(AdapterData), 6)
      set RevisionID = *($(AdapterData), 7)
      // set Identity   = *($(AdapterData), 8)
   endif

#if defined(_DEBUG)
   ifint $(PciID) == DIGI_PCI_DEVICEID_CHASKA
      ifint $(SubPciID) == DIGI_PCI_DEVICEID_CHASKA
         _Trace("Reseting Chaska sub-PCI id", _Show(PciID)_Show(SubPciID))
         set SubPciID = DIGI_PCI_SUBDEVICEID_CHASKA_80
      endif
   endif

   ifint $(PciID) == DIGI_PCI_DEVICEID_LONDON
      ifint $(SubPciID) == 16710
         _Trace("Reseting London sub-PCI id", _Show(PciID)_Show(SubPciID))
         set SubPciID = DIGI_PCI_SUBDEVICEID_LONDON_U
      endif
   endif
#endif

   _LocalShell ResetInfOption $(Option) $(VendorID) $(PciID) $(SubPciID)
   _AssertGoto($($R0), Error)
   set Option = $($R1)

	read-syms DriverPackageConstants       // refresh this one
	read-syms DriverConstants-$(Option)

	_LocalShell IsOptionInstalled $(Option)
	_If($($R0))
		_Trace("Skipping software install", "")
		goto InstallAdapter
	endif

InstallSoftware = +

	_Trace("Software install", "")

	ifstr(i) $(DoCopy) == "YES"
	   _LocalShell GetSourceDir $(SrcDir)
		ifstr $($R0) != "STATUS_SUCCESSFUL"
			set Status = $($R0)
         _AssertMsgGoto(FALSE, "GetSourceDir failed: "$(Status), Error)
		endif
		set SrcDir = $($R1)

	   // Copy core files
      _LocalShell CopyCoreFiles $(Option) $(SrcDir) $(AddCopy) $(DoCopy)
      _AssertGoto($($R0), Error)
   endif

   _MakeStdRegKey($(!REG_H_LOCAL), $(PackageInstalledOptionsKeyName), KeyInstalledOptions)
	_IfNotValidKey($(KeyInstalledOptions))
      _AssertGoto(FALSE, Error)
	endif

	_MakeStdRegKey($(!REG_H_LOCAL), $(PackageOptionInstalledKeyName), KeyOptionInstalled)
	_IfNotValidKey($(KeyOptionInstalled))
      _AssertGoto(FALSE, Error)
	endif

   // need to do this since we create these keys by hand
   _LocalShell SetRefCountByKey $(KeyOptionInstalled) 0
   _AssertGoto($($R0), Error)

   _LocalShell WriteConfigData

	ifstr(i) $(DoCopy) == "YES"
      _LocalShell InstallDiags $(Option) $(SrcDir) $(AddCopy) $(DoCopy)
      _AssertGoto($($R0), Error)
   endif

	_LocalShell AddService "PAMA"
   _AssertGoto($($R0), Error)
	set InstalledDriverList = >($(InstalledDriverList), "PAMA")

InstallDriver = +

#if defined(SUPPORT_SYNC570)
	ifcontains(i) $(Option) in $(OptionsThatNeedStreams)
		_LocalShell AddStreamsService
      _AssertGoto($($R0), Error)
	endif
#endif

	_Trace("Installing Driver", "")
	_LocalShell AddService $(Option)
   _AssertGoto($($R0), Error)
	set InstalledDriverList = >($(InstalledDriverList), $(Option))

InstallAdapter = +

	_Trace("Installing Adapter", "")

   _UtilityShell IncrementRefCount $(PackageKeyName)
   _OnShellErrorGoto(Error)
   _OnUtilityShellErrorGoto($($R0), Error)
   set IncrementedPackageRefCount = TRUE

   _UtilityShell IncrementRefCount $(PackageOptionInstalledKeyName)
   _OnShellErrorGoto(Error)
   _OnUtilityShellErrorGoto($($R0), Error)
   set IncrementedInstalledOptionRefCount = TRUE

	set HardwareParametersValueList = EMPTY_LIST

	// Install adapter.
	set HardwareParametersValueList = >($(HardwareParametersValueList),  _MakeSzData(DXB_REGVAL_BUS_NAME, $(BusName)))
	set HardwareParametersValueList = >($(HardwareParametersValueList),  _MakeDwordData(DXB_REGVAL_BUS_TYPE, $(BusType)))
	set HardwareParametersValueList = >($(HardwareParametersValueList),  _MakeDwordData(DXB_REGVAL_BUS_NUMBER, $(BusNumber)))

	ifstr $(BusName) == "ISA"
      set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_IO_ADDRESS, $(IOBaseAddress)))
      set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_MEMORY_ADDRESS, $(MemoryAddress)))
      set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_INTERRUPT, $(InterruptNumber)))
	else-ifstr $(BusName) == "PCI"
		set HardwareParametersValueList = >($(HardwareParametersValueList),  _MakeDwordData(DXB_REGVAL_SLOT_NUMBER, $(SlotNumber)))
		set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_VENDOR_ID, $(VendorID)))
		set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_DEVICE_ID, $(PciID)))
		set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_SUBVENDOR_ID, $(SubVendorID)))
		set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_SUBDEVICE_ID, $(SubPciID)))
		set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_REVISION_ID, $(RevisionID)))
  endif

	_LocalShell FirmwareImageNames $(Option) $(BusName)
   set BiosImage = $($R0)
   set FepImage = $($R1)
   set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeSzData(DXB_REGVAL_FEP, $(FepImage)))
   set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeSzData(DXB_REGVAL_BIOS, $(BiosImage)))

   ifstr $(FepImage) == "FepClyde.Bin"
     set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_DXBVERSION2, 1))
   else-ifstr $(FepImage) == "FepPrime.Bin"
     set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_DXBVERSION2, 1))
   endif



	_LocalShell CalculateNumberOfLines $(Option) $(BusName) $(VendorID) $(PciID) $(SubPciID) $(Identity)
   set NumberOfLines = $($R0)
   set Identity = $($R1)
	set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeDwordData(DXB_REGVAL_NUMBEROFLINES, $(NumberOfLines)))
  set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeSzData(DXB_REGVAL_IDENTITY, $(Identity)))

	set HardwareParametersValueList = >($(HardwareParametersValueList), _MakeSzData(DXB_REGVAL_OPTION, $(Option)))

	_LocalShell AddAdapter $(Option) $(Option) EMPTY_STR EMPTY_STR EMPTY_LIST EMPTY_LIST $(HardwareParametersValueList)
   _AssertGoto($($R0), Error)

   // OK, this may not be the most kosher way to get the AdapterServiceName, but
   // we all know that this is how it's done.
   set AdapterNumber = $($R1)
   set AdapterServiceName = $(ProductHardwareName)$(AdapterNumber)
	set InstalledAdapterList = >($(InstalledAdapterList), { $(Option), $(AdapterNumber) })

	_OpenServiceParamKey($(AdapterServiceName), KeyHardwareParameters)
	_IfNotValidKey($(KeyHardwareParameters))
      _AssertGoto(FALSE, Error)
	endif

	ifcontains(i) $(Option) in $(OptionsWithX25Svcs)
		; Copy the WANX Router Data
	   _LocalShell CopyRouterData $(KeyHardwareParameters)
	endif

	_LocalShell ConfigureAdapter-$(Option) $(SrcDir) $(Option) $(KeyHardwareParameters) $(AdapterServiceName)
	set Status = $($R0)

	ifstr(i) $(Status) == "STATUS_USERCANCEL"
		goto Error
	endif

	ifstr(i) $(Status) == "STATUS_FAILED"
		goto Error
	endif

	goto Exit

Error = +

	_DebugExitPoint
	_Error("Error during install!", _Show(DeleteInfOnExit))

   // HKLM\SOFTWARE\Digi\WAN Links\InstalledOptions\xxxx
   _Error("Checking installed option", _Show(IncrementedInstalledOptionRefCount))
   _If($(IncrementedInstalledOptionRefCount))
      _Error("Decrementing installed option refcount", "")
      _UtilityShell DecrementRefCount $(PackageOptionInstalledKeyName)
      _UtilityShell IsRefCountEqualZero $(PackageOptionInstalledKeyName)
      _If($($R1))
         _Error("Deleting installed option reg key", _Show(PackageOptionInstalledKeyName))
	      DeleteRegTree $(!REG_H_LOCAL) $(PackageOptionInstalledKeyName)
	   endif
   endif

   // HKLM\SOFTWARE\Digi\WAN Links
   _Error("Checking package", _Show(IncrementedPackageRefCount))
   _If($(IncrementedPackageRefCount))
      _Error("Decrementing package refcount", "")
      _UtilityShell DecrementRefCount $(PackageKeyName)
   endif
   _UtilityShell IsRefCountEqualZero $(PackageKeyName)
   _If($($R1))
      _Error("Removing package", _Show(PackageSoftwareName))
		_UtilityShell RemoveSoftwareComponent $(Manufacturer) $(PackageSoftwareName)
#if defined(_DEBUG)
      _ShellError(Dontcare)
      _UtilityShellError($($R0), DontCare)
#endif

#if defined(OLD_PRODUCT_VERSION)
      // Delete hack
	   read-syms OldDriverConstants
		_UtilityShell RemoveSoftwareComponent $(Manufacturer) $(OldProductSoftwareName) "FALSE"
#if defined(_DEBUG)
      _ShellError(Dontcare)
      _UtilityShellError($($R0), DontCare)
#endif
#endif

	  _LocalShell RemoveGroupFromServiceGroupOrder $(DStreamsDependOnGroup)

      _Error("Removing diags", "")
      _LocalShell RemoveDiags $(Option) $(SrcDir) $(AddCopy) $(DoCopy)
	   set DeleteInfOnExit = TRUE
	endif

	ForListDo $(InstalledAdapterList)
      set Type = *($($), 1)
      set AdapterNumber = *($($), 2)

		_Trace("Adapter Type", _Show(Type))
		_Trace("Adapter Number", _Show(AdapterNumber))

	   read-syms DriverConstants-$(Type)

#if defined(SUPPORT_SYNC570)

		ifcontains(i) $(Option) in $(OptionsThatNeedStreams)

			_Trace("Remove Digisoh!", _Show(ProductHardwareName)_Show(AdapterNumber))

			// Remove the Adapter from the DigiSOH List
			_LocalShell RemoveAdapterFromMiniportAdapters $(ProductHardwareName)$(AdapterNumber)

		endif

		_UtilityShell RemoveHardwareComponent $(Manufacturer) $(ProductHardwareName) $(KEY_NETWORKCARDS)"\\"$(AdapterNumber)
#if defined(_DEBUG)
      _ShellError(Dontcare)
      _UtilityShellError($($R0), DontCare)
#endif

#endif

	EndForListDo

	ForListDo $(InstalledDriverList)
      set Type = $($)
	   read-syms DriverConstants-$(Type)
      _Error("Checking ref count for", _Show(ProductKeyName))
      _UtilityShell IsRefCountEqualZero $(ProductKeyName)
      _If($($R1))
         _Error("Removing software component", _Show(ProductSoftwareName))
		   _UtilityShell RemoveSoftwareComponent $(Manufacturer) $(ProductSoftwareName)
#if defined(_DEBUG)
         _ShellError(Dontcare)
         _UtilityShellError($($R0), DontCare)
#endif
      endif
	EndForListDo

   _LocalShell RemoveFilesInRemoveList

	set ManufacturerKeyName = $(!NTN_SoftwareBase)"\\"$(Manufacturer)
	_OpenRegKey_HKLM($(ManufacturerKeyName), KeyManufacturer)
	_IfValidKey($(KeyManufacturer))
		EnumRegKey $(KeyManufacturer) DigiProductList
		CloseRegKey $(KeyManufacturer)
		QueryListSize NumDigiProducts $(DigiProductList)
		ifint $(NumDigiProducts) == 0
			DeleteRegTree $(!REG_H_LOCAL) $(ManufacturerKeyName)
		endif
	endif

Exit = +

	_If($(DeleteInfOnExit))
		_Trace("Deleting", _Show(STF_CONTEXTINFNAME))
		LibraryProcedure Result $(!LIBHANDLE) DelFile $(STF_CONTEXTINFNAME)
	endif

	// Close keys if open.
	_CloseRegKey($(KeyPackage))
	_CloseRegKey($(KeyInstalledOptions))
	_CloseRegKey($(KeyOptionInstalled))
	_CloseRegKey($(KeyHardwareParameters))

	EndWait

	_Exit("InstallMode", _Show(Status))
	Return $(Status)
