/
Nsminit.asm
3608 lines (3466 loc) · 99.8 KB
/
Nsminit.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;*****************************************************************************
;* National Semiconductor Company Confidential *
;* *
;* National Semiconductor *
;* NDIS 2.0.1 MAC device driver *
;* Code for National Semiconductor's CDI driver Initialisation portion. *
;* *
;* Source Name: NSMINIT.ASM *
;* Authors: *
;* Frank DiMambro *
;* *
;* $Log: /home/crabapple/nsclib/tech/ndis2/nsm/vcs/nsminit.asv $ *
;
; Rev 1.15 05/17/00 03:46p IP
; Fixed EMM386 conflict
; Rev 1.4 10/06/95 13:17:38 frd
; No change.
;
; Rev 1.3 10/06/95 13:17:18 frd
;
; Rev 1.0 09/14/95 16:55:58 frd
; Initial revision.
;
; Rev 1.14 26 May 1995 12:29:34 FRD
;
;
; Rev 1.13 26 May 1995 11:48:56 FRD
;
;
; Rev 1.12 17 May 1995 16:54:00 FRD
;
;
; Rev 1.11 17 May 1995 16:50:26 FRD
;
;
; Rev 1.10 17 May 1995 16:35:46 FRD
; Removing Bus type Banner text.
;
; Rev 1.9 17 May 1995 14:35:40 FRD
; Removing the Nms_Delay external declaration
;
; Rev 1.8 01 May 1995 13:52:08 FRD
; Modified include definitions to allow the driver to be
; built in the nsclib directory.
;
; Rev 1.7 26 Apr 1995 09:53:08 FRD
;
;
; Rev 1.6 12 Apr 1995 16:53:50 FRD
;
;
; Rev 1.0 12 Apr 1995 14:08:20 FRD
;
;
; Rev 1.5 12 Apr 1995 13:13:20 FRD
;
;*
;* Rev 1.4 12 Apr 1995 13:11:46 FRD
;*
;* *
;*****************************************************************************
INCLUDE cdi.inc
INCLUDE nsm.inc
INCLUDE hsm.inc
INCLUDE NSMdef.inc
INCLUDE NSMSTDIO.inc
IFDEF OS2
extern OS2_Hdr:FAR16
extern OS2_Global_sel:FAR16
extern Rx_Phys_Store:FAR16
extern DH_Addr:FAR16
extern action:FAR16
extern NICContext:FAR16
extern cc_tbl:FAR16
extern mc_stat:FAR16
extern mc_spec:FAR16
extern pmgrnam:FAR16
extern pmgrhdl:FAR16
extern pmblock:FAR16
extern ddsptbl:FAR16
extern dvrflags:FAR16
extern MediaTypeStore:FAR16
extern NSSNAIStableptr:FAR16
extern NSSNAISIntName:FAR16
extern NSSNAISIntVerMaj:FAR16
extern NSSNAISIntVerMin:FAR16
extern NSSNAISStatBufSz:FAR16
extern TranDataBuf:FAR16
extern TranDataBuf1:FAR16
extern Tx_Immed_Start:FAR16
extern Tx_Immed_Rd:FAR16
extern Tx_Immed_Wr:FAR16
extern Tx_Immed_End:FAR16
extern Tx_Immed_Start_Phys:FAR16
extern NSM_Heap:FAR16
extern dta_end:FAR16
extern _HsmInitContext:NEAR16
extern _HsmFindAdapter:NEAR16
extern _HsmValidateContext:NEAR16
extern _HsmCheckNic:NEAR16
extern NSSNAIS_UpdatStat:NEAR16
extern TTLMsg:FAR16
extern TTLMsgEnd:FAR16
extern Banner:FAR16
extern OS_Banner:FAR16
extern NDIS_VStr:FAR16
extern Dvr_Ver:FAR16
extern New_line:FAR16
extern INSTDvr:FAR16
extern PMEMsg:FAR16
extern PMVEMsg:FAR16
extern PIEMsg:FAR16
extern PICEMsg:FAR16
extern HiMMsg:FAR16
extern PEMsg1:FAR16
extern PEMsgK1:FAR16
extern PEMsgK2:FAR16
extern PEMsgK3:FAR16
extern PEMsgK4:FAR16
extern PEMsgK5:FAR16
extern PEMsgK6:FAR16
extern PEMsgK7:FAR16
extern PEMsgK8:FAR16
extern PEMsgK9:FAR16
extern PEMsgK10:FAR16
extern PEMsgK11:FAR16
extern PEMsgK12:FAR16
extern PEMsgK13:FAR16
extern PEMsgK14:FAR16
extern PEMsgK15:FAR16
extern PEMsgK16:FAR16
extern PEMsgK17:FAR16
extern PEMsgK18:FAR16
extern PEMsgD1:FAR16
extern PEMsgD2:FAR16
extern CfgMsg1:FAR16
extern CfgMsg2:FAR16
extern Std_EMsg:FAR16
extern Std_EMsg1:FAR16
extern CfgWMsg1:FAR16
extern CfgWTotal:FAR16
extern CfgWMsg2:FAR16
extern CfgWGt1:FAR16
extern CfgWMsg3:FAR16
extern GFEMsg:FAR16
extern PCISys:FAR16
extern EISASys:FAR16
extern MCASys:FAR16
extern ISASys:FAR16
extern PnPSys:FAR16
extern SysBad:FAR16
extern EisaDv:FAR16
extern NoEisaDv:FAR16
extern Find_Err:FAR16
extern Find_Err1:FAR16
extern TGMsg:FAR16
;extern CtxHdl_IndicComp:FAR16
;extern CtxHdl_IndicComp2:FAR16
;extern NsmCtxIndicComp:FAR16
;extern NsmCtxIndicComp2:FAR16
_TEXT segment word public use16 'CODE'
assume cs:_TEXT,ds:_DATA
ELSE
extern DOS_Hdr:NEAR16
extern NICContext:NEAR16
extern cc_tbl:NEAR16
extern mc_stat:NEAR16
extern mc_spec:NEAR16
extern pmgrnam:NEAR16
extern pmgrhdl:NEAR16
extern pmblock:NEAR16
extern ddsptbl:NEAR16
extern dvrflags:NEAR16
extern MediaTypeStore:NEAR16
extern NSSNAIStableptr:NEAR16
extern NSSNAISIntName:NEAR16
extern NSSNAISIntVerMaj:NEAR16
extern NSSNAISIntVerMin:NEAR16
extern NSSNAISStatBufSz:NEAR16
extern TranDataBuf:NEAR16
extern TranDataBuf1:NEAR16
extern Tx_Immed_Start:NEAR16
extern Tx_Immed_Rd:NEAR16
extern Tx_Immed_Wr:NEAR16
extern Tx_Immed_End:NEAR16
extern Tx_Immed_Start_Phys:NEAR16
extern NSM_Heap:NEAR16
extern dta_end:NEAR16
extern _HsmInitContext:NEAR16
extern _HsmFindAdapter:NEAR16
extern _HsmValidateContext:NEAR16
extern _HsmCheckNic:NEAR16
extern NSSNAIS_UpdatStat:NEAR16
extern TTLMsg:NEAR16
extern TTLMsgEnd:NEAR16
extern Banner:NEAR16
extern OS_Banner:NEAR16
extern NDIS_VStr:NEAR16
extern Dvr_Ver:NEAR16
extern New_line:NEAR16
extern INSTDvr:NEAR16
extern PMEMsg:NEAR16
extern PMVEMsg:NEAR16
extern PIEMsg:NEAR16
extern PICEMsg:NEAR16
extern HiMMsg:NEAR16
extern PEMsg1:NEAR16
extern PEMsgK1:NEAR16
extern PEMsgK2:NEAR16
extern PEMsgK3:NEAR16
extern PEMsgK4:NEAR16
extern PEMsgK5:NEAR16
extern PEMsgK6:NEAR16
extern PEMsgK7:NEAR16
extern PEMsgK8:NEAR16
extern PEMsgK9:NEAR16
extern PEMsgK10:NEAR16
extern PEMsgK11:NEAR16
extern PEMsgK12:NEAR16
extern PEMsgK13:NEAR16
extern PEMsgK14:NEAR16
extern PEMsgK15:NEAR16
extern PEMsgK16:NEAR16
extern PEMsgK17:NEAR16
extern PEMsgK18:NEAR16
extern PEMsgD1:NEAR16
extern PEMsgD2:NEAR16
extern CfgMsg1:NEAR16
extern CfgMsg2:NEAR16
extern Std_EMsg:NEAR16
extern Std_EMsg1:NEAR16
extern CfgWMsg1:NEAR16
extern CfgWTotal:NEAR16
extern CfgWMsg2:NEAR16
extern CfgWGt1:NEAR16
extern CfgWMsg3:NEAR16
extern GFEMsg:NEAR16
extern PCISys:NEAR16
extern EISASys:NEAR16
extern MCASys:NEAR16
extern ISASys:NEAR16
extern PnPSys:NEAR16
extern SysBad:NEAR16
extern EisaDv:NEAR16
extern NoEisaDv:NEAR16
extern Find_Err:NEAR16
extern Find_Err1:NEAR16
extern TGMsg:NEAR16
_TEXT segment dword public use16 'CODE' ;DOS Driver contained in one segment.
assume cs:_TEXT,ds:_TEXT
ENDIF
;
;****** Driver Initialization ******
;
;*****************************************************************************
;
; "Driver Initialization Routine"
;
; This routine is called from the Strategy routine when an INIT packet
; is received. At entry, ES:BX points to the INIT packet. The protocol
; managers configuration data is accessed and used to configure the
; driver. The driver is then "registered" with the protocol manager.
; For OS/2, this code is then "dismissed" from memory. For DOS,
; this code then becomes part of the output queue or input area.
;
;*****************************************************************************
PUBLIC DRInit
DRInit:
IFNDEF OS2
cli ;Disable CPU interrupts.
mov cs:SaveSP,sp ;Switch to auxiliary stack.
mov cs:SaveSS,ss
push cs
pop ss
mov sp,offset StakTop
sti ;Re-enable CPU interrupts.
push ax ;Save remaining regs.
push cx
push dx
push si
push di
push ds
ENDIF
push bp ;Save BP-reg.
sub sp,4 ;Reserve 2 words on stack.
mov bp,sp ;Point to reserved words.
mov [bp],bx ;Save packet address on stack.
mov [bp+2],es
IFDEF OS2
; int 3 ; << debug >>
mov ax,es:word ptr[bx].SRqPkt.Dev_hlp_off
mov dx,es:word ptr[bx].SRqPkt.Dev_hlp_seg
mov word ptr DH_Addr.farptr.ofs,ax
mov word ptr DH_Addr.farptr.sgm,dx
IFNDEF OS2
les bx,[bp] ;Reload INIT packet ptr.
mov word ptr dta_end,es:[bx].SRqPkt.Mem_end_seg
ENDIF
mov al,SYS_INFOSEG
mov dl,DH_GETDOSVAR
call dword ptr DH_Addr
mov es,ax
mov ax,es:[bx]
mov word ptr OS2_Global_sel,ax
mov ax,ds
ELSE
mov ax,cs
mov ds,ax
ENDIF
mov es,ax ; Call HsmInitContext
mov ax,offset NICContext
push ax
call _HsmInitContext
add sp,2
call NSMInitContext
mov di,offset Banner ;Display "title" message.
call PutCSt
mov di,offset OS_Banner ;Display "title" message.
call PutCSt
mov cx,sizeof cctable.cc_name
mov di,offset cc_tbl.cctable.cc_name
;open our current name
Hsm_NxtLtr:
mov al,[di]
cmp al,0
je Hsm_NxtLtr2
mov [di],al
inc di
loopw Hsm_NxtLtr
Nsm_NxtLtr2:
cmp cx,0
jne Nsm_NxtLtrX
Hsm_NxtLtr2:
mov al,'$'
mov [di],al
Nsm_NxtLtrX:
stc
mov ax,kwordsAllowed.dblword.lw
rcl ax,1
mov Board1.ExpectedKeys.dblword.lw,ax
mov Board1.OptionalKeys.dblword.lw,ax
mov ax,kwordsAllowed.dblword.hw
rcl ax,1
mov Board1.ExpectedKeys.dblword.hw,ax
mov Board1.OptionalKeys.dblword.hw,ax
mov cx,MAXDVRINST
IFDEF OS2
Trynewname:
push cx
push ds ;Stack parameters to "open" our driver.
push offset cc_tbl.cctable.cc_name ;open our current name
push ds
push offset pmgrhdl
push ds
push offset action
push 0
push 0 ; file size (long)
push 0 ; file attribute
push 1 ; open flag: file must exist
push SHARED_RW ; open mode (share R/W private)
push 0
push 0 ; 0L reserved
call DOSOPEN
test ax,ax ;Any errors?
jnz Name_ok ;Current name ok
inc DriverInst
push word ptr pmgrhdl
;Open was a success so must close
call DOSCLOSE ;the open file and change driver name.
ELSE
Trynewname:
push cx
mov ah,OPEN_FILE ;Open our driver.
mov al,SHARED_RW
mov dx,offset cc_tbl.cctable.cc_name
push cs ;Save CS-reg.
int 021h ;Do desired DOS function.
pop ds ;Reload DS-reg.
jc Name_ok
inc DriverInst
mov bx,ax ;handle was returned in ax.
mov ah,CLOSE_FILE ;Open was a success so must close
;then open file and change driver name.
push cs ;Save CS-reg.
int 021h ;Do desired DOS function.
pop ds ;Reload DS-reg.
ENDIF
mov ax,ds
mov es,ax
mov cx,(sizeof cctable.cc_name)+3
mov al,0h
mov di,offset cc_tbl.cctable.cc_name
repne scasb
sub di,3
NoSet_Two:
cmp [di].dblbyte.lb,'0'
jb Set_Two
cmp [di].dblbyte.lb,'9'
ja Set_Two
inc [di].dblbyte.lb ;Change the 2nd last character.
jmp Next_Try
Set_Two:
mov al,[di+1].dblbyte.lb
mov [di+2].dblbyte.lb,al
mov [di+1].dblbyte.lb,'1'
Next_Try:
pop cx
loopw Trynewname
TooManyDvrs:
mov di,offset INSTDvr
call PutCSt
jmp I_Fail
Name_ok:
mov al,byte ptr DriverInst
cmp al,0
je Name_ok1
and Board1.OptionalKeys,not mask PnPSerial_Fnd
Name_ok1:
pop cx
mov si, offset cc_tbl.cctable.cc_name
IFDEF OS2
mov di, offset OS2_Hdr.header.Hdr_Nam
ELSE
mov di, offset DOS_Hdr.header.Hdr_Nam
ENDIF
mov cx, 8
mov al,0
Next_DrvLtr:
mov ah,[si].dblbyte.lb
inc si
cmp al,ah
je Pad_Space
mov [di].dblbyte.lb,ah
inc di
loopw Next_DrvLtr
jmp Hardware_Srh
Pad_Space:
mov [di].dblbyte.lb,20h
inc di
loopw Next_DrvLtr
Hardware_Srh:
mov si, offset cc_tbl.cctable.cc_name
mov di, offset Hsm_Short_Name
; mov di, offset NICContext.HsmContext.DriverName
mov cx, (sizeof cctable.cc_name)+2
rep movsb
mov di,offset NICContext.HsmContext.pnpId
mov cx,4
Try_OEM_PnPId:
mov ax,[di].dblword.hw
mov Board1.DeviceID.dblword.hw,ax
mov ax,[di].dblword.lw
mov Board1.DeviceID.dblword.lw,ax
push di
push cx
call NsmFindHardware
pop cx
pop di
cmp byte ptr Board1.Cards_Presnt,0
jne Open_Protman
dec cx
jcxz Open_Protman
add di,4
jmp Try_OEM_PnPId
Open_Protman:
IFDEF OS2
push ds ;Stack parameters for protocol-manager "open".
push offset pmgrnam
push ds
push offset pmgrhdl
push ds
push offset action
push 0
push 0 ; file size (long)
push 0 ; file attribute
push 1 ; open flag: file must exist
push SHARED_RW ; open mode (share R/W private)
push 0
push 0 ; 0L reserved
call DOSOPEN
test ax,ax ;Any errors?
jz I_opprot ;Yes, sayonara!
mov di,offset PMEMsg
call PutCSt
jmp I_Fail
I_opprot:
mov pmblock.pm_req_block.pm_op,GET_PM_INFO
push 0 ;Request protocol-manager data.
push 0
push ds
push offset pmblock
push IONC_PM
push IOC_NC
push word ptr pmgrhdl
call DOSDEVIOCTL
test ax,ax ;Any I/O errors?
jz I_gtprot
mov di,offset PIEMsg
call PutCSt
jmp I_Fail
I_gtprot:
ELSE
mov ah,OPEN_FILE ;Open protocol-manager file.
mov al,SHARED_RW
mov dx,offset pmgrnam
push cs ;Save CS-reg.
int 021h ;Do desired DOS function.
pop ds ;Reload DS-reg.
jnc I_opprot ;Error -- sayonara!
mov di,offset PMEMsg
call PutCSt
jmp I_Fail
I_opprot:
mov word ptr pmgrhdl,ax ;Save file "handle".
mov pmblock.pm_req_block.pm_op,GET_PM_INFO
;Request protocol-manager data.
mov bx,word ptr pmgrhdl
mov cx,PMSIZE
mov dx,offset pmblock
mov ah,IOCTL
mov al,RXCTRLDATA
push cs ;Save CS-reg.
int 021h ;Do desired DOS function.
pop ds ;Reload DS-reg.
jnc I_gtprot
mov di,offset PIEMsg
call PutCSt
jmp I_Fail
I_gtprot:
ENDIF
mov ax,word ptr pmblock.pm_req_block.pm_stat
;Get protocol-manager return code.
test ax,ax ;Any errors with protocol.ini information?
jz I_ckprotv ;Yes, treat as initialization failure!
mov di,offset PICEMsg
call PutCSt
jmp I_Fail
I_ckprotv:
cmp pmblock.pm_req_block.pm_w1,PM_VEXP
;Correct version of protocol manager?
jae I_pmvok ;No, treat as initialization failure!
mov di,offset PMVEMsg
call PutCSt
jmp I_Fail
I_pmvok:
les bx,dword ptr pmblock.pm_req_block.pm_ptr1
;Point to configuration-image data.
call Parse ;"Parse" the data.
test ax,ax ;Any errors?
jz I_SetS ;No, set up segment values.
I_Err: jmp I_Fail ;Error -- treat as initialization failure!
I_SetS:
mov di,offset Board1
mov bl,[di].BoardType.Cards_Presnt
cmp bl,0
je HSMFindCard
mov bh,0
; SLOT start is 0, default value is also 0. check always slot.
IFNDEF NECWARP
mov al,byte ptr NICContext.HsmContext.Slot
or al,al
jnz Check_Slot
jmp Check_Serial
ENDIF
Check_Slot:
dec bx
push bx
mov al,byte ptr NICContext.HsmContext.Slot
cmp al,[di+bx].BoardType.slot
je Adapter_Found
pop bx
cmp bx,0
jne Check_Slot
; Skip other check. use PCI Slot only.
IFNDEF NECWARP
Check_Serial:
mov bl,[di].BoardType.Cards_Presnt
mov bh,0
mov ax,word ptr NICContext.HsmContext.uniqueId.dblword.hw
or ax,word ptr NICContext.HsmContext.uniqueId.dblword.lw
jnz Check_Next
dec bx
push bx
jmp Adapter_Found
Check_Next:
dec bx
push bx
shl bx,2
mov ax,NICContext.HsmContext.uniqueId.dblword.hw
cmp ax,[di+bx].BoardType.SerialID.dblword.hw
jne Check_Next1
mov ax,NICContext.HsmContext.uniqueId.dblword.lw
cmp ax,[di+bx].BoardType.SerialID.dblword.lw
je Adapter_Found
Check_Next1:
pop bx
cmp bx,0
jne Check_Next
ENDIF
jmp NoAdapter_Fail
Adapter_Found:
pop bx
mov al,[di+bx].BoardType.IntLines
mov NICContext.HsmContext.Irq.dblbyte.lb,al
shl bx,2
mov ax,[di+bx].BoardType.Cards_IOAddr.dblword.lw
mov NICContext.HsmContext.IOaddr.dblword.lw,ax
mov ax,[di+bx].BoardType.memaddrs.dblword.hw
mov NICContext.HsmContext.MEMaddr.dblword.hw,ax
mov ax,[di+bx].BoardType.memaddrs.dblword.lw
mov NICContext.HsmContext.MEMaddr.dblword.lw,ax
jmp I_SetS1
HSMFindCard:
mov ax,word ptr PnPEntry.farptr.sgm
or ax,word ptr PnPEntry.farptr.ofs
jz HSMFindCard1
mov di,offset Find_Err1
call PutCSt
jmp I_Fail
HSMFindCard1:
cli
mov ax,offset NICContext
push ax
call _HsmFindAdapter ; Do Heristic method of finding an
add sp,2 ; adapter.
sti
cmp ax,HsmOK ;Any errors?
je I_SetS1 ;No, set up segment values.
cmp ax,HsmMultipleHsmsFound
jne I_FindFail
mov di,offset Find_Err
call PutCSt
I_FindFail:
jmp I_Fail
I_SetS1:
IFNDEF OS2
mov ah,DOSVERGET ;Get DOS version number.
push cs ;Save CS-reg.
int 021h ;Do desired DOS function.
pop ds ;Reload DS-reg.
cmp al,5 ;Are we running under DOS V5.0 or better?
jb I_HardC ;No, skip high-memory checks (can't load high).
mov ax,offset dvr_end ;Get ending driver offset.
add ax,15 ;"Round" ending offset up to a page boundary.
shr ax,4 ;Get number of driver "pages".
mov cx,cs ;Get ending driver "page" address.
add ax,cx
cmp ax,word ptr dta_end
;Can this driver fit in hi-memory?
jbe I_HardC ;Yes, go check Hardware.
mov di,offset HiMMsg ;Display "Not enough high memory" message.
call PutCSt
jmp I_Fail ;Go display "Initialization failure" & exit.
I_HardC:
ENDIF
mov ax,offset NICContext
push ax
call _HsmCheckNic
add sp,2
cmp ax,HsmOK ;Any errors?
jz I_Hardok ;Error -- treat as initialization failure!
cmp ax,HsmNotFound
jne I_NoHard
NoAdapter_Fail:
mov di,offset Std_EMsg
call PutCSt
mov di, offset Hsm_Short_Name
; mov di,offset NICContext.HsmContext.DriverName
call PutCSt
mov di,offset Std_EMsg1 + 2
call PutCSt
I_NoHard:
jmp I_Fail ;Go display "Initialization failure" & exit.
I_Hardok:
mov di,offset CfgMsg1
call PutCSt
mov di, offset Hsm_Short_Name
; mov di,offset NICContext.HsmContext.DriverName
call PutCSt
mov di,offset CfgMsg2
call PutCSt
IFDEF OS2
; mov ax,ds:header.Hdr_PCS ;OS/2 -- get CS- and DS-selector values.
; mov bx,ds:header.Hdr_PDS
mov ax,cs ;Prot/Real selectors in header
mov bx,ds ; are now not used(reserved).
and ax,-4 ;ring3 -> ring0 selector
ELSE
mov ax,cs ;DOS -- get CS- and DS-reg. values.
mov bx,ds
ENDIF
mov cc_tbl.cctable.cc_ds,bx ;Initialize common-mode characteristics table.
mov cc_tbl.cctable.cc_spec.farptr.sgm,bx
mov cc_tbl.cctable.cc_stat.farptr.sgm,bx
mov cc_tbl.cctable.cc_udsp.farptr.sgm,bx
mov cc_tbl.cctable.cc_sys.farptr.sgm,ax
;Initialize our "dispatch" table.
mov ddsptbl.dd_sptbl.dd_ctbl.farptr.sgm,bx
mov ddsptbl.dd_sptbl.dd_req.farptr.sgm,ax
mov ddsptbl.dd_sptbl.dd_tx.farptr.sgm,ax
mov ddsptbl.dd_sptbl.dd_rx.farptr.sgm,ax
mov ddsptbl.dd_sptbl.dd_rrel.farptr.sgm,ax
mov ddsptbl.dd_sptbl.dd_ion.farptr.sgm,ax
mov ddsptbl.dd_sptbl.dd_ioff.farptr.sgm,ax
;Initialize MAC characteristics table.
mov mc_spec.specific.mc_list.farptr.sgm,bx
mov mc_spec.specific.mc_idno.farptr.sgm,bx
or mc_spec.specific.mc_flg2,mask Receive_type ; RXCHAIN
;Initialize MAC status table.
mov mc_stat.status.ms_sptr.farptr.sgm,bx
mov pmblock.pm_req_block.pm_op,REGISTER_MODULE ;Set up "register module" parameters.
mov pmblock.pm_req_block.pm_ptr2.farptr.ofs,0
mov pmblock.pm_req_block.pm_ptr2.farptr.sgm,0
mov pmblock.pm_req_block.pm_ptr1.farptr.ofs,offset cc_tbl
mov pmblock.pm_req_block.pm_ptr1.farptr.sgm,bx
mov NSSNAIStableptr.farptr.sgm,bx
mov ax,word ptr NICContext.HsmContext.txQSize
mov word ptr mc_spec.specific.mc_txdth,ax
mov cx,PKTMAX
mov word ptr mc_spec.specific.mc_1buftx,cx
mul cx
mov word ptr mc_spec.specific.mc_tottx,ax
mov ax,word ptr NICContext.HsmContext.rxQSize
mul cx
mov word ptr mc_spec.specific.mc_rxbf,ax
IFDEF OS2
push 0 ;OS/2 -- set up "register module" call.
push 0
push ds
push offset pmblock
push IONC_PM
push IOC_NC
push word ptr pmgrhdl
call DOSDEVIOCTL
test ax,ax ;Any I/O errors?
jnz I_RErr ;Yes, treat as initialization failure!
mov ax,word ptr pmblock.pm_req_block.pm_stat
;Get protocol-manager status.
test ax,ax ;Any errors?
jz I_IRQ0 ;No, close protocol manager.
I_RErr: jmp I_Err ;Treat as initialization failure & exit!
I_IRQ0: push ds ;Save DS-reg.
push word ptr pmgrhdl
;Close the protocol manager.
call DOSCLOSE
pop ds ;Reload DS-reg.
I_temp:
ELSE
I_temp: mov bx,word ptr pmgrhdl
;DOS -- set up "register module" call.
mov cx,PMSIZE
mov dx,offset pmblock
mov ah,IOCTL
mov al,RXCTRLDATA
push cs ;Save CS-reg.
int 021h ;Do desired DOS function.
pop ds ;Reload DS-reg.
jnc I_IRQ0 ;Any "register-module" errors?
jmp I_Err ;Yes?? Treat as initialization failure!!
I_IRQ0: mov bx,word ptr pmgrhdl
;Close the protocol-manager.
mov ah,CLOSE_FILE
push cs ;Save CS-reg.
int 021h ;Do desired DOS function.
pop ds ;Reload DS-reg.
ENDIF
les bx,[bp] ;Reload INIT packet ptr.
mov ax,offset DRInit
add ax,3
and ax,not 3
IFNDEF OS2
mov word ptr NSM_Heap,ax
ELSE
mov es:[bx].SRqPkt.Code_end_off,ax
ENDIF ;Set code limit.
push bx
mov ax,offset NICContext
push ax
call _HsmValidateContext
add sp,2
pop bx
cmp ax,HsmOK ;Any errors?
je I_SetS2 ;No, set up segment values.
jmp I_Fail
I_SetS2:
; mov cx,word ptr NSM_Heap
; mov word ptr Tx_Immed_Start,cx
; mov word ptr Tx_Immed_Rd,cx
; mov word ptr Tx_Immed_Wr,cx
IFNDEF OS2
mov ax,MXIMMED
ELSE
mov ax,MXIMMED+16+2
ENDIF
mul byte ptr NICContext.HsmContext.txQSize
; add cx,ax
; mov word ptr Tx_Immed_End,cx
; mov word ptr NSM_Heap,cx
push es
push bx
push ax
push ds
push offset Tx_Immed_Start_Phys
push ax
push offset NICContext
call _NsmMallocPhys
add sp,4*2
pop cx
pop bx
pop es
mov word ptr Tx_Immed_Start,ax
mov word ptr Tx_Immed_Wr,ax
add cx,ax
or ax,dx
jz short I_Fail
mov ax,ds
xor ax,dx
jnz short I_Fail
mov word ptr Tx_Immed_End,cx
IFNDEF OS2
mov es:[bx].SRqPkt.Free_mem_seg,cs
;Set segment of beginning of free memory.
mov cx,word ptr NSM_Heap
mov es:[bx].SRqPkt.Free_mem_off,cx
mov word ptr NICContext.HsmContext.DriverSize.dblword.lw,cx
mov word ptr NICContext.HsmContext.DriverSize.dblword.hw,0
or word ptr dvrflags,mask Init_comp
I_Exit: mov es:[bx].SRqPkt.No_of_units,0
;Exit -- set character-device values.
cli ;Disable CPU interrupts & post "done" status.
mov es:[bx].SRqPkt.SRqStat,mask done
;(So memory isn't dismissed until exit).
add sp,4 ;Unreserve 2 words on stack.
pop bp ;Reload working regs.
pop ds
pop di
pop si
pop dx
pop cx
pop ax
mov ss,cs:SaveSS ;Reset caller's stack.
mov sp,cs:SaveSP
pop bx ;Reload remaining regs.
pop es
popf
ELSE
mov cx,word ptr NSM_Heap
mov es:[bx].SRqPkt.Data_end_off,cx
push es ; Set data limit.
mov ax,ds
mov es,ax
IF 0 ; Tx_Immed PhysToGDT is not used for this case:DP83815.
IF NOT NSM_DOUBLE_BUFFER EQ 1
test word ptr NICContext.HsmContext.hsmOptions,NEED_TX_PHYSADDRS
jnz short I_SelSetup1
ENDIF
mov cx,0
mov cl,byte ptr NICContext.HsmContext.txQSize
mov di,word ptr Tx_Immed_Wr
I_SelSetup:
add di,MXIMMED+2
push cx
mov cx,8
mov dl,DH_ALLOCGDT
call dword ptr DH_Addr
pop cx
add di,16
loopw I_SelSetup
ENDIF
I_SelSetup1:
mov di,offset Rx_Phys_Store+2
mov cx,8
mov dl,DH_ALLOCGDT
call dword ptr DH_Addr
pop es
I_CtxHook:
IF 0
push bx
mov eax,offset NsmCtxIndicComp
mov ebx,-1
mov dl,DH_ALLOCCTXHOOK
call dword ptr [DH_Addr]
pop bx
jc short I_Fail
mov dword ptr [CtxHdl_IndicComp],eax
push bx
mov eax,offset NsmCtxIndicComp2
mov ebx,-1
mov dl,DH_ALLOCCTXHOOK
call dword ptr [DH_Addr]
pop bx
jc short I_Fail
mov dword ptr [CtxHdl_IndicComp2],eax
ENDIF
or word ptr dvrflags,mask Init_comp
I_Exit:
mov es:[bx].SRqPkt.No_of_units,0
;Exit -- set character-device values.
mov es:[bx].SRqPkt.Bpb_array_off,0
mov es:[bx].SRqPkt.Bpb_array_seg,0
add sp,4 ;Unreserve 2 words on stack.
pop bp ;Reload BP-reg.
pushf ;Save CPU flags & disable CPU interrupts.
cli ;(So memory isn't "dismissed" until we exit).
mov es:[bx].SRqPkt.SRqStat,mask done
;Post "done" packet status.
popf ;Reload CPU flags.
ENDIF
retf ;Exit.
;
; Initialization FAILURE! Display message & set up "error" return.
;
I_Fail:
mov di,offset GFEMsg ;Display "failure to init" msg.
call PutCSt
les bx,[bp] ;Get INIT packet pointer.
IFNDEF OS2
mov DOS_Hdr.header.Dev_Att,0 ;DOS -- clear character flag.
mov word ptr DOS_Hdr.header.Hdr_Nam,02020h
;"Blank" device name.
ENDIF
mov es:word ptr[bx].SRqPkt.Code_end_off,0
;OS/2 -- install nothing.
mov es:word ptr[bx].SRqPkt.Data_end_off,0
jmp short I_Exit ;Go take error return.
;----------------------------------------------------------------------------
;****************************************************************************
;
; "NSMInitContext"
;
; This subroutine looks at the HSMContext and as much as possible sets up
; the NDIS tables.
;
;****************************************************************************
NSMInitContext:
mov word ptr NICContext.HsmContext.DriverIFType,IF_TYPE_NDIS
mov cx,3
mov si,offset NDIS_VStr
mov di,offset NICContext.HsmContext.DriverIFTypeSpec
push es
mov ax,ds
mov es,ax
rep movsw
pop es
mov word ptr NICContext.HsmContext.sendRetries,0
test NICContext.HsmContext.hsmOptions,DOES_RX_MULTICOPIES
jz NSMInitContext1
or mc_spec.specific.mc_flg2,mask Multiple_tranferdatas
NSMInitContext1:
test NICContext.HsmContext.hsmOptions,NEED_TX_PHYSADDRS
jz NSMInitContext2
and mc_spec.specific.mc_flg2,not mask Gdt_virt_addr_supported
NSMInitContext2:
mov si,offset TTLMsg+2
mov di,offset NICContext.HsmContext.DriverName
mov cx,offset TTLMsgEnd
sub cx,offset TTLMsg+1
rep movsb
mov byte ptr [di],'v'
inc di
mov si,offset Dvr_Ver
mov cx,4
rep movsb
mov si,offset NSSNAISIntName
mov di,offset NICContext.HsmContext.Interfacename
mov cx,8
rep movsb ; Copy SNMP Interface name to NIC
; Context.
mov al,byte ptr NSSNAISIntVerMaj
mov byte ptr NICContext.HsmContext.StatBufMajVer,al
mov al,byte ptr NSSNAISIntVerMin
mov byte ptr NICContext.HsmContext.StatBufMinVer,al
mov ax,word ptr NSSNAISStatBufSz
mov word ptr NICContext.HsmContext.StatBufSize,ax
mov word ptr NICContext.HsmContext.OffsetUpdStats,offset NSSNAIS_UpdatStat
mov word ptr NICContext.HsmContext.SegmentUpdStats,cs
mov ax,word ptr Dvr_Ver.dblword.hw
mov word ptr NICContext.HsmContext.DriverVersion.dblword.hw,ax
mov ax,word ptr Dvr_Ver.dblword.lw
mov word ptr NICContext.HsmContext.DriverVersion.dblword.lw,ax
mov ax,HSM_MEDIA_10BASETfx or HSM_MEDIA_100BASEXfx
test ax,word ptr NICContext.HsmContext.mediaTypes
jz NSMInitContext3