]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - msdos/ndis_0.asm
Apply vendor revision 470df104c6f55f6d6f390df7448d8eb65c7642b9:
[FreeBSD/FreeBSD.git] / msdos / ndis_0.asm
1 PAGE 60,132
2 NAME NDIS_0
3
4 ifdef 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
25 else
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
43 endif
44
45 ;-------------------------------------------
46
47 D_SEG
48
49 D_END
50
51
52 _TEXT SEGMENT
53
54 EXTRN _NdisSystemRequest      : near
55 EXTRN _NdisRequestConfirm     : near
56 EXTRN _NdisTransmitConfirm    : near
57 EXTRN _NdisReceiveLookahead   : near
58 EXTRN _NdisIndicationComplete : near
59 EXTRN _NdisReceiveChain       : near
60 EXTRN _NdisStatusProc         : near
61 EXTRN _NdisAllocStack         : near
62 EXTRN _NdisFreeStack          : near
63
64 ;
65 ; *ALL* interrupt threads come through this macro.
66 ;
67 CALLBACK 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
121 endm
122
123 ;
124 ; Define all of the callbacks for the NDIS procs.
125 ;
126
127 PUBPROC systemRequestGlue
128 CALLBACK _NdisSystemRequest,14
129 RETF
130
131 PUBPROC requestConfirmGlue
132 CALLBACK _NdisRequestConfirm,12
133 RETF
134
135 PUBPROC transmitConfirmGlue
136 CALLBACK _NdisTransmitConfirm,10
137 RETF
138
139 PUBPROC receiveLookaheadGlue
140 CALLBACK _NdisReceiveLookahead,16
141 RETF
142
143 PUBPROC indicationCompleteGlue
144 CALLBACK _NdisIndicationComplete,4
145 RETF
146
147 PUBPROC receiveChainGlue
148 CALLBACK _NdisReceiveChain,16
149 RETF
150
151 PUBPROC statusGlue
152 CALLBACK _NdisStatusProc,12
153 RETF
154
155 ;
156 ; int FAR NdisGetLinkage (int handle, char *data, int size);
157 ;
158
159 ifdef 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
172 else
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
184 endif
185
186 ENDS
187
188 END