source: trunk/src/kernel32/FastInfoBlocksa.asm@ 22015

Last change on this file since 22015 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 4.0 KB
Line 
1; $Id: FastInfoBlocksa.asm,v 1.1 2003-03-06 10:22:25 sandervl Exp $
2;
3; Fast InfoBlock Access.
4;
5; Copyright (c) 2003 knut st. osmundsen <bird@anduin.net>
6;
7; Project Odin Software License can be found in LICENSE.TXT.
8;
9;
10
11
12.386
13
14CODE32 segment use32 dword public 'CODE'
15CODE32 ends
16
17CODE16 segment use16 dword public 'CODE'
18CODE16 ends
19
20DATA32 segment use32 dword public 'DATA'
21DATA32 ends
22
23
24;*******************************************************************************
25;* Global Variables *
26;*******************************************************************************
27DATA32 segment use32 dword public 'DATA'
28__gpfibLIS dd 0
29__gfpfibLIS dd 0
30__gpfibGIS dd 0
31__gfpfibGIS dd 0
32__gpfibPIB dd 0
33DATA32 ends
34
35
36;*******************************************************************************
37;* Exported Symbols *
38;*******************************************************************************
39public __gpfibLIS
40public __gfpfibLIS
41public __gpfibGIS
42public __gfpfibGIS
43public __gpfibPIB
44public _fibInit
45
46
47CODE32 segment
48 ASSUME ds:FLAT, es:FLAT, ss:FLAT, fs:nothing, gs:nothing
49
50;;
51; Initiates the globals of the fib.
52;
53; @cproto int fibInit(void);
54; @returns 0 on success
55; @returns OS/2 error code on failure
56; @uses eax, edx, ecx
57; @sketch
58; @status
59; @author knut st. osmundsen<bird@anduin.net>
60; @remark
61;
62_fibInit proc near
63 push ebp
64 mov ebp, esp
65 cmp __gpfibPIB, 0
66 jz @doinit
67 jmp @exit_ok
68@doinit:
69
70if 1
71 ;
72 ; Ensure stack 512bytes of stack.
73 ;
74 cmp sp, 0f800h
75 jb @stackok
76 sub esp, 800h
77 mov eax, [esp] ; touch it
78@stackok:
79
80 ;
81 ; Now call APIRET APIENTRY DosGetInfoSeg(PSEL pselGlobal, PSEL pselLocal);
82 ; In order to do this, we must have a 16-bit stack.
83 ;
84 ; prepare switch back.
85 mov edx, esp
86 push ss
87 push edx
88 ; the switch.
89 mov eax, esp
90 shr eax, 13
91 and eax, 0fff8h
92 or eax, 7h
93 mov edx, esp
94 and edx, 0ffffh
95 push eax
96 push edx
97 lss esp, ss:[esp]
98 ASSUME ss:nothing
99
100 ; Now we're on 16-bit stack.
101 ; Lets go to 16-bit code too
102 jmp far ptr CODE16:Thunk16_fibInit
103CODE32 ends
104CODE16 segment
105Thunk16_fibInit::
106 push 0
107 mov cx, sp
108 push 0
109 mov dx, sp
110 push ss
111 push cx
112 push ss
113 push dx
114IFDEF __EMX__
115 extrn _16_Dos16GetInfoSeg:far
116 call _16_Dos16GetInfoSeg
117ELSE
118 extrn DOS16GETINFOSEG:far
119 call DOS16GETINFOSEG
120ENDIF
121 pop dx ; sel LIS
122 pop cx ; sel GIS
123 jmp far ptr FLAT:Thunk32_fibInit
124CODE16 ends
125CODE32 segment
126Thunk32_fibInit::
127 ; Switch back the stack
128 lss esp, ss:[esp]
129 ASSUME ss:FLAT
130
131 ;
132 ; Check return value.
133 ;
134 movsx eax, ax
135 or eax, eax
136 jnz @exit
137
138else
139
140 ;
141 ; Use the DOSCALLS imports
142 ;
143 extrn DOSGLOBALINFO:abs
144 extrn DOSLOCALINFO:abs
145 mov edx, DOSLOCALINFO
146 mov ecx, DOSGLOBALINFO
147
148endif
149
150 ;
151 ; Store far pointers.
152 ;
153 mov word ptr [__gfpfibLIS + 2], dx
154 mov word ptr [__gfpfibGIS + 2], cx
155
156 ;
157 ; Make 32-bit pointers of the return values.
158 ;
159 and edx, 0fff8h
160 shl edx, 13
161 mov [__gpfibLIS], edx
162
163 and ecx, 0fff8h
164 shl ecx, 13
165 mov [__gpfibGIS], ecx
166
167
168 ;
169 ; Call APIRET APIENTRY DosGetInfoBlocks(PTIB *pptib,PPIB *pppib);
170 ;
171 push 0
172 mov edx, esp
173 push 0
174 mov eax, esp
175 push edx
176 push eax
177 mov al, 2
178 extrn DosGetInfoBlocks:near
179 call DosGetInfoBlocks ; assumes that this *never* failes.
180 add esp, 8h
181 pop eax ; ptib, ignore.
182 pop eax ; ppib
183 mov [__gpfibPIB], eax
184
185 ;
186 ; Return to caller.
187 ;
188@exit_ok:
189 xor eax,eax
190@exit:
191 leave
192 ret
193_fibInit endp
194
195
196CODE32 ends
197
198
199end
Note: See TracBrowser for help on using the repository browser.