1PAGE 60,132 2NAME NDIS_0 3 4ifdef DOSX 5 .386 6 _TEXT SEGMENT PUBLIC DWORD USE16 'CODE' 7 _TEXT ENDS 8 _DATA SEGMENT PUBLIC DWORD USE16 'CODE' 9 _DATA ENDS 10 _TEXT32 SEGMENT PUBLIC BYTE USE32 'CODE' 11 _TEXT32 ENDS 12 CB_DSEG EQU <CS> ; DOSX is tiny-model 13 D_SEG EQU <_TEXT SEGMENT> 14 D_END EQU <_TEXT ENDS> 15 ASSUME CS:_TEXT,DS:_TEXT 16 17 PUSHREGS equ <pushad> 18 POPREGS equ <popad> 19 20 PUBPROC macro name 21 align 4 22 public @&name 23 @&name label near 24 endm 25else 26 .286 27 _TEXT SEGMENT PUBLIC DWORD 'CODE' 28 _TEXT ENDS 29 _DATA SEGMENT PUBLIC DWORD 'DATA' 30 _DATA ENDS 31 CB_DSEG EQU <SEG _DATA> ; 16bit is small/large model 32 D_SEG EQU <_DATA SEGMENT> 33 D_END EQU <_DATA ENDS> 34 ASSUME CS:_TEXT,DS:_DATA 35 36 PUSHREGS equ <pusha> 37 POPREGS equ <popa> 38 39 PUBPROC macro name 40 public _&name 41 _&name label far 42 endm 43endif 44 45;------------------------------------------- 46 47D_SEG 48 49D_END 50 51 52_TEXT SEGMENT 53 54EXTRN _NdisSystemRequest : near 55EXTRN _NdisRequestConfirm : near 56EXTRN _NdisTransmitConfirm : near 57EXTRN _NdisReceiveLookahead : near 58EXTRN _NdisIndicationComplete : near 59EXTRN _NdisReceiveChain : near 60EXTRN _NdisStatusProc : near 61EXTRN _NdisAllocStack : near 62EXTRN _NdisFreeStack : near 63 64; 65; *ALL* interrupt threads come through this macro. 66; 67CALLBACK macro callbackProc, argsSize 68 69 pushf 70 PUSHREGS ;; Save the registers 71 72 push es 73 push ds 74 mov ax,CB_DSEG ;; Load DS 75 mov ds,ax 76 call _NdisAllocStack ;; Get and install a stack. 77 78 mov bx,ss ;; Save off the old stack in other regs 79 mov cx,sp 80 mov ss,dx ;; Install the new one 81 mov sp,ax 82 push bx ;; Save the old one on to the new stack 83 push cx 84 sub sp,&argsSize ;; Allocate space for arguments on the stack 85 86 mov ax,ss ;; Set up the destination for the move 87 mov es,ax 88 mov di,sp 89 mov ds,bx ;; Set up the source for the move. 90 mov si,cx 91 add si,4+6+32 92 93 mov cx,&argsSize ;; Move the arguments to the stack. 94 shr cx,1 95 cld 96 rep movsw 97 98 mov ax,CB_DSEG ;; Set my data segment again. 99 mov ds,ax 100 101 call &callbackProc ;; Call the real callback. 102 pop di ;; Pop off the old stack 103 pop si 104 mov bx,ss ;; Save off the current allocated stack. 105 mov cx,sp 106 mov ss,si ;; Restore the old stack 107 mov sp,di 108 push ax ;; Save the return code 109 push bx ;; Free the stack. Push the pointer to it 110 push cx 111 call _NdisFreeStack 112 add sp,4 113 pop ax ;; Get the return code back 114 add di,32 ;; Get a pointer to ax on the stack 115 mov word ptr ss:[di],ax 116 pop ds 117 pop es 118 119 POPREGS 120 popf 121endm 122 123; 124; Define all of the callbacks for the NDIS procs. 125; 126 127PUBPROC systemRequestGlue 128CALLBACK _NdisSystemRequest,14 129RETF 130 131PUBPROC requestConfirmGlue 132CALLBACK _NdisRequestConfirm,12 133RETF 134 135PUBPROC transmitConfirmGlue 136CALLBACK _NdisTransmitConfirm,10 137RETF 138 139PUBPROC receiveLookaheadGlue 140CALLBACK _NdisReceiveLookahead,16 141RETF 142 143PUBPROC indicationCompleteGlue 144CALLBACK _NdisIndicationComplete,4 145RETF 146 147PUBPROC receiveChainGlue 148CALLBACK _NdisReceiveChain,16 149RETF 150 151PUBPROC statusGlue 152CALLBACK _NdisStatusProc,12 153RETF 154 155; 156; int FAR NdisGetLinkage (int handle, char *data, int size); 157; 158 159ifdef DOSX 160 PUBPROC NdisGetLinkage 161 push ebx 162 mov ebx, [esp+8] ; device handle 163 mov eax, 4402h ; IOCTRL read function 164 mov edx, [esp+12] ; DS:EDX -> result data 165 mov ecx, [esp+16] ; ECX = length 166 int 21h 167 pop ebx 168 jc @fail 169 xor eax, eax 170 @fail: ret 171 172else 173 PUBPROC NdisGetLinkage 174 enter 0, 0 175 mov bx, [bp+6] 176 mov ax, 4402h 177 mov dx, [bp+8] 178 mov cx, [bp+12] 179 int 21h 180 jc @fail 181 xor ax, ax 182 @fail: leave 183 retf 184endif 185 186ENDS 187 188END 189