Subversion Repositories Kolibri OS

Rev

Rev 9567 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9567 Rev 9910
Line 19... Line 19...
19
;;                                                              ;;
19
;;                                                              ;;
20
;;  See file COPYING for details                                ;;
20
;;  See file COPYING for details                                ;;
21
;;                                                              ;;
21
;;                                                              ;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 23... Line 23...
23
 
23
 
Line 24... Line 24...
24
$Revision: 9567 $
24
$Revision: 9910 $
25
 
25
 
26
;***************************************************************************
26
;***************************************************************************
27
;   Function
27
;   Function
Line 55... Line 55...
55
endg
55
endg
Line 56... Line 56...
56
 
56
 
Line 57... Line 57...
57
align 4
57
align 4
58
 
-
 
59
pci_api:
58
 
60
 
59
pci_api:
61
;cross
60
;cross
62
        mov     eax, ebx
61
        mov     eax, ebx
Line 75... Line 74...
75
        cmp     al, 10
74
        cmp     al, 10
76
        ja      pci_service_not_supported
75
        ja      pci_service_not_supported
77
end if
76
end if
Line 78... Line 77...
78
 
77
 
79
        call    dword [f62call+edx*4]
78
        call    dword [f62call + edx*4]
80
        mov     dword [esp+32], eax
79
        mov     dword [esp + SYSCALL_STACK.eax], eax
Line 81... Line 80...
81
        ret
80
        ret
82
 
81
 
Line 114... Line 113...
114
        mov     al, [BOOT.pci_data.access_mechanism]
113
        mov     al, [BOOT.pci_data.access_mechanism]
115
        ret
114
        ret
Line 116... Line 115...
116
 
115
 
117
pci_service_not_supported:
116
pci_service_not_supported:
118
        or      eax, -1
117
        or      eax, -1
119
        mov     dword [esp+32], eax
118
        mov     dword [esp + SYSCALL_STACK.eax], eax
Line 120... Line 119...
120
        ret
119
        ret
121
 
120
 
122
;***************************************************************************
121
;***************************************************************************
Line 155... Line 154...
155
align 4
154
align 4
Line 156... Line 155...
156
 
155
 
157
pci_read_reg:
156
pci_read_reg:
158
        push    ebx esi
157
        push    ebx esi
159
        cmp     [BOOT.pci_data.access_mechanism], 2; what mechanism will we use?
158
        cmp     [BOOT.pci_data.access_mechanism], 2; what mechanism will we use?
Line 160... Line 159...
160
        je      pci_read_reg_2
159
        je      .pci_read_reg_2
161
 
160
 
162
                ; mechanism 1
161
                ; mechanism 1
Line 174... Line 173...
174
        mov     dl, 0xfc
173
        mov     dl, 0xfc
175
        and     bl, 3
174
        and     bl, 3
176
        or      dl, bl   ; add to port address first 2 bits of register address
175
        or      dl, bl   ; add to port address first 2 bits of register address
Line 177... Line 176...
177
 
176
 
178
        or      esi, esi
177
        or      esi, esi
179
        jz      pci_read_byte1
178
        jz      .byte1
180
        cmp     esi, 1
179
        cmp     esi, 1
181
        jz      pci_read_word1
180
        jz      .word1
182
        cmp     esi, 2
181
        cmp     esi, 2
183
        jz      pci_read_dword1
182
        jz      .dword1
Line 184... Line 183...
184
        jmp     pci_fin_read1
183
        jmp     .fin_read1
185
 
184
 
186
pci_read_byte1:
185
.byte1:
187
        in      al, dx
186
        in      al, dx
188
        jmp     pci_fin_read1
187
        jmp     .fin_read1
189
pci_read_word1:
188
.word1:
190
        in      ax, dx
189
        in      ax, dx
191
        jmp     pci_fin_read1
190
        jmp     .fin_read1
192
pci_read_dword1:
191
.dword1:
193
        in      eax, dx
192
        in      eax, dx
194
pci_fin_read1:
193
.fin_read1:
-
 
194
        pop     esi ebx
195
        pop     esi ebx
195
        ret
Line 196... Line 196...
196
        ret
196
 
197
pci_read_reg_2:
197
.pci_read_reg_2:
Line 198... Line 198...
198
 
198
 
199
        test    bh, 128 ;mech#2 only supports 16 devices per bus
199
        test    bh, 128 ;mech#2 only supports 16 devices per bus
Line 200... Line 200...
200
        jnz     pci_read_reg_err
