/***********************************************************************
;
; OEMSETUP.INF
;
;       Intel EtherExpress PRO-100 network card and 
;       driver SETUP INF file.
;
;       This will work with:
;
;           E100      EISA  10/100  MB
;           E100      PCI   10/100  MB
;           
;
;
;***********************************************************************

;-----------------------------------------------------------------------
; OPTION TYPE
; -----------
; This identifies the Option type we are dealing with.  The different
; possible types are:
;
; COMPUTER, DISPLAY, MOUSE, KEYBOARD, LAYOUT, SCSI, PRINTER, ...
;
;  Types specific to networking:
;
; NetAdapter,        a netcard / adapter combination or just a netcard
; NetDriver,         just a netcard driver
; NetTransport,      a complete NDIS-compliant TDI transport stack
; NetService,        an NT networking service
; NetWork,           a complete network ensemble.
; NetProvider        a complete network which supports NT MPR protocol
;-----------------------------------------------------------------------

[Identification]
    OptionType = NetAdapter

;-----------------------------------------------------------------------
; PlatformsSupported
; ------------------
; This identifies the platforms supported by the adapter card.
; Possible types are:
;
; ISA, EISA and MCA
;
; For PCI the use of ISA is required. (MeThinks -TM)
;
;-----------------------------------------------------------------------

[PlatformsSupported]
    ISA
    EISA
    "Jazz-Internal Bus"

;-----------------------------------------------------------------------
; LANGUAGES SUPPORTED
; -------------------
;
; The languages supported by the OEM INF, For every language supported
; we need to have a separate text section for every displayable text
; section.
;
;-----------------------------------------------------------------------

[LanguagesSupported]
    ENG

;-----------------------------------------------------------------------
; OPTION LIST
; -----------
; This section lists the OEM Option key names.  These keys are locale
; independent and used to represent the option in a locale independent
; manner.
;
;-----------------------------------------------------------------------

[Options]
    E100EISA
    E100PCI

;-----------------------------------------------------------------------
; OPTION TEXT SECTION
; -------------------
; These are text strings used to identify the option to the user.  There
; are separate sections for each language supported.  The format of the
; section name is "OptionsText" concatenated with the Language represented
; by the section.
;
;-----------------------------------------------------------------------

[OptionsTextENG]
    E100EISA = "Intel EtherExpress PRO/100 EISA LAN Adapter"
    E100PCI  = "Intel EtherExpress PRO/100 PCI LAN Adapter"


[Files-Inf]
1, oemsetup.inf, SIZE=65535, RENAME=$(!UG_Filename)


[Files-AUX]
1,E100NT.DLL, SIZE=65535
1,E100NT.HLP, SIZE=65535



[Files-E100PCI]
1, E100.SYS, SIZE=65535
1, PROKDD.SYS, SIZE=65535

[Files-E100EISA]
1, E100.SYS, SIZE=65535
1, PROKDD.SYS, SIZE=65535

;***********************************************************************
; CONSTANTS FOR USING DIALOGS
;***********************************************************************

[FileConstants]
;
;  File names, etc.
;
UtilityInf      = "UTILITY.INF"
subroutineinf   = "SUBROUTN.INF"
SoftwareType    = "driver"
Exit_Code       = 0

;
; EventLog Message File
;
NetEventDLL     = "%SystemRoot%\System32\netevent.dll"
IoLogMsgDLL     = "%SystemRoot%\System32\IoLogMsg.dll"

;
; Product Info
;
Manufacturer        =  "Intel"
ProductMajorVersion = "3"
ProductMinorVersion = "1"
ProductVersion      = $(ProductMajorVersion)"."$(ProductMinorVersion)

;
; Software
;
ProductSoftwareName     = "E100"
ProductSoftwareTitle    = "Intel EtherExpress PRO/100 LAN Adapter Driver"
ProductSoftwareImagePath = "\SystemRoot\System32\drivers\E100.sys"
NetRuleSoftwareType     = "E100Sys ndisDriver E100Driver"
NetRuleSoftwareUse      = $(SoftwareType)
NetRuleSoftwareBindForm = """E100Sys"" yes no container"
NetRuleSoftwareClass    = {"E100Driver basic"}
NetRuleSoftwareBindable = {"E100Driver E100Adapter non exclusive 100"}

;
; Hardware
;
ProductHardwareName     = "E100"
ProductHardwareTitle    = "Intel EtherExpress PRO/100 Adapter"
NetRuleHardwareType     = "E100 E100Adapter"
NetRuleHardwareBindForm = " yes yes container"
NetRuleHardwareClass    = {"E100Adapter basic"}

;
;  EISA System ID Info
;
NETCARD_ID      = 1102885            ; E100 10D425
NETCARD1_ID     = 1102885            ; Flash32 10D425
SPEEDO_ID       = 1611715621         ; E100 6010D425
FLASH32_ID      = 269538341          ; Flash32 1010D425

;NETCARD1_ID     = 49749             ; Un00C255

;OEMCARD1_ID     = 134267477         ; Un0800C255
;NETCARD2_ID     = 13216416          ; SnC9AAA0
;OEMCARD2_ID     = 1305062048        ; Sn4DC9AAA0
;NETCARD3_ID     = 13216432          ; SnC9AAB0
;OEMCARD3_ID     = 1305062064        ; Sn4DC9AAB0
;NETCARD4_ID     = 13216464          ; SnC9AAD0
;OEMCARD4_ID     = 1305062096        ; Sn4DC9AAD0
;NETCARD5_ID     = 2136129           ; In209841
;OEMCARD5_ID     = 18913345          ; In01209841

;
; Registry Key
;
ProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
ParamKeyName    = $(!NTN_ServiceBase)"\"$(ProductHardwareName)"\Parameters"

[ProductType]
STF_PRODUCT  = Winnt
STF_PLATFORM = I386

[GeneralConstants]
;
;  Program flow control variables.
;
from      = ""
to        = ""

;
;  Return codes; Exit_Code is set to one of these
;
ExitCodeOk     = 0
ExitCodeCancel = 1
ExitCodeFatal  = 2

KeyNull            = ""
MAXIMUM_ALLOWED    = 33554432
RegistryErrorIndex = NO_ERROR
KeyProduct         = ""
KeyParameters      = ""

TRUE            = 1
FALSE           = 0
NoTitle         = 0

ExitState   = "Active"
OldVersionExisted = $(FALSE)

DriverPath      = $(!STF_NTPATH)\drivers

EisaId      = $(SPEEDO_ID)

;***********************************************************************
; Language-Dependent Dialog Constants
;***********************************************************************

[FileConstantsENG]
;
;  Variables to support thermometer gauge and error dialogs
;
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:"

;
; Product Info
;
FunctionTitle = "Intel EtherExpress PRO/100 LAN Adapter Setup"

;
; Software
;
ProductSoftwareDescription = "Intel EtherExpress PRO/100 LAN Adapter Driver"

;
; Hardware
;
ProductHardwareDescription = "Intel EtherExpress PRO/100 LAN Adapter"

;
; Dialog Message Information
;
CANNOT_FIND_ANY_CARD       = "Network card is not present in the system"

[DialogConstantsENG]
;
; Common button names, etc.
;
Help        = "&Help"
Exit        = "Cancel"
OK          = "OK"
HelpContext = ""
Continue    = "Continue"
Cancel      = "Cancel"

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

[Source Media Descriptions]
    1  = "Intel EtherExpress PRO/100 Driver Disk" 

;-----------------------------------------------
; Input DIALOGS
;-----------------------------------------------
[FileDependentDlgENG]

;---------------------------------------------------------------------------
; 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]
    Debug-Output "foobar 1"
    read-syms Identification

    set !G:DebugOutputControl = 1

    set Status     = STATUS_SUCCESSFUL
    set Identifier = $(OptionType)
    set Media      = #("Source Media Descriptions", 1, 1)

    Debug-Output "OPTIONS: $(Status) $(Identifier) $(Media)"
    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 = {}

    ;
    ; Check if the language requested is supported
    ;
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) in $(LanguageList)
	;
	; Check if the platforms requested is supported
	;
	ifstr(i) $($1) == ""
	    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

    ;
    ; form a list of all the options and another of the text representing
    ;
returnoptions = +
    set OptionList     = ^(Options, 1)
;       set OptionList  = $(Options)
    set OptionTextList = ^(OptionsText$($0), 1)
;       set OptionTextList = $(OptionsText$($0))
    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 !G:DebugOutputControl = 1
    ;
    ; Set default values
    ;
    Debug-Output "At InstallOption"
    set Status   = STATUS_FAILED

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

    ;
    ; Check if the language requested is supported
    ;
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) NOT-IN $(LanguageList)
	Return STATUS_NOLANGUAGE
    endif

    set-subst LF = "\n"

    read-syms GeneralConstants
    read-syms FileConstants

    read-syms DialogConstants$(!STF_LANGUAGE)
    ifstr(i) $(!NTN_Origination) == "NCPA"
	set Continue = "OK"
    endif

    read-syms FileConstants$(!STF_LANGUAGE)

    detect date

    set-title  $(FunctionTitle)

    set to   = Begin
    set from = Begin

    ;
    ; Assume all is well.
    ;
    set CommonStatus = STATUS_SUCCESSFUL

    EndWait

;
; Set up the operation-mode-based variables and welcome
; the user.  If the "install mode" variable is improperly set,
; assume this is a new installation.
;
Begin = +
    Debug-Output "At Begin"

    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
	;
	; You cannot config the software component
	;
	Debug-Output "Configure: ProductKeyName, NTN_RegBase="$(ProductKeyName)","$(!NTN_RegBase)

	Ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
	    Debug-Output "Cannot configure the E100 driver software."
;           Shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) "WARNING" "Equal case"
	    goto setfailed
	else
	    Debug-Output "Configuring the E100 driver software."

;
;   This happens when the user is trying to configure the adapter.
;   We're going to allow the user to reconfigure the configurable
;   parameters: FIFO, ON, OFF, and Slot/EID
;
;   Since we've already installed the driver we have initial values for
;   these already in the registry (see the adapterverify section),
;   get the existing values and put them in the dialog as the defaults.
;
	    ;********************************************************
	    ; 1) Get the current values.

	    ;    Get some handles, etc before fetching the params
	    ;
	    Ifstr $(KeyProduct) == $(KeyNull)
		OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) KeyProduct
		Ifstr $(KeyProduct) == $(KeyNull)
		    set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
		    Debug-Output "Cannot find component product key"
		    goto fatalregistry
		Endif
	    Endif

	    ;
	    ; Get the other parameters;  they're attached to the service parameters key
	    ;
	    Debug-Output "INF: Shelling to FindService"

	    Shell $(UtilityInf) FindService, $(KeyProduct)
	    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output "INF: FindService shell failure"
		Goto ShellCodeError
	    Endif

	    Ifstr(i) $($R0) != NO_ERROR
		Debug-Output "INF: FindService Shell error: "$($R0)
		Goto fatalregistry
	    Endif

	    Set KeyParameters = $($R2)

	    ;
	    ;  We don't need the services key, so close it.
	    ;
	    CloseRegKey $($R1)

	    Ifstr $(KeyParameters) == $(KeyNull)
		set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
		Debug-Output "Cannot find component service"
		goto fatalregistry
	    Endif

	    set ValueName = ""
	    set ValueData = ""
	    set ValueStr  = ""
	    set ValueList = {}

	    ;
	    ; Get the old values, finally.
	    ;
	    EnumRegValue $(KeyParameters) ValueList

	    ForListDo $(ValueList)
		set ValueItem = $($)
		set ValueName = *($(ValueItem),1)
		set ValueData = *($(ValueItem),4)

		Ifstr(i) $(ValueName) == "Fifo"
		    set FifoValue = $(ValueData)
		    Debug-Output "Registry FIFO: "$(FifoValue)

		else-ifstr(i) $(ValueName) == "On"
		    set OnValue = $(ValueData)
		    Debug-Output "Registry ON: "$(OnValue)

		else-ifstr(i) $(ValueName) == "Off"
		    set OffValue = $(ValueData)
		    Debug-Output "Registry OFF: "$(OffValue)

		else-ifstr(i) $(ValueName) == "Threshold"
		    set ThresholdValue = $(ValueData)
		    Debug-Output "Registry THRESHOLD: "$(ThresholdValue)

		else-ifstr(i) $(ValueName) == "Speed"
		    set SpeedValue = $(ValueData)
		    Debug-Output "Registry SPEED: "$(SpeedValue)

		else-ifstr(i) $(ValueName) == "Slot"
		    set SlotValue = $(ValueData)
		    Debug-Output "Registry SLOT: "$(SlotValue)

		else-ifstr(i) $(ValueName) == "Eid"
		    set NodeAddressValue = $(ValueData)
		    Debug-Output "Registry NodeAddress: "$(NodeAddressValue)

		else-ifstr(i) $(ValueName) == "BusTypeLocal"
		    set BusTypeValue = $(ValueData)
		    Debug-Output "Registry BusTypeLocal: "$(BusTypeValue)

		else-ifstr(i) $(ValueName) == "MapRegisters"
		    set MapRegistersValue = $(ValueData)
		    Debug-Output "Registry MapRegisters: "$(MapRegistersValue)
		endif
	    EndForListDo

	    ;
	    ; Might have to set defaults - just in case.
	    ;
	    ifstr(i) $(FifoValue) == ""
		   set FifoValue = 12
		   Debug-Output "Setting Default FIFO"
	    endif

	    ifstr(i) $(OnValue) == ""
		   set OnValue = 272
		   Debug-Output "Setting Default ON"
	    endif

	    ifstr(i) $(OffValue) == ""
		   set OffValue = 2
		   Debug-Output "Setting Default OFF"
	    endif

	    ifstr(i) $(SlotValue) == ""
		   set SlotValue = 0
		   Debug-Output "Setting Default SLOT"
	    endif

	    ifstr(i) $(NodeAddressValue) == ""
		   set NodeAddressValue = 0
		   Debug-Output "Setting Default NODEADDRESS"
	    endif

	    ifstr(i) $(SpeedValue) == ""
		   set Speed = 0
		   Debug-Output "Setting Default SPEED"
	    endif

	    ifstr(i) $(ThresholdValue) == ""
		   set ThresholdValue = 16
		   Debug-Output "Setting Default THRESHOLD"
	    endif

		ifstr(i) $(MapRegistersValue) == ""
		   ifstr(i)     $(BusTypeValue) == "5"
		      set MapRegistersValue = 10
		   else-ifstr(i) $(BusTypeValue) == "2"
			  set MapRegistersValue = 32
		   endif
		   Debug-Output "Setting Default THRESHOLD"
	    endif


	    ;********************************************************
	    ; 2) At this point, we have the current registry values
	    ;    for the variable parameters.
	    ;    Now we need to open up the DLL and tell it what the
	    ;    the values are.

	    ;
	    ; Load the E100NT.DLL and set the current values.
	    ;

;                        LoadLibrary "x" $(!STF_NTPATH)\E100NT.DLL MYLIBHANDLE
			LoadLibrary "x" $(!STF_CWDDIR)\E100NT.DLL MYLIBHANDLE
			;InitSlotArray
			Debug-Output "made it past load library, right before initslotaray"
			;LibraryProcedure MyResult $(MYLIBHANDLE), InitSlotArray  ;, $(!STF_HWND), $(!NCPA_HANDLE)
			Debug-Output "made it past initslotaray"
			Debug-Output $(NETCARD_ID)

			Ifstr(i) $(BusTypeValue) == "2"  
			Shell $(UtilityInf), EISAFindBus, $(NETCARD_ID)
			ifstr(i) $($R1) != {}       
				Debug-Output "EISA Controller NETCARD_ID found!"
				set AdapterList = $($R1)
					; this is to add this slot number to the slotlist in the dll.
					ForListDo $(AdapterList)
						LibraryProcedure MyResult $(MYLIBHANDLE), IncSlotValue, $(!STF_HWND), $(!NCPA_HANDLE), *($($),2)
					EndForListDo
				set EisaId = $(SPEEDO_ID)
					Debug-Output "EISA Controller NETCARD_ID:::  $($R1) "
				goto ContinueConf
			endif
			endif
			Ifstr(i) $(BusTypeValue) == "5" 
				;
				;check to see if there are pci adapters in the system
				;
			    LibraryProcedure MyResult $(MYLIBHANDLE), StuffNodeAddress, $(!STF_HWND), $(!NCPA_HANDLE), $(!STF_WINDOWSSYSPATH)\drivers 
				;
				ifstr(i) $(MyResult) == "DETECTED"   
				   ;the dll detects some pci adapters
			       goto ContinueConf
				endif
		endif

		Debug-Output "EISA Controller Search failed! - this means none were found anywhere!!!"
			Debug-Output "EISA Controller NETCARD4_ID:::  $($R1) "
		set NoCard = "TRUE"
			goto ContinueConf


ContinueConf = +
			; this is a test to see if I can pass a string with all the parameters in it
			; to the dll
			;
			; first I need to put the values in a list
			; then I need to send that list to my dll
			;
			; it is for EISA {""EISABusType"",""slot"",""speed"",""threshold"",""fifo"",""on"",""off""}
			;       for PCI  {""PCIBusType"",""NodeAddress"",""speed"",""threshold"",""fifo"",""on"",""off""}

			
			ifstr(i) $(BusTypeValue) == "2"
			   set ValueList2 = {2,$(SlotValue),$(SpeedValue),$(ThresholdValue),$(FifoValue),$(OnValue),$(OffValue),$(MapRegistersValue)}
			else-ifstr(i)  $(BusTypeValue) == "5"
			   set ValueList2 = {5,$(NodeAddressValue),$(SpeedValue),$(ThresholdValue),$(FifoValue),$(OnValue),$(OffValue),$(MapRegistersValue)}
			endif

			Debug-Output "VallistBefore1:  $(ValueList2)"
			LibraryProcedure MyResult $(MYLIBHANDLE), SetValues, $(!STF_HWND), $(!NCPA_HANDLE), $(ValueList2)
			Debug-Output "VallistBefore2:  $(ValueList2)"


	    ;
	    ; Now put up the dialog box and it should have the last user
	    ; entered values.
	    ;
; kroot
	    ; get our services subkey so the DLL know our current instance

	    Debug-Output "***************** Get the instance 1 *****************"
	    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) +
		  $(MAXIMUM_ALLOWED) NetworkCardKey
	    Ifstr(i) $(NetworkCardKey) != $(KeyNull)
		;
		; Get Service name
		;
		GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
		set ServiceName = *($(ServiceNameInfo), 4)


		CloseRegKey $(NetworkCardKey)
	    else
		;
		; Error, cannot open network card key
		;
		Debug-Output "Unable to open NTN_RegBase: $(!NTN_RegBase)"
		set ServiceName = ""
		;goto setfailed
	    endif
; kroot

	    Debug-Output "My service name is $(ServiceName)"


;            LibraryProcedure MyResult $(MYLIBHANDLE), ConfigFunc, $(!STF_HWND), $(!NCPA_HANDLE), $(BusTypeValue), $(ServiceName)
	    LibraryProcedure MyResult $(MYLIBHANDLE), ConfigFunc, +
		$(!STF_HWND), $(BusTypeValue), $(ServiceName)

			; this is a test to see if the dll returns the right kind of string
			;LibraryProcedure ValueList2 $(MYLIBHANDLE), GetValues, $(!STF_HWND), $(!NCPA_HANDLE)
			;Debug-Output "VallistAfter:  $(ValueList2)"


			ifstr(i) $(MyResult) == "CANCEL"
				FreeLibrary $(MYLIBHANDLE)
				goto setfailed     
			endif
	    ifstr(i) $(MyResult) == "OK"
		;
		; If the user says it's OK, go get the new parameter values...
		;
				LibraryProcedure ValueList2 $(MYLIBHANDLE), GetValues, $(!STF_HWND), $(!NCPA_HANDLE)
			    Debug-Output "VallistAfter:  $(ValueList2)"

				;
				; Set the values to the returned values
				;
				ifstr(i) $(BusTypeValue) == "2"
				    set SlotValue = *($(ValueList2),2)
				else-ifstr(i) $(BusTypeValue) == "5"
				    set NodeAddressValue = *($(ValueList2),2)
				endif
				set SpeedValue = *($(ValueList2),3)
				set ThresholdValue = *($(ValueList2),4)
				set FifoValue = *($(ValueList2),5)
				set OnValue = *($(ValueList2),6)
				set OffValue = *($(ValueList2),7)                
				set MapRegistersValue = *($(ValueList2),8)                

				Debug-Output "BusTypeLocal: $(BusTypeValue)"                         
				Debug-Output "Speed: $(SpeedValue)"
				Debug-Output "Threshold: $(ThresholdValue)"
				Debug-Output "Fifo: $(FifoValue)"                               
				Debug-Output "On: $(OnValue)"
				Debug-Output "Off: $(OffValue)"
				Debug-Output "Threshold: $(SlotValue)"

				Debug-Output "NodeAddress: $(NodeAddressValue)"
				



writeparameters1 = +

		;
		; ...and write them to the registry.
		;
		Debug-Output "At 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
		;
		   ifstr(i) $(BusTypeValue) == "2"   ;if eisa
		   set NewValueList = {+
				       {Fifo,$(NoTitle),$(!REG_VT_DWORD),$(FifoValue)},+
				       {On,$(NoTitle),$(!REG_VT_DWORD),$(OnValue)},+
				       {Slot,$(NoTitle),$(!REG_VT_DWORD),$(SlotValue)},+
					   {Speed,$(NoTitle),$(!REG_VT_DWORD),$(SpeedValue)},+
					   {Threshold,$(NoTitle),$(!REG_VT_DWORD),$(ThresholdValue)},+
					   {MapRegisters,$(NoTitle),$(!REG_VT_DWORD),$(MapRegistersValue)},+
				       {Off,$(NoTitle),$(!REG_VT_DWORD),$(OffValue)}+
				      }
		   else-ifstr(i) $(BusTypeValue) == "5"     ; if pci
		   set NewValueList = { +
					   {Fifo,$(NoTitle),$(!REG_VT_DWORD),$(FifoValue)},+
				       {On,$(NoTitle),$(!REG_VT_DWORD),$(OnValue)},+
				       {Eid,$(NoTitle),$(!REG_VT_DWORD),$(NodeAddressValue)},+
					   {Speed,$(NoTitle),$(!REG_VT_DWORD),$(SpeedValue)},+
					   {Threshold,$(NoTitle),$(!REG_VT_DWORD),$(ThresholdValue)},+
					   {MapRegisters,$(NoTitle),$(!REG_VT_DWORD),$(MapRegistersValue)},+
				       {Off,$(NoTitle),$(!REG_VT_DWORD),$(OffValue)} +
				      }
; !!!
			Debug-Output "writeParam1: PCI NewValueList going to registry:  $(NewValueList)"
		   endif


		Shell  $(UtilityInf), AddValueList, $(KeyParameters), $(NewValueList)

		CloseRegKey $(KeyParameters)

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

		set RegistryErrorIndex = $($R0)

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

	    endif   ; OK

	    FreeLibrary $(MYLIBHANDLE)

	    goto successful
	endif

	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error: cannot get an error string."
	    goto ShellCodeError
	endif

	set Error = $($R0)
	set from = end
	set to = end
	goto nonfatalinfo
    else
	set StartLabel = installadapter
	set OEM_ABANDON_OPTIONS = {}
	set OEM_ABANDON_SOFTWARE = FALSE
	set OEM_ABANDON_ON = TRUE
    endif

    Set from = $(fatal)
    Set to = $(fatal)
    Goto $(StartLabel)

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

installadapter = +
    Debug-Output "At installadapter"
    Debug-Output ": ProductKeyName=$(ProductKeyName), NTN_RegBase=$(!NTN_RegBase)"

    ;
    ; First, check whether the same version of the software exists
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) 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)
	   ;
	   ; Cannot Install the same software again
	   ;
	   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?
	   ;
	   set OldVersionExisted = $(TRUE)
	endif
    endif

    goto adapterverify

;-----------------------------------------------
; Configuration Section
;-----------------------------------------------
configureadapter = +
    Debug-Output "At configureadapter"

    set Error = "Configure: Sorry, not yet implemented."
    goto fatal

adapterverify = +

; CardFound =  +

 ;   ifstr $($R0) != "NO_ERROR"
 ;       ifstr $($R0) != "STATUS_SUCCESSFUL"
 ;           set Error = $($R0)
 ;           goto fatal
 ;       endif
 ;   endif

 ;   ifstr(i) $($R1) == {}
 ;       set Error = $(CANNOT_FIND_ANY_CARD)
 ;       set CommonStatus = STATUS_USERCANCEL
 ;       set from = end
 ;       goto nonfatal
 ;   endif

    set NoCard = "FALSE"
    set AdapterList = $($R1)

    ;
    ; Add Software Component
    ;
    ;ifint $(OldVersionExisted) == $(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 "At install Install-Option"

	    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


;--------------- this used to be before the copy ------------------------------
;********************
    Debug-Output "At adapterverify"

    StartWait

    set DriverOnly = "FALSE"

    
;        LoadLibrary "x" $(!STF_NTPATH)\E100NT.DLL MYLIBHANDLE   
	LoadLibrary "x" $(!STF_CWDDIR)\E100NT.DLL MYLIBHANDLE   
	Debug-Output "made it past load library, right before initslotaray"
    Debug-Output $(NETCARD_ID)

	Ifstr(i) $(Option) == "E100EISA"
	    Shell $(UtilityInf), EISAFindBus, $(NETCARD_ID)
	    ifstr(i) $($R1) != {}           
		Debug-Output "EISA Controller NETCARD_ID found!"
		set AdapterList = $($R1)
			; this is to add this slot number to the slotlist in the dll.
			ForListDo $(AdapterList)
			   LibraryProcedure MyResult $(MYLIBHANDLE), IncSlotValue, $(!STF_HWND), $(!NCPA_HANDLE), *($($),2)
			EndForListDo
		set EisaId = $(SPEEDO_ID)
			Debug-Output "EISA Controller NETCARD_ID:::  $($R1) "
		goto ContinueInst
	    endif
	endif
	Ifstr(i) $(Option) == "E100PCI"
	   ;
	   ; This call should shove the node address values into the dll's global variable list
	   ; 
			    LibraryProcedure MyResult $(MYLIBHANDLE), StuffNodeAddress, $(!STF_HWND), $(!NCPA_HANDLE), $(!STF_WINDOWSSYSPATH)\drivers 
	   ifstr(i) $(MyResult) == "DETECTED"   
	      ;the dll detects some pci adapters
	      goto ContinueInst
	   endif
	endif
    Debug-Output "EISA Controller Search failed! - this means none were found anywhere!!!"
	Debug-Output "EISA Controller NETCARD4_ID:::  $($R1) "
    set NoCard = "TRUE"
;       goto ContinueInst
    goto AddDriverWithoutBoard
    goto ShellCodeError

;FreeLibrary $(MYLIBHANDLE)
;--------------- end stuff I copied -------------------------------------------

ContinueInst = +

    ifint $(OldVersionExisted) == $(FALSE)
	    
	Debug-Output "At AddSoftwareComponent $(OldVersionExisted) ::::: $(FALSE)"
	Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), +
	    $(ProductSoftwareName), +
	    $(ProductSoftwareTitle), $(STF_CONTEXTINFNAME), +
	    $(ProductSoftwareImagePath), "kernel", "NDIS", {}, "",+
	    $(NetEventDLL)
		Set OEM_ABANDON_SOFTWARE = TRUE


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

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

	Ifstr(i) $(RegistryErrorIndex) != 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),$(ProductSoftwareDescription)},+
			   {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareName)},+
			   {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}

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

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != 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 "At AddValueList - bindform"
	Shell  $(UtilityInf), AddValueList, $(SoftNetRulesKey), $(NewValueList)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error."
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	CloseRegKey $(KeyProduct)
	CloseRegKey $(SoftNetRulesKey)

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

    ;
    ; Create the HARDWARE\Netcard region and its corresponding service
    ;
CreateDriverEntry = +

    set CardInstalled = "NO"

    ;ForListDo $(AdapterList)

	;set BusNum = *($($),1)
	;set SlotNum = *($($),2)
	set BusNum = 0
	set SlotNum = 1

	ifstr(i) $(Option) == "E100PCI"
	   set MapRegistersValue = "10"
	   set BusTypeValue = "5"
	else-ifstr(i) $(Option) == "E100EISA"
	   set MapRegistersValue = "32"
	   Set BusTypeValue = "2"
	endif

	Debug-Output "MapRegistersValue: $(MapRegistersValue)"

	Debug-Output "Adding registry parameters, BusNum $(BusNum) SlotNum $(SlotNum)"

	ifstr $(SlotNum) != "0"

	    ifstr $(DriverOnly) == "TRUE"
		set Retval0 = "NO_ERROR"
		set Retval1 = "NO"
	    else
;               Shell $(UtilityInf), IsNetCardAlreadyInstalled, $(BusNum), +
		Shell "", IsE100CardAlreadyInstalled, $(BusNum), +
		    $(SlotNum), $(ProductHardwareDescription), $(ProductHardwareName)
		set Retval0 = $($R0)
		set Retval1 = $($R1)
	    endif

	    ifint $($ShellCode) != $(!SHELL_CODE_OK)
		goto ShellCodeError
	    endif

	    ifstr $(Retval0) != "NO_ERROR"
		set Error = $($R0)
		goto fatal
	    endif


	    ifstr(i) $(Retval1) != "YES"

		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)
		    goto ShellCodeError
		endif

		set RegistryErrorIndex = $($R0)

		Ifstr(i) $(RegistryErrorIndex) != "NO_ERROR"
		    EndWait
		    CloseRegKey $($R1)
		    CloseRegKey $($R2)
		    CloseRegKey $($R3)
		    goto fatalregistry
		endif

		;
		;   At this point:
		;     $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 HardNetCardKey      = $($R1)
		Set HardNetRuleKey      = $($R2)
		Set HardParameterKey    = $($R3)
		set AdapterNumber       = $($R4)

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

		Shell  $(UtilityInf), AddValueList, $(HardNetCardKey), $(NewValueList)
		ifint $($ShellCode) != $(!SHELL_CODE_OK)
		    goto ShellCodeError
		endif

; kroot
	    ; get our services subkey so the DLL know our current instance

	    Debug-Output "***************** Get the instance 2 *****************"
	    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) +
		  $(MAXIMUM_ALLOWED) NetworkCardKey
	    Ifstr(i) $(NetworkCardKey) != $(KeyNull)
		;
		; Get Service name
		;
		GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
		set ServiceName = *($(ServiceNameInfo), 4)


		CloseRegKey $(NetworkCardKey)
	    else
		;
		; Error, cannot open network card key
		;
		Debug-Output "Unable to open NTN_RegBase: $(!NTN_RegBase)"
		set ServiceName = ""

		;goto setfailed
	    endif
; kroot

		Debug-Output "My service name is $(ServiceName)"
		;
		; Put up the dialog box and allow the user to configure
		; FIFO, ON, OFF parameters.  We have found the board in a
		; particular slot so we won't allow them to alter the slot
		; parameter yet.
		;
		
		ifstr(i) $(Option) == "E100EISA"
		   LibraryProcedure MyResult $(MYLIBHANDLE), ConfigFunc, +
			$(!STF_HWND), 2, $(ServiceName)
		else-ifstr(i) $(Option) == "E100PCI"
		   LibraryProcedure MyResult $(MYLIBHANDLE), ConfigFunc, +
			$(!STF_HWND), 5, $(ServiceName)
		endif
		;*--- this is if the user cancelled from the dialog box ---*
		ifstr(i) $(MyResult) == "CANCEL"
		    goto setfailed     
		endif

		; I want the thing after the if to get the values from the dll
		ifstr(i) $(MyResult) == "OK"
				    ;
			; If the user says it's OK, go get the new parameter values...
			;

					LibraryProcedure ValueList2 $(MYLIBHANDLE), GetValues, $(!STF_HWND), $(!NCPA_HANDLE)
				    Debug-Output "VallistAfter:  $(ValueList2)"

					;
					; Set the values to the returned values
					;
					ifstr(i) $(Option) == "E100EISA"
					    set SlotValue = *($(ValueList2),2)
					else-ifstr(i) $(Option) == "E100PCI"
						set NodeAddressValue = *($(ValueList2),2)
					    Debug-Output "NodeAddr returned to inf:  $(NodeAddressValue)"
					endif
					set SpeedValue = *($(ValueList2),3)
					set ThresholdValue = *($(ValueList2),4)
					set FifoValue = *($(ValueList2),5)
					set OnValue = *($(ValueList2),6)
					set OffValue = *($(ValueList2),7)                                    
					set MapRegistersValue = *($(ValueList2),8)                
					ifstr(i) $(SpeedValue) == "Auto Detect"
					   set SpeedValue = 0
					endif
					
		endif

				Debug-Output "Slot: $(SlotValue)"                               
				Debug-Output "BusTypeLocal: $(BusTypeValue)"                         
				Debug-Output "Speed: $(SpeedValue)"
				Debug-Output "Threshold: $(ThresholdValue)"
				Debug-Output "Fifo: $(FifoValue)"                               
				Debug-Output "On: $(OnValue)"
				Debug-Output "Off: $(OffValue)"                         
				Debug-Output "MapRegisters: $(MapRegistersValue)"

				Debug-Output "NodeAddress: $(NodeAddressValue)"


		FreeLibrary $(MYLIBHANDLE)

		set CardInstalled = "YES"

		
		
		;-------------- if it is eisa -------------------------------------------
		ifstr(i) $(Option) == "E100EISA"
		set NewValueList = {{BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusTypeValue)},+
							{BusTypeLocal,$(NoTitle),$(!REG_VT_DWORD),$(BusTypeValue)},+
							{MediaType,$(NoTitle),$(!REG_VT_DWORD),1},+             
							{Fifo,$(NoTitle),$(!REG_VT_DWORD),$(FifoValue)},+
							{On,$(NoTitle),$(!REG_VT_DWORD),$(OnValue)},+    
							{BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNum)},+                                                             
							{Off,$(NoTitle),$(!REG_VT_DWORD),$(OffValue)},+                         
							{Speed,$(NoTitle),$(!REG_VT_DWORD),$(SpeedValue)},+     
							{Slot,$(NoTitle),$(!REG_VT_DWORD),$(SlotValue)},+
							{MapRegisters,$(NoTitle),$(!REG_VT_DWORD),$(MapRegistersValue)},+                                                                                                                       
						{Eid,$(NoTitle),$(!REG_VT_DWORD),$(EisaId)},+                   
							{Threshold,$(NoTitle),$(!REG_VT_DWORD),$(ThresholdValue)}+              
				   }


		; ------------- if it is pci -------------------------------------------
		else-ifstr(i) $(Option) == "E100PCI"
		set NewValueList = {{BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusTypeValue)},+
							{BusTypeLocal,$(NoTitle),$(!REG_VT_DWORD),$(BusTypeValue)},+
							{MediaType,$(NoTitle),$(!REG_VT_DWORD),1},+             
							{Fifo,$(NoTitle),$(!REG_VT_DWORD),$(FifoValue)},+
							{On,$(NoTitle),$(!REG_VT_DWORD),$(OnValue)},+    
							{BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNum)},+                                                             
							{Off,$(NoTitle),$(!REG_VT_DWORD),$(OffValue)},+                         
							{Speed,$(NoTitle),$(!REG_VT_DWORD),$(SpeedValue)},+                                                             
							{MapRegisters,$(NoTitle),$(!REG_VT_DWORD),$(MapRegistersValue)},+                                                                                                                       
						{Eid,$(NoTitle),$(!REG_VT_DWORD),$(NodeAddressValue)},+                 
							{Threshold,$(NoTitle),$(!REG_VT_DWORD),$(ThresholdValue)}+              
				   }
; !!!
			Debug-Output "writeParam2: PCI NewValueList going to registry:  $(NewValueList)"
		endif
		Shell  $(UtilityInf), AddValueList, $(HardParameterKey), $(NewValueList)
		ifint $($ShellCode) != $(!SHELL_CODE_OK)
		    goto ShellCodeError
		endif

		

		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)} }
		Shell  $(UtilityInf), AddValueList, $(HardNetRuleKey), $(NewValueList)

		CloseRegKey $(HardNetCardKey)
		CloseRegKey $(HardNetRuleKey)
		CloseRegKey $(HardParameterKey)
		ifint $($ShellCode) != $(!SHELL_CODE_OK)
		    goto ShellCodeError
		endif
	    endif
	endif

	ifstr $(DriverOnly) == "TRUE"
	    goto writeparameters2
	endif
    ;EndForListDo

    ;
    ; If no cards were installed, it means that either there were no cards
    ; found (NoCard = TRUE) or all cards in the system have already had
    ; drivers installed for them (CardInstalled = NO).
    ;
    ; What we want to do here is allow the user to install the driver for
    ; a board that is not yet in the system.  This way the user can get the
    ; driver installed, shutdown NT, install the adapter and reboot.
    ; If we don't let the user install a driver for a non-existent board,
    ; then he has to shutdown NT, install the board, reboot, install the
    ; driver, shutdown and then reboot again - what a pain.
    ;
AddDriverWithoutBoard =  +
    ifstr $(NoCard) == "TRUE"
;        Shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) "WARNING" "No adapter found.  Install driver anyway?"
;        ifstr(i) $($R1) == "OK"
	    ;
	    ; NOTE: this will only work for E100 boards
	    ;
	    set EisaId = "1611715621"
			; note this is for speedo - fl32 will have to change if installed
	    set AdapterList = {{"0", "10", "269538341"}}
	    set DriverOnly = "TRUE"
	    set NoCard = "FALSE"
	    goto ContinueInst
;        endif
    endif


    ifstr $(CardInstalled) == "NO"
; kroot!!!
; This message happens when it shouldn't
	Shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) "Got that bogus message again. Show Ken how you got here!"

;        Shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) "WARNING" "Drivers are already installed for the current hardware.  Install driver anyway?"
;        ifstr(i) $($R1) == "OK"
	    ;
	    ; NOTE: this will only work for E100 boards
	    ;
	    set EisaId = "1611715621" ;  fl32 will have to change if installed
			; this is for speedo
	    set AdapterList = {{"0", "10", "269538341"}}
	    set DriverOnly = "TRUE"
	    goto ContinueInst
;        endif
    endif

;
; REQUIRED:   $(KeyParameters) contains service Parameters key handle
;
writeparameters2 = +
    Debug-Output "At writeparameters"
    EndWait
    goto successful

;-----------------------------------------------
; Binding section
;-----------------------------------------------
bindingadapter =+
    Debug-Output "At bindingadapter"
    set Error = "Binding: Sorry, not yet implemented."
    goto fatal

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

removeadapter = +
    Debug-Output "At removeadapter"
    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 RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != 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 RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    endif
	; look to see if it can be removed
	Debug-Output "Before call to InfLookup"

;        LoadLibrary "x" $(!STF_NTPATH)\E100NT.DLL MYLIBHANDLE
	LoadLibrary "x" $(!STF_CWDDIR)\E100NT.DLL MYLIBHANDLE
	LibraryProcedure MyResult $(MYLIBHANDLE), SharedInfSearch, $(!STF_HWND), $(!NCPA_HANDLE), $(STF_CONTEXTINFNAME)    
    FreeLibrary $(MYLIBHANDLE)
	Debug-Output "MyResult: $(MyResult)"

	Debug-Output "After call to InfLookup"

	ifstr(i) $(MyResult) != "FOUND_SOME"
	   ; delete it from the registry
	   set RegInfFileNameKey = "SYSTEM\Setup\InfOptions"
	   OpenRegKey $(!REG_H_LOCAL) "" $(RegInfFileNameKey) $(MAXIMUM_ALLOWED) ProductKey
       Ifstr $(ProductKey) == $(KeyNull)
	  Debug-Output "OEMSETUP.INF: could not open Software product key"          
       endif
       DeleteRegTree $(ProductKey) $(MyResult)
       CloseRegKey $(ProductKey)

	   ;delete it from the disk
	   Debug-Output "nuking STF_CONTEXTINFNAME="$(STF_CONTEXTINFNAME)
	   LoadLibrary "x" $(!STF_CWDDIR)\setupdll.dll !LIBHANDLE
	   LibraryProcedure Status1, $(!LIBHANDLE), DelFile, $(STF_CONTEXTINFNAME)
	   FreeLibrary $(!LIBHANDLE)
	endif
    goto end

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

UpgradeSoftware = +
    Debug-Output "At UpgradeSoftware"
    ;
    ; First determine whether we want to do upgrade or update for software
    ; or hardware component. Then we will determine whether the Mode is
    ; update or upgrade.
    ;
    ; If the same version of the product existed in the registry, we do
    ; update. Otherwise, we will do an upgrade.
    ;
    ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
	; Upgrade software component
	;
	; see whether the same version exist or not
	;
	OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

	Ifstr $(KeyProduct) != $(KeyNull)
	    GetRegValue $(KeyProduct),"MajorVersion", VersionInfo
	    set Version = *($(VersionInfo), 4)

	    ;
	    ; Update the binaries
	    ;
	    Split-String $(!NTN_Infname), "\", FilenameList
	    QueryListSize ListSize $(FilenameList)
	    set !UG_Filename = *($(FilenameList), $(ListSize))

	    install "Install-Update"
	    ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
		goto fatal
	    endif

	    ; Upgrade the version number
	    ;
	    SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMajorVersion)}
	    SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMinorVersion)}

	    ;
	    ; do nothing for update
	    ;
	    ifint $(Version) != $(ProductVersion)
	       ;
	       ; If the major version number is not the same,
	       ; it is major upgrade. So let's Upgrade the product
	       ;
	       ; make other upgrade change if necessary
	       ;
	    endif
	    CloseRegKey $(KeyProduct)
	else
	    ;
	    ; Cannot Open software key, goto ERROR
	    ;
	    goto fatalregistry
	endif
    else
	;
	; upgrade/update hardware component
	; There is no different between upgrade and update for hardware
	; component
	;
	; 1. Get the Service Name
	; 2. Change the NetRule section if necessary
	;
	OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) +
	      $(MAXIMUM_ALLOWED) NetworkCardKey
	Ifstr(i) $(NetworkCardKey) != $(KeyNull)
	    ;
	    ; Get Service name
	    ;
	    GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
	    set ServiceName = *($(ServiceNameInfo), 4)

	    ;
	    ; Change the NetRule if necessary
	    ;
	    OpenRegKey $(NetworkCardKey) "" "NetRules" +
		$(MAXIMUM_ALLOWED) NetRuleKey
	    Ifstr(i) $(NetRuleKey) != $(KeyNull)
		;
		; Make the change....
		;
	    else
		;
		; Error, cannot open net rules key
		;
		goto fatalregistry
	    endif

	    CloseRegKey $(NetRules)
	    CloseRegKey $(NetworkCardKey)
	else
	    ;
	    ; Error, cannot open network card key
	    ;
	    goto fatalregistry
	endif
	;
	; 3. Change the service section of the hardware. i.e.,
	;    ParameterName change, value change, etc.
	;
	OpenRegKey $(!REG_H_LOCAL) "" +
	      $(!NTN_ServiceBase)"\"$(ServiceName) +
	      $(MAXIMUM_ALLOWED) ServiceKey

	Ifstr(i) $(ServiceKey) != $(KeyNull)
	    ;
	    ; Get the ServiceKey to change the Start value
	    ; or Type value. Or open Parameters key to
	    ; change the hardware parameters if necessary.
	    ;
	    CloseRegKey $(ServiceKey)
	else
	    ;
	    ; Error, cannot open network card key
	    ;
	    goto fatalregistry
	endif
    endif

    goto end
    ;
    ; End of Upgrade Software
    ;

;
;  Escape hatches
;
successful = +
    Debug-Output "At successful"
    goto end

abandon = +
    Debug-Output "At abandon"
    ForListDo $(OEM_ABANDON_OPTIONS)
	Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), $($)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    EndForListDo

    ; remove the inf file here
	; look to see if it can be removed
	Debug-Output "Before call to InfLookup"

;        LoadLibrary "x" $(!STF_NTPATH)\E100NT.DLL MYLIBHANDLE
	LoadLibrary "x" $(!STF_CWDDIR)\E100NT.DLL MYLIBHANDLE
	LibraryProcedure MyResult $(MYLIBHANDLE), SharedInfSearch, $(!STF_HWND), $(!NCPA_HANDLE), $(STF_CONTEXTINFNAME)    
    FreeLibrary $(MYLIBHANDLE)
	Debug-Output "MyResult: $(MyResult)"

	Debug-Output "After call to InfLookup"

	;               
	ifstr(i) $(MyResult) != "FOUND_SOME"
	   ; delete it from the registry
	   set RegInfFileNameKey = "SYSTEM\Setup\InfOptions"
	   OpenRegKey $(!REG_H_LOCAL) "" $(RegInfFileNameKey) $(MAXIMUM_ALLOWED) ProductKey
       Ifstr $(ProductKey) == $(KeyNull)
	  Debug-Output "OEMSETUP.INF: could not open Software product key"          
       endif
       DeleteRegTree $(ProductKey) $(MyResult)
       CloseRegKey $(ProductKey)

	   ; delete it from the disk
       Debug-Output "nuking STF_CONTEXTINFNAME="$(STF_CONTEXTINFNAME)
       LoadLibrary "x" $(!STF_CWDDIR)\setupdll.dll !LIBHANDLE
       LibraryProcedure Status1, $(!LIBHANDLE), DelFile, $(STF_CONTEXTINFNAME)
       FreeLibrary $(!LIBHANDLE)
	endif

    Ifstr(i) $(OEM_ABANDON_SOFTWARE) == TRUE
	; Remove Software Component
	Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), FALSE
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    endif

    goto end

;
; warning display
;
warning = +
    Debug-Output "At 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
;
; non fatal error display
;
nonfatalinfo = +
    Debug-Output "At nonfatalinfo"
    Set Severity = STATUS
    Set CommonStatus = STATUS_USERCANCEL
    goto nonfatalmsg

nonfatal = +
    Debug-Output "At nonfatal"
    Set Severity = NONFATAL
    goto nonfatalmsg

nonfatalmsg = +
    Debug-Output "At 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

;
;  Registry is broken
;
fatalregistry = +
    Debug-Output "At fatalregistry"
    Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif
    set Error = $($R0)
    goto fatal
;
; fatal error display
;
fatal = +
    Debug-Output "At 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

;
;  Shelling error
;
ShellCodeError = +
    Debug-Output "At ShellCodeError"
    set DlgType      = "MessageBox"
    set STF_MB_TITLE = "Error: "$(FunctionTitle)
    set STF_MB_TEXT  = "Shell Code Error"
    set STF_MB_TYPE  = 1
    set STF_MB_ICON  = 3
    set STF_MB_DEF   = 1
    ui start "Error Message"
    goto setfailed

setfailed = +
    Debug-Output "At setfailed"
    set CommonStatus = STATUS_FAILED
    ;
    ; if OEM_ABANDON_ON == TRUE, then remove the registry entries
    ;
    ifstr(i) $(OEM_ABANDON_ON) == TRUE
	set OEM_ABANDON_ON = FALSE
	goto abandon
    endif
    goto end

end = +
    Debug-Output "At end"
    goto term

term = +
    Debug-Output "At term"
    Return $(CommonStatus)


[DebugConfiguration]
    return


;***************************************************************
;  INSTALL SECTIONS
;***************************************************************
[Install-Option]
    Debug-Output "At Install-Option"
    set STF_VITAL = ""

    ifstr(i) $(AddCopy) == "YES"

	Debug-Output "AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers"

	;
	; Add the files to the copy list
	;
	;  BUGBUG: eliminate the "nt2" in the next line when Sunil fixes
	;      the other INF files
	;
	AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
		AddSectionFilesToCopyList Files-AUX $(SrcDir) $(!STF_WINDOWSSYSPATH)

    endif

    ifstr(i) $(DoCopy) == "YES"

       Debug-Output "CopyFilesInCopyList"

       ;
       ; Copy files in the copy list
       ;
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList

    endif

    Exit

[Install-Update]
    Debug-Output "At Install-Update"
   set STF_VITAL        = ""
   set STF_OVERWRITE    = "VERIFYSOURCEOLDER"
   ;set STF_VERSION     = "YES"

   AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
   AddSectionFilesToCopyList Files-Inf $(SrcDir) $(!STF_WINDOWSSYSPATH)

   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   CopyFilesInCopyList

   exit


[IsE100CardAlreadyInstalled]
    read-syms InitBaseVars
    set AlreadyExisted  = "NO"
    set BusNum  = $($0)
    set SlotNum = $($1)
    set Description = $($2)
    set Product = $($3)
    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardKeyName) $(MAXIMUM_ALLOWED) IE_KeyNetcards
    Ifstr $(IE_KeyNetcards) == $(KeyNull)
       set RegistryErrorIndex = UNABLE_OPEN_NETWORKCARD_SECTION
       goto IE_Return
    endif
    EnumRegKey $(IE_KeyNetcards) IE_KeyNameList
    ForListDo  $(IE_KeyNameList)
	set IE_KeyName = *($($),1)
	OpenRegKey $(IE_KeyNetcards) "" $(IE_KeyName) $(MAXIMUM_ALLOWED) IE_Card
	Ifstr $(IE_Card) == $(KeyNull)
	   set RegistryErrorIndex = UNABLE_OPEN_NETWORKCARD_SECTION
	   goto IE_Return
	endif
	GetRegValue $(IE_Card),"Description", DescriptionInfo
	GetRegValue $(IE_Card),"ProductName", ProductNameInfo
	set CardDescription     = *($(DescriptionInfo), 4)
	set CardProductName     = *($(ProductNameInfo), 4)
	ifstr(i) $(CardDescription) == $(Description)
	    ifstr(i) $(CardProductName) == $(Product)
		GetRegValue $(IE_Card), "ServiceName", ServiceNameInfo
		set ServiceName = *($(ServiceNameInfo), 4)
		OpenRegKey $(!REG_H_LOCAL) "" +
		   $(ServicesBaseName)"\"$(ServiceName)"\Parameters" +
		   $(MAXIMUM_ALLOWED) IE_KeyService
		Ifstr $(IE_KeyService) == $(KeyNull)
		   set RegistryErrorIndex = UNABLE_OPEN_NETWORKCARD_SECTION
		   goto IE_Return
		endif
		GetRegValue $(IE_KeyService), "BusNumber", BusInfo
		GetRegValue $(IE_KeyService), "Slot", SlotInfo
		set CardBusNum = *($(BusInfo), 4)
		set CardSlotNum = *($(SlotInfo), 4)
		ifint $(CardBusNum) == $(BusNum)
		    ifint $(CardSlotNum) == $(SlotNum)
			set AlreadyExisted = "YES"
		    endif
		endif
	    endif
	endif
    EndForListDo
IE_Return = +
    return $(RegistryErrorIndex) $(AlreadyExisted)

[InitBaseVars]
KeyNull            = ""
MAXIMUM_ALLOWED    = 33554432
KeyInfo            = {}
RegistryErrorIndex = NO_ERROR
NoTitle            = 0
CurrentControlSet  = "SYSTEM\CurrentControlSet"
ServicesBaseName   = $(CurrentControlSet)"\Services"
NetworkCardKeyName = $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards"
!RegLastError      = NO_ERROR
[RegistryErrorSetup]
RegistryErrorIndex = ^(RegistryErrors$(!STF_LANGUAGE),1)
RegistryErrorList = ^(RegistryErrors$(!STF_LANGUAGE),2)
