]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/pm/common/_pcihelp.asm
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / pm / common / _pcihelp.asm
1 ;****************************************************************************
2 ;*
3 ;*                  SciTech OS Portability Manager Library
4 ;*
5 ;*  ========================================================================
6 ;*
7 ;*    The contents of this file are subject to the SciTech MGL Public
8 ;*    License Version 1.0 (the "License"); you may not use this file
9 ;*    except in compliance with the License. You may obtain a copy of
10 ;*    the License at http://www.scitechsoft.com/mgl-license.txt
11 ;*
12 ;*    Software distributed under the License is distributed on an
13 ;*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 ;*    implied. See the License for the specific language governing
15 ;*    rights and limitations under the License.
16 ;*
17 ;*    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18 ;*
19 ;*    The Initial Developer of the Original Code is SciTech Software, Inc.
20 ;*    All Rights Reserved.
21 ;*
22 ;*  ========================================================================
23 ;*
24 ;* Language:    80386 Assembler, TASM 4.0 or NASM
25 ;* Environment: Any
26 ;*
27 ;* Description: Helper assembler functions for PCI access module.
28 ;*
29 ;****************************************************************************
30
31         IDEAL
32
33 include "scitech.mac"           ; Memory model macros
34
35 header  _pcilib
36
37 begcodeseg  _pcilib
38
39 ifdef flatmodel
40
41 ;----------------------------------------------------------------------------
42 ; uchar _ASMAPI _BIOS32_service(
43 ;   ulong service,
44 ;   ulong func,
45 ;   ulong *physBase,
46 ;   ulong *length,
47 ;   ulong *serviceOffset,
48 ;   PCIBIOS_entry entry);
49 ;----------------------------------------------------------------------------
50 ; Call the BIOS32 services directory
51 ;----------------------------------------------------------------------------
52 cprocstart   _BIOS32_service
53
54         ARG     service:ULONG, func:ULONG, physBase:DPTR, len:DPTR, off:DPTR, entry:QWORD
55
56         enter_c
57         mov     eax,[service]
58         mov     ebx,[func]
59 ifdef   USE_NASM
60         call far dword [entry]
61 else
62         call    [FWORD entry]
63 endif
64         mov     esi,[physBase]
65         mov     [esi],ebx
66         mov     esi,[len]
67         mov     [esi],ecx
68         mov     esi,[off]
69         mov     [esi],edx
70         leave_c
71         ret
72
73 cprocend
74
75 endif
76
77 ;----------------------------------------------------------------------------
78 ; ushort _ASMAPI _PCIBIOS_isPresent(ulong i_eax,ulong *o_edx,ushort *oeax,
79 ;   uchar *o_cl,PCIBIOS_entry entry)
80 ;----------------------------------------------------------------------------
81 ; Call the PCI BIOS to determine if it is present.
82 ;----------------------------------------------------------------------------
83 cprocstart   _PCIBIOS_isPresent
84
85         ARG     i_eax:ULONG, o_edx:DPTR, oeax:DPTR, o_cl:DPTR, entry:QWORD
86
87         enter_c
88         mov     eax,[i_eax]
89 ifdef   flatmodel
90 ifdef   USE_NASM
91         call far dword [entry]
92 else
93         call    [FWORD entry]
94 endif
95 else
96         int     1Ah
97 endif
98         _les    _si,[o_edx]
99         mov     [_ES _si],edx
100         _les    _si,[oeax]
101         mov     [_ES _si],ax
102         _les    _si,[o_cl]
103         mov     [_ES _si],cl
104         mov     ax,bx
105         leave_c
106         ret
107
108 cprocend
109
110 ;----------------------------------------------------------------------------
111 ; ulong _PCIBIOS_service(ulong r_eax,ulong r_ebx,ulong r_edi,ulong r_ecx,
112 ;   PCIBIOS_entry entry)
113 ;----------------------------------------------------------------------------
114 ; Call the PCI BIOS services, either via the 32-bit protected mode entry
115 ; point or via the Int 1Ah 16-bit interrupt.
116 ;----------------------------------------------------------------------------
117 cprocstart   _PCIBIOS_service
118
119         ARG     r_eax:ULONG, r_ebx:ULONG, r_edi:ULONG, r_ecx:ULONG, entry:QWORD
120
121         enter_c
122         mov     eax,[r_eax]
123         mov     ebx,[r_ebx]
124         mov     edi,[r_edi]
125         mov     ecx,[r_ecx]
126 ifdef   flatmodel
127 ifdef   USE_NASM
128         call far dword [entry]
129 else
130         call    [FWORD entry]
131 endif
132 else
133         int     1Ah
134 endif
135         mov     eax,ecx
136 ifndef  flatmodel
137         shld    edx,eax,16      ; Return result in DX:AX
138 endif
139         leave_c
140         ret
141
142 cprocend
143
144 ;----------------------------------------------------------------------------
145 ; int _PCIBIOS_getRouting(PCIRoutingOptionsBuffer *buf,PCIBIOS_entry entry);
146 ;----------------------------------------------------------------------------
147 ; Get the routing options for PCI devices
148 ;----------------------------------------------------------------------------
149 cprocstart   _PCIBIOS_getRouting
150
151         ARG     buf:DPTR, entry:QWORD
152
153         enter_c
154         mov     eax,0B10Eh
155         mov     bx,0
156         _les    _di,[buf]
157 ifdef   flatmodel
158 ifdef   USE_NASM
159         call far dword [entry]
160 else
161         call    [FWORD entry]
162 endif
163 else
164         int     1Ah
165 endif
166         movzx   eax,ah
167         leave_c
168         ret
169
170 cprocend
171
172 ;----------------------------------------------------------------------------
173 ; ibool _PCIBIOS_setIRQ(int busDev,int intPin,int IRQ,PCIBIOS_entry entry);
174 ;----------------------------------------------------------------------------
175 ; Change the IRQ routing for the PCI device
176 ;----------------------------------------------------------------------------
177 cprocstart   _PCIBIOS_setIRQ
178
179         ARG     busDev:UINT, intPin:UINT, IRQ:UINT, entry:QWORD
180
181         enter_c
182         mov     eax,0B10Fh
183         mov     bx,[USHORT busDev]
184         mov     cl,[BYTE intPin]
185         mov     ch,[BYTE IRQ]
186 ifdef   flatmodel
187 ifdef   USE_NASM
188         call far dword [entry]
189 else
190         call    [FWORD entry]
191 endif
192 else
193         int     1Ah
194 endif
195         mov     eax,1
196         jnc     @@1
197         xor     eax,eax         ; Function failed!
198 @@1:    leave_c
199         ret
200
201 cprocend
202
203 ;----------------------------------------------------------------------------
204 ; ulong _PCIBIOS_specialCycle(int bus,ulong data,PCIBIOS_entry entry);
205 ;----------------------------------------------------------------------------
206 ; Generate a special cycle via the PCI BIOS.
207 ;----------------------------------------------------------------------------
208 cprocstart   _PCIBIOS_specialCycle
209
210         ARG     bus:UINT, data:ULONG, entry:QWORD
211
212         enter_c
213         mov     eax,0B106h
214         mov     bh,[BYTE bus]
215         mov     ecx,[data]
216 ifdef   flatmodel
217 ifdef   USE_NASM
218         call far dword [entry]
219 else
220         call    [FWORD entry]
221 endif
222 else
223         int     1Ah
224 endif
225         leave_c
226         ret
227
228 cprocend
229
230 ;----------------------------------------------------------------------------
231 ; ushort _PCI_getCS(void)
232 ;----------------------------------------------------------------------------
233 cprocstart   _PCI_getCS
234
235         mov     ax,cs
236         ret
237
238 cprocend
239
240 ;----------------------------------------------------------------------------
241 ; int PM_inpb(int port)
242 ;----------------------------------------------------------------------------
243 ; Reads a byte from the specified port
244 ;----------------------------------------------------------------------------
245 cprocstart  PM_inpb
246
247         ARG     port:UINT
248
249         push    _bp
250         mov     _bp,_sp
251         xor     _ax,_ax
252         mov     _dx,[port]
253         in      al,dx
254         pop     _bp
255         ret
256
257 cprocend
258
259 ;----------------------------------------------------------------------------
260 ; int PM_inpw(int port)
261 ;----------------------------------------------------------------------------
262 ; Reads a word from the specified port
263 ;----------------------------------------------------------------------------
264 cprocstart  PM_inpw
265
266         ARG     port:UINT
267
268         push    _bp
269         mov     _bp,_sp
270         xor     _ax,_ax
271         mov     _dx,[port]
272         in      ax,dx
273         pop     _bp
274         ret
275
276 cprocend
277
278 ;----------------------------------------------------------------------------
279 ; ulong PM_inpd(int port)
280 ;----------------------------------------------------------------------------
281 ; Reads a word from the specified port
282 ;----------------------------------------------------------------------------
283 cprocstart  PM_inpd
284
285         ARG     port:UINT
286
287         push    _bp
288         mov     _bp,_sp
289         mov     _dx,[port]
290         in      eax,dx
291 ifndef flatmodel
292         shld    edx,eax,16      ; DX:AX = result
293 endif
294         pop     _bp
295         ret
296
297 cprocend
298
299 ;----------------------------------------------------------------------------
300 ; void PM_outpb(int port,int value)
301 ;----------------------------------------------------------------------------
302 ; Write a byte to the specified port.
303 ;----------------------------------------------------------------------------
304 cprocstart  PM_outpb
305
306         ARG     port:UINT, value:UINT
307
308         push    _bp
309         mov     _bp,_sp
310         mov     _dx,[port]
311         mov     _ax,[value]
312         out     dx,al
313         pop     _bp
314         ret
315
316 cprocend
317
318 ;----------------------------------------------------------------------------
319 ; void PM_outpw(int port,int value)
320 ;----------------------------------------------------------------------------
321 ; Write a word to the specified port.
322 ;----------------------------------------------------------------------------
323 cprocstart  PM_outpw
324
325         ARG     port:UINT, value:UINT
326
327         push    _bp
328         mov     _bp,_sp
329         mov     _dx,[port]
330         mov     _ax,[value]
331         out     dx,ax
332         pop     _bp
333         ret
334
335 cprocend
336
337 ;----------------------------------------------------------------------------
338 ; void PM_outpd(int port,ulong value)
339 ;----------------------------------------------------------------------------
340 ; Write a word to the specified port.
341 ;----------------------------------------------------------------------------
342 cprocstart  PM_outpd
343
344         ARG     port:UINT, value:ULONG
345
346         push    _bp
347         mov     _bp,_sp
348         mov     _dx,[port]
349         mov     eax,[value]
350         out     dx,eax
351         pop     _bp
352         ret
353
354 cprocend
355
356 endcodeseg  _pcilib
357
358         END