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 |
|
---|
14 | CODE32 segment use32 dword public 'CODE'
|
---|
15 | CODE32 ends
|
---|
16 |
|
---|
17 | CODE16 segment use16 dword public 'CODE'
|
---|
18 | CODE16 ends
|
---|
19 |
|
---|
20 | DATA32 segment use32 dword public 'DATA'
|
---|
21 | DATA32 ends
|
---|
22 |
|
---|
23 |
|
---|
24 | ;*******************************************************************************
|
---|
25 | ;* Global Variables *
|
---|
26 | ;*******************************************************************************
|
---|
27 | DATA32 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
|
---|
33 | DATA32 ends
|
---|
34 |
|
---|
35 |
|
---|
36 | ;*******************************************************************************
|
---|
37 | ;* Exported Symbols *
|
---|
38 | ;*******************************************************************************
|
---|
39 | public __gpfibLIS
|
---|
40 | public __gfpfibLIS
|
---|
41 | public __gpfibGIS
|
---|
42 | public __gfpfibGIS
|
---|
43 | public __gpfibPIB
|
---|
44 | public _fibInit
|
---|
45 |
|
---|
46 |
|
---|
47 | CODE32 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 |
|
---|
70 | if 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
|
---|
103 | CODE32 ends
|
---|
104 | CODE16 segment
|
---|
105 | Thunk16_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
|
---|
114 | IFDEF __EMX__
|
---|
115 | extrn _16_Dos16GetInfoSeg:far
|
---|
116 | call _16_Dos16GetInfoSeg
|
---|
117 | ELSE
|
---|
118 | extrn DOS16GETINFOSEG:far
|
---|
119 | call DOS16GETINFOSEG
|
---|
120 | ENDIF
|
---|
121 | pop dx ; sel LIS
|
---|
122 | pop cx ; sel GIS
|
---|
123 | jmp far ptr FLAT:Thunk32_fibInit
|
---|
124 | CODE16 ends
|
---|
125 | CODE32 segment
|
---|
126 | Thunk32_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 |
|
---|
138 | else
|
---|
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 |
|
---|
148 | endif
|
---|
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 |
|
---|
196 | CODE32 ends
|
---|
197 |
|
---|
198 |
|
---|
199 | end
|
---|