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 | extrn fibDumpAll:near
|
---|
36 |
|
---|
37 |
|
---|
38 | ;*******************************************************************************
|
---|
39 | ;* Exported Symbols *
|
---|
40 | ;*******************************************************************************
|
---|
41 | public _gpfibLIS
|
---|
42 | public _gfpfibLIS
|
---|
43 | public _gpfibGIS
|
---|
44 | public _gfpfibGIS
|
---|
45 | public _gpfibPIB
|
---|
46 | public fibInit
|
---|
47 |
|
---|
48 |
|
---|
49 | CODE32 segment
|
---|
50 | ASSUME ds:FLAT, es:FLAT, ss:FLAT, fs:nothing, gs:nothing
|
---|
51 |
|
---|
52 | ;;
|
---|
53 | ; Initiates the globals of the fib.
|
---|
54 | ;
|
---|
55 | ; @cproto int fibInit(void);
|
---|
56 | ; @returns 0 on success
|
---|
57 | ; @returns OS/2 error code on failure
|
---|
58 | ; @uses eax, edx, ecx
|
---|
59 | ; @sketch
|
---|
60 | ; @status
|
---|
61 | ; @author knut st. osmundsen<bird@anduin.net>
|
---|
62 | ; @remark
|
---|
63 | ;
|
---|
64 | fibInit proc near
|
---|
65 | push ebp
|
---|
66 | mov ebp, esp
|
---|
67 | cmp _gpfibPIB, 0
|
---|
68 | jz @doinit
|
---|
69 | jmp @exit_ok
|
---|
70 | @doinit:
|
---|
71 |
|
---|
72 | if 1
|
---|
73 | ;
|
---|
74 | ; Ensure stack 512bytes of stack.
|
---|
75 | ;
|
---|
76 | cmp sp, 0f800h
|
---|
77 | jb @stackok
|
---|
78 | sub esp, 800h
|
---|
79 | mov eax, [esp] ; touch it
|
---|
80 | @stackok:
|
---|
81 |
|
---|
82 | ;
|
---|
83 | ; Now call APIRET APIENTRY DosGetInfoSeg(PSEL pselGlobal, PSEL pselLocal);
|
---|
84 | ; In order to do this, we must have a 16-bit stack.
|
---|
85 | ;
|
---|
86 | ; prepare switch back.
|
---|
87 | mov edx, esp
|
---|
88 | push ss
|
---|
89 | push edx
|
---|
90 | ; the switch.
|
---|
91 | mov eax, esp
|
---|
92 | shr eax, 13
|
---|
93 | and eax, 0fff8h
|
---|
94 | or eax, 7h
|
---|
95 | mov edx, esp
|
---|
96 | and edx, 0ffffh
|
---|
97 | push eax
|
---|
98 | push edx
|
---|
99 | lss esp, ss:[esp]
|
---|
100 | ASSUME ss:nothing
|
---|
101 |
|
---|
102 | ; Now we're on 16-bit stack.
|
---|
103 | ; Lets go to 16-bit code too
|
---|
104 | jmp far ptr CODE16:Thunk16_fibInit
|
---|
105 | CODE32 ends
|
---|
106 | CODE16 segment
|
---|
107 | Thunk16_fibInit::
|
---|
108 | push 0
|
---|
109 | mov cx, sp
|
---|
110 | push 0
|
---|
111 | mov dx, sp
|
---|
112 | push ss
|
---|
113 | push cx
|
---|
114 | push ss
|
---|
115 | push dx
|
---|
116 | extrn DOS16GETINFOSEG:far
|
---|
117 | call DOS16GETINFOSEG
|
---|
118 | pop dx ; sel LIS
|
---|
119 | pop cx ; sel GIS
|
---|
120 | jmp far ptr FLAT:Thunk32_fibInit
|
---|
121 | CODE16 ends
|
---|
122 | CODE32 segment
|
---|
123 | Thunk32_fibInit::
|
---|
124 | ; Switch back the stack
|
---|
125 | lss esp, ss:[esp]
|
---|
126 | ASSUME ss:FLAT
|
---|
127 |
|
---|
128 | ;
|
---|
129 | ; Check return value.
|
---|
130 | ;
|
---|
131 | movsx eax, ax
|
---|
132 | or eax, eax
|
---|
133 | jnz @exit
|
---|
134 |
|
---|
135 | else
|
---|
136 |
|
---|
137 | ;
|
---|
138 | ; Use the DOSCALLS imports
|
---|
139 | ;
|
---|
140 | extrn DOSGLOBALINFO:abs
|
---|
141 | extrn DOSLOCALINFO:abs
|
---|
142 | mov edx, DOSLOCALINFO
|
---|
143 | mov ecx, DOSGLOBALINFO
|
---|
144 |
|
---|
145 | endif
|
---|
146 |
|
---|
147 | ;
|
---|
148 | ; Store far pointers.
|
---|
149 | ;
|
---|
150 | mov word ptr [_gfpfibLIS + 2], dx
|
---|
151 | mov word ptr [_gfpfibGIS + 2], cx
|
---|
152 |
|
---|
153 | ;
|
---|
154 | ; Make 32-bit pointers of the return values.
|
---|
155 | ;
|
---|
156 | and edx, 0fff8h
|
---|
157 | shl edx, 13
|
---|
158 | mov [_gpfibLIS], edx
|
---|
159 |
|
---|
160 | and ecx, 0fff8h
|
---|
161 | shl ecx, 13
|
---|
162 | mov [_gpfibGIS], ecx
|
---|
163 |
|
---|
164 |
|
---|
165 | ;
|
---|
166 | ; Call APIRET APIENTRY DosGetInfoBlocks(PTIB *pptib,PPIB *pppib);
|
---|
167 | ;
|
---|
168 | push 0
|
---|
169 | mov edx, esp
|
---|
170 | push 0
|
---|
171 | mov eax, esp
|
---|
172 | push edx
|
---|
173 | push eax
|
---|
174 | mov al, 2
|
---|
175 | extrn DosGetInfoBlocks:near
|
---|
176 | call DosGetInfoBlocks ; assumes that this *never* failes.
|
---|
177 | add esp, 8h
|
---|
178 | pop eax ; ptib, ignore.
|
---|
179 | pop eax ; ppib
|
---|
180 | mov [_gpfibPIB], eax
|
---|
181 |
|
---|
182 | ;
|
---|
183 | ; Return to caller.
|
---|
184 | ;
|
---|
185 | @exit_ok:
|
---|
186 | xor eax,eax
|
---|
187 | @exit:
|
---|
188 | leave
|
---|
189 | ret
|
---|
190 | fibInit endp
|
---|
191 |
|
---|
192 |
|
---|
193 | CODE32 ends
|
---|
194 |
|
---|
195 |
|
---|
196 | end
|
---|