200
        jnz     .pci_read_reg_err
Line 215... Line 215...
215
        shr     bh, 3; func is ignored in mechanism 2
215
        shr     bh, 3; func is ignored in mechanism 2
216
        or      bh, 0xc0
216
        or      bh, 0xc0
217
        mov     dx, bx
217
        mov     dx, bx
Line 218... Line 218...
218
 
218
 
219
        or      esi, esi
219
        or      esi, esi
220
        jz      pci_read_byte2
220
        jz      .byte2
221
        cmp     esi, 1
221
        cmp     esi, 1
222
        jz      pci_read_word2
222
        jz      .word2
223
        cmp     esi, 2
223
        cmp     esi, 2
224
        jz      pci_read_dword2
224
        jz      .dword2
Line 225... Line 225...
225
        jmp     pci_fin_read2
225
        jmp     .fin_read2
226
 
226
 
227
pci_read_byte2:
227
.byte2:
228
        in      al, dx
228
        in      al, dx
229
        jmp     pci_fin_read2
229
        jmp     .fin_read2
230
pci_read_word2:
230
.word2:
231
        in      ax, dx
231
        in      ax, dx
232
        jmp     pci_fin_read2
232
        jmp     .fin_read2
233
pci_read_dword2:
233
.dword2:
Line 234... Line 234...
234
        in      eax, dx
234
        in      eax, dx
235
pci_fin_read2:
235
.fin_read2:
Line 236... Line 236...
236
 
236
 
237
        pop     esi ebx
237
        pop     esi ebx
238
        ret
238
        ret
239
 
239
 
240
pci_read_reg_err:
240
.pci_read_reg_err:
Line 279... Line 279...
279
        and     bl, 3
279
        and     bl, 3
280
        or      dl, bl
280
        or      dl, bl
281
        mov     eax, ecx
281
        mov     eax, ecx
Line 282... Line 282...
282
 
282
 
283
        or      esi, esi
283
        or      esi, esi
284
        jz      pci_write_byte1
284
        jz      .byte1
285
        cmp     esi, 1
285
        cmp     esi, 1
286
        jz      pci_write_word1
286
        jz      .word1
287
        cmp     esi, 2
287
        cmp     esi, 2
288
        jz      pci_write_dword1
288
        jz      .dword1
Line 289... Line 289...
289
        jmp     pci_fin_write1
289
        jmp     .fin_write1
290
 
290
 
291
pci_write_byte1:
291
.byte1:
292
        out     dx, al
292
        out     dx, al
293
        jmp     pci_fin_write1
293
        jmp     .fin_write1
294
pci_write_word1:
294
.word1:
295
        out     dx, ax
295
        out     dx, ax
296
        jmp     pci_fin_write1
296
        jmp     .fin_write1
297
pci_write_dword1:
297
.dword1:
Line 298... Line 298...
298
        out     dx, eax
298
        out     dx, eax
299
pci_fin_write1:
299
.fin_write1:
Line 300... Line 300...
300
 
300
 
301
        xor     eax, eax
301
        xor     eax, eax
Line 302... Line 302...
302
        pop     ebx esi
302
        pop     ebx esi
303
 
303
 
Line 304... Line 304...
304
        ret
304
        ret
305
pci_write_reg_2:
305
pci_write_reg_2:
Line 325... Line 325...
325
        mov     dx, bx
325
        mov     dx, bx
326
                ; write register
326
                ; write register
327
        mov     eax, ecx
327
        mov     eax, ecx
Line 328... Line 328...
328
 
328
 
329
        or      esi, esi
329
        or      esi, esi
330
        jz      pci_write_byte2
330
        jz      .byte2
331
        cmp     esi, 1
331
        cmp     esi, 1
332
        jz      pci_write_word2
332
        jz      .word2
333
        cmp     esi, 2
333
        cmp     esi, 2
334
        jz      pci_write_dword2
334
        jz      .dword2
Line 335... Line 335...
335
        jmp     pci_fin_write2
335
        jmp     .fin_write2
336
 
336
 
337
pci_write_byte2:
337
.byte2:
338
        out     dx, al
338
        out     dx, al
339
        jmp     pci_fin_write2
339
        jmp     .fin_write2
340
pci_write_word2:
340
.word2:
341
        out     dx, ax
341
        out     dx, ax
342
        jmp     pci_fin_write2
342
        jmp     .fin_write2
343
pci_write_dword2:
343
.dword2:
Line 344... Line 344...
344
        out     dx, eax
344
        out     dx, eax
345
pci_fin_write2:
345
.fin_write2:
346
 
346
 
Line 347... Line 347...
347
        xor     eax, eax
347
        xor     eax, eax
348
        pop     ebx esi
348
        pop     ebx esi
349
        ret
349
        ret
350
 
350
 
351
pci_write_reg_err:
351
.pci_write_reg_err:
Line 430... Line 430...
430
        mov     al, 2   ; al : DW to read
430
        mov     al, 2   ; al : DW to read
431
        call    pci_read_reg
431
        call    pci_read_reg
432
        or      eax, eax
432
        or      eax, eax
433
        jnz     @f
433
        jnz     @f
434
        mov     eax, -3 ; empty I/O space
434
        mov     eax, -3 ; empty I/O space
435
        jmp     mmio_ret_fail
435
        jmp     .mmio_ret_fail
436
@@:
436
@@:
437
        test    eax, 1
437
        test    eax, 1
438
        jz      @f
438
        jz      @f
439
        mov     eax, -4 ; damned ports (not MMIO space)
439
        mov     eax, -4 ; damned ports (not MMIO space)
440
        jmp     mmio_ret_fail
440
        jmp     .mmio_ret_fail
441
@@:
441
@@:
442
        pop     ecx     ; ecx = block size, bytes (expanded to whole page)
442
        pop     ecx     ; ecx = block size, bytes (expanded to whole page)
443
        mov     ebx, ecx; user_alloc destroys eax, ecx, edx, but saves ebx
443
        mov     ebx, ecx; user_alloc destroys eax, ecx, edx, but saves ebx
444
        and     eax, 0xFFFFFFF0
444
        and     eax, 0xFFFFFFF0
445
        push    eax           ; store MMIO physical address + keep 2DWords in the stack
445
        push    eax           ; store MMIO physical address + keep 2DWords in the stack
446
        stdcall user_alloc, ecx
446
        stdcall user_alloc, ecx
447
        or      eax, eax
447
        or      eax, eax
448
        jnz     mmio_map_over
448
        jnz     .mmio_map_over
449
        mov     eax, -5 ; problem with page allocation
449
        mov     eax, -5 ; problem with page allocation
Line 450... Line 450...
450
 
450
 
451
mmio_ret_fail:
451
.mmio_ret_fail:
452
        pop     ecx
452
        pop     ecx
453
        pop     edx
453
        pop     edx
Line 454... Line 454...
454
        ret
454
        ret
455
 
455
 
456
mmio_map_over:
456
.mmio_map_over:
457
        mov     ecx, ebx; ecx = size (bytes, expanded to whole page)
457
        mov     ecx, ebx; ecx = size (bytes, expanded to whole page)
458
        shr     ecx, 12 ; ecx = number of pages
458
        shr     ecx, 12 ; ecx = number of pages
459
        mov     ebx, eax; ebx = linear address
459
        mov     ebx, eax; ebx = linear address
Line 594... Line 594...
594
        jmp     .return_abc
594
        jmp     .return_abc
595
.not_WRITE_CONFIG:
595
.not_WRITE_CONFIG:
596
.unsupported_func:
596
.unsupported_func:
597
        mov     ah, 0x81                ; FUNC_NOT_SUPPORTED
597
        mov     ah, 0x81                ; FUNC_NOT_SUPPORTED
598
.return:
598
.return:
599
        mov     dword[esp + 4 ], edi
599
        mov     dword[esp + SYSCALL_STACK.edi], edi
600
        mov     dword[esp + 8], esi
600
        mov     dword[esp + SYSCALL_STACK.esi], esi
601
.return_abcd:
601
.return_abcd:
602
        mov     dword[esp + 24], edx
602
        mov     dword[esp + SYSCALL_STACK.edx], edx
603
.return_abc:
603
.return_abc:
604
        mov     dword[esp + 28], ecx
604
        mov     dword[esp + SYSCALL_STACK.ecx], ecx
605
.return_ab:
605
.return_ab:
606
        mov     dword[esp + 20], ebx
606
        mov     dword[esp + SYSCALL_STACK.ebx], ebx
607
.return_a:
607
.return_a:
608
        mov     dword[esp + 32], eax
608
        mov     dword[esp + SYSCALL_STACK.eax], eax
609
        ret
609
        ret
Line 610... Line 610...
610
 
610
 
611
proc pci_enum
611
proc pci_enum
612
        push    ebp
612
        push    ebp