source: trunk/src/win32k/dev32/devfirst.asm@ 6218

Last change on this file since 6218 was 6218, checked in by bird, 24 years ago

Added thunks for open and close calls.

File size: 8.9 KB
Line 
1; $Id: devfirst.asm,v 1.8 2001-07-08 02:55:25 bird Exp $
2;
3; DevFirst - entrypoint and segment definitions
4;
5; Copyright (c) 1999 knut st. osmundsen
6;
7; Project Odin Software License can be found in LICENSE.TXT
8;
9 .386p
10
11;
12; Include files
13;
14 include devsegdf.inc
15 include sas.inc
16
17;
18; Exported symbols
19;
20 public CODE16START
21 public CODE16_INITSTART
22 public DATA16START
23 public DATA16START
24 public DATA16_BSSSTART
25 public DATA16_CONSTSTART
26 public DATA16_INITSTART
27 public CODE16START
28 public CODE32START
29 public DATA32START
30 public BSS32START
31 public CONST32_ROSTART
32 public _VFTSTART
33 public EH_DATASTART
34
35
36 public _strategyAsm0
37 public _strategyAsm1
38 public _CallGetKernelInfo32
39 public _CallElfIOCtl
40 public _CallWin32kIOCtl
41 public _CallWin32kOpen
42 public _CallWin32kClose
43 public _SSToDS_16a
44 public GetOS2KrnlMTE
45 public x86DisableWriteProtect
46 public x86RestoreWriteProtect
47
48
49;
50; Externs
51;
52 extrn _TKSSBase16:dword
53 extrn GETKERNELINFO32:FAR
54 extrn ELFIOCTL:FAR
55 extrn WIN32KIOCTL:FAR
56 extrn WIN32KOPEN:FAR
57 extrn WIN32KCLOSE:FAR
58 .286p
59 extrn _strategy:near
60
61
62CODE16 segment
63 ASSUME CS:CODE16, DS:DATA16, ES:NOTHING, SS:NOTHING
64
65CODE16START label byte
66
67 .286p
68;$win32ki entry point
69_strategyAsm0:
70; int 3
71 push 0
72 jmp _strategyAsm
73
74;$win32k entry point
75_strategyAsm1:
76; int 3
77 push 1
78 jmp _strategyAsm
79
80;;
81; Stub which pushes parameters onto the stack and call the 16-bit C strategy routine.
82; @returns returns the return value of strategy(...)
83; @author knut st. osmundsen
84_strategyAsm proc far
85 push es
86 push bx
87 push ds
88 pop es
89 call _strategy
90 pop bx
91 pop es
92 mov word ptr es:[bx+3], ax
93 add sp, 2
94 retf
95_strategyAsm endp
96
97
98 .386p
99;;
100; Thunk procedure for R0Init32.
101; @cproto USHORT NEAR CallGetKernelInfo32(ULONG addressKrnlInfoBuf);
102; @returns Same as GetKernelInfo32.
103; @param addressKrnlInfoBuf 32-bit pointer to request data on stack.
104; @status completely implemented.
105; @author knut st. osmundsen
106_CallGetKernelInfo32 PROC NEAR
107 ASSUME CS:CODE16
108 push ds
109 push word ptr [esp+6] ; push high word.
110 push word ptr [esp+6] ; push low word.
111 call far ptr FLAT:GETKERNELINFO32
112 pop ds
113 ret
114_CallGetKernelInfo32 ENDP
115
116
117
118
119;;
120; Thunk procedure for .
121; @cproto USHORT NEAR CallElfIOCtl(void);
122; @returns Same as ElfIOCtl
123; @param address of IOCtl request packet (32-bit pointer).
124; @status completely implemented.
125; @author knut st. osmundsen
126_CallElfIOCtl PROC NEAR
127 ASSUME CS:CODE16
128 push ds
129 push word ptr [esp+6] ; push high word.
130 push word ptr [esp+6] ; push low word.
131 call far ptr FLAT:ELFIOCTL
132 pop ds
133 retn
134_CallElfIOCtl ENDP
135
136;;
137; Thunk procedure for .
138; @cproto USHORT NEAR CallWin32kIOCtl(void);
139; @returns Same as Win32kIOCtl
140; @param address of IOCtl request packet (32-bit pointer).
141; @status completely implemented.
142; @author knut st. osmundsen
143_CallWin32kIOCtl PROC NEAR
144 ASSUME CS:CODE16
145 push ds
146 push word ptr [esp+6] ; push high word.
147 push word ptr [esp+6] ; push low word.
148 call far ptr FLAT:WIN32KIOCTL
149 pop ds
150 retn
151_CallWin32kIOCtl ENDP
152
153
154;;
155; Thunk procedure for .
156; @cproto USHORT NEAR CallWin32kOpen(LIN);
157; @returns Same as Win32kOpen
158; @param address of Open request packet (32-bit pointer).
159; @status completely implemented.
160; @author knut st. osmundsen
161_CallWin32kOpen PROC NEAR
162 ASSUME CS:CODE16
163 push ds
164 push word ptr [esp+6] ; push high word.
165 push word ptr [esp+6] ; push low word.
166 call far ptr FLAT:WIN32KOPEN
167 pop ds
168 retn
169_CallWin32kOpen ENDP
170
171
172;;
173; Thunk procedure for strategy close.
174; @cproto USHORT NEAR CallWin32kClose(LIN);
175; @returns Same as Win32kIOCtl
176; @param address of Open request packet (32-bit pointer).
177; @status completely implemented.
178; @author knut st. osmundsen
179_CallWin32kClose PROC NEAR
180 ASSUME CS:CODE16
181 push ds
182 push word ptr [esp+6] ; push high word.
183 push word ptr [esp+6] ; push low word.
184 call far ptr FLAT:WIN32KCLOSE
185 pop ds
186 retn
187_CallWin32kClose ENDP
188
189
190
191;;
192; SSToDS - stack pointer to Flat pointer.
193; @cproto extern LIN SSToDS_16a(void NEAR *pStackVar);
194; @returns ax:dx makes up a 32-bit flat pointer to stack.
195; @param pStackVar Stack pointer which is to be made a flat pointer.
196; @equiv SSToDS in 32-bit code.
197; @sketch Get Flat CS
198; Get TKSSBase address. (FLAT)
199; return *TKSSBase + pStackVar.
200; @status completely implemented.
201; @author knut st. osmundsen
202; @remark es is cs, not ds!
203_SSToDS_16a proc NEAR
204 assume CS:CODE16, DS:DATA16, ES:NOTHING
205 mov edx, ds:_TKSSBase16 ; get pointer held by _TKSSBase16 (pointer to stack base)
206 call far ptr FLAT:far_getCS ; get flat selector.
207 push es
208 mov es, ax
209 assume es:FLAT
210 mov eax, es:[edx] ; get pointer to stack base
211 pop es
212 movzx edx, word ptr ss:[esp + 2] ; 16-bit stack pointer (parameter)
213 add eax, edx ; 32-bit stack pointer in eax
214 mov edx, eax
215 shr edx, 16 ; dx high 16-bit of 32-bit stack pointer.
216 retn
217_SSToDS_16a endp
218
219CODE16 ends
220
221
222;
223; all segments have a <segmentname>START label at the start of the segment.
224;
225
226CODE32 segment
227CODE32START label byte
228
229;;
230; Gets the current cs.
231; @cproto none.
232; @returns CS
233; @author knut st. osmundsen
234; @remark internal method. called from 16-bit code...
235far_getCS proc far
236 ASSUME DS:nothing, ES:nothing
237 mov ax, cs
238 retf
239far_getCS endp
240
241
242
243;;
244; Gets the a 32-bit flat pointer to the OS/2 Kernel MTE.
245; @cproto extern PMTE _System GetOS2KrnlMTE(void);
246; @returns Pointer to kernel MTE.
247; @status completely implemented.
248; @author knut st. osmundsen
249GetOS2KrnlMTE PROC NEAR
250 push es
251
252 mov ax, SAS_selector ;70h - Read-only SAS selector.
253 mov es, ax
254 xor ebx, ebx
255 assume ebx: PTR SAS
256 mov bx, es:[ebx].SAS_vm_data ;SAS_vm_data (0ch)
257 assume ebx: PTR SAS_vm_section
258 mov eax, es:[ebx].SAS_vm_krnl_mte ;SAS_vm_krnl_mte (0ch)
259
260 pop es
261 ret
262GetOS2KrnlMTE ENDP
263
264
265;;
266; Disables the ring-0 write protection.
267; It's used to help us write to readonly code segments and objects.
268; @cproto extern ULONG _Optlink x86DisableWriteProtect(void);
269; @return Previous write protection flag setting.
270; @uses eax, edx
271; @status completely implemented.
272; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
273; @remark Used by importTabInit.
274x86DisableWriteProtect proc near
275 cli
276 mov edx, cr0 ; Get current cr0
277 test edx, 000010000h ; Test for the WriteProtect flag (bit 16)
278 setnz al
279 movzx eax, al ; Old flag setting in eax (return value)
280 and edx, 0fffeffffh ; Clear the 16th (WP) bit.
281 mov cr0, edx ;
282 sti
283 ret ; return eax holds previous WP value.
284x86DisableWriteProtect endp
285
286
287;;
288; Restore the WP flag of CR0 to it's previous state.
289; The call is intent only to be called with the result from x86DisableWriteProtect,
290; and will hence only enable the WP flag.
291; @cproto extern ULONG _Optlink x86RestoreWriteProtect(ULONG flWP);
292; @return Previous write protection flag setting.
293; @param eax - flWP Boolean value. (1 = WP was set, 0 WP was clear)
294; @uses eax
295; @status completely implemented.
296; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
297; @remark Used by importTabInit.
298x86RestoreWriteProtect proc near
299 test eax, eax ; Check if the flag was previously clear
300 jnz x86RWP_set ; If set Then Set it back.
301 jmp x86RWP_end ; If clear Then nothing to do.
302x86RWP_set:
303 cli
304 mov eax, cr0 ; Get current cr0.
305 or eax, 000010000h ; The the 16-bit (WP) bit.
306 mov cr0, eax ; Update cr0.
307 sti
308
309x86RWP_end:
310 ret
311x86RestoreWriteProtect endp
312
313
314CODE32 ends
315
316CODE16_INIT segment
317CODE16_INITSTART label byte
318CODE16_INIT ends
319
320DATA16 segment
321DATA16START label byte
322DATA16 ends
323
324DATA16_BSS segment
325DATA16_BSSSTART label byte
326DATA16_BSS ends
327
328DATA16_CONST segment
329DATA16_CONSTSTART label byte
330DATA16_CONST ends
331
332DATA16_INIT segment
333DATA16_INITSTART label byte
334DATA16_INIT ends
335
336DATA32 segment
337DATA32START label byte
338DATA32 ends
339
340BSS32 segment
341BSS32START label byte
342BSS32 ends
343
344CONST32_RO segment
345CONST32_ROSTART label byte
346CONST32_RO ends
347
348_VFT segment
349_VFTSTART LABEL BYTE
350_VFT ends
351
352EH_DATA segment
353EH_DATASTART LABEL BYTE
354EH_DATA ends
355
356END
357
Note: See TracBrowser for help on using the repository browser